@zuplo/zudoku-plugin-monetization 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +12 -6
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -478,19 +478,25 @@ const CheckoutPage = () => {
|
|
|
478
478
|
const auth = useAuth();
|
|
479
479
|
const { generateUrl } = useUrlUtils();
|
|
480
480
|
const deploymentName = useDeploymentName();
|
|
481
|
-
const selectedPlan = usePlans(deploymentName).data?.items.find((plan) => plan.id === planId);
|
|
482
481
|
if (!auth.profile?.email) throw new Error("No email found for user. Make sure your Authentication Provider exposes the email address.");
|
|
483
|
-
if (!
|
|
482
|
+
if (!planId) throw new Error(`missing planId in URL`);
|
|
483
|
+
const email = auth.profile?.email;
|
|
484
|
+
const successUrl = new URL(generateUrl("/checkout-confirm"));
|
|
485
|
+
successUrl.searchParams.set("plan", planId);
|
|
484
486
|
const checkoutLink = useQuery({
|
|
485
|
-
queryKey: [
|
|
487
|
+
queryKey: [
|
|
488
|
+
`/v3/zudoku-metering/${deploymentName}/stripe/checkout`,
|
|
489
|
+
planId,
|
|
490
|
+
email
|
|
491
|
+
],
|
|
486
492
|
meta: {
|
|
487
493
|
context: zudoku,
|
|
488
494
|
request: {
|
|
489
495
|
method: "POST",
|
|
490
496
|
body: JSON.stringify({
|
|
491
|
-
email
|
|
492
|
-
planId
|
|
493
|
-
successURL:
|
|
497
|
+
email,
|
|
498
|
+
planId,
|
|
499
|
+
successURL: successUrl.toString(),
|
|
494
500
|
cancelURL: generateUrl("/pricing")
|
|
495
501
|
})
|
|
496
502
|
}
|