┌─────────────────────────────────────────────────────────────┐
│ 1. Page Load - Initialize UseePay SDK │
│ UseePay(publicKey) → elements(options) │
└────────────────────────┬────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 2. Create and Mount Payment Element │
│ elements.create('payment', options) │
│ paymentElement.mount(domId) │
└────────────────────────┬────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 3. ready Event Triggered │
│ → Payment Element is Ready │
└────────────────────────┬────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 4. Customer Fills Payment Information │
│ → Select payment method (card, Apple Pay, Google Pay) │
│ → Fill required information │
└────────────────────────┬────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 5. Customer Clicks Pay Button │
│ → Call elements.submit() to validate form │
└────────────────────────┬────────────────────────────────────┘
↓
┌───────────────┴───────────────┐
│ Validation Passed? │
└───────┬───────────────┬───────┘
│ No │ Yes
↓ ↓
┌──────────────────┐ ┌──────────────────────┐
│ Show validation │ │ 6. Call backend API │
│ errors, let │ │ Create payment │
│ customer correct │ │ intent, return │
└──────────────────┘ │ paymentIntentId │
│ and clientSecret │
└──────────┬───────────┘
↓
┌──────────────────────┐
│ 7. Confirm Payment │
│ useepay.confirmPayment│
└──────────┬───────────┘
↓
┌──────────────────┴──────────────────┐
│ Payment Result │
└──────┬───────────────────┬──────────┘
│ Success │ Failure
↓ ↓
┌──────────────────┐ ┌──────────────────┐
│ 8a. Redirect to │ │ 8b. Show error │
│ success page │ │ message, let │
│ │ │ customer retry│
└──────────────────┘ └──────────────────┘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 public 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: 'card' (credit/debit card), 'apple_pay' (Apple Pay), 'google_pay' (Google Pay), etc. If not provided, all supported payment methods will be displayed |
| Parameter | Type | Required | Description |
|---|---|---|---|
applePay | Object | No | Apple Pay specific configuration options. Required when mode is 'subscription' |
📖 Detailed Parameter Documentation
For detailed parameters and configuration for Apple Pay recurring payments, please 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 the customer |
managementURL | String | Yes | Management URL where customers 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, the billing item name displayed to the 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., 2 for every 2 months |
mode: 'subscription', you must configure Apple Pay's recurring payment functionality:domId (String): The ID of the DOM element where the component should be mountedoptions (Object): Update optionsapplePay (Object, optional): Apple Pay specific configuration updatesevent (Object): Event objectoptions (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., ['card', 'google_pay']| Parameter | Type | Description |
|---|---|---|
selectedPaymentMethod | String | The payment method selected by the customer (e.g., 'card', 'apple_pay', 'google_pay') |
error | Object | Error information object, null if validation succeeds |
| Parameter | Type | Description |
|---|---|---|
type | String | Error type |
message | String | Error message |
| Value | Description |
|---|---|
no_select_payment_method | No payment method selected |
validation_error | Form validation error (e.g., invalid card number, missing required fields) |
google_pay_cancel | Google Pay payment was cancelled |
apple_pay_cancel | Apple Pay payment was cancelled |
| 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) |
mode is 'subscription', you must provide the applePay configuration when creating the Payment Element.elements.submit() for form validation.error object in the return values of submit() and confirmPayment().