Overview
WeChat Pay direct integration supports only the following payment methods: PC QR code payment, Mini Program payment, and in-app payment. Merchants should set the methods parameter based on the payment scenario and handle the API response accordingly.
For all WeChat Pay payment scenarios, see the WeChat Pay integration guide.
Flowchart
Request
The merchant’s server submits the required parameters using direct integration:
- PC QR Code Payment
- Mini Program
- APP
| Scenario | Description | Payment (methods)[/docs/payment/parameter#request-parameters] value |
|---|---|---|
| PC QR Code Payment | Opens in a desktop browser. The merchant generates a QR code for the user to scan and pay. | WeChatPay_Web |
cURL -X POST 'https://test-secure.oceanpayment.com/gateway/directservice/pay'
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'account=995149' \
-d 'terminal=99514901' \
-d 'signValue=6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b' \
-d 'backUrl=https://www.abc.com/back.php' \
-d 'noticeUrl=https://www.abc.com/notice.php' \
-d 'order_number=NO12345678' \
-d 'order_currency=HKD' \
-d 'order_amount=0.01' \
-d 'methods=WeChatPay_Web' \
-d 'order_notes=' \
-d 'billing_firstName=test' \
-d 'billing_lastName=test' \
-d 'billing_email=test@gmail.com' \
-d 'billing_phone=13800138000' \
-d 'billing_country=HK' \
-d 'billing_state=HK' \
-d 'billing_city=Washington D.C.' \
-d 'billing_address=705A big Road' \
-d 'billing_zip=529012' \
-d 'billing_ip=127.0.0.1' \
-d 'productNum=1' \
-d 'productName=Red Dress' \
-d 'productSku=#001' \
-d 'productPrice=0.01' \
| Scenario | Description | Payment (methods)[/docs/payment/parameter#request-parameters] value |
|---|---|---|
| Mini Program | Opens in a WeChat Mini Program to complete the payment. | WeChatPay_MPro |
cURL -X POST 'https://test-secure.oceanpayment.com/gateway/directservice/pay'
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'account=995149' \
-d 'terminal=99514901' \
-d 'signValue=6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b' \
-d 'backUrl=https://www.abc.com/back.php' \
-d 'noticeUrl=https://www.abc.com/notice.php' \
-d 'order_number=NO12345678' \
-d 'order_currency=HKD' \
-d 'order_amount=0.01' \
-d 'methods=WeChatPay_Mpro' \
-d 'order_notes=' \
-d 'billing_firstName=test' \
-d 'billing_lastName=test' \
-d 'billing_email=test@gmail.com' \
-d 'billing_phone=13800138000' \
-d 'billing_country=HK' \
-d 'billing_state=HK' \
-d 'billing_city=Washington D.C.' \
-d 'billing_address=705A big Road' \
-d 'billing_zip=529012' \
-d 'billing_ip=127.0.0.1' \
-d 'productNum=1' \
-d 'productName=Red Dress' \
-d 'productSku=#001' \
-d 'productPrice=0.01' \
| Scenario | Description | Payment (methods)[/docs/payment/parameter#request-parameters] value |
|---|---|---|
| APP | Opens in the app to complete the payment. | WeChatPay_APP |
cURL -X POST 'https://test-secure.oceanpayment.com/gateway/directservice/pay'
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'account=995149' \
-d 'terminal=99514901' \
-d 'signValue=6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b' \
-d 'backUrl=https://www.abc.com/back.php' \
-d 'noticeUrl=https://www.abc.com/notice.php' \
-d 'order_number=NO12345678' \
-d 'order_currency=HKD' \
-d 'order_amount=0.01' \
-d 'methods=WeChatPay_APP' \
-d 'order_notes=' \
-d 'billing_firstName=test' \
-d 'billing_lastName=test' \
-d 'billing_email=test@gmail.com' \
-d 'billing_phone=13800138000' \
-d 'billing_country=HK' \
-d 'billing_state=HK' \
-d 'billing_city=Washington D.C.' \
-d 'billing_address=705A big Road' \
-d 'billing_zip=529012' \
-d 'billing_ip=127.0.0.1' \
-d 'productNum=1' \
-d 'productName=Red Dress' \
-d 'productSku=#001' \
-d 'productPrice=0.01' \
Response
See the full list of response parameters.
- PC QR Code Payment
- Mini Program
- APP
<?xml version="1.0" encoding="UTF-8"?>
<response>
<notice_type>transaction</notice_type>
<push_dateTime>2026-11-12 07:25:57</push_dateTime>
<account>995149</account>
<terminal>99514901</terminal>
<signValue>41FE077BA389DB90DEF5EEC70AB2C401D7027D6940F1203700FBAE3CB116BB42</signValue>
<methods>WeChatPay_Web</methods>
<order_number>NO12345678</order_number>
<card_country></card_country>
<order_currency>HKD</order_currency>
<order_amount>0.01</order_amount>
<order_notes></order_notes>
<card_number></card_number>
<card_type></card_type>
<payment_country>HK</payment_country>
<payment_id>231219095247018026021</payment_id>
<payment_authType>0</payment_authType>
<payment_status>-1</payment_status>
<payment_details>80700:Transaction was not finished</payment_details>
<payment_solutions></payment_solutions>
<payment_risk></payment_risk>
<payment_amount></payment_amount>
<payment_exchangeRate></payment_exchangeRate>
<pay_barCode>weixin://wxpay/bizpayurl?pr=158DR2T159DS2F1U</pay_barCode>
<pay_userId></pay_userId>
<payment_transactionNetworkId></payment_transactionNetworkId>
<payment_transactionLinkId></payment_transactionLinkId>
</response>
- Order status: When
payment_status=-1, the order is pending. The merchant should retrieve the WeChat QR code parameterpay_barCodeand generate a QR code on the payment page for the user to scan and pay. - QR code generation example
- Use the frontend
qrcodepackage to generate the QR code.
npm install qrcode
- Pass the complete
pay_barCodevalue directly to the QR code generator. After generating the QR code, scan it with WeChat to verify it.
import QRCode from 'qrcode';
const payUrl = 'weixin://wxpay/bizpayurl?pr=158DR2T159DS2F1U';
QRCode.toCanvas(document.getElementById('qrcode'), payUrl, (error) => {
if (error) console.error('QR code generation failed.', error);
});
- Add the following to the page:
<canvas id="qrcode"></canvas>
<?xml version="1.0" encoding="UTF-8"?>
<response>
<notice_type>transaction</notice_type>
<push_dateTime>2026-11-12 16:18:07</push_dateTime>
<response_type>1</response_type>
<account>995149</account>
<terminal>99514901</terminal>
<signValue>37439C92DCB47DE826AE32A7388B038F017D8709DB4D2750658C9AF937F0FFB4</signValue>
<methods>WeChatPay_MPro</methods>
<order_number>NO12345678</order_number>
<card_country></card_country>
<order_currency>HKD</order_currency>
<order_amount>0.01</order_amount>
<order_notes></order_notes>
<card_number></card_number>
<card_type></card_type>
<payment_country>HK</payment_country>
<payment_id>231219095247018026022</payment_id>
<payment_authType>0</payment_authType>
<payment_status>-1</payment_status>
<payment_details>80700:Transaction was not finished</payment_details>
<payment_solutions></payment_solutions>
<payment_risk></payment_risk>
<payment_amount></payment_amount>
<payment_exchangeRate></payment_exchangeRate>
<pay_barCode></pay_barCode>
<pay_userId></pay_userId>
<payment_transactionNetworkId></payment_transactionNetworkId>
<payment_transactionLinkId></payment_transactionLinkId>
<payment_bankInfo>{"timeStamp":"1794367610","package":"prepay_id=wx03975974041111c34277632432","paySign":"5440562B4A1D1B0A0F69DC3321D75","signType":"MD5","nonceStr":"3231317676"}</payment_bankInfo>
</response>
- Order status: After the merchant submits a payment request, the synchronous response returns
payment_status=-1, indicating that the payment is pending. Once the user completes the payment, the system returns the payment result in real time. - Payment parameters:
payment_bankInfocontains the parameters required to call WeChat Mini Program’swx.requestPayment. The Mini Program can pass these parameters directly towx.requestPaymentwithout recalculatingpaySign. For details, see the WeChat Pay official documentation.
- Mini Program payment invocation example
// The server returns `payment_bankInfo`.
// { payment_bankInfo: "{\"timeStamp\":\"...\",\"package\":\"...\", ...}" }
function invokeWechatPay(paymentBankInfo) {
const params = typeof paymentBankInfo === 'string' ?
JSON.parse(paymentBankInfo) : paymentBankInfo;
wx.requestPayment({
timeStamp: String(params.timeStamp),
nonceStr: params.nonceStr,
package: params.package,
signType: params.signType,
paySign: params.paySign,
success(res) {
console.log('WeChat Pay call successful.', res);
},
fail(err) {
console.error('WeChat Pay call failed.', err);
}
});
}
<?xml version="1.0" encoding="UTF-8"?>
<response>
<notice_type>transaction</notice_type>
<push_dateTime>2026-11-12 16:18:07</push_dateTime>
<response_type>1</response_type>
<account>995149</account>
<terminal>99514901</terminal>
<signValue>37439C92DCB47DE826AE32A7388B038F017D8709DB4D2750658C9AF937F0FFB4</signValue>
<methods>WeChatPay_APP</methods>
<order_number>NO12345678</order_number>
<card_country></card_country>
<order_currency>HKD</order_currency>
<order_amount>0.01</order_amount>
<order_notes></order_notes>
<card_number></card_number>
<card_type></card_type>
<payment_country>HK</payment_country>
<payment_id>231219095247018026022</payment_id>
<payment_authType>0</payment_authType>
<payment_status>-1</payment_status>
<payment_details>80700:Transaction was not finished</payment_details>
<payment_solutions></payment_solutions>
<payment_risk></payment_risk>
<payment_amount></payment_amount>
<payment_exchangeRate></payment_exchangeRate>
<pay_barCode></pay_barCode>
<pay_userId></pay_userId>
<payment_transactionNetworkId></payment_transactionNetworkId>
<payment_transactionLinkId></payment_transactionLinkId>
<payment_bankInfo>MkU4NzQxQjU5NDZDRUVCMjgwQTJDNUU3N0Y3MkY0Njk6NjE0NzAxMjQ3Ond4YzNmOWI3ZWMzOTEy
NDhkNDpTaWduPVdYUGF5OjE3OTQ0Njc1Nzc6RjlDNEU2MzREQ0ZFNjQ4OEU1OTk4QTVDRTVBMEVB
QjQ6d3g3ODc1MDA1MjIxMjExMTI4NDUwMDAwMDU1NTIwMjYzMDAw</payment_bankInfo>
</response>
- Order status: After the merchant submits a payment request, the synchronous response returns
payment_status=-1, indicating that the payment is pending. Once the user completes the payment, the system returns the payment result in real time. - Payment response:
payment_bankInfois a Base64-encoded string. The merchant must decode it, assemble the WeChat OpenSDKPayReqobject in the specified field order, and call the SDK to initiate WeChat Pay. For details, see the WeChat Pay official documentation.
Base64 is an encoding, not encryption. Transmit the parameters over HTTPS and avoid logging the full payment_bankInfo value or the decoded payment parameters. Follow the field order defined in Oceanpayment’s response parameters.
- Retrieve and decode
payment_bankInfo. The fields are in the following order:
nonceStr:partnerId:appId:package:timeStamp:sign:prepayId
- Decode and call OpenSDK on Android.
//java
import android.util.Base64;
import com.tencent.mm.opensdk.modelpay.PayReq;
String encoded = paymentBankInfo; // Base64 string in `payment_bankInfo`
String decoded = new String(
Base64.decode(encoded, Base64.DEFAULT),
java.nio.charset.StandardCharsets.UTF_8
);
String[] fields = decoded.split(":", -1);
if (fields.length != 7) {
throw new IllegalArgumentException("Invalid `payment_bankInfo` format.");
}
PayReq request = new PayReq();
request.nonceStr = fields[0];
request.partnerId = fields[1];
request.appId = fields[2];
request.packageValue = fields[3];
request.timeStamp = fields[4];
request.sign = fields[5];
request.prepayId = fields[6];
// api is an initialized IWXAPI instance with the merchant AppID registered
api.sendReq(request);
- Decode and call OpenSDK on iOS.
//objective-c
#import <CommonCrypto/CommonCrypto.h>
#import "WXApi.h"
#import "PayReq.h"
NSData *decodedData = [[NSData alloc]
initWithBase64EncodedString:paymentBankInfo
options:0];
NSString *decoded = [[NSString alloc]
initWithData:decodedData
encoding:NSUTF8StringEncoding];
NSArray<NSString *> *fields = [decoded componentsSeparatedByString:@":"];
if (fields.count != 7) {
// Invalid `payment_bankInfo` format.
return;
}
PayReq *request = [[PayReq alloc] init];
request.nonceStr = fields[0];
request.partnerId = fields[1];
request.appId = fields[2];
request.package = fields[3];
request.timeStamp = fields[4];
request.sign = fields[5];
request.prepayId = fields[6];
[WXApi sendReq:request];
Payment Status
See Payment Status for details.
Asynchronous Notification
You also need to receive the transaction’s asynchronous notification via noticeUrl.
Signature
See Signature Generation and Verification for details.