Testing
Testing the WeChat Pay integration
Test in the sandbox environment first.
Pre-flight checklist
| Check | Where to verify |
|---|---|
| Page is served over HTTPS | Browser address bar |
Component bundle loads from test-pay.dnapayments.com | Network tab |
| WeChat Pay is enabled on your test terminal (confirm with DNA Payments) | DNA Payments account manager |
init() receives a valid access_token | Your backend |
paymentData contains at least amount, currency and paymentSettings.terminalId | Your code |
Scenarios to run
| Scenario | How to trigger | Expected event |
|---|---|---|
| Successful payment | Tap the button, scan the QR with a sandbox WeChat Pay account, complete the payment | onPaymentSuccess(result) |
| User closes the modal | Tap the button, then close the QR modal | onCancel() |
| QR countdown expires | Tap the button, do nothing until the timer hits zero | onError({ code: 1006 }) |
| paymentData missing | Call init() without paymentData and do not return one from onBeforeProcessPayment | onError({ code: 1004 }) |
| Token missing | Call init() without token and do not return one from onBeforeProcessPayment | onError({ code: 1005 }) |
onBeforeProcessPayment throws | Throw an exception inside onBeforeProcessPayment | onError({ code: 1007 }) |
| paymentData mismatch | Return paymentData from onBeforeProcessPayment whose amount, currency or delivery address differs from the init() values | onError({ code: 1011 }) |
See Handling Error Codes for the full code list.
Troubleshooting
- Button does not render. Confirm the container element exists in the DOM at the time of
init()and that the script has loaded.onError({ code: 1001 })fires when the mount fails. - QR modal closes before the customer scans. Check that
paymentTimeoutInSecondsis large enough for your audience. Default is 900 (15 minutes); bump it viainit()or fromonBeforeProcessPaymentif needed. 1011after the customer authorizes. YouronBeforeProcessPaymentis returning apaymentDatawith a differentamount,currencyor delivery address than the one passed atinit(). UseonBeforeProcessPaymentto add server-side fields (likeinvoiceId), not to change the displayed total.401on every attempt. The access token is expired or has the wrong scopes. Refresh it via your backend: see Authentication.