Integrate Google Pay with JS SDK for direct merchants

DocsCurrentLast updated: December 13th 2023, @ 3:50:11 pm


We've made changes to this page and its layout to improve the developer experience

Let us know what you think of the updated documentation by selecting the feedback tab below.

Supported countries and currencies

Google Pay supports payments in 32 countries and 22 currencies:

  • Countries: Australia, Austria, Belgium, Bulgaria, Canada, Cyprus, Czech Republic, Denmark, Estonia, Finland, France, Germany, Greece, Hungary, Ireland, Italy, Latvia, Liechtenstein, Lithuania, Luxembourg, Malta, Netherlands, Norway, Poland, Portugal, Romania, Slovakia, Slovenia, Spain, Sweden, United States, United Kingdom
  • Currencies: AUD, BRL, CAD, CHF, CZK, DKK, EUR, GBP, HKD, HUF, ILS, JPY, MXN, NOK, NZD, PHP, PLN, SEK, SGD, THB, TWD, USD

Tip: If you want to integrate additional methods of accepting payment beyond Google Pay, visit our Advanced Checkout guide for additional integration choices.

Get up and running in GitHub Codespaces

GitHub Codespaces are cloud-based development environments where you can code and test your PayPal integrations. Learn more

This screenshot shows the Google Pay sandbox settings in the mobile and digital payments section of the PayPal Developer Dashboard. This only applies to direct merchant integrations:

Testing in your live environment

When testing a purchase in production, consider:

  • The business account receiving money can't also make the purchase.
  • If you create a personal account with the same information as the business account, those accounts might experience restrictions.

How to test Google Pay payments in a live environment:

  1. Open your test page with a supported browser.
  2. Select the Google Pay button to open a pop-up with the Google Pay payment sheet.
  3. Proceed with the Google Pay checkout transaction.
  4. If you have an additional confirmation page on your merchant website, continue to confirm the payment.
  5. Log in to your merchant account and confirm that the money has moved into that account.

Troubleshoot your integration

Make sure that there are no browser console warnings or errors. The JavaScript SDK configuration attributes have distinct validation checks for input formatting and values.

If the validation fails, the web browser's developer console shows warning messages that say which property is incorrect and what you need to do to address the issue. The library generally attempts to revert to the safe default values if missing or incorrect inputs exist.

Initialize payment with paypal.Googlepay()

Creates an instance of a PayPal Google Pay SDK Client.

Arguments

None

Returns

JavaScript SDK Client

JavaScript SDK client methods

Use the JavaScript SDK client methods to start a Google Pay payment and confirm an order.

Use config() to fetch the PaymentMethod data needed to start the payment.


Arguments


None


Returns


TypeDescription
Promise

Resolved: An object that contains the payment data needed to create a PaymentDataRequest to the Google SDK. For more details, see ConfigResponse.

Rejected: An error object that passes information about why the call wasn't successful.


Use confirmOrder() to confirm that the buyer intends to pay for the order using the payment source.


Arguments


NameDescription
confirmOrderParamsFor details on the different properties you can configure, see ConfirmOrderParams.

Returns

NameDescription
Promise

Resolved: An object that returns the response of a successful confirmOrder. For more details, see ConfirmOrderResponse.

Rejected: An error object that passes information about why the call wasn't successful.

Arguments

NameDescription
initiatePayerActionParams

For details on the different properties you can configure, see InitiatePayerActionParams.


Returns

TypeDescription
Promise

Resolved: An object that passes information about 3D Secure liability shift. See InitiatePayerActionResponse for more information.

Rejected: An error object that passes information about why the call wasn't successful.

Request objects

Use the following JavaScript SDK request objects in a Google Pay payment:

PropertyTypeRequiredDescription
paymentMethodDataobjectYes

Details about a selected payment method. When a buyer approves payment, the PaymentData response object from Google passes the paymentMethodData.

For more details about this object, see the Google Pay documentation.

orderIdstringYesThe PayPal order ID.
shippingAddressobjectNo

Passes the shipping address when shippingAddressRequired in the PaymentDataRequest is set to true.

For more details about this object, see the Google Pay documentation.

billingAddressobjectNo

The default billing address is part of the CardInfo object. Use this property to pass a new billing address and overwrite the default.

For more details about this object, see the Google Pay documentation.

emailstringNoPasses the email address when emailRequired in the PaymentDataRequest is set to true.
PropertyTypeRequiredDescription
orderIdstringYesPayPal OrderID

Response objects

Google Pay responses include the following objects:

PropertyTypeAlways existsDescription
configfunctionYesAPI for PaymentData.
confirmOrderfunctionYesAPI for confirmOrder.
initiatePayerActionfunctionYesAPI for 3D Secure handling.
PropertyTypeAlways existsDescription
allowedPaymentMethodsobjectYes

Passes the payment methods supported by the Google Pay API.

For more details about this object, see the Google Pay documentation.

merchantInfoobjectYes

Passes information about the seller requesting payment data.

For more details about this object, see the Google Pay documentation.

PropertyTypeAlways existsDescription
idstringYesThe ID of the order.
statusstringYes

The order status.

For a list of supported values for this property, see the Orders API documentation.

payment_sourceobjectYes

The payment source used to fund the payment.

For more details about this object, see the Orders API documentation.

linksarray of objectsYes

The request-related HATEOAS link information.

For more details about this property, see the Orders API documentation.

PropertyTypeAlways existsDescription
liabilityShiftstringYes

The liability shift indicator shows the outcome of the issuer's authentication.

For a list of supported values for this property, see the Orders API documentation.