Skip to main content

Testing

Testing the WeChat Pay integration

Test in the sandbox environment first.

Pre-flight checklist

CheckWhere to verify
Page is served over HTTPSBrowser address bar
Component bundle loads from test-pay.dnapayments.comNetwork tab
WeChat Pay is enabled on your test terminal (confirm with DNA Payments)DNA Payments account manager
init() receives a valid access_tokenYour backend
paymentData contains at least amount, currency and paymentSettings.terminalIdYour code

Scenarios to run

ScenarioHow to triggerExpected event
Successful paymentTap the button, scan the QR with a sandbox WeChat Pay account, complete the paymentonPaymentSuccess(result)
User closes the modalTap the button, then close the QR modalonCancel()
QR countdown expiresTap the button, do nothing until the timer hits zeroonError({ code: 1006 })
paymentData missingCall init() without paymentData and do not return one from onBeforeProcessPaymentonError({ code: 1004 })
Token missingCall init() without token and do not return one from onBeforeProcessPaymentonError({ code: 1005 })
onBeforeProcessPayment throwsThrow an exception inside onBeforeProcessPaymentonError({ code: 1007 })
paymentData mismatchReturn paymentData from onBeforeProcessPayment whose amount, currency or delivery address differs from the init() valuesonError({ 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 paymentTimeoutInSeconds is large enough for your audience. Default is 900 (15 minutes); bump it via init() or from onBeforeProcessPayment if needed.
  • 1011 after the customer authorizes. Your onBeforeProcessPayment is returning a paymentData with a different amount, currency or delivery address than the one passed at init(). Use onBeforeProcessPayment to add server-side fields (like invoiceId), not to change the displayed total.
  • 401 on every attempt. The access token is expired or has the wrong scopes. Refresh it via your backend: see Authentication.