Skip to content

Commit

Permalink
feat(website): close checkout overlay when it is completed
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Oct 25, 2024
1 parent baea7f2 commit 01054e4
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions apps/website/app/routes/me.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,27 @@ export default function Index() {
initializePaddle({
token: loaderData.clientToken,
environment: loaderData.isSandbox ? "sandbox" : undefined,
eventCallback: (data) => {
if (data.name === CheckoutEventNames.CHECKOUT_COMPLETED) {
paddle?.Checkout.close();
const transactionId = data.data?.transaction_id;
if (!transactionId) throw new Error("Transaction ID not found");
submit(
{ transactionId },
{
method: "POST",
encType: "application/json",
action: withQuery(".", { intent: "processPurchase" }),
},
);
}
},
}).then((paddleInstance) => {
if (paddleInstance) setPaddle(paddleInstance);
if (paddleInstance) {
paddleInstance.Update({
eventCallback: (data) => {
if (data.name === CheckoutEventNames.CHECKOUT_COMPLETED) {
paddleInstance.Checkout.close();
const transactionId = data.data?.transaction_id;
if (!transactionId) throw new Error("Transaction ID not found");
submit(
{ transactionId },
{
method: "POST",
encType: "application/json",
action: withQuery(".", { intent: "processPurchase" }),
},
);
}
},
});
setPaddle(paddleInstance);
}
});
}, []);

Expand Down

0 comments on commit 01054e4

Please sign in to comment.