import { Order } from './orders.types'; /** * Contains functionality for ordering a site's pricing plans. * * Use the Pricing Plans Checkout API to create online orders for [pricing plans](https://support.wix.com/en/article/pricing-plans-an-overview) from page code. * * * ### Setup pricing plans * * To use APIs for checking out orders, first set up a site to: * * + Accept payments as described in [About Accepting Payments](https://support.wix.com/en/article/about-accepting-payments). * + Offer membership plans as described in [About Pricing Plans](https://support.wix.com/en/article/about-pricing-plans). When setting up a site to accept pricing plans, * define the plans you want to offer [using a Wix user's dashboard](https://support.wix.com/en/article/creating-a-plan-in-pricing-plans) or * [using the Pricing Plan APIs](https://dev.wix.com/docs/velo/api-reference/wix-pricing-plans-backend/create-plan). * * * ### Check out pricing plans * * Use the Checkout APIs to create orders and facilitate payment. * * The Checkout API allows you to: * + Create online orders and facilitate their payment. * + Create your own customized ordering process. * * Updating the properties of a pricing plan doesn't affect any current orders of the plan by site members. * The existing orders retain their existing terms and pricing. * * Site members can order pricing plans in 2 ways: * * + **Online**. Site members order and pay for their plans on a site without manual intervention. This can also be done * in [backend code](https://dev.wix.com/docs/velo/api-reference/wix-pricing-plans-backend/checkout/create-online-order). * + **Offline**. Site members place their order by phone, text, or email. This can only be done * in [backend code](https://dev.wix.com/docs/velo/api-reference/wix-pricing-plans-backend/checkout/create-offline-order). * * ### Drafts * * Orders created online are considered drafts until they're paid for. Drafts aren't listed in the Subscriptions * dashboard page and aren't saved in the `Orders` collection. * * Offline orders are never considered drafts even if they're not yet paid for. Unlike online orders, * offline orders are immediately listed in the Subscriptions dashboard page and saved in the `Orders` collection. * * * ### Orders and subscriptions * * Actions related to basic pricing plan management are available from the [Pricing Plans](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmembership%3FreferralInfo%3Dvelo-docs) * page in a Wix user's dashboard. These actions correspond to the methods available in the Pricing Plans API. * * Every pricing plan order corresponds to a Wix subscription, including orders for single payment plans. You can see all orders from a site's * [Subscriptions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fsubscriptions%3FreferralInfo%3Dvelo-docs) * page in a Wix user's dashboard. Actions available on this page correspond to the methods available in the [Orders APIs](pricing-plans/orders/introduction) and the [Checkout APIs](pricing-plans/checkout/introduction). * * > **Notes**: * > * > + Wix pricing plans are 1 type of Wix subscriptions available from the Subscriptions page. For example, the Subscriptions page also includes Wix Stores subscriptions and Wix Invoice subscriptions. * > * > + Pricing plans can be 1 of 3 different pricing models: `singlePaymentForDuration`, `singlePaymentUnlimited`, and `subscription`. Orders for all pricing plan models are displayed * on the Subscriptions page, not just `subscription` type models. See Pricing Models ([SDK](https://dev.wix.com/docs/sdk/backend-modules/pricing-plans/introduction#pricing-models) | [Velo](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/introduction#apis_wix-pricing-plans-backend_pricing-models)) to learn more. * * ### Roles and permissions * * You need "Manage Pricing Plans" [permissions](https://support.wix.com/en/article/roles-permissions-accessing-roles-permissions) to perform pricing * plan checkout methods. * * * ### Import the APIs * * To use the Checkout API, import `checkout` from the `wix-pricing-plans-frontend` module. * * ```javascript * import {checkout} from 'wix-pricing-plans-frontend'; * ``` */ export interface Checkout { /** * Orders a pricing plan. * * To process pricing plans on a site, a site first must be set up to offer pricing plans * as described in [Pricing Plans: An Overview](https://support.wix.com/en/article/pricing-plans-an-overview). * When setting up a site to accept pricing plans, [define the plans you want to offer](https://support.wix.com/en/article/pricing-plans-creating-a-one-time-payment-plan). * * Ordering a plan places an order for the plan, without actually purchasing it. You can then continue the * payment process with [Wix Pay](https://dev.wix.com/docs/velo/apis/wix-pay-frontend/introduction), which applies the plan to the buyer on completion of payment. * * To understand how `createOnlineOrder()` is used in a customized pricing plan lifecycle, * see the Custom Purchase Flow API ([SDK](https://dev.wix.com/docs/sdk/frontend-modules/pricing-plans/custom-purchase-flow/introduction) | [Velo](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-frontend/custom-purchase-flow/introduction)). * * * > **Note:** * > + To work with the Pricing Plans API, a site needs to be published. * @param planId - The plan ID. * @requiredField planId * @param startDate - Start date and time for the ordered plan. * @returns Fulfilled - The created order. * @servicePath wix-pricing-plans-frontend.Orders.Order */ createOnlineOrder(planId: string, startDate?: Date): Promise; /** * Orders and purchases a pricing plan. * * `startOnlinePurchase()` returns a Promise that resolves to a `Purchase` * object when the member completes the purchase process. Depending on whether the plan * is free, the `Purchase` object returns different properties. * * To process pricing plans on a site, a site first must be set up to offer pricing plans * as described in [Pricing Plans: An Overview](https://support.wix.com/en/article/pricing-plans-an-overview). * When setting up a site to accept pricing plans, [define the plans you want to offer](https://support.wix.com/en/article/pricing-plans-creating-a-one-time-payment-plan), * including the payment method. * * Purchasing a plan orders the plan and continues the * payment process with the [Wix Pay API](https://dev.wix.com/docs/velo/apis/wix-pay-frontend/introduction). After payment is complete, the plan * is assigned to the member. * * To understand the lifecycle of how `startOnlinePurchase()` is used, * see [Direct Purchase of a Pricing Plan](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-frontend/introduction#apis_wix-pricing-plans-frontend_direct-order-of-a-pricing-plan). * * > **Note:** * > + To work with the Pricing Plans API, a site needs to be published publish. * @param planId - The plan ID. * @requiredField planId * @param startDate - Start date and time for the ordered plan. * @returns Fulfilled - Details about the purchased plan. * @servicePath wix-pricing-plans-frontend.Checkout.Purchase */ startOnlinePurchase(planId: string, startDate?: Date): Promise; } export interface CreateOnlineOrderOptions { /** * Start date and time for the ordered plan. * * Default: Current date and time */ startDate?: Date; /** * Coupon code to apply. * * To learn more about coupons, see [applyCoupon()](https://dev.wix.com/docs/velo/api-reference/wix-pricing-plans-backend/checkout/applycoupon). */ couponCode?: string; } /** * An object representing the period for which a plan is valid. */ export interface Period { /** * The number of units until the plan expires. * @requiredField amount */ amount: number; /** * Time period for billing the plan, such as `"MONTH"`. * @requiredField unit */ unit: string; } /** * An object representing the price of a purchased plan. */ export interface Price { /** * Payment currency. A three-letter * [ISO-4217](https://en.wikipedia.org/wiki/ISO_4217) currency code. * @requiredField currency */ currency: string; /** * The cost of the plan. * @requiredField amount */ amount: number; } /** * An object representing a purchase for a non-free plan. */ export interface Purchase { /** * The order being purchased. * @requiredField order * @servicePath wix-pricing-plans-frontend.Orders.Order */ order: Order; /** * Payment status in [Wix Pay](https://www.wix.com/velo/reference/wix-pay-frontend). Omitted for free plans. * One of: * + `"Successful"`: Payment was successfully received. * + `"Pending"`: Payment is pending payment provider approval. * + `"Failed"`: Payment has failed. * + `"Chargeback"`: Payment is chargeback. * + `"Refunded"`: Payment was fully refunded. * + `"Offline"`: Payment will be executed offline. * + `"PartiallyRefunded"`: Payment was partially refunded. * + `"Cancelled"`: Payment was cancelled and was not processed. * + `"Undefined"`: Payment status is pending payment provider input. */ wixPayStatus?: string; } export interface StartOnlinePurchaseOptions { /** * Start date and time for the ordered plan. * * Default: Current date and time */ startDate?: Date; /** * Coupon code to apply. * * To learn more about coupons, see [applyCoupon()](https://dev.wix.com/docs/velo/api-reference/wix-pricing-plans-backend/checkout/applycoupon). */ couponCode?: string; } /** * An object representing how long a plan is valid. */ export interface ValidFor { /** * If true, the plan does not expire. * @requiredField forever */ forever: boolean; /** * Object containing the period for which the plan is valid. * @requiredField period * @servicePath wix-pricing-plans-frontend.Checkout.Period */ period: Period; } /** * Orders a pricing plan. * * To process pricing plans on a site, a site first must be set up to offer pricing plans * as described in [Pricing Plans: An Overview](https://support.wix.com/en/article/pricing-plans-an-overview). * When setting up a site to accept pricing plans, [define the plans you want to offer](https://support.wix.com/en/article/pricing-plans-creating-a-one-time-payment-plan). * * Ordering a plan places an order for the plan, without actually purchasing it. You can then continue the * payment process with [Wix Pay](https://dev.wix.com/docs/velo/apis/wix-pay-frontend/introduction), which applies the plan to the buyer on completion of payment. * * To understand how `createOnlineOrder()` is used in a customized pricing plan lifecycle, * see the Custom Purchase Flow API ([SDK](https://dev.wix.com/docs/sdk/frontend-modules/pricing-plans/custom-purchase-flow/introduction) | [Velo](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-frontend/custom-purchase-flow/introduction)). * * * > **Note:** * > + To work with the Pricing Plans API, a site needs to be published. * @param planId - The plan ID. * @requiredField planId * @param startDate - Start date and time for the ordered plan. * @returns Fulfilled - The created order. * @servicePath wix-pricing-plans-frontend.Orders.Order */ export function createOnlineOrder(planId: string, startDate?: Date): Promise; /** * Orders and purchases a pricing plan. * * `startOnlinePurchase()` returns a Promise that resolves to a `Purchase` * object when the member completes the purchase process. Depending on whether the plan * is free, the `Purchase` object returns different properties. * * To process pricing plans on a site, a site first must be set up to offer pricing plans * as described in [Pricing Plans: An Overview](https://support.wix.com/en/article/pricing-plans-an-overview). * When setting up a site to accept pricing plans, [define the plans you want to offer](https://support.wix.com/en/article/pricing-plans-creating-a-one-time-payment-plan), * including the payment method. * * Purchasing a plan orders the plan and continues the * payment process with the [Wix Pay API](https://dev.wix.com/docs/velo/apis/wix-pay-frontend/introduction). After payment is complete, the plan * is assigned to the member. * * To understand the lifecycle of how `startOnlinePurchase()` is used, * see [Direct Purchase of a Pricing Plan](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-frontend/introduction#apis_wix-pricing-plans-frontend_direct-order-of-a-pricing-plan). * * > **Note:** * > + To work with the Pricing Plans API, a site needs to be published publish. * @param planId - The plan ID. * @requiredField planId * @param startDate - Start date and time for the ordered plan. * @returns Fulfilled - Details about the purchased plan. * @servicePath wix-pricing-plans-frontend.Checkout.Purchase */ export function startOnlinePurchase(planId: string, startDate?: Date): Promise;