┌─────────────────────────────────────────────────────────────┐
│ 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') |
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 |
| Parameter | Type | Required | Description |
|---|---|---|---|
business | Object | No | Business information displayed during checkout |
business.name | String | No | Business name displayed to customer |
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 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 flowoptions (Boolean | Object): Confirmation optionstrue: Simple confirmation, continue with current configurationlineItems (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 change| 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)