Search…
Alipay
Alipay is a delayed fulfillment payment method, meaning fulfillment occurs after authorization and settlement.
Alipay works much like PayPal, where the consumer chooses to make a payment and is directed to the external Alipay site, where they enter (or choose existing) payment information.

Configuring Alipay for DigitalRiver.js

Create an Alipay payment method for your app or website in four easy steps:

Step 1: Build an Alipay source request object

Build an Alipay Source Request object. The Alipay Source Request object requires the following fields.
Field
Value
type
alipay
sessionId
The payment session identifier.
owner
alipay
An Alipay Source Details object that includes the details of the transaction.

Alipay source details object

1
{
2
"returnUrl": "https://example.com"
3
}
Copied!
Field
Required/Optional
Description
returnUrl
Required
Where you will redirect your customer after the customer authorizes or cancels within the Alipay experience.

Step 2: Create the Alipay source using DigitalRiver.js

Use the DigitalRiver.js library to create and mount elements to the HTML container.
1
let alipaySourceData = {
2
"type": "alipay",
3
"sessionId": "3c9473b0-630d-4f20-af61-63d3aa8acb35",
4
"owner": {
5
"firstName": "Donglei",
6
"lastName": "Ye",
7
"email": "[email protected]",
8
"phoneNumber": "13063725095",
9
"address": {
10
"line1": "Wei Bai Chang",
11
"city": "ShunDe District)",
12
"state": "Guangdong",
13
"country": "CN",
14
"postalCode": "528322"
15
}
16
},
17
"alipay": {
18
"returnUrl": redirectUrl
19
}
20
}
21
22
digitalriver.createSource(alipaySourceData ).then(function(result) {
23
if (result.error) {
24
//handle errors as something went wrong
25
} else {
26
var source = result.source;
27
28
//do something with the created source
29
}
30
});
Copied!

Alipay source example

1
{
2
"clientId": "gc",
3
"channelId": "drdod15",
4
"liveMode": false,
5
"id": "5ce08114-143b-4bf6-ae0e-6fc501ee0c24",
6
"clientSecret": "5ce08114-143b-4bf6-ae0e-6fc501ee0c24_a468b08e-2c47-4531-82af-d48d80ff6dcc",
7
"type": "alipay",
8
"reusable": false,
9
"owner": {
10
"firstName": "Donglei",
11
"lastName": "Ye",
12
"email": "[email protected]",
13
"phoneNumber": "13063725095",
14
"address": {
15
"line1": "Wei Bai Chang",
16
"city": "ShunDe District)",
17
"state": "Guangdong",
18
"country": "CN",
19
"postalCode": "528322"
20
}
21
},
22
"amount": "10.00",
23
"currency": "CNY",
24
"state": "pending_redirect",
25
"creationIp": "10.81.3.92",
26
"createdTime": "2020-02-26T02:48:11.508Z",
27
"updatedTime": "2020-02-26T02:48:11.508Z",
28
"flow": "redirect",
29
"redirect": {
30
"redirectUrl": "https://api.digitalriverws.com:443/payments/redirects/51314834-9bf9-483f-b3a7-4b36a14d3f5c?apiKey=pk_hc_e03ee62c0d964bb3ac75595b1203d13c",
31
"returnUrl": "returnUrl.com"
32
},
33
"alipay": {}
34
}
Copied!

Step 3: Authorize an Alipay source

When you create an Alipay 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 authorization

To redirect your customer to the payment provider for authorization, use the redirectUrl parameter in your createSource response.
1
window.location.href = sourceResponse.redirect.redirectUrl;
Copied!
The payment provider will present the customer with the transaction details to authorize, or cancel the transaction. A successful authorization redirects the customer to the Alipay Return URL parameter you specified when you created the source.

Step 4: Use the authorized source

Once authorized, you can use the source by attaching it to a cart.
POST /v1/shoppers/me/carts/active/apply-payment-method
1
{
2
"paymentMethod": {
3
"sourceId": "e7ba0595-059c-460c-bad8-2812123b9313"
4
}
5
Copied!

Supported markets

For information on supported markets and currencies for Drop-in and DigitalRiver.js, go to:
Last modified 1mo ago