Testing and Go Live
Google Pay in the JavaScript SDK is available across multiple browsers. See Google's documentation for a full list.
Use this page to test your Google Pay integration in the sandbox environment and to enable Google Pay for production use.
Prerequisites
Complete the Google Pay integration steps to create your googlePaymentInstance before you test or go live.
In order to test the entire user flow on an Android device, the user must have at least one card or PayPal account stored in either Google Pay or their Google account. The user can also add a payment method to their Google Pay account during the checkout process if none is present.
Be sure to test your website on the latest version of a supported web browser.
In the sandbox environment, Google Pay will return valid testing nonces that point to a test virtual account number or a PayPal account. You can simulate server behaviors by using test amounts on your transactions and test nonces. Transactions will show in the Braintree gateway as Google Pay transactions immediately upon completion, however, PayPal via Google Pay transactions will show as PayPal transactions. The payer_email will not match the email of the PayPal account added to Google Pay; in production, the email will match.
Go live
After you've tested your integration, you'll need to enable Google Pay in your production account through the Control Panel. If you haven't done so already, here's how:
- Log into your Control Panel
- Click the gear icon in the top right corner
- Click Processing from the drop-down menu
- Scroll to the Payment Methods section
- Next to Google Pay, click the toggle to turn it on
In production, you'll also need to follow Google's documentation to register your domain and receive a merchant ID.
Use this merchant ID when creating the payment data request.
- Javascript
async function requestPayment() {
const paymentDataRequest = googlePaymentInstance.createPaymentDataRequest({
merchantId: 'your-merchant-id-from-google', // Omit this line in sandbox; insert your Google merchant ID in production
transactionInfo: {
currencyCode: 'USD',
totalPriceStatus: 'FINAL',
totalPrice: '100.00' // Your amount
}
});
const paymentsClient = new google.payments.api.PaymentsClient({
environment: 'PRODUCTION'
});
try {
const paymentData = await paymentsClient.loadPaymentData(paymentDataRequest);
const result = await googlePaymentInstance.parseResponse(paymentData);
// Send result.nonce to your server
} catch (err) {
// Handle errors
}
}A successful call resolves with a nonce in result.nonce, which you send to your server to create a transaction.
If you already have Google Pay activated in your Control Panel but need it enabled for a particular merchant account, contact us.