If you choose to use the full redirect flow, this is where you will redirect your customer to after cancelling within the Afterpay experience.
returnUrl
Required
If you choose to use the full redirect flow, this is where you will redirect your customer to after authorizing within the Afterpay experience.
shipping
Optional
if the order contains a physical product that requires a shipping address, include it here.JSON
Step 2: Create an Afterpay source using DigitalRiver.js
Use the DigitalRiver.js library to create and mount elements to the HTML container.
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.
var sourceData = {"type":"afterPay","sessionId":"ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","owner":{"firstName":"Jane","lastName":"Doe","email":"example@example.com","phoneNumber":"9525551212","address":{"line1":"10380 Bren Rd W","line2":"Suite 180","city":"Minnetonka","state":"MN","postalCode":"55344","country":"US" } },"afterPay":{"returnUrl":"https://js-test.digitalriver.com/v1/1.20220329.1453/components/redirect-receiver/redirect-receiver.html?controllerId=controller-76ef3046-888c-4073-90ad-1b5d61a8af08&componentId=redirect-receiver-1757f835-c21b-4f4e-b208-92adc5c30573&action=return","cancelUrl":"https://js-test.digitalriver.com/v1/1.20220329.1453/components/redirect-receiver/redirect-receiver.html?controllerId=controller-76ef3046-888c-4073-90ad-1b5d61a8af08&componentId=redirect-receiver-1757f835-c21b-4f4e-b208-92adc5c30573&action=cancel","shipping":{"address":{"line1":"10380 Bren Rd W","line2":"Suite 180","city":"Minnetonka","state":"MN","country":"US","postalCode":"55344" },"email":"example@example.com","recipient":"Jane Doe","phoneNumber":"9525551212" } }}digitalriver.createSource(sourceData).then(function(result) {if(result.error) {//handle error messagevar errorMessage =result.error.errors[0].message; } else {//send the source to the back end for processingvar source =result.source; }});
When you create an Afterpay source, the customer is required to authorize the charge through their payment provider. You can accomplish this by redirecting the customer to their payment provider.
Redirecting the customer for Afterpay authorization
Use the redirectUrl parameter in your createSource response to redirect your customer to the payment provider for authorization.
The payment provider will present the customer with the transaction details, and the customer can authorize or cancel the transaction. A successful authorization redirects the customer to the Afterpay Return URL parameter you specified when you created the source.
Once authorized, the source state will change to chargeable.