WeChat Pay
Basic information
Customers pay with WeChat Pay in the client scenario enabled for your application.
- Integration paths: Checkout, Web SDK, Direct API
- Transaction type: One-time online payment
lpmsInfo.lpmsType:WeChat
| Payer wallet market | Order currency |
|---|---|
| 🇨🇳 CN (mainland China WeChat Pay) | GBP, USD, EUR, CNY, JPY, HKD |
Before integrating, ask Onerway to confirm the payer wallet, order currency, and client scenario enabled for your application. The wallet market and each order currency above require that confirmation; the table is not a list of generally available configurations. Confirm the client scenarios for Checkout and Web SDK with Onerway; Direct API scenarios are described below. Available currencies and payment scenarios depend on your account configuration and the availability query for the current order.
Before you begin
Complete Setup and confirm the scenarios enabled for your merchant account. Follow Query available payment methods and that API's own parameters for order availability. The Direct API paymentMode values are not a replacement for the query API's parameter definitions. See Currency and amount validation; confirm your account's transaction limits and settlement currencies with Onerway.
Create a payment
Checkout
Confirm that your client scenario is enabled with Onerway before integrating.
Follow Checkout integration to create the payment and send the customer to the returned redirectUrl. Onerway handles payment selection and customer interaction. After the customer returns to your site, confirm the server-side result as described below.
Web SDK
Confirm that your client scenario is enabled with Onerway before integrating.
Follow Web SDK integration to create an SDK order, initialize the SDK with the returned paymentId, and mount the payment component. The SDK handles customer interaction. Handle payment events and subsequent actions as described in that guide, and confirm the final result on your server.
Direct API
Provide the WeChat AppID for your chosen client to Onerway for configuration. This is a WeChat identifier, distinct from the Onerway appId used in API requests. For mini program payments, you must obtain the customer's openid under the same mini program AppID and submit it in lpmsInfo.walletAccountId.
For H5, provide Onerway with the domain of the page that initiates payment. Onerway registers it with WeChat Pay. This is the originating page's domain, not the domain of the returned WeChat payment URL; configuring a return URL alone does not complete domain registration.
Scenario (paymentMode) | Customer action and response field |
|---|---|
Website QR code (WEB) | QrCode: display the code in data.codeForm |
Mobile browser H5 (WAP) | RedirectURL: open data.redirectUrl |
Mini program (MINI_PROGRAM) | ShowContext: invoke payment with data.presentContext |
Native app (IN_APP) | ShowContext: invoke payment with data.presentContext |
Call Create direct transaction with productType=LPMS, subProductType=DIRECT, txnType=SALE, and lpmsInfo.lpmsType=WeChat. Set paymentMode for the customer's environment. See paymentMode and lpmsInfo.walletAccountId for scenario selection and the mini program customer identifier.
In the request examples for Create direct transaction, select the illustrative WeChat Pay WEB, H5, mini program, or app request. Replace its placeholders with your own order and client data.
Use actionType to choose the customer action. A response can include a redirectUrl alongside presentContext; when actionType=ShowContext, use the client parameters as described below.
In the response examples for Create direct transaction, select the corresponding WeChat Pay scenario: WEB, H5, mini program, or app. See codeForm, redirectUrl, and presentContext for the field definitions.
Web QR code
For QrCode, codeForm is a JSON object; do not call JSON.parse on it. Inspect codeForm.codeDetails and select a supported representation using each entry's codeValueType and displayType:
- For a
QRCODEentry withdisplayType=TEXT, encodecodeValueas a QR code for the customer to scan in WeChat. - For a
QRCODEentry withdisplayType=IMAGE, display the image at the returnedcodeValueURL.
Do not depend on a fixed number or order of entries. If expireTime is present, use it to handle expiry; do not assume a fixed validity period.
H5
For RedirectURL, open data.redirectUrl from the registered mobile web page in a browser outside WeChat. Test on the actual domain that initiates payment, including its Referer behavior. See the WeChat Pay H5 troubleshooting guide for domain and Referer checks.
Mini program
For ShowContext, map the returned presentContext object to wx.requestPayment. Map timestamp to timeStamp and noncestr to nonceStr; pass package, signType, and paySign unchanged. The returned appid must match the mini program invoking payment. Do not generate a replacement signature in the client.
App
Pass the returned presentContext parameters to the official WeChat OpenSDK for your platform. They include appid, partnerid, prepayid, package, noncestr, timestamp, and sign. Match the SDK's field names and types, retaining the supplied values and signature. Follow the client-side App payment section of the WeChat Pay development guide for SDK setup and invocation.
Customer action and final result
Confirm the transaction result
A scan, a browser return, or a successful client callback does not prove payment success. Use the transaction's status from the verified payment result webhook, or Query transactions when reconciling the result. See Webhooks for verification, acknowledgement, and duplicate handling.
Only status=S confirms a successful payment; status=F indicates failure. Handle other values according to the API reference and retain a pending state where applicable.
Refunds and disputes
Confirm refund availability, refund restrictions, and the applicable dispute process with Onerway for your account. When refunds are enabled, follow Refunds. Do not assume that every WeChat Pay feature is available through your Onerway configuration.
Testing and go-live
Confirm the available test environment, test accounts, and enabled client scenarios with Onerway before following Testing.
- Test Checkout redirects or SDK customer interaction for the integration path you use. For Direct API, test each client scenario you will launch: scan the rendered QR code for WEB; open the H5 link from the registered domain; invoke mini program payment with the matching AppID and
openid; invoke the app SDK using the returned parameters. - For each scenario, complete a payment and verify that the order becomes paid only after a verified notification or server query reports
status=S. - Test cancellation, an interrupted return, and a missing notification. Confirm that frontend events alone do not mark the order paid and that transaction queries can reconcile the result.
- Before launch, confirm production scenario enablement, currencies, limits, and the notification endpoint. For Direct API, check AppID configuration and any H5 domain registration required for your chosen client. Test refunds if enabled for your account.