Testing
Testing the Apple Pay 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 |
| 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 flow end-to-end with a sandbox card | onPaymentSuccess(result) |
| User cancels the sheet | Open the Apple Pay sheet, dismiss it | onCancel() |
| 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 and without returning one from onBeforeProcessPayment | onError({ code: 1008 }) |
| 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 opens but
onPaymentSuccessnever fires. Check the Network tab for a failed call to the DNA Payments API; inspect the response body for the underlying decline. 1010 PAYMENT_DATA_MISMATCHafter wiringonBeforeProcessPayment. The component compares the returnedpaymentDataagainst the values frominit(). UseonBeforeProcessPaymentto supply missing fields, not to mutateamount/currencyafter the fact.