Testing
Testing the PayPal integration
Test in the sandbox environment first.
Test account setup
You need a PayPal sandbox Personal (buyer) account to log in when the PayPal checkout window opens. DNA Payments does not provide PayPal sandbox accounts: your developer team creates them in the PayPal Developer Dashboard. See the PayPal sandbox accounts guide for the full procedure.
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 |
PayPal is enabled on your test terminal in test-portal at Settings → Online payment methods → PayPal | Portal UI |
| A sandbox PayPal buyer account is available for testing | PayPal Developer Dashboard |
Scenarios to run
| Scenario | How to trigger | Expected event |
|---|---|---|
| Successful payment | Click the PayPal button, log in with a sandbox buyer, approve the payment | onPaymentSuccess(result) |
| User cancels the PayPal window | Click the button, then close the PayPal window or click Cancel | onCancel() |
| Missing container element | Call init() with a non-existent or detached element | onError({ code: 1002 }) |
paymentData missing | Call init() without paymentData and do not return one from onBeforeProcessPayment | onError({ code: 1008 }) |
| Token missing | Call init() without token and do not return one from onBeforeProcessPayment | onError({ code: 1009 }) |
onBeforeProcessPayment throws | Throw an exception inside onBeforeProcessPayment | onError({ code: 1010 }) |
paymentData mismatch | Return paymentData from onBeforeProcessPayment whose amount, currency or delivery address differs from the init() values | onError({ code: 1017 }) |
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: 1007 })fires when the render fails. Check for CSP rules that might block the PayPal SDK host. 1004/1005. PayPal is disabled (or not yet enabled) on the terminal. Toggle it on in the portal atSettings → Online payment methods → PayPal.1006. The terminal's PayPalclientIdis missing on the DNA side. Contact DNA Payments.1017after the customer approves. 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.