mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat: integrate LemonSqueezy to subscription payment
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { Service } from 'typedi';
|
||||
import { createCheckout } from '@lemonsqueezy/lemonsqueezy.js';
|
||||
import { SystemUser } from '@/system/models';
|
||||
import { configureLemonSqueezy } from './utils';
|
||||
|
||||
@Service()
|
||||
export class LemonSqueezyService {
|
||||
/**
|
||||
* Retrieves the LemonSqueezy checkout url.
|
||||
* @param {number} variantId
|
||||
* @param {SystemUser} user
|
||||
*/
|
||||
async getCheckout(variantId: number, user: SystemUser) {
|
||||
configureLemonSqueezy();
|
||||
|
||||
return createCheckout(process.env.LEMONSQUEEZY_STORE_ID!, variantId, {
|
||||
checkoutOptions: {
|
||||
embed: true,
|
||||
media: true,
|
||||
logo: true,
|
||||
},
|
||||
checkoutData: {
|
||||
email: user.email,
|
||||
custom: {
|
||||
user_id: user.id + '',
|
||||
tenant_id: user.tenantId + '',
|
||||
},
|
||||
},
|
||||
productOptions: {
|
||||
enabledVariants: [variantId],
|
||||
redirectUrl: `http://localhost:4000/dashboard/billing/`,
|
||||
receiptButtonText: 'Go to Dashboard',
|
||||
receiptThankYouNote: 'Thank you for signing up to Lemon Stand!',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user