Introduction
Using the Pricing Plans API, you can build a customized membership plan experience.
The Pricing Plans APIs replace the deprecated Paid Plans APIs.
If Paid Plans APIs are already in your code, the APIs will continue to work, but they will not receive updates. To keep any existing code compatible with future changes, see the migration instructions for each function.
Setting Up Pricing Plans
First, set up your site to:
Accept payments as described in About Accepting Payments.
Offer membership plans as described in About Pricing Plans. When setting up your site to accept pricing plans, define the plans you want to offer with either the Pricing Plans app or the Pricing Plans APIs.
When plans are set up, you can use the API to:
- Get information about pricing plans.
- Let site members order a plan directly, as if they were using the Pricing Plans app.
- Let site members order a plan using your own customized process.
- Let site members cancel orders that they have purchased.
There are two flows for setting up pricing plans: Direct purchases and customized purchases.
Note: To work with the Pricing Plans API, you need to publish your site.
Direct Order of a Pricing Plan
Direct ordering mirrors the ordering of a plan using the Pricing Plans app.
For standard pricing plan processing, call the startOnlinePurchase()
function.
The following outlines the steps in a direct order lifecycle:
- Get and display a list of membership plans from one of the following:
- A dataset connected to the Plans collection.
- A query on the Plans collection.
- A logged-in site member selects a membership plan by clicking the plan or a button. If the member is not logged in, the sign up page is automatically displayed.
- The corresponding event handler calls the
startOnlinePurchase()
function to handle all stages of buying the plan (selecting, ordering, and payment):- If the plan is free, the plan is immediately ordered and is considered paid for. The
wixPayStatus
isSuccessful
. - If the plan is not free, the plan is ordered but not yet paid for and the
wixPayStatus
isPending
and the order'sstatus
isDRAFT
. The site member fills in contact details and selects a payment method. Once payment is completed, thewixPayStatus
isSuccessful
and the order'sstatus
isACTIVE
.
- If the plan is free, the plan is immediately ordered and is considered paid for. The
- Handle additional updates when a plan is successfully purchased using the
onPlanPurchased()
event.
Customized Pricing Plan Purchases
This flow lets buyers (logged-in site members) order and pay for a plan using a customized flow. You customize the entire process of selecting, requesting, and paying for a plan. You can add elements, such as confirmation lightboxes and forms, to customize the buyer's experience.
To let the buyer order a plan, call the createOnlineOrder()
function.
The following outlines the steps for customizing the pricing plan purchase:
- Get and display a list of membership plans from one of the following:
- A dataset connected to the Plans collection.
- A query on the Plans collection.
- A logged-in site member selects a membership plan by clicking the plan or a button. If the member is not logged in, the signup page is automatically displayed.
- The corresponding event handler calls the
createOnlineOrder()
function to handle the initial order of the plan. - The site member uses a series of customized elements you created, such as lightboxes, and forms, to continue ordering/purchasing.
- The site member uses Wix Pay to complete the purchase.
- Handle additional updates when a plan is successfully purchased using the
onOrderPurchased()
event.
Importing Pricing Plan Modules
For ordering pricing plans, import wixPricingPlansFrontend
from the wix-pricing-plans-frontend
module.
javascript | Copy Codeimport wixPricingPlansFrontend from 'wix-pricing-plans-frontend';
Was this helpful?