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).
The customer has authorized the payment and a source, and DigitalRiver.js returned associated data.
Note: To use Google Pay, you must listen to, at minimum, the Source event.
googlepay.on('source',function(event) {var source =result.source;//pass the source to your back end for further processing. //once verified that the source is created successfully, complete the Google Pay session by answering with a success messageevent.complete('success');});googlepay.on('shippingaddresschange',function(event) {var shippingAddress =event.shippingAddress;//create a Payment Request Details Update Objectvar newDetails =createPaymentRequestDetailsUpdateObject();event.updateWith(newDetails);});
The Shipping Address Changed and Shipping Method Changed events require a response of updated details to present to the Shopper. This system expects the response to be in the format of a Payment Request Details Update object.
Place the elements on the page
The following example shows how to place the elements on the page. For more information on placing elements on a page, see Google Pay example.
if (googlepay.canMakePayment()) {googlepay.mount("googlepay-element");document.getElementById('googlepay-element').style.display ='block';}
Receive the source event and use the source
googlepay.on('source',function(event) {var source =result.source;//pass the source to your back end for further processing. //once verified that the source is created successfully, complete the Google Pay session by answering with a success messageevent.complete('success');});
Google Pay example
The source event will surface a Source plus other details provided from Google Pay like the shopper's billing address, shipping address, and contact information in the response.
The address object must contain postal code and state/province data thatadheres to a standardized format using the state attribute. Note that the state attribute listed below corresponds to the countrySubdivision attribute used when providing address information. The payment session manages the correct field name on the backend.
The following example shows how to place a Google Pay element on your page. Use this in conjunction with the DigitalRiver.js reference guide to build your solution.