type Primitive = number | string | boolean | bigint | symbol | null | undefined; type Tags = Record; type Context = Record; type Contexts = Record; interface SpanContextData { traceId: string; spanId: string; } interface Span { spanContext(): SpanContextData; end(): void; } interface SpanOptions { name: string; tags?: Tags; } interface Breadcrumb { type?: string; category?: string; message: string; level?: 'info' | 'warning' | 'error'; data?: Record; } interface CaptureContext { level?: 'info' | 'warning' | 'error'; tags?: Tags; contexts?: Contexts; } interface MonitoringClient { /** * Captures an exception event and sends it to Sentry. * @param error The error to capture * @param captureContext Optional additional data to attach to the Sentry e vent. * @returns the id of the captured Sentry event. */ captureException(error: unknown, captureContext?: CaptureContext): string; /** * Captures a message event and sends it to Sentry. * @param message The message to capture * @param captureContext Define the level of the message or pass in additional data to attach to the message. * @returns the id of the captured message. */ captureMessage(message: string, captureContext?: CaptureContext): string; /** * Wraps a function with a span and finishes the span after the function is done. The created span is the active span and will be used as parent by other spans created inside the function, as long as the function is executed while the scope is active. * @param spanOptions The options for the span * @param callback The function to wrap with a span * @returns The return value of the callback */ startSpan(spanOptions: SpanOptions, callback: (span: Span | undefined) => T): T; /** * Records a new breadcrumb which will be attached to future events. * Breadcrumbs will be added to subsequent events to provide more context on user's actions prior to an error or crash. * @param breadcrumb The breadcrumb to record. */ addBreadcrumb(breadcrumb: Breadcrumb): void; } type HostModule = { __type: 'host'; create(host: H): T; }; type HostModuleAPI> = T extends HostModule ? U : never; type Host$1 = { channel?: { observeState(callback: (props: unknown, environment: Environment) => unknown): { disconnect: () => void; } | Promise<{ disconnect: () => void; }>; }; environment?: Environment; /** * Optional name of the environment, use for logging */ name?: string; /** * Optional bast url to use for API requests, for example `www.wixapis.com` */ apiBaseUrl?: string; /** * Optional function to get a monitoring client */ getMonitoringClient?: () => MonitoringClient; /** * Possible data to be provided by every host, for cross cutting concerns * like internationalization, billing, etc. */ essentials?: { /** * The language of the currently viewed session */ language?: string; /** * The locale of the currently viewed session */ locale?: string; /** * Any headers that should be passed through to the API requests */ passThroughHeaders?: Record; }; }; type HTTPMethod = 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'; type RESTFunctionDescriptor any = (...args: any[]) => any> = (httpClient: HttpClient) => T; interface HttpClient { request(req: RequestOptionsFactory): Promise>; fetchWithAuth: typeof fetch; wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise; getActiveToken?: () => string | undefined; } type RequestOptionsFactory = (context: any) => RequestOptions; type HttpResponse = { data: T; status: number; statusText: string; headers: any; request?: any; }; type RequestOptions<_TResponse = any, Data = any> = { method: HTTPMethod; url: string; data?: Data; params?: URLSearchParams; } & APIMetadata; type APIMetadata = { methodFqn?: string; entityFqdn?: string; packageName?: string; }; type BuildRESTFunction = T extends RESTFunctionDescriptor ? U : never; type EventDefinition = { __type: 'event-definition'; type: Type; isDomainEvent?: boolean; transformations?: (envelope: unknown) => Payload; __payload: Payload; }; declare function EventDefinition(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): () => EventDefinition; type EventHandler = (payload: T['__payload']) => void | Promise; type BuildEventDefinition> = (handler: EventHandler) => void; type ServicePluginMethodInput = { request: any; metadata: any; }; type ServicePluginContract = Record unknown | Promise>; type ServicePluginMethodMetadata = { name: string; primaryHttpMappingPath: string; transformations: { fromREST: (...args: unknown[]) => ServicePluginMethodInput; toREST: (...args: unknown[]) => unknown; }; }; type ServicePluginDefinition = { __type: 'service-plugin-definition'; componentType: string; methods: ServicePluginMethodMetadata[]; __contract: Contract; }; declare function ServicePluginDefinition(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition; type BuildServicePluginDefinition> = (implementation: T['__contract']) => void; declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error"; type RequestContext = { isSSR: boolean; host: string; protocol?: string; }; type ResponseTransformer = (data: any, headers?: any) => any; /** * Ambassador request options types are copied mostly from AxiosRequestConfig. * They are copied and not imported to reduce the amount of dependencies (to reduce install time). * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315 */ type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK'; type AmbassadorRequestOptions = { _?: T; url?: string; method?: Method; params?: any; data?: any; transformResponse?: ResponseTransformer | ResponseTransformer[]; }; type AmbassadorFactory = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions) & { __isAmbassador: boolean; }; type AmbassadorFunctionDescriptor = AmbassadorFactory; type BuildAmbassadorFunction = T extends AmbassadorFunctionDescriptor ? (req: Request) => Promise : never; declare global { // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged. interface SymbolConstructor { readonly observable: symbol; } } declare const emptyObjectSymbol: unique symbol; /** Represents a strictly empty plain object, the `{}` value. When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)). @example ``` import type {EmptyObject} from 'type-fest'; // The following illustrates the problem with `{}`. const foo1: {} = {}; // Pass const foo2: {} = []; // Pass const foo3: {} = 42; // Pass const foo4: {} = {a: 1}; // Pass // With `EmptyObject` only the first case is valid. const bar1: EmptyObject = {}; // Pass const bar2: EmptyObject = 42; // Fail const bar3: EmptyObject = []; // Fail const bar4: EmptyObject = {a: 1}; // Fail ``` Unfortunately, `Record`, `Record` and `Record` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}. @category Object */ type EmptyObject = {[emptyObjectSymbol]?: never}; /** Returns a boolean for whether the two given types are equal. @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650 @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796 Use-cases: - If you want to make a conditional branch based on the result of a comparison of two types. @example ``` import type {IsEqual} from 'type-fest'; // This type returns a boolean for whether the given array includes the given item. // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal. type Includes = Value extends readonly [Value[0], ...infer rest] ? IsEqual extends true ? true : Includes : false; ``` @category Type Guard @category Utilities */ type IsEqual = (() => G extends A & G | G ? 1 : 2) extends (() => G extends B & G | G ? 1 : 2) ? true : false; /** Filter out keys from an object. Returns `never` if `Exclude` is strictly equal to `Key`. Returns `never` if `Key` extends `Exclude`. Returns `Key` otherwise. @example ``` type Filtered = Filter<'foo', 'foo'>; //=> never ``` @example ``` type Filtered = Filter<'bar', string>; //=> never ``` @example ``` type Filtered = Filter<'bar', 'foo'>; //=> 'bar' ``` @see {Except} */ type Filter = IsEqual extends true ? never : (KeyType extends ExcludeType ? never : KeyType); type ExceptOptions = { /** Disallow assigning non-specified properties. Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`. @default false */ requireExactProps?: boolean; }; /** Create a type from an object type without certain keys. We recommend setting the `requireExactProps` option to `true`. This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically. This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)). @example ``` import type {Except} from 'type-fest'; type Foo = { a: number; b: string; }; type FooWithoutA = Except; //=> {b: string} const fooWithoutA: FooWithoutA = {a: 1, b: '2'}; //=> errors: 'a' does not exist in type '{ b: string; }' type FooWithoutB = Except; //=> {a: number} & Partial> const fooWithoutB: FooWithoutB = {a: 1, b: '2'}; //=> errors at 'b': Type 'string' is not assignable to type 'undefined'. // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures. // Consider the following example: type UserData = { [metadata: string]: string; email: string; name: string; role: 'admin' | 'user'; }; // `Omit` clearly doesn't behave as expected in this case: type PostPayload = Omit; //=> type PostPayload = { [x: string]: string; [x: number]: string; } // In situations like this, `Except` works better. // It simply removes the `email` key while preserving all the other keys. type PostPayload = Except; //=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; } ``` @category Object */ type Except = { [KeyType in keyof ObjectType as Filter]: ObjectType[KeyType]; } & (Options['requireExactProps'] extends true ? Partial> : {}); /** Returns a boolean for whether the given type is `never`. @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919 @link https://stackoverflow.com/a/53984913/10292952 @link https://www.zhenghao.io/posts/ts-never Useful in type utilities, such as checking if something does not occur. @example ``` import type {IsNever, And} from 'type-fest'; // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts type AreStringsEqual = And< IsNever> extends true ? true : false, IsNever> extends true ? true : false >; type EndIfEqual = AreStringsEqual extends true ? never : void; function endIfEqual(input: I, output: O): EndIfEqual { if (input === output) { process.exit(0); } } endIfEqual('abc', 'abc'); //=> never endIfEqual('abc', '123'); //=> void ``` @category Type Guard @category Utilities */ type IsNever = [T] extends [never] ? true : false; /** An if-else-like type that resolves depending on whether the given type is `never`. @see {@link IsNever} @example ``` import type {IfNever} from 'type-fest'; type ShouldBeTrue = IfNever; //=> true type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>; //=> 'bar' ``` @category Type Guard @category Utilities */ type IfNever = ( IsNever extends true ? TypeIfNever : TypeIfNotNever ); /** Extract the keys from a type where the value type of the key extends the given `Condition`. Internally this is used for the `ConditionalPick` and `ConditionalExcept` types. @example ``` import type {ConditionalKeys} from 'type-fest'; interface Example { a: string; b: string | number; c?: string; d: {}; } type StringKeysOnly = ConditionalKeys; //=> 'a' ``` To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below. @example ``` import type {ConditionalKeys} from 'type-fest'; type StringKeysAndUndefined = ConditionalKeys; //=> 'a' | 'c' ``` @category Object */ type ConditionalKeys = { // Map through all the keys of the given base type. [Key in keyof Base]-?: // Pick only keys with types extending the given `Condition` type. Base[Key] extends Condition // Retain this key // If the value for the key extends never, only include it if `Condition` also extends never ? IfNever, Key> // Discard this key since the condition fails. : never; // Convert the produced object into a union type of the keys which passed the conditional test. }[keyof Base]; /** Exclude keys from a shape that matches the given `Condition`. This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties. @example ``` import type {Primitive, ConditionalExcept} from 'type-fest'; class Awesome { name: string; successes: number; failures: bigint; run() {} } type ExceptPrimitivesFromAwesome = ConditionalExcept; //=> {run: () => void} ``` @example ``` import type {ConditionalExcept} from 'type-fest'; interface Example { a: string; b: string | number; c: () => void; d: {}; } type NonStringKeysOnly = ConditionalExcept; //=> {b: string | number; c: () => void; d: {}} ``` @category Object */ type ConditionalExcept = Except< Base, ConditionalKeys >; /** * Descriptors are objects that describe the API of a module, and the module * can either be a REST module or a host module. * This type is recursive, so it can describe nested modules. */ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule | EventDefinition | ServicePluginDefinition | { [key: string]: Descriptors | PublicMetadata | any; }; /** * This type takes in a descriptors object of a certain Host (including an `unknown` host) * and returns an object with the same structure, but with all descriptors replaced with their API. * Any non-descriptor properties are removed from the returned object, including descriptors that * do not match the given host (as they will not work with the given host). */ type BuildDescriptors | undefined, Depth extends number = 5> = { done: T; recurse: T extends { __type: typeof SERVICE_PLUGIN_ERROR_TYPE; } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction : T extends RESTFunctionDescriptor ? BuildRESTFunction : T extends EventDefinition ? BuildEventDefinition : T extends ServicePluginDefinition ? BuildServicePluginDefinition : T extends HostModule ? HostModuleAPI : ConditionalExcept<{ [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors : never; }, EmptyObject>; }[Depth extends -1 ? 'done' : 'recurse']; type PublicMetadata = { PACKAGE_NAME?: string; }; declare global { interface ContextualClient { } } /** * A type used to create concerete types from SDK descriptors in * case a contextual client is available. */ type MaybeContext = globalThis.ContextualClient extends { host: Host$1; } ? BuildDescriptors : T; declare global { /** * A global interface to set the exposure toggle for the SDK. * @example * ```ts * declare global { * interface SDKExposureToggle { * alpha: true; * } * } */ interface SDKExposureToggle { } } type WixNamespace = string; interface Channel { observeState(callback: (props: unknown, environment: Environment) => unknown): { disconnect: () => void; } | Promise<{ disconnect: () => void; }>; } interface WebsiteChannel extends Channel { invoke: (args: { namespace: WixNamespace; method: string; args: unknown[]; }) => Promise; getAccessToken: () => Promise; } type Host = { channel: WebsiteChannel; environment?: Environment; }; /** * The Pricing Plans Orders API contains functionality for managing * a site's pricing plan [orders](https://support.wix.com/en/article/pricing-plans-an-overview). * * Use the Pricing Plans Orders API to manage orders for pricing plans. The Pricing Plans * Orders API provides functionality for managing pricing plan orders created * in the Wix Pricing Plans app or using this Wix Pricing Plans API. * * * ### Set up orders * * To use APIs to manage plan 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). * * * ### Manage orders * * 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). * * Use the Orders API to manage online pricing plan orders. You can: * * + List orders for the currently logged-in site member. * + Allow site members to request cancellation of their own orders. * * * ### 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 APIs](pricing-plans/introduction). * * 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 ([Velo](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/introduction#apis_wix-pricing-plans-backend_pricing-models) | [SDK](https://dev.wix.com/docs/sdk/backend-modules/pricing-plans/introduction#pricing-models)) to learn more. * * * ### Roles and permissions * * The current site visitor needs to be logged in to perform * plan order methods, such as `listCurrentMemberOrders()` or `requestCurrentMemberOrderCancellation()`. * * * ### Import the APIs * * To use the Orders API, import `orders` from the `wix-pricing-plans-frontend` module. * * ```javascript * import {orders} from 'wix-pricing-plans-frontend'; * ``` */ interface Orders { /** * Lists the orders for the currently logged-in member. * * > **Note:** * > + To work with the Pricing Plans API, a site needs to be published. * > * > + `listCurrentMemberOrders()` doesn't work in preview mode. * @param filters - Filter options for limiting which orders are listed. * @servicePath wix-pricing-plans-frontend.Orders.CurrentMemberFilterOptions * @param sorting - Sorting options, such as by which property and in which direction. * @servicePath wix-pricing-plans-frontend.Orders.SortingOptions * @param paging - Pagination options, such as how many results are listed at a time. * @servicePath wix-pricing-plans-frontend.Orders.PaginationOptions * @returns Fulfilled - An array of order objects for the currently logged-in member. * Rejected - Error message. * @servicePath wix-pricing-plans-frontend.Orders.Order */ listCurrentMemberOrders(filters?: CurrentMemberFilterOptions, sorting?: SortingOptions, paging?: PaginationOptions): Promise; /** * Requests the cancellation of a specific order of a plan for the currently logged-in member. * * `requestCurrentMemberOrderCancellation()` requests the cancellation of an order, * after verifying that the site member is logged in. * * This method doesn't immediately cancel the order. The cancellation request is initiated * and the `status` of the order is updated to `"PENDING_CANCELLATION"`. When the cancellation * is completed, the order status is updated to `"CANCELED"`. * * Keep in mind that a site member can order several subscriptions of the same plan. * This API doesn't cancel the plan and remove all corresponding subscriptions. * This API removes only the one specified order of the plan. * * If a plan's [Allow Plan Cancellation](https://support.wix.com/en/article/pricing-plans-allowing-clients-to-cancel-plans) * setting is disabled and the currently logged-in site member tries to cancel an order for the plan using `requestCurrentMemberOrderCancellation()`, * an error is thrown. * * * > **Note**: * > + To work with the Pricing Plans API, a site needs to be published. * @param orderId - The order ID of the order whose cancellation is requested. * @requiredField orderId * @param effectiveAt - When the cancellation should take effect. * One of: * + `"IMMEDIATELY"`. The cancellation occurs immediately and the buyer cannot use the plan at this point. * + `"NEXT_PAYMENT_DATE"`. The cancellation occurs at the next payment date. The buyer can continue to use the plan until that date. * @requiredField effectiveAt * @returns Fulfilled - When the order cancellation is requested. */ requestCurrentMemberOrderCancellation(orderId: string, effectiveAt: string): Promise; } /** * Buyer details. */ interface Buyer { /** * Member ID for the buyer. See the Members API to learn more about a site's members. * @requiredField memberId */ memberId: string; /** * Contact ID for the buyer. See the Contacts API to learn more about a site's contacts. * @requiredField contactId */ contactId: string; } /** * Details about the cancellation of an order. Only present if the order `status` is `"CANCELED"`. */ interface Cancellation { /** * Date and time when the cancellation was requested. * @requiredField requestedDate */ requestedDate: Date; /** * The reason for the cancellation. * Supported values: * + `"OWNER_ACTION"`: The Wix user canceled the order. * + `"MEMBER_ACTION"`: The buyer initiated the cancellation. * + `"PAYMENT_FAILURE"`: A payment transaction failed. * + `"PAYMENT_SETUP_FAILURE"`: The buyer's payment details weren't set up correctly. * @requiredField cause */ cause: string; /** * When the cancellation takes effect. Set when cancelling the order. * Supported values: * + `"IMMEDIATELY"`: The cancellation occurs immediately and the buyer can no longer use the plan at this point. * + `"NEXT_PAYMENT_DATE"`: The cancellation occurs at the next payment date and time. The buyer can continue to use the plan until that date and time. * @requiredField effectiveAt */ effectiveAt: string; } /** * Coupon applied to the order. * * To learn more about coupons, see `applyCoupon()`. */ interface Coupon { /** * Code of the applied coupon. * @requiredField code */ code: string; /** * Total discount of the coupon, as a monetary amount. * @requiredField amount */ amount: string; /** * Coupon ID. * @requiredField id */ id: string; } /** * Current payment cycle for the order. * * `currentCycle` will be omitted if the order's `status` is `CANCELED` or `ENDED`, or if the `startDate` hasn't been reached yet. */ interface CurrentCycle { /** * Index of the current payment cycle in the order. * * `0` when the order is in a free trial period. In all other cases, the index starts with `1`. * @requiredField index */ index: number; /** * Start date and time for the current payment cycle. * @requiredField startedDate */ startedDate: Date; /** * End date and time for the current payment cycle. * @requiredField endedDate */ endedDate: Date; } /** * Fields to filter by when listing orders for the current member. */ interface CurrentMemberFilterOptions { /** * Specific IDs of plans that were ordered by the current member. */ planIds?: string[]; /** * Whether the auto-renewal of the current member's recurring orders was canceled. */ autoRenewCanceled?: boolean; /** * Specific statuses for the current member's orders. * + `"DRAFT"`: The order has been initiated but payment hasn't been processed yet. The plan isn't yet available for use. * + `"PENDING"`: Payment is being processed. The plan isn't yet available for use. * + `"ACTIVE"`: The order has been processed and paid for. The plan is available for use. * + `"PAUSED"`: Use of the plan has been paused, see `pauseOrder()`, for example, if the buyer is away. The plan can be resumed, see `resumeOrder()`. * + `"ENDED"`: The order has completed its duration and is no longer available for use. * + `"CANCELED"`: The order has been canceled, see `cancelOrder()`. */ orderStatuses?: string[]; /** * Specific payment statuses for the current member's orders. * + `"PAID"`: The last payment was paid. * + `"REFUNDED"`: The last payment was refunded. * + `"FAILED"`: The last payment transaction didn't complete. * + `"UNPAID"`: The last payment wasn't paid. * + `"PENDING"`: Awaiting payment. * + `"NOT_APPLICABLE"`: No payment was necessary, such as for free plans or free trials. */ paymentStatuses?: string[]; } /** * Length of one payment cycle. For example, `1` `MONTH` for monthly payments. */ interface Duration { /** * The amount of a duration `unit` in a single payment cycle. * * Currently limited to support only value of `1`. * @requiredField count */ count: number; /** * Unit of time for the cycle duration. * * Supported values: `"UNDEFINED"`, `"DAY"`, `"WEEK"`, `"MONTH"`, `"YEAR"` * @requiredField unit */ unit: string; } interface Order { /** * Order ID. * @requiredField _id */ _id: string; /** * ID of the plan that was ordered. * @requiredField planId */ planId: string; /** * ID of the related Wix subscription. * * 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 the dashboard. * @requiredField subscriptionId */ subscriptionId: string; /** * ID of the associated Wix Pay order. * * Created by the `createOnlineOrder()` or `createOfflineOrder()` method. For online orders, send this value as a parameter to the Wix Pay `startPayment()` method to enable a buyer to pay for an order. `wixPayOrderId` is omitted if the order is free. */ wixPayOrderId?: string; /** * The buyer's IDs. Includes `memberId` and `contactId`. * * Currently, Pricing Plan orders are limited to members only. `contactId` is returned, but a buyer won't be able to order a plan without a `memberId`. * @requiredField buyer * @servicePath wix-pricing-plans-frontend.Orders.Buyer */ buyer: Buyer; /** * **Deprecated.** Use `pricing` instead. * @requiredField priceDetails * @servicePath wix-pricing-plans-frontend.Orders.PriceDetails */ priceDetails: PriceDetails; /** * Order pricing model, price, and payment schedule. 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. * @servicePath wix-pricing-plans-frontend.Orders.Pricing */ pricing?: Pricing; /** * How the order was processed. * Supported values: * + `"ONLINE"`: The buyer ordered the plan using the site. * + `"OFFLINE"`: The buyer made a manual, offline order without using the site. * @requiredField type */ type: string; /** * Status of the order. * Supported values: * + `"DRAFT"`: The order has been initiated but payment hasn't been processed yet. The plan isn't yet available for use. * + `"PENDING"`: The order has been processed and its start date is set in the future. The plan isn't yet available for use. * + `"ACTIVE"`: The order has been processed. The plan is available for use. * + `"PAUSED"`: The order and use of the plan is paused, see `pauseOrder()`. For example, if the buyer is away. The order and use of the plan can be resumed, see `resumeOrder()`. * + `"ENDED"`: The order has completed its duration and is no longer available for use. * + `"CANCELED"`: The order has been canceled, see `cancelOrder()`. * @requiredField status */ status: string; /** * Whether the order will be canceled at the next payment date. * * If `true`, the order `status` will be `"CANCELED"` and the next payment won't be charged. Omitted for single payment orders. */ autoRenewCanceled?: boolean; /** * Details about the cancellation of an order. Only present if the `status` is `"CANCELED"`. * @servicePath wix-pricing-plans-frontend.Orders.Cancellation */ cancellation?: Cancellation; /** * Status of the last payment for the order. This is updated automatically for online orders. The Wix user updates this manually for offline orders. * Supported values: * + `"PAID"`: The last payment was paid. * + `"REFUNDED"`: The last payment was refunded. * + `"FAILED"`: The last payment transaction didn't complete. * + `"UNPAID"`: The last payment wasn't paid. * + `"PENDING"`: Awaiting payment. * + `"NOT_APPLICABLE"`: No payment was necessary. For example, for free plans or free trials. * @requiredField lastPaymentStatus */ lastPaymentStatus: string; /** * Start date and time for the ordered plan. * @requiredField startDate */ startDate: Date; /** * Current date and time the ordered plan will expire. * * `endDate` may be updated over the course of an order. If the order is paused, see `pauseOrder()`, it will have a later `endDate` once it resumes, see `resumeOrder()`. `endDate` may also be postponed, see `postponeEndDate()`. * * Omitted if the order is valid until canceled and still `"ACTIVE"`. */ endDate?: Date; /** * List of periods during which this order is paused. * @requiredField pausePeriods * @servicePath wix-pricing-plans-frontend.Orders.PausePeriod */ pausePeriods: PausePeriod[]; /** * Free trial period, in days. Only available for recurring plans. */ freeTrialDays?: string; /** * Earliest end date and time that the plan for this order can expire. * * This is calculated by adding all pause periods to the original end date. Omitted if the order is active until canceled. Reserved for future use. */ earliestEndDate?: Date; /** * Current payment cycle for the order. * * `currentCycle` will be omitted if the order's status is `"CANCELED"` or `"ENDED"`, or if the `startDate` hasn't passed yet. * @requiredField currentCycle * @servicePath wix-pricing-plans-frontend.Orders.CurrentCycle */ currentCycle: CurrentCycle; /** * Name of the plan at the time of the order. * @requiredField planName */ planName: string; /** * Description of the plan at the time of the order. * @requiredField planDescription */ planDescription: string; /** * Plan price as it was at the moment of order creation. * @requiredField planPrice */ planPrice: string; /** * Date and time the order was created. * @requiredField _createdDate */ _createdDate: Date; /** * Date and time the order was last updated. For example, the date and time an order was paused, resumed, or canceled. * @requiredField _updatedDate */ _updatedDate: Date; } /** * The order has recurring payments. */ interface OrderRecurrence { /** * Length of one payment cycle. For example, `1` `MONTH` for monthly payments. * @requiredField cycleDuration * @servicePath wix-pricing-plans-frontend.Orders.Duration */ cycleDuration: Duration; /** * Amount of payment cycles this subscription is valid for. * * `0` for orders of plans that are unlimited or until-canceled. * @requiredField cycleCount */ cycleCount: number; } interface PaginationOptions { /** * Limit the number of orders returned. * * Default: `50` */ limit?: number; /** * Number of entries to skip. */ skip?: number; } /** * Period during which the order of a plan is suspended. */ interface PausePeriod { /** * Status of the pause period. * Supported values: * + `"ACTIVE"`. Status while the order is [paused](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-v2/orders/pause-order). * + `"ENDED"`. Status while the order is [resumed](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-v2/orders/resume-order). * @requiredField status */ status: string; /** * Start date and time of the pause period. * @requiredField pauseDate */ pauseDate: Date; /** * End date and time of the pause period. * * Omitted while the pause period remains `"ACTIVE"`. * @requiredField resumeDate */ resumeDate: Date; } /** * Order price details. */ interface Price$1 { /** * Price of the order excluding tax, specified as a monetary amount. For example, `"9.99"`. * @requiredField subtotal */ subtotal: string; /** * Coupon applied to the order. * * To learn more about coupons, see `applyCoupon()`. * @requiredField coupon * @servicePath wix-pricing-plans-frontend.Orders.Coupon */ coupon: Coupon; /** * Total discount applied to the order. * @requiredField discount */ discount: string; /** * Tax applied to the order. * @servicePath wix-pricing-plans-frontend.Orders.Tax */ tax?: Tax; /** * Price after tax and discount is applied, specified as a monetary amount. For example, `"13.98"`. * * If no tax is applied, this amount is the same as `subtotal`. * @requiredField total */ total: string; /** * 3-letter currency code in [ISO 4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. * @requiredField currency */ currency: string; } /** * **Deprecated.** Use `pricing` instead. */ interface PriceDetails extends priceDetailsPricingModelOneOf { /** * Price of the order, excluding tax. Specified as a monetary amount, such as `"3.99"`. * @requiredField subtotal */ subtotal: string; /** * Tax applied for the plan. Omitted if no tax was applied. * @servicePath wix-pricing-plans-frontend.Orders.Tax */ tax?: Tax; /** * Price after tax is applied. Specified as a monetary amount, such as `"4.98"`. If no tax was applied, this amount is the same as `subtotal`. * @requiredField total */ total: string; /** * Price of the plan when the order was created. This price is the amount for a single payment. For subscriptions, this is the amount to pay for each single payment cycle and the `planPrice` is required. Otherwise, the payment is for the entire plan. * @requiredField planPrice */ planPrice: string; /** * Currency code. Must be a valid [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code (for example, `"USD"`). * @requiredField currency */ currency: string; /** * Pricing model indicating that the order has recurring payments. This type of subscription isn't a "Wix subscription," which encompasses various types of subscriptions, such as Wix Stores subscriptions, Wix invoice subscriptions, and *all* pricing plan models. * @servicePath wix-pricing-plans-frontend.Orders.OrderRecurrence */ subscription?: OrderRecurrence; /** * Pricing model indicating that the order is paid with a single payment per cycle and what the length of the cycle is. The cycle is the duration of the order's plan, not a payment cycle. * @servicePath wix-pricing-plans-frontend.Orders.Duration */ singlePaymentForDuration?: Duration; /** * Pricing model indicating that the order of the plan is paid in 1 single payment and that the order is active until canceled. */ singlePaymentUnlimited?: boolean; /** * Free trial period for the order in days. Available only for orders whose plans are recurring, meaning plans whose pricing model is `subscription`. */ freeTrialDays?: number; } /** * @oneof */ interface priceDetailsPricingModelOneOf { /** * Pricing model indicating that the order is paid with a single payment per cycle and what the length of the cycle is. The cycle is the duration of the order's plan, not a payment cycle. * @servicePath wix-pricing-plans-frontend.Orders.Duration */ singlePaymentForDuration?: Duration; /** * Pricing model indicating that the order of the plan is paid in 1 single payment and that the order is active until canceled. */ singlePaymentUnlimited?: boolean; /** * Pricing model indicating that the order has recurring payments. This type of subscription isn't a "Wix subscription," which encompasses various types of subscriptions, such as Wix Stores subscriptions, Wix invoice subscriptions, and *all* pricing plan models. * @servicePath wix-pricing-plans-frontend.Orders.OrderRecurrence */ subscription?: OrderRecurrence; } /** * Cycle duration to apply `price` for. */ interface PriceDuration { /** * Price starts to apply with this cycle. * * `1` is the first payment cycle for all pricing models. * @requiredField cycleFrom */ cycleFrom: number; /** * Amount of cycles to apply price for. * * For `subscription` pricing models with a finite number of cycles, the `numberOfCycles` is the same as `pricing.subscription.cycleCount`. * * For `subscription` pricing models that are unlimited or until-canceled, the `numberOfCycles` isn't returned. * * For `singlePaymentForDuration` and `singlePaymentUnlimited` pricing models, the `numberOfCycles` is `1`. * @requiredField numberOfCycles */ numberOfCycles: number; } /** * Pricing details for all pricing models. */ interface Prices { /** * Cycle duration to apply `price` for. * * Use with all pricing models. Can apply the same price to multiple payment cycles. * @requiredField duration * @servicePath wix-pricing-plans-frontend.Orders.PriceDuration */ duration: PriceDuration; /** * Order price. * @requiredField price * @servicePath wix-pricing-plans-frontend.Orders.Price */ price: Price$1; } /** * Order pricing model, price, and payment schedule. */ interface Pricing extends pricingPricingModelOneOf { /** * Pricing model for an order with recurring payment cycles. * @servicePath wix-pricing-plans-frontend.Orders.OrderRecurrence */ subscription?: OrderRecurrence; /** * Pricing model for an order with a one-time payment and the order is valid for a specific amount of time. * @servicePath wix-pricing-plans-frontend.Orders.Duration */ singlePaymentForDuration?: Duration; /** * Pricing model for an order with a one-time payment and the order is valid until canceled. */ singlePaymentUnlimited?: boolean; /** * Pricing details for all pricing models. * @requiredField prices * @servicePath wix-pricing-plans-frontend.Orders.Prices */ prices: Prices; } /** * @oneof */ interface pricingPricingModelOneOf { /** * Pricing model for an order with a one-time payment and the order is valid for a specific amount of time. * @servicePath wix-pricing-plans-frontend.Orders.Duration */ singlePaymentForDuration?: Duration; /** * Pricing model for an order with a one-time payment and the order is valid until canceled. */ singlePaymentUnlimited?: boolean; /** * Pricing model for an order with recurring payment cycles. * @servicePath wix-pricing-plans-frontend.Orders.OrderRecurrence */ subscription?: OrderRecurrence; } /** * Sorting details. */ interface SortingOptions { /** * Name of the property to sort by. * * Supported values: `_createdDate`, `endDate` * * Default: `_createdDate` */ fieldName?: string; /** * Sort order. * * Supported values: * + `"ASC"`: Ascending * + `"DESC"`: Descending * * Default: `"ASC"` */ order?: string; } /** * Tax applied to the order. If empty, no tax was applied. */ interface Tax { /** * Name of the tax. For example, VAT. * @requiredField name */ name: string; /** * Whether tax is included in the original price. When `false`, tax is added at checkout. * @requiredField includedInPrice */ includedInPrice: boolean; /** * Tax rate percentage, as a number between 0 and 100. For example, a 7% tax rate is `"7.00"`. * @requiredField rate */ rate: string; /** * Total tax, specified as a monetary amount. For example, `"3.99"`. * @requiredField amount */ amount: string; } /** * Lists the orders for the currently logged-in member. * * > **Note:** * > + To work with the Pricing Plans API, a site needs to be published. * > * > + `listCurrentMemberOrders()` doesn't work in preview mode. * @param filters - Filter options for limiting which orders are listed. * @servicePath wix-pricing-plans-frontend.Orders.CurrentMemberFilterOptions * @param sorting - Sorting options, such as by which property and in which direction. * @servicePath wix-pricing-plans-frontend.Orders.SortingOptions * @param paging - Pagination options, such as how many results are listed at a time. * @servicePath wix-pricing-plans-frontend.Orders.PaginationOptions * @returns Fulfilled - An array of order objects for the currently logged-in member. * Rejected - Error message. * @servicePath wix-pricing-plans-frontend.Orders.Order */ declare function listCurrentMemberOrders(filters?: CurrentMemberFilterOptions, sorting?: SortingOptions, paging?: PaginationOptions): Promise; /** * Requests the cancellation of a specific order of a plan for the currently logged-in member. * * `requestCurrentMemberOrderCancellation()` requests the cancellation of an order, * after verifying that the site member is logged in. * * This method doesn't immediately cancel the order. The cancellation request is initiated * and the `status` of the order is updated to `"PENDING_CANCELLATION"`. When the cancellation * is completed, the order status is updated to `"CANCELED"`. * * Keep in mind that a site member can order several subscriptions of the same plan. * This API doesn't cancel the plan and remove all corresponding subscriptions. * This API removes only the one specified order of the plan. * * If a plan's [Allow Plan Cancellation](https://support.wix.com/en/article/pricing-plans-allowing-clients-to-cancel-plans) * setting is disabled and the currently logged-in site member tries to cancel an order for the plan using `requestCurrentMemberOrderCancellation()`, * an error is thrown. * * * > **Note**: * > + To work with the Pricing Plans API, a site needs to be published. * @param orderId - The order ID of the order whose cancellation is requested. * @requiredField orderId * @param effectiveAt - When the cancellation should take effect. * One of: * + `"IMMEDIATELY"`. The cancellation occurs immediately and the buyer cannot use the plan at this point. * + `"NEXT_PAYMENT_DATE"`. The cancellation occurs at the next payment date. The buyer can continue to use the plan until that date. * @requiredField effectiveAt * @returns Fulfilled - When the order cancellation is requested. */ declare function requestCurrentMemberOrderCancellation(orderId: string, effectiveAt: string): Promise; type ordersSdkModuleRuntime_Buyer = Buyer; type ordersSdkModuleRuntime_Cancellation = Cancellation; type ordersSdkModuleRuntime_Coupon = Coupon; type ordersSdkModuleRuntime_CurrentCycle = CurrentCycle; type ordersSdkModuleRuntime_CurrentMemberFilterOptions = CurrentMemberFilterOptions; type ordersSdkModuleRuntime_Duration = Duration; type ordersSdkModuleRuntime_Order = Order; type ordersSdkModuleRuntime_OrderRecurrence = OrderRecurrence; type ordersSdkModuleRuntime_Orders = Orders; type ordersSdkModuleRuntime_PaginationOptions = PaginationOptions; type ordersSdkModuleRuntime_PausePeriod = PausePeriod; type ordersSdkModuleRuntime_PriceDetails = PriceDetails; type ordersSdkModuleRuntime_PriceDuration = PriceDuration; type ordersSdkModuleRuntime_Prices = Prices; type ordersSdkModuleRuntime_Pricing = Pricing; type ordersSdkModuleRuntime_SortingOptions = SortingOptions; type ordersSdkModuleRuntime_Tax = Tax; declare const ordersSdkModuleRuntime_listCurrentMemberOrders: typeof listCurrentMemberOrders; type ordersSdkModuleRuntime_priceDetailsPricingModelOneOf = priceDetailsPricingModelOneOf; type ordersSdkModuleRuntime_pricingPricingModelOneOf = pricingPricingModelOneOf; declare const ordersSdkModuleRuntime_requestCurrentMemberOrderCancellation: typeof requestCurrentMemberOrderCancellation; declare namespace ordersSdkModuleRuntime { export { type ordersSdkModuleRuntime_Buyer as Buyer, type ordersSdkModuleRuntime_Cancellation as Cancellation, type ordersSdkModuleRuntime_Coupon as Coupon, type ordersSdkModuleRuntime_CurrentCycle as CurrentCycle, type ordersSdkModuleRuntime_CurrentMemberFilterOptions as CurrentMemberFilterOptions, type ordersSdkModuleRuntime_Duration as Duration, type ordersSdkModuleRuntime_Order as Order, type ordersSdkModuleRuntime_OrderRecurrence as OrderRecurrence, type ordersSdkModuleRuntime_Orders as Orders, type ordersSdkModuleRuntime_PaginationOptions as PaginationOptions, type ordersSdkModuleRuntime_PausePeriod as PausePeriod, type Price$1 as Price, type ordersSdkModuleRuntime_PriceDetails as PriceDetails, type ordersSdkModuleRuntime_PriceDuration as PriceDuration, type ordersSdkModuleRuntime_Prices as Prices, type ordersSdkModuleRuntime_Pricing as Pricing, type ordersSdkModuleRuntime_SortingOptions as SortingOptions, type ordersSdkModuleRuntime_Tax as Tax, ordersSdkModuleRuntime_listCurrentMemberOrders as listCurrentMemberOrders, type ordersSdkModuleRuntime_priceDetailsPricingModelOneOf as priceDetailsPricingModelOneOf, type ordersSdkModuleRuntime_pricingPricingModelOneOf as pricingPricingModelOneOf, ordersSdkModuleRuntime_requestCurrentMemberOrderCancellation as requestCurrentMemberOrderCancellation }; } /** * 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'; * ``` */ 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; } 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. */ 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. */ 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. */ 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; } 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. */ 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 */ declare 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 */ declare function startOnlinePurchase(planId: string, startDate?: Date): Promise; type checkoutSdkModuleRuntime_Checkout = Checkout; type checkoutSdkModuleRuntime_CreateOnlineOrderOptions = CreateOnlineOrderOptions; type checkoutSdkModuleRuntime_Period = Period; type checkoutSdkModuleRuntime_Price = Price; type checkoutSdkModuleRuntime_Purchase = Purchase; type checkoutSdkModuleRuntime_StartOnlinePurchaseOptions = StartOnlinePurchaseOptions; type checkoutSdkModuleRuntime_ValidFor = ValidFor; declare const checkoutSdkModuleRuntime_createOnlineOrder: typeof createOnlineOrder; declare const checkoutSdkModuleRuntime_startOnlinePurchase: typeof startOnlinePurchase; declare namespace checkoutSdkModuleRuntime { export { type checkoutSdkModuleRuntime_Checkout as Checkout, type checkoutSdkModuleRuntime_CreateOnlineOrderOptions as CreateOnlineOrderOptions, type checkoutSdkModuleRuntime_Period as Period, type checkoutSdkModuleRuntime_Price as Price, type checkoutSdkModuleRuntime_Purchase as Purchase, type checkoutSdkModuleRuntime_StartOnlinePurchaseOptions as StartOnlinePurchaseOptions, type checkoutSdkModuleRuntime_ValidFor as ValidFor, checkoutSdkModuleRuntime_createOnlineOrder as createOnlineOrder, checkoutSdkModuleRuntime_startOnlinePurchase as startOnlinePurchase }; } type Methods$2 = { [P in keyof T as T[P] extends Function ? P : never]: T[P]; }; declare const checkoutRuntime: MaybeContext, Host> & Methods$2>; /** * The Custom Purchase Flow API contains functionality for customizing the plan purchase flow on a site. * * Use the Custom Purchase Flow API to customize the pages in the plan purchase flow on a site. This API provides * functionality for directing users to the Plans & Pricing and Checkout pages outside of the default flow. It also * allows you to customize the content displayed on the Plan & Pricing, Checkout, and Thank You pages. * * ### Set up pricing plans * To use APIs to customize the plan purchase flow, a site must first be set up to: * * + Accept payments as described in [Accepting Payments: An Overview](https://support.wix.com/en/article/accepting-payments-an-overview). * * + Offer membership 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 [using the dashboard](https://support.wix.com/en/article/pricing-plans-creating-a-one-time-payment-plan) or * using the Pricing Plan APIs. * * ### Direct users to pages in the purchase flow * The Custom Purchase Flow API lets you direct customers to either of 2 pages in the plan purchase flow: * * + **The Plans & Pricing page**: You can navigate from anywhere in a site to the Plans & Pricing page. * + **The Checkout page**: If a site uses a custom Plans & Pricing page, you can navigate to checkout from anywhere in a site, including * the Plans & Pricing page. If a site uses the default Plans & Pricing page, visitors will still be directed from Plans & Pricing to the * Checkout page without you calling any method. However, you may also direct customers to checkout from any other page in a site. * * ### Customize the content of the Plans & Pricing and Checkout pages * You can use `navigateToPricingPage()` and `navigateToCheckout()` methods to customize * pages in the plan purchase flow: * * + **Customizing the Plans & Pricing page**: You can set page content such as the title and subtitle of the Plans & Pricing page by passing * options to `navigateToPricingPage()`. In the same method you can also pass options to customize the content * on the Checkout and Thank You pages. * + **Customizing the Checkout page**: In `navigateToCheckout()`, you can pass options to customize the * content displayed on the Checkout and Thank You pages. * + **Retrieving the Pricing Page options**: You can call `getPricingPageOptions()` on the Plans & Pricing page to * retrieve the Pricing page options you set in `navigateToPricingPage()`. * * ### Customize the pricing plan purchase flow * You can now add custom pages to the pricing plan flow, as well as build a custom Plans & Pricing page. * * If you add pages between Plans & Pricing and Checkout, you'll need to store the options set in `navigateToPricingPage()` * globally, for example using the Wix Storage API and access them before you call `navigateToCheckout()`. * * If you are navigating directly from the Plans & Pricing page to Checkout, you can * call [`getPricingPageOptions()`](#getPricingPageOptions) and pass the retrieved options directly to [`navigateToCheckout()`](#navigateToCheckout). * * ### Import the APIs * To use the CustomPurchaseFlow API, import `customPurchaseFlow` from the `wix-pricing-plans-frontend` module. * * ```javascript * import { customPurchaseFlow } from 'wix-pricing-plans-frontend'; * ``` */ interface CustomPurchaseFlow { /** * Returns the options set for the current Plans & Pricing page. * * `getPricingPageOptions()` retrieves the options set for the Plans & Pricing Page in `navigateToPricingPage()`. * The returned `PricingPageOptions` object also includes any options set for the Checkout and Thank You pages. * * Call this method in the page code of a default or custom Plans & Pricing page. If you need to pass the returned pricing page * options to `navigateToCheckout()` at a later point, store the options object globally so you can access it later. * * > **Note:** * > + To work with the Pricing Plans API, a site needs to be published. * * @servicePath wix-pricing-plans-frontend.CustomPurchaseFlow.PricingPageOptions */ getPricingPageOptions(): Promise; /** * Directs site visitor to the Checkout page in the plan purchase flow. * * `navigateToCheckout()` redirects the site visitor to the Checkout page from any other page on a site. It also provides * options to customize the Checkout and Thank You pages that come later in the plan purchase flow. * * Note that the use of `navigateToCheckout()` differs slightly depending on whether you use the default Plans & Pricing page or a custom one: * + If you choose to use the default Plans & Pricing page, you won't be able to call `navigateToCheckout()` from there, but * you may still call it from any other page in a site. * + If you are using a custom Plans & Pricing page, you can call `navigateToCheckout()` on the plans page as well as anywhere else on a * site. * * > **Notes:** * > + Setting the `minStartDate` and `maxStartDate` parameters have no effect unless you've allowed customers * > to [set the plan start date](https://support.wix.com/en/article/pricing-plans-creating-a-one-time-payment-plan#step-4-adjust-your-plans-settings). * > + To work with the Pricing Plans API, a site needs to be published. * @param options - Options to customize the Checkout page and subsequent flow. * @requiredField options * @servicePath wix-pricing-plans-frontend.CustomPurchaseFlow.CheckoutOptions */ navigateToCheckout(options: CheckoutOptions): Promise; /** * Directs site visitor to the Pricing & Plans page in the plan purchase flow. * * `navigateToPricingPage()` directs the site visitor to the active Plans & Pricing page from any other page on a site. * It also provides options to customize the Checkout and Thank You pages that come later in the plan purchase flow. This allows you to * customize each of the pages in the flow with a single method. * * > **Notes:** * > * > + Setting the `minStartDate` and `maxStartDate` parameters have no effect unless you've allowed customers * > to [set the plan start date](https://support.wix.com/en/article/pricing-plans-creating-a-one-time-payment-plan#step-4-adjust-your-plans-settings). * > + To work with the Pricing Plans API, a site needs to be published. * @param options - Options to customize the Plans & Pricing page and subsequent flow. * @requiredField options * @servicePath wix-pricing-plans-frontend.CustomPurchaseFlow.PricingPageOptions */ navigateToPricingPage(options: PricingPageOptions): Promise; } /** * Sets the data associated with the Checkout page. */ interface CheckoutOptions { /** * Selected pricing plan ID. * @requiredField planId */ planId: string; /** * Earliest date the selected plan can start in `yyyy-MM-dd` format. */ minStartDate?: string; /** * Latest date the selected plan can start in `yyyy-MM-dd` format. */ maxStartDate?: string; /** * The data associated with the Thank You page. * @servicePath wix-pricing-plans-frontend.CustomPurchaseFlow.ThankYouPage */ thankYouPage?: ThankYouPage; } /** * Sets the data associated with the Checkout page. */ interface CheckoutPageOptions { /** * Earliest date the selected plan can start in `yyyy-MM-dd` format. */ minStartDate?: string; /** * Latest date the selected plan can start in `yyyy-MM-dd` format. */ maxStartDate?: string; /** * The data associated with the Thank You page. * @servicePath wix-pricing-plans-frontend.CustomPurchaseFlow.ThankYouPage */ thankYouPage?: ThankYouPage; } /** * Settings for the display of the Plans & Pricing page and subsequent pages in the plan purchase flow. */ interface PricingPageOptions { /** * List of plan IDs displayed on the Plans & Pricing page. */ planIds?: string[]; /** * Plans & Pricing page title. */ title?: string; /** * Plans & Pricing page subtitle. */ subtitle?: string; /** * The data associated with the Checkout page. * @servicePath wix-pricing-plans-frontend.CustomPurchaseFlow.CheckoutPageOptions */ checkout?: CheckoutPageOptions; } /** * Options to customize the Thank You page that's displayed after a customer purchases a plan. */ interface ThankYouPage { /** * The content displayed on the Thank You page. * @servicePath wix-pricing-plans-frontend.CustomPurchaseFlow.content */ content?: content; /** * The page to navigate to when a user clicks the button on the Thank You Page. * It must be a page on a site. * @servicePath wix-pricing-plans-frontend.CustomPurchaseFlow.navigation */ navigation?: navigation; } /** * The content displayed on the Thank You page. */ interface content { /** * Thank You page title. */ title?: string; /** * Thank You page body. */ message?: string; /** * Thank You page button label. */ cta?: string; } /** * The page to navigate to when a user clicks the button on the Thank You Page. * It must be a page on a site. */ interface navigation { /** * URL of a page on a site. The link may be relative or a site's base URL. Examples: * + `/home` * + `https://my.wixsite.com/path` * @requiredField url */ url: string; /** * Link type. * * Supported values: * - `"url"` * @requiredField type */ type: string; } /** * Returns the options set for the current Plans & Pricing page. * * `getPricingPageOptions()` retrieves the options set for the Plans & Pricing Page in `navigateToPricingPage()`. * The returned `PricingPageOptions` object also includes any options set for the Checkout and Thank You pages. * * Call this method in the page code of a default or custom Plans & Pricing page. If you need to pass the returned pricing page * options to `navigateToCheckout()` at a later point, store the options object globally so you can access it later. * * > **Note:** * > + To work with the Pricing Plans API, a site needs to be published. * * @servicePath wix-pricing-plans-frontend.CustomPurchaseFlow.PricingPageOptions */ declare function getPricingPageOptions(): Promise; /** * Directs site visitor to the Checkout page in the plan purchase flow. * * `navigateToCheckout()` redirects the site visitor to the Checkout page from any other page on a site. It also provides * options to customize the Checkout and Thank You pages that come later in the plan purchase flow. * * Note that the use of `navigateToCheckout()` differs slightly depending on whether you use the default Plans & Pricing page or a custom one: * + If you choose to use the default Plans & Pricing page, you won't be able to call `navigateToCheckout()` from there, but * you may still call it from any other page in a site. * + If you are using a custom Plans & Pricing page, you can call `navigateToCheckout()` on the plans page as well as anywhere else on a * site. * * > **Notes:** * > + Setting the `minStartDate` and `maxStartDate` parameters have no effect unless you've allowed customers * > to [set the plan start date](https://support.wix.com/en/article/pricing-plans-creating-a-one-time-payment-plan#step-4-adjust-your-plans-settings). * > + To work with the Pricing Plans API, a site needs to be published. * @param options - Options to customize the Checkout page and subsequent flow. * @requiredField options * @servicePath wix-pricing-plans-frontend.CustomPurchaseFlow.CheckoutOptions */ declare function navigateToCheckout(options: CheckoutOptions): Promise; /** * Directs site visitor to the Pricing & Plans page in the plan purchase flow. * * `navigateToPricingPage()` directs the site visitor to the active Plans & Pricing page from any other page on a site. * It also provides options to customize the Checkout and Thank You pages that come later in the plan purchase flow. This allows you to * customize each of the pages in the flow with a single method. * * > **Notes:** * > * > + Setting the `minStartDate` and `maxStartDate` parameters have no effect unless you've allowed customers * > to [set the plan start date](https://support.wix.com/en/article/pricing-plans-creating-a-one-time-payment-plan#step-4-adjust-your-plans-settings). * > + To work with the Pricing Plans API, a site needs to be published. * @param options - Options to customize the Plans & Pricing page and subsequent flow. * @requiredField options * @servicePath wix-pricing-plans-frontend.CustomPurchaseFlow.PricingPageOptions */ declare function navigateToPricingPage(options: PricingPageOptions): Promise; type customPurchaseFlowSdkModuleRuntime_CheckoutOptions = CheckoutOptions; type customPurchaseFlowSdkModuleRuntime_CheckoutPageOptions = CheckoutPageOptions; type customPurchaseFlowSdkModuleRuntime_CustomPurchaseFlow = CustomPurchaseFlow; type customPurchaseFlowSdkModuleRuntime_PricingPageOptions = PricingPageOptions; type customPurchaseFlowSdkModuleRuntime_ThankYouPage = ThankYouPage; type customPurchaseFlowSdkModuleRuntime_content = content; declare const customPurchaseFlowSdkModuleRuntime_getPricingPageOptions: typeof getPricingPageOptions; declare const customPurchaseFlowSdkModuleRuntime_navigateToCheckout: typeof navigateToCheckout; declare const customPurchaseFlowSdkModuleRuntime_navigateToPricingPage: typeof navigateToPricingPage; type customPurchaseFlowSdkModuleRuntime_navigation = navigation; declare namespace customPurchaseFlowSdkModuleRuntime { export { type customPurchaseFlowSdkModuleRuntime_CheckoutOptions as CheckoutOptions, type customPurchaseFlowSdkModuleRuntime_CheckoutPageOptions as CheckoutPageOptions, type customPurchaseFlowSdkModuleRuntime_CustomPurchaseFlow as CustomPurchaseFlow, type customPurchaseFlowSdkModuleRuntime_PricingPageOptions as PricingPageOptions, type customPurchaseFlowSdkModuleRuntime_ThankYouPage as ThankYouPage, type customPurchaseFlowSdkModuleRuntime_content as content, customPurchaseFlowSdkModuleRuntime_getPricingPageOptions as getPricingPageOptions, customPurchaseFlowSdkModuleRuntime_navigateToCheckout as navigateToCheckout, customPurchaseFlowSdkModuleRuntime_navigateToPricingPage as navigateToPricingPage, type customPurchaseFlowSdkModuleRuntime_navigation as navigation }; } type Methods$1 = { [P in keyof T as T[P] extends Function ? P : never]: T[P]; }; declare const customPurchaseFlowRuntime: MaybeContext, Host> & Methods$1>; type Methods = { [P in keyof T as T[P] extends Function ? P : never]: T[P]; }; declare const ordersRuntime: MaybeContext, Host> & Methods>; export { checkoutRuntime as checkout, customPurchaseFlowRuntime as customPurchaseFlow, ordersRuntime as orders };