Google Pay elements
Learn how to use Google Pay elements.
Use DigitalRiver.js to create a Google Pay element and interact with Google Pay.
Creating a Google Pay element
Google Pay element styles and customization
All Google Payment buttons on your site must adhere to the Google Pay Brand Guidelines, which include, but aren't limited to, the following requirements. Digital River provides the following Google Pay button options for clients to add to the product page/checkout page (express checkout) or payment options page.
Configure Button Type | HTML Code |
---|---|
| |
| |
| |
Configure Button Color | HTML Code |
| |
|
When configuring a button, note the following:
The button color must contrast with the background color of the area that surrounds it.
Observe the Google Pay Dos and Don'ts.
Google Pay element functions
googlepay.canMakePayment();
googlepay.mount();
Call this function to place the created Google Pay element on your page.
googlepay.show();
Call this function to show the Google Pay Payment Request interface. This will automatically happen when using the element. If you'd like to trigger using another mechanism, you must call it as part of the user interaction (click handler).
googlepay.unmount();
Call this function to remove the Google Pay element from your page. The element may be re-added to your page by calling mount()
.
googlepay.destroy();
Call this function to remove the Google Pay element from your page as well as remove its functionality. You cannot re-add the destroyed element to your page via mount().
googlepay.update();
Call this function to update the Google Pay element's data.
Google Pay element events — googlepay.on('event', handler);
The Google Pay Element can receive the following events by creating an event listener. Use this function to listen to events that can be used to build and enhance your purchase flow.
Event | Triggered When |
---|---|
ready | The created element is loaded and ready to accept an update request. |
click | A shopper clicked the element's button. |
cancel | The customer has canceled the experience. |
shippingoptionchange | The customer has chosen a different shipping option than was previously selected. You should use this data to re-price your order totals (if applicable). |
shippingaddresschange | The customer has chosen a different address than was previously selected. You should use this data to re-price your order totals (if applicable). |
source | The customer has authorized the payment and a source, and DigitalRiver.js returned its associated data. |
Source
The Source event emits when the customer completes their interaction with the Payment Request interface, and creates a Payment Source. The emitted object will be a Payment Request Response object.
Ready
The Ready event emits when the Google Pay Element has loaded and is available to take an update()
call.
Click
The Click event emits when the customer clicks a Google Pay Element.
Cancel
The Cancel event emits when the customer closes the Google Pay Element Payment Request interface.
Shipping option change
The Shipping Option Change event emits when the Customer selects a different Shipping Option within the Payment Request interface. The event will emit the following object structure.
Key | Type | Description |
---|---|---|
updateWith | Function | Calling this function with a Payment Request Details Update object merges your updates into the current Payment Request object. |
shippingOption | A Payment Request Shipping Option object contains the details of the customer's chosen Shipping Option. |
Shipping address change
The Shipping Address Change emits when the Customer selects a different Shipping Address within the Payment Request interface. The event will emit the following object structure.
Key | Type | Description |
---|---|---|
updateWith | Function | Calling this function with a Payment Request Details Update object merges your updates into the current Payment Request object. |
shippingAddress | A Shipping Address object contains the details of the customer's chosen Shipping Option. |
Last updated