Testing
Testing the Apple Pay Express Checkout integration
Test in the sandbox environment first.
Test device setup
You need a device that can make Apple Pay payments and is signed into an Apple Sandbox tester account, with a sandbox card added to Wallet.
Sandbox testers are created by you in App Store Connect. DNA Payments does not provide sandbox tester credentials. Follow Apple's sandbox testing guide for the full procedure: it covers creating a sandbox tester in App Store Connect, signing it in on your test device (paths differ between iOS, iPadOS and macOS versions), and adding sandbox cards to Wallet.
note
The sandbox tester account only governs the iCloud login on the test device; it has nothing to do with your DNA merchant credentials.
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 |
Domain is registered in test-portal at Settings → Online payment methods → Apple Pay | Portal UI |
await DNAPayments.ApplePayComponent.isAvailable() resolves to true | DevTools console |
payload provides at least requiredShippingContactFields and shippingMethods | Your code |
| Sandbox tester is signed in on the device | Device settings |
| Sandbox card is in Wallet | Wallet app |
Scenarios to run
| Scenario | How to trigger | Expected event |
|---|---|---|
| Successful payment | Run the full flow with a sandbox card | onPaymentSuccess(result) |
| User cancels the sheet | Open the Apple Pay sheet, dismiss it | onCancel() |
| Shipping address selected | Pick or change the shipping address inside the sheet | onShippingContactSelected(resolve, reject, event) |
| Shipping method selected | Pick a shipping method inside the sheet | onShippingMethodSelected(resolve, reject, event) |
| Domain not registered | Open the page from a host not added to test-portal | onError({ code: 1003 }) |
| Token missing | Call init() without token and without returning one from onBeforeProcessPayment | onError({ code: 1007 }) |
| paymentData missing | Call init() without paymentData | onError({ code: 1008 }) |
| Shipping handler throws | Throw an error (or call reject(error)) inside onShippingMethodSelected | onError({ code: 1006 }) |
| paymentData mismatch | Return paymentData from onBeforeProcessPayment whose amount, currency or delivery address differs from the values passed at init() | onError({ code: 1010 }) |
See Handling Error Codes for the full code list.
Troubleshooting
- Button does not render. Confirm
isAvailable()returnstrue. On Android it returnsfalse: Apple Pay is not supported. 1003on every attempt. Verify the registered domain matcheswindow.location.hostnameexactly. Ngrok URLs change between runs, so re-register or use a paid ngrok plan with a static domain.- Sheet does not show shipping fields. Verify
payload.requiredShippingContactFieldsandpayload.shippingMethodsare passed toinit(). Without them the sheet falls back to the standard (non-Express) flow. 1006after a shipping method selection. YouronShippingMethodSelectedhandler raised an exception. InspectadditionalInfofor the cause; for validation issues useresolve({ errors: [...] })instead of throwing. See1006in Handling Error Codes.