If you're using , you can create an 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 on the page.
the apple-developer-merchantid-domain-association file.
Save the file to the following location on the domain where you want to offer Apple Pay: /.well-known/apple-developer-merchantid-domain-association Repeat 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 the apple-developer-merchantid-domain-association file 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 .
Create an Apple Pay element
After setting up your library per the , create an Apple Pay element with any customizations you would like to apply.
The Apple Pay element will surface events, giving you more information to facilitate what is happening within the Apple Pay experience.
These events include:
Note: To use Apple Pay, you must listen to, at minimum, the Shipping Address Changed and Source events.
applepay.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 Apple Pay session by answering with a success message
event.complete('success');
});
applepay.on('shippingaddresschange', function(event) {
var shippingAddress = event.shippingAddress;
//create a Payment Request Details Update Object
var newDetails = createPaymentRequestDetailsUpdateObject();
event.updateWith(newDetails);
});
Place the elements on the page
if (applepay.canMakePayment()) {
applepay.mount("applepay-element");
document.getElementById('applepay-element').style.display = 'blocck';
}
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.
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 .
The following example shows how to place the elements on the page. For more information on placing elements on a page, see the .
The address object must contain and data that .
Once authorized, you can use the source by .
The following example shows placing an Apple Pay element on your page. Use this in conjunction with the to build your solution.
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).