Skip to main content
QFPay’s Element SDK enables merchants to build customised checkout experiences using secure, prebuilt payment components hosted by QFPay. It provides flexible front-end integration while keeping payment processing secure and compliant. The Element SDK supports standard payments as well as saving a customer’s payment method for supported future token-based payment scenarios. This guide explains how to integrate the Element SDK into your website or application.

Integration Flow

Element Sequence diagram

Flow Summary

  1. Create a Payment Intent via QFPay API.
  2. Initialise the SDK using QFpay.config().
  3. Render the payment UI.
  4. Collect customer payment details.
  5. Initiate the payment using payment.pay() or payment.walletPay().
  6. Confirm the payment using confirmPayment() or confirmWalletPayment().
  7. If customer_id is provided, QFPay also generates a token_id for 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 an appearance object to customise the styling and displayed billing address fields.

Step 6: Render Payment UI

Enhanced Payment Interface (Wallet + Card)

Use elements.createEnhance() to render an enhanced payment interface that supports multiple payment methods.

Card Payment Form Only

Use elements.create() to render a card-only payment form.

Step 7: Initiate Payment

Card Payment

Use payment.pay() to collect card payment details and initiate the payment.

Multi-Payment Interface

Use payment.walletPay() to initialise the multi-payment interface.
After calling walletPay(), render the payment interface by calling:
  • txamt, txcurrcd, and out_trade_no should preferably be generated together with the Payment Intent by your backend and returned to the frontend.
  • If support_pay_type is omitted, the SDK displays all payment methods enabled for the merchant.
  • walletPay() does not return the final transaction result. Complete the payment flow by calling qfpay.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.
The Element SDK supports saving a customer’s payment method during a successful payment. To request payment token creation, provide 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

  1. Create a Payment Intent.
  2. Render the payment interface using the Element SDK.
  3. The customer enters their payment details.
  4. Initiate a card payment using payment.pay() with customer_id.
  5. The customer completes the payment.
  6. QFPay generates a payment token.
  7. A token_id is returned.
  8. Store the token_id securely in your backend.

Token Parameters

The following parameters are available when initiating a card payment using payment.pay().

Example - Card Payment


Payment Result

When a card payment is completed successfully and customer_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.
Store the returned token_id securely in your backend.Do not rely solely on browser storage or frontend state for future use.

Token Confirmation

Although confirmPayment() 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.
The Token Creation Notification uses a dedicated notification endpoint, which is different from the standard payment notification endpoint.To enable Token Creation Notifications, please contact QFPay Technical Support and provide your notification URL together with your Merchant ID and Store ID.Email: technical.support@qfpay.com
Use the synchronous SDK response to provide immediate feedback to the customer.Use the Token Creation Notification as the final source of truth for persisting the generated token_id.
Do not store raw card details collected through the Element SDK.Store only the QFPay-issued token_id.

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.
Use Transaction Enquiry as a fallback mechanism when payment status is uncertain due to network interruptions, browser closure, or other unexpected scenarios.

Important Notes

If lang is not specified, the SDK automatically uses the browser language.
Do not place the Element container inside a <form> element. Rendering may fail.
Payment Intent expiry:
  • Production: 2 years
  • Sandbox: 7 days
Always generate signatures and create Payment Intents from your backend.Never expose your AppKey or any secret credentials in frontend code.
Do not rely solely on the frontend SDK response to determine the final transaction result.Implement Asynchronous Notifications and Transaction Enquiry to reliably confirm payment status before fulfilling an order.