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 the options available for the specified 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
string

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

planOrderId
string

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

benefitId
string

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

remainingCredits
number

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

totalCredits
number

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

planExpiration
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

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