@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.
Files changed (2) hide show
  1. package/dist/index.mjs +12 -6
  2. 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 (!selectedPlan) throw new Error(`Invalid plan id: ${planId}`);
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: [`/v3/zudoku-metering/${deploymentName}/stripe/checkout`],
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: auth.profile?.email,
492
- planId: selectedPlan.id,
493
- successURL: generateUrl("/checkout-confirm") + (selectedPlan.id ? `?plan=${selectedPlan.id}` : ""),
497
+ email,
498
+ planId,
499
+ successURL: successUrl.toString(),
494
500
  cancelURL: generateUrl("/pricing")
495
501
  })
496
502
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/zudoku-plugin-monetization",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/zuplo/zudoku",