Testing
Testing the Google Pay integration
Test in the sandbox environment first.
Test device setup
Google Pay sandbox uses real Google accounts but routes all transactions through Google's test infrastructure. You need:
- A modern browser that supports Google Pay. WebView does not work, see Prerequisites.
- A Google account signed in on that device.
- At least one test card added to Google Wallet. Use Google's test card suite: the cards listed there are the only ones that will work against the sandbox.
note
You do not need a Google Pay & Wallet Console account to test. Google sandbox runs against the test card suite on any logged-in Google account.
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 |
Google Pay is enabled on your terminal in test-portal at Settings → Online payment methods → Google Pay | Portal UI |
| At least one Google test card is added to Google Wallet | Wallet app |
| The page is not loaded inside a WebView | Open the page directly in Chrome / Safari, not inside an embedded view |
Scenarios to run
| Scenario | How to trigger | Expected event |
|---|---|---|
| Successful payment | Run the full flow with a Google test card | onPaymentSuccess(result) |
| 3-D Secure challenge | Use a test card that requires 3DS | A built-in 3DS modal renders; onPaymentSuccess fires after the customer completes the challenge |
| User cancels the sheet | Open the Google Pay sheet, dismiss it | onCancel() |
| paymentData missing | Call init() without paymentData | onError({ code: 1006 }) |
| Token missing | Call init() without token and do not return one from onBeforeProcessPayment | onError({ code: 1007 }) |
paymentData mismatch | Return paymentData from onBeforeProcessPayment whose amount, currency or delivery address differs from the values passed at init() | onError({ code: 1010 }) |
onBeforeProcessPayment throws | Throw an exception inside onBeforeProcessPayment | onError({ code: 1005 }) |
See Handling Error Codes for the full code list.
Troubleshooting
- Button does not render. Most often
onError({ code: 1003 }): the device cannot run Google Pay. Check that the page is not loaded inside a WebView, that the browser supports Google Pay, and that a card is present in Google Wallet. - Sheet opens but the wallet has no cards. Add a card from Google's test card suite. Live cards will not appear in the sandbox wallet flow.
1010after the customer authorizes. 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. If the cart amount can change, re-initialize the component.