Configuring Apple Pay
Learn how to configure Apple Pay for DigitalRiver.js with Elements.
If you're using DigitalRiver.js with Elements, you can create an Apple Pay payment method for your app or website in three easy steps:
Step 1: Submit domain for Apple validation
For details on validating your domain with Apple, refer to How to configure on the Apple Pay page.
Click to Download the
apple-developer-merchantid-domain-associationfile.Save the file to the following location on the domain where you want to offer Apple Pay:
/.well-known/apple-developer-merchantid-domain-associationRepeat this step for each additional domain where you want to offer Apple Pay. For example:https://buy.mydomain.com/.well-known/apple-developer-merchantid-domain-association https://shop.mydomain.com/.well-known/apple-developer-merchantid-domain-association https://www.mydomain.com/.well-known/apple-developer-merchantid-domain-associationNote: You must serve theapple-developer-merchantid-domain-associationfile over HTTPS.Contact your Digital River representative with the domains you want to register.
Step 2: Create an Apple Pay source using DigitalRiver.js
To create an Apple Pay payment source, follow the instructions in the DigitalRiver.js reference guide.
Create an Apple Pay element
After setting up your library per the DigitalRiver.js reference guide, create an Apple Pay element with any customizations you would like to apply.
var paymentRequestData = digitalriver.paymentRequest({
country: "US",
currency: "USD",
total: {
label: "Order Total",
amount: 100
},
displayItems: lineItems,
shippingOptions: shippingOptions,
style: {
buttonType: "plain",
buttonColor: "dark",
buttonLanguage: "en"
},
"sessionId": "9f180964-9da4-43ac-b8e0-ae54d832b03c"
});
var applepay = digitalriver.createElement('applepay', paymentRequestData);Configure the Apple Pay element to handle events
The Apple Pay element will surface events, giving you more information to facilitate what is happening within the Apple Pay experience.
These events include:
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.
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 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 associated data.
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 the Apple Pay example.
Apple Pay source and response examples
The source event will surface a Source plus other shopper details Apple Pay provides, like the billing address, shipping address, and contact information.
Step 3: Use the authorized source
Once authorized, you can use the source by attaching it to a checkout.
Apple Pay example
The following example shows placing an Apple Pay element on your page. Use this in conjunction with the DigitalRiver.js reference guide to build your solution.
Testing Apple Pay
See Testing standard payment methods for testing instructions.
Last updated