Skip to main content

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

CheckWhere to verify
Page is served over HTTPSBrowser address bar
Component bundle loads from test-pay.dnapayments.comNetwork tab
PayPal is enabled on your test terminal in test-portal at Settings → Online payment methods → PayPalPortal UI
A sandbox PayPal buyer account is available for testingPayPal Developer Dashboard

Scenarios to run

ScenarioHow to triggerExpected event
Successful paymentClick the PayPal button, log in with a sandbox buyer, approve the paymentonPaymentSuccess(result)
User cancels the PayPal windowClick the button, then close the PayPal window or click CancelonCancel()
Missing container elementCall init() with a non-existent or detached elementonError({ code: 1002 })
paymentData missingCall init() without paymentData and do not return one from onBeforeProcessPaymentonError({ code: 1008 })
Token missingCall init() without token and do not return one from onBeforeProcessPaymentonError({ code: 1009 })
onBeforeProcessPayment throwsThrow an exception inside onBeforeProcessPaymentonError({ code: 1010 })
paymentData mismatchReturn paymentData from onBeforeProcessPayment whose amount, currency or delivery address differs from the init() valuesonError({ 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 at Settings → Online payment methods → PayPal.
  • 1006. The terminal's PayPal clientId is missing on the DNA side. Contact DNA Payments.
  • 1017 after the customer approves. 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.