Search.../

getCheckoutOptions( )

Gets the valid checkout options for a service's slot.

Description

The getCheckoutOptions() function returns a Promise that resolves to the valid checkout options for the given service's slot.

To understand how getCheckoutOptions() is used in a typical booking lifecycle, see Typical Booking Lifecycle.

The passed checkoutOptionOptions object contains the slot ID for the service. Typically, you retrieve the slot ID with the getServiceAvailability() function.

getCheckoutOptions() returns only the options available for the currently-logged-in user. For example, if the user has not purchased any pricing plans, pricing plans are not returned even if there are pricing plans associated with the service.

Syntax

function getCheckoutOptions(checkoutOptionOptions: CheckoutOptionOptions): Promise<Array<CheckoutOption>>

getCheckoutOptions Parameters

NAME
TYPE
DESCRIPTION
checkoutOptionOptions

CheckoutOptionOptions

An object containing the information needed to identify the service for which to list the possible checkout options. Currently, you can request the checkout options using the ID of a slot.

Returns

Fulfilled - The available payment options for the service and the logged-in user. Rejected - Checkout payment options error object.

Return Type:

Promise<Array<CheckoutOption>>
NAME
TYPE
DESCRIPTION
type

string

Type of the available payment option. Valid options are:

  • "wixPay_Online" for online collections
  • "wixPay_Offline" for offline collections
  • "package" for a package-type pricing plan
  • "membership" for a membership-type pricing plan
planName
Optional

string

Name of the plan package or membership. For booking with pricing plans only.

planOrderId
Optional

string

Order ID of the plan package or membership. For booking with pricing plans only.

benefitId
Optional

string

ID of the benefit provided by the plan package. For booking with package-type pricing plans only.

remainingCredits
Optional

number

Number of sessions remaining in the plan package. For booking with package-type pricing plans only.

totalCredits
Optional

number

Number of sessions initially provided with the plan package. For booking with package-type pricing plans only.

planExpiration
Optional

Date

Date by which the plan package or membership expires. For booking with pricing plans only.

Was this helpful?

Get the checkout options for a service that are available to the logged-in user

Code Example

Copy Code
1import wixBookings from 'wix-bookings';
2
3// ...
4
5// get available slot with `getServiceAvailability()`
6let options = {
7 "slotId": slot._id
8}
9
10wixBookings.getCheckoutOptions(options)
11 .then((checkoutOptions) => {
12 let firstOptionType = checkoutOptions[0].type;
13 });
14
15/* An object containing checkout options:
16 * {
17 * [
18 * {
19 * "type":"wixPay_Online"
20 * },
21 * {
22 * "type":"wixPay_Offline"
23 * },
24 * {
25 * "type":"membership",
26 * "planName":"Frequent Flier",
27 * "planOrderId":"b1a75-...-a236",
28 * "planExpiration":"2021-01-08T11:39:29.218Z",
29 * "benefitId":"93de9c-...-48e6"
30 * },
31 * {
32 * "type":"package",
33 * "planName":"Repeat Customer",
34 * "planOrderId":"9551f-...-1b8039",
35 * "planExpiration":"2020-07-08T11:39:11.340Z",
36 * "benefitId":"8b11cc-...-67a49e",
37 * "remainingCredits":58,
38 * "totalCredits":60
39 * }
40 * ]
41 * }
42 */