forked from BuildFire/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Stripe payment links
charkhaw edited this page Dec 12, 2024
·
4 revisions
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.
- 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.
- 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.paymentsDataand 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)
- Call a new API to store the selected BF plan into
- A list of plans with
- 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);- In the existing upgrade API, check if
wlPlanIdis set inpaymentsData. - If
wlPlanIdis set:- Get WL stripe plans.
- Get stripe
priceof 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
wlPlanIdis not set, continue with the existing logic.
- Modify
stripePricingPlanDetail.htmlandstripePricingPlanDetailCtrl.jsto include the "Make it invisible" option. - Update the plan object to include the
invisibleproperty.
- Modify
appManagement.htmlandappManagementCtrl.jsto add the "Create Payment Link" option. - Create a new dialog for selecting invisible plans and generating the payment link.
- Create a new file
/web/server/api/whitelabel/app/paymentlink/post.js - Implement logic to update
paymentsDatawith the selectedwlPlanId.
- Modify
upgrade.jsto check forwlPlanIdinpaymentsData. - If
wlPlanIdis set, create a Stripe session using the selected plan. - If
wlPlanIdis not set, continue with the existing logic.