Skip to content

Stripe payment links

charkhaw edited this page Dec 12, 2024 · 4 revisions

Technical Specification: Payment Link Creation for Stripe Payment

Overview

The goal is to enhance the existing Stripe upgrade API/page to optionally act as a payment link. This involves adding new features to the Stripe plan creation/editing process and the app management interface.

Requirements

1. Stripe Plan Creation/Edit Enhancements

  • Add an option called "Make it invisible" to the Stripe plan creation/edit page.
  • This option will add an extra property to the Stripe plan: invisible: true.

2. App Management Enhancements

  • Add an option to the app list dropdown called "Create Payment Link".
  • This will open a new dialog containing:
    • A list of plans with invisible: true.
    • When a user selects a plan and clicks Save:
      • Call a new API to store the selected BF plan into app.paymentsData and just display the payment link (normal link to the upgrade page) with a copy icon/functionality. -This will override all stripe configuration (we will lock this app to payment links upgrade)

3. New API Endpoint

  • route: /api/whitelabel/app/:appId/paymentlink
  • path: /web/server/api/whitelabel/app/paymentlink/post.js
  • This API will:
  // fetch the app info.
  // set `wlPlanId` into `paymentsData` as following

        appData.paymentsData =     
    {
      "stripe": {
        "wlPlanId": "selected_id"
      }
    }
    // update the app with the paymentsData
    await appsDao.updateApp(appData);

4. Upgrade API Enhancements

  • In the existing upgrade API, check if wlPlanId is set in paymentsData.
  • If wlPlanId is set:
    • Get WL stripe plans.
    • Get stripe price of the selected WL plan.
    • Create a Stripe session with only the selected price:
      if (appData.paymentsData.stripe.wlPlanId) {
          addTransactionLogs("createStripeSession", "START");
          const session = await bfStripeService.createSession(
              customerId,
              appData.paymentsData.stripe.wlPlanId,
              price, // fetched from BF planId
              whitelabel.name
          );
          addTransactionLogs("createStripeSession", "SUCCESS", session);
          return res.redirect(session.url);
      }
  • If wlPlanId is not set, continue with the existing logic.

Implementation Steps

1. Stripe Plan Creation/Edit Enhancements

  • Modify stripePricingPlanDetail.html and stripePricingPlanDetailCtrl.js to include the "Make it invisible" option.
  • Update the plan object to include the invisible property.

2. App Management Enhancements

  • Modify appManagement.html and appManagementCtrl.js to add the "Create Payment Link" option.
  • Create a new dialog for selecting invisible plans and generating the payment link.

3. New API Endpoint

  • Create a new file /web/server/api/whitelabel/app/paymentlink/post.js
  • Implement logic to update paymentsData with the selected wlPlanId.

4. Upgrade API Enhancements

  • Modify upgrade.js to check for wlPlanId in paymentsData.
  • If wlPlanId is set, create a Stripe session using the selected plan.
  • If wlPlanId is not set, continue with the existing logic.

Clone this wiki locally