Integration Flow
Flow Summary
- Create a Payment Intent via QFPay API.
- Initialise the SDK using
QFpay.config(). - Render the payment UI.
- Collect customer payment details.
- Initiate the payment using
payment.pay()orpayment.walletPay(). - Confirm the payment using
confirmPayment()orconfirmWalletPayment(). - If
customer_idis provided, QFPay also generates atoken_idfor the saved payment method.
Saving a payment method is optional.If
customer_id is not provided, the payment is processed as a standard payment and no payment token is generated.Supported Payment Methods
The Element SDK supports:- Alipay (Mainland China & Hong Kong)
- WeChat Pay
- UnionPay / QuickPass
- FPS
- PayMe
- Visa / Mastercard
- Apple Pay
- Visa / Mastercard Pre-authorisation
Integration Steps
Step 1: Load SDK
Include the SDK script in your page.Step 2: Initialise SDK
Initialise the SDK and configure the required region and environment.
Returns the global
qfpay object for subsequent SDK operations.
Step 3: Create Payment Intent (Backend)
Endpoint:/payment_element/v1/create_payment_intent
Method: POST
Headers
Request Parameters
Response Example
Step 4: Retrieve Payment Intent (Frontend)
After your backend creates the Payment Intent, retrieve and validate it from the frontend.Step 5: Configure Appearance (Optional)
Initialise the UI element handler for rendering the card form or multi-payment interface. You can provide anappearance object to customise the styling and displayed billing address fields.
Step 6: Render Payment UI
Enhanced Payment Interface (Wallet + Card)
Useelements.createEnhance() to render an enhanced payment interface that supports multiple payment methods.
Card Payment Form Only
Useelements.create() to render a card-only payment form.
Step 7: Initiate Payment
Card Payment
Usepayment.pay() to collect card payment details and initiate the payment.
Multi-Payment Interface
Usepayment.walletPay() to initialise the multi-payment interface.
walletPay(), render the payment interface by calling:
txamt,txcurrcd, andout_trade_noshould preferably be generated together with the Payment Intent by your backend and returned to the frontend.- If
support_pay_typeis omitted, the SDK displays all payment methods enabled for the merchant. walletPay()does not return the final transaction result. Complete the payment flow by callingqfpay.confirmWalletPayment().
Optional: Generate a Payment Token (Card Payments Only)
Payment token generation is currently supported only for card payments initiated using
payment.pay().Payment tokens are not generated for wallet payment methods.customer_id when calling payment.pay() or payment.walletPay().
When customer_id is provided and the payment is completed successfully, QFPay generates a payment token and returns a token_id associated with the customer.
Saving a payment method is optional.If
customer_id is not provided, the payment will be processed normally and no token_id will be generated.Token Creation Flow
- Create a Payment Intent.
- Render the payment interface using the Element SDK.
- The customer enters their payment details.
- Initiate a card payment using
payment.pay()withcustomer_id. - The customer completes the payment.
- QFPay generates a payment token.
- A
token_idis returned. - Store the
token_idsecurely in your backend.
Token Parameters
The following parameters are available when initiating a card payment usingpayment.pay().
Example - Card Payment
Payment Result
When a card payment is completed successfully andcustomer_id is provided, QFPay generates a payment token and returns a token_id.
The returned token_id uniquely identifies the customer’s saved payment method.
Token Confirmation
AlthoughconfirmPayment() and confirmWalletPayment() may return a token_id, QFPay recommends using the Token Creation Notification as the authoritative confirmation that the payment token has been successfully created.
Merchants should persist the token_id using the asynchronous notification whenever possible.
Step 8: Confirm Payment
After the customer completes the payment, confirm the payment result using the corresponding SDK method.Card / Apple Pay
Wallet Payments
When payment token creation is requested,
confirmPayment() may also return the generated token_id.Token generation is currently supported only for card payments.Step 9: Query Transaction
If the final payment result cannot be reliably determined from the client-side response, query the transaction status using the inquiry API.Important Notes
Payment Intent expiry:
- Production: 2 years
- Sandbox: 7 days

