Skip to main content

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

CheckWhere to verify
Page is served over HTTPSBrowser address bar
Component bundle loads from test-pay.dnapayments.comNetwork tab
Domain is registered in test-portal at Settings → Online payment methods → Apple PayPortal UI
await DNAPayments.ApplePayComponent.isAvailable() resolves to trueDevTools console
payload provides at least requiredShippingContactFields and shippingMethodsYour code
Sandbox tester is signed in on the deviceDevice settings
Sandbox card is in WalletWallet app

Scenarios to run

ScenarioHow to triggerExpected event
Successful paymentRun the full flow with a sandbox cardonPaymentSuccess(result)
User cancels the sheetOpen the Apple Pay sheet, dismiss itonCancel()
Shipping address selectedPick or change the shipping address inside the sheetonShippingContactSelected(resolve, reject, event)
Shipping method selectedPick a shipping method inside the sheetonShippingMethodSelected(resolve, reject, event)
Domain not registeredOpen the page from a host not added to test-portalonError({ code: 1003 })
Token missingCall init() without token and without returning one from onBeforeProcessPaymentonError({ code: 1007 })
paymentData missingCall init() without paymentDataonError({ code: 1008 })
Shipping handler throwsThrow an error (or call reject(error)) inside onShippingMethodSelectedonError({ code: 1006 })
paymentData mismatchReturn 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() returns true. On Android it returns false: Apple Pay is not supported.
  • 1003 on every attempt. Verify the registered domain matches window.location.hostname exactly. 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.requiredShippingContactFields and payload.shippingMethods are passed to init(). Without them the sheet falls back to the standard (non-Express) flow.
  • 1006 after a shipping method selection. Your onShippingMethodSelected handler raised an exception. Inspect additionalInfo for the cause; for validation issues use resolve({ errors: [...] }) instead of throwing. See 1006 in Handling Error Codes.