Implement Lemon Squeezy billing services

Added implementation for various billing services with Lemon Squeezy. This includes processing of webhooks for order and subscription handling, verification of webhook signatures, and validating subscription statuses and order states. Additionally, types for order and subscription webhooks have been created.
This commit is contained in:
giancarlo
2024-04-02 09:33:26 +08:00
parent dee0814e6d
commit f58aaa330c
7 changed files with 595 additions and 4 deletions

View File

@@ -0,0 +1 @@
export * from './lemon-squeezy-embedded-checkout';

View File

@@ -0,0 +1,29 @@
interface LemonSqueezyWindow extends Window {
createLemonSqueezy: () => void;
LemonSqueezy: {
Setup: (options: {
eventHandler: (event: { event: string }) => void;
}) => void;
Refresh: () => void;
Url: {
Open: (url: string) => void;
Close: () => void;
};
};
}
export function LemonSqueezyEmbeddedCheckout(props: { checkoutToken: string }) {
return (
<script
src="https://app.lemonsqueezy.com/js/lemon.js"
defer
onLoad={() => {
const win = window as unknown as LemonSqueezyWindow;
win.createLemonSqueezy();
win.LemonSqueezy.Url.Open(props.checkoutToken);
}}
></script>
);
}