Add Lemon Squeezy Billing System

This commit is contained in:
giancarlo
2024-04-01 21:43:18 +08:00
parent 84a4b45bcd
commit 8784a40a69
59 changed files with 424 additions and 74 deletions

View File

@@ -0,0 +1,26 @@
import 'server-only';
import { Logger } from '@kit/shared/logger';
import { getLemonSqueezyEnv } from '../schema/lemon-squeezy-server-env.schema';
/**
* @description Initialize the Lemon Squeezy client
*/
export async function initializeLemonSqueezyClient() {
const { lemonSqueezySetup } = await import('@lemonsqueezy/lemonsqueezy.js');
const env = getLemonSqueezyEnv();
lemonSqueezySetup({
apiKey: env.secretKey,
onError(error) {
Logger.error(
{
name: `billing.lemon-squeezy`,
error: error.message,
},
'Error in Lemon Squeezy SDK',
);
},
});
}