βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. Page Load - Initialize UseePay SDK β
β UseePay(publicKey) β elements(options) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 2. Create and Mount Express Checkout Element β
β elements.create('expressCheckout', options) β
β expressCheckoutElement.mount(domId) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 3. ready Event Triggered β
β β Check available payment methods (Apple Pay/Google Pay)β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 4. Customer Clicks Express Payment Button β
β β click event triggered (complete within 1 second) β
β β Optional: Dynamically update lineItems/shippingRates/ β
β applePay β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββ΄ββββββββββββββββ
β Shipping Required? β
βββββββββ¬ββββββββββββββββ¬ββββββββ
β Yes β No
β β
ββββββββββββββββββββββββ β
β 5a. Customer Selects/ β β
β Changes Address β β
β shippingAddressChangeβ β
β (complete within 20s) β β
β β Return shipping β β
β rates β β
ββββββββββββ¬ββββββββββββ β
β β
ββββββββββββββββββββββββ β
β 5b. Customer Selects β β
β Shipping Rate β β
β shippingRateChange β β
β (complete within 20s) β β
ββββββββββββ¬ββββββββββββ β
ββββββββββ¬βββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 6. Customer Confirms Payment - confirm event triggered β
β β Get billingDetails and shippingAddress β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 7. Call Backend API to Create Payment Intent β
β POST /api/create-payment-intent β
β β Return paymentIntentId and clientSecret β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 8. Confirm Payment β
β useepay.confirmPayment({ elements, paymentIntentId, β
β clientSecret }) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββ΄ββββββββββββββββ
β Payment Result β
βββββββββ¬ββββββββββββββββ¬ββββββββ
β Success β Failure
β β
ββββββββββββββββββββ ββββββββββββββββββββ
β 9a. Redirect to β β 9b. Display Error β
β Success Page β β Let Customer β
β β β Retry β
ββββββββββββββββββββ ββββββββββββββββββββ| Event | Timeout | Description |
|---|---|---|
click | 1 second | Must respond quickly, avoid time-consuming operations |
shippingAddressChange | 20 seconds | Can call API to calculate shipping costs |
shippingRateChange | 20 seconds | Can call API to update order information |
confirm | Unlimited | Need to create payment intent and confirm payment |
window.onload or DOMContentLoaded eventUseePay_PK_ (e.g., UseePay_PK_1234567890abcdef...)UseePay_PK_TEST_ (e.g., UseePay_PK_TEST_1234567890abcdef...)β οΈ Important: Please obtain the correct public key from the MC management dashboard. Never use test keys in production environment.
| Parameter | Type | Required | Description |
|---|---|---|---|
mode | String | Yes | Payment mode, options: 'payment' (one-time payment) or 'subscription' (subscription payment) |
amount | Number | Yes | Payment amount (actual amount) |
currency | String | Yes | Currency code (e.g., 'USD', 'EUR', 'CNY') |
appId | String | No | The transaction subject submitted and approved in the MC merchant management backend. οΌe.g., www.pay.com) |
paymentMethodTypes | Array | No | Array of available payment method strings. Options include: 'google_pay' (Google Pay), 'apple_pay' (Apple Pay),'link' (Link), etc. If not provided, all supported payment methods will be displayed |
appearance | Object | No | You can customize your appearance |
| Parameter | Type | Required | Description |
|---|---|---|---|
variables | Object | No | The variables option works like CSS variables |
| Parameter | Type | Required | Description |
|---|---|---|---|
borderRadius | String | No | The border radius used for button (e.g., '4px') |
| Parameter | Type | Required | Description |
|---|---|---|---|
business | Object | No | Business information displayed during checkout |
business.name | String | No | Business name displayed to customer |
emailRequired | Boolean | No | Collect the customer's email by setting this option to true |
phoneNumberRequired | Boolean | No | Collect the customer's phone number by setting this option to true. Google Pay makes a best effort to return the phone number registered to the wallet, but doesn't guarantee it will be provided in all cases. |
buttonHeight | Number | No | By default, the height of the buttons are 44px.You can override this to specify a custom button height in the range of 40px-55px. |
shippingAddressRequired | Boolean | No | Whether customer must provide shipping address. If set to true, you must provide valid shippingRates options in create, click, or shippingAddressChange event |
allowedShippingCountries | Array | No | Array of allowed shipping country codes (e.g., ['US', 'CA']) |
shippingRates | Array | No | Shipping options available for customer selection |
lineItems | Array | No | Order line items to display |
applePay | Object | No | Apple Pay specific configuration options |
| Parameter | Type | Required | Description |
|---|---|---|---|
id | String | Yes | Unique identifier for the shipping method |
displayName | String | Yes | Shipping method name displayed to customer |
amount | Number | Yes | Shipping cost (actual amount) |
| Parameter | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Name (description of the line item) |
amount | Number | Yes | Price (actual amount) |
π Detailed Parameter Documentation
For detailed parameters and configuration for Apple Pay recurring payments, refer to Apple's official documentation:
Apple Pay on the Web - Recurring Payments
| Parameter | Type | Required | Description |
|---|---|---|---|
recurringPaymentRequest | Object | No | Recurring payment request configuration for subscription-type payments |
| Parameter | Type | Required | Description |
|---|---|---|---|
paymentDescription | String | Yes | Payment description explaining the purpose of this recurring payment to customer |
managementURL | String | Yes | Management URL where customer can manage their subscription |
regularBilling | Object | Yes | Regular billing configuration |
billingAgreement | String | No | Billing agreement text |
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | Number | Yes | Recurring payment amount (actual amount) |
label | String | Yes | Billing label, billing item name displayed to customer |
recurringPaymentStartDate | Date | Yes | Recurring payment start date |
recurringPaymentEndDate | Date | Yes | Recurring payment end date |
recurringPaymentIntervalUnit | String | Yes | Recurring payment interval unit, options: 'year', 'month', 'day', 'hour', 'minute' |
recurringPaymentIntervalCount | Number | Yes | Recurring payment interval count, e.g., every 2 months = 2 |
mode: 'subscription', you can configure Apple Pay's recurring payment feature:domId (String): The ID of the DOM element where the component should be mountedoptions (Object): Update optionsallowedShippingCountries (Array, optional): Array of allowed shipping country codesshippingAddressRequired (Boolean, optional): Whether customer must provide shipping addressoptions (Object): Update optionsmode (String, optional): Payment mode ('payment' or 'subscription')amount (Number, optional): Payment amountcurrency (String, optional): Currency codepaymentMethodTypes (Array, optional): Array of available payment method strings, e.g., ['google_pay']event (Object): Event objectavailablePaymentMethods (Object): Available payment methods object, keys are payment method names, values are booleansapple_pay (Boolean): Whether Apple Pay is availablegoogle_pay (Boolean): Whether Google Pay is availablelink (Boolean): Whether Link is availableresolve() within 1 second, otherwise the payment flow may timeoutevent (Object): Event objectelementType (String): Element type, value is 'expressCheckout'expressPaymentType (String): Express payment type, possible values:'apple_pay': Apple Pay'google_pay': Google Pay'link': Linkresolve(options): Call to continue payment flowreject(): Call to cancel the payment interfaceoptions (Object): Confirmation optionslineItems (Array, optional): Updated line items arrayshippingRates (Array, optional): Updated shipping rates arrayapplePay (Object, optional): Apple Pay specific configuration updaterecurringPaymentRequest: Recurring payment request configuration (see ApplePay Object)paymentIntentId and clientSecret to call confirmPayment to complete the payment.event (Object): Event objectelementType (String): Element type, value is 'expressCheckout'expressPaymentType (String): Express payment type, possible values:'apple_pay': Apple Pay'google_pay': Google Pay'link': LinkbillingDetails (BillingAddressType, optional): Billing informationshippingAddress (ShippingAddressType, optional): Shipping address informationshippingRate (ShippingRateTypeοΌoptional)οΌShipping rate information| Property | Type | Description |
|---|---|---|
name | String | Billing holder name |
email | String | Email address |
phone | String | Phone number |
address | AddressDetail | Billing address details |
| Property | Type | Description |
|---|---|---|
name | String | Recipient name |
address | AddressDetail | Shipping address details |
| Property | Type | Description |
|---|---|---|
line1 | String | Address line 1 (street address) |
line2 | String | Address line 2 (apartment, suite, etc.) |
city | String | City |
state | String | State/Province |
postal_code | String | Postal code |
country | String | Country code (e.g., 'US') |
| Property | Type | Description |
|---|---|---|
id | String | Unique identifier for the shipping method |
displayName | String | Shipping method name displayed to customer |
amount | Number | Shipping cost (actual amount) |
resolve() or reject() within 20 seconds, otherwise the payment flow may timeoutevent (Object): Event objectelementType (String): Element type, value is 'expressCheckout'address (Address): Customer's selected shipping addressresolve(options): Call to accept address change and update shipping optionsreject(): Call to reject the address (e.g., if cannot ship to location)| Property | Type | Description |
|---|---|---|
city | String | City |
state | String | State/Province |
postal_code | String | Postal code |
country | String | Country code (e.g., 'US') |
options (Object): Update optionslineItems (Array): Updated line items arrayshippingRates (Array): Updated shipping rates arrayapplePay (Object, optional): Apple Pay specific configuration updaterecurringPaymentRequest: Recurring payment request configuration (see ApplePay Object)resolve() within 20 seconds, otherwise the payment flow may timeoutevent (Object): Event objectelementType (String): Element type, value is 'expressCheckout'shippingRate (ShippingRate): Customer's selected shipping rateresolve(options): Call to confirm shipping rate changereject(): Call to customer's shipping rate is invalid| Property | Type | Description |
|---|---|---|
id | String | Unique identifier for the shipping method |
amount | Number | Shipping cost (actual amount) |
displayName | String | Shipping method display name |
options (Object, optional): Update optionslineItems (Array): Updated line items arrayapplePay (Object): Apple Pay specific configuration updaterecurringPaymentRequest: Recurring payment request configuration (see ApplePay Object)| Parameter | Type | Required | Description |
|---|---|---|---|
elements | Elements | Yes | Elements instance |
paymentIntentId | String | Yes | Payment intent ID returned from backend API |
clientSecret | String | Yes | Client secret returned from backend API |
| Parameter | Type | Description |
|---|---|---|
paymentIntent | Object | Payment intent object (when payment succeeds) |
error | Object | Error information object (when payment fails) |