Search…
Payment sessions
Learn the basics of payment sessions and how to migrate your integration.
A payment session tracks a customer's order and payment throughout the checkout flow. Although you're not required to, we highly recommend you use payment sessions to reduce the complexity of building DigitalRiver.js payment collection flows and to comply with PSD2 and Strong Customer Authentication (SCA) regulations.
Migrating to payment sessions is relatively straightforward and mostly involves updating the code for each of your approved payment methods.

Why use payment sessions?

Payment sessions allow you to comply with PSD2 and SCA regulations. When using payment sessions to create credit card sources, applicable PSD2 transactions automatically collect the required authentication data from the customer.
Payment sessions also simplify source creation by reducing the data you're required to provide. If you don't use payment sessions, you'll need to copy data returned in the response and ensure it is properly formatted before passing it to the create source method.
When creating a source with payment sessions, however, you can provide the unique identifier of the session, thereby minimizing the data you must transfer.
They also allow you to gain access to Drop-in, which lessens your front-end development burden. For each transaction, Drop-in needs to retrieve the available payment methods, and the payment session flow supports this functionality.

Creating a source with payment sessions

When creating a source, specify the sessionId in the payload that you pass to the DigitalRiver.js create source method. Alternatively, if you're using the recommended Drop-in solution, you set the payment session identifier in the configuration object that you pass to the create Drop-in method.
In both cases, the details required to create the source are retrieved from the payment session. We then return a source object to you.
JavaScript
1
let payload = {
2
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
3
"type": "payPal",
4
"payPal": {
5
"returnUrl": "https://yourReturnUrl.com",
6
"cancelUrl": "https://yourCancelUrl.com"
7
}
8
}
9
10
digitalriver.createSource(payload).then(function(result) {
11
12
if(result.state === "chargeable") {
13
sendToBackEnd(result);
14
} else {
15
doErrorScenario();
16
}
17
});
Copied!

Retrieving available payment methods

With the retrieveAvailablePaymentMethods in DigitalRiver.js, payment sessions allow you to return the payment methods available for each transaction. You can then display these to the customer during the checkout process.
The method also returns the data required to use one-click payment methods like Apple Pay and Google Pay, as well as the data needed to retrieve compliance information via the DigitalRiver.js compliance methods.
JavaScript
1
digitalriver.retrieveAvailablePaymentMethods({
2
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f"
3
}).then(function(result) {
4
//do something with the data
5
});
Copied!

Migrating to payment sessions

Although we generally recommend that you use Drop-in to integrate payments, you can also migrate your existing integration directly to payment sessions.
Once you have completed this migration process, you'll need to build your SCA workflows using Drop-in or Elements.

Enable payment sessions

To enable payment sessions for the Commerce API, you'll need to contact your Account Manager. Once enabled, you'll see the following hash table returned in your Cart responses:
JSON
1
{
2
...
3
"paymentSession": {
4
"id": "8af78166-e526-40bd-9c95-1071d161a94a",
5
"clientSecret": "8af78166-e526-40bd-9c95-1071d161a94a_4179e432-b714-4451-9137-ac08a1d9af19",
6
"status": "requires_source"
7
}
8
...
9
}
Copied!

Update your code

You'll need to update your code to fully integrate with payment sessions. For each payment method supported by DigitalRiver.js, add the sessionId parameter to the payload that you pass to the createSource method.
The parameters to remove are specific to each payment method. These parameters, along with example code, are listed in the following sections: Credit Card, PayPal, PayPal Billing, PayPal Credit, SEPA Direct Debit, Wire Transfer, Cash on Delivery - Japan, Payco - Korea Payments, Bank Transfer - Korea Payments, Online Banking - IBP, bPay, Konbini, Klarna, Klarna Recurring, TreviPay.

Credit Card

For credit cards, you add sessionId to the payload but do not remove any existing parameters.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
var payload = {
2
"type": "creditCard",
3
"owner": {
4
firstName: "John",
5
lastName: "Doe",
6
7
phoneNumber: "000-000-0000",
8
address: {
9
line1: "10380 Bren Road West",
10
line2: "Suite 123",
11
city: "Minnetonka",
12
state: "MN",
13
postalCode: "55343",
14
country: "US"
15
}
16
}
17
}
18
19
digitalriver.createSource(cardCVV, payload).then(function(result) {
20
if (result.error) {
21
//handle errors
22
} else {
23
var source = result.source;
24
//send source to back end
25
sendToBackend(source);
26
}
27
});
Copied!
1
var payload = {
2
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
3
"type": "creditCard",
4
"owner": {
5
firstName: "John",
6
lastName: "Doe",
7
8
phoneNumber: "000-000-0000",
9
address: {
10
line1: "10380 Bren Road West",
11
line2: "Suite 123",
12
city: "Minnetonka",
13
state: "MN",
14
postalCode: "55343",
15
country: "US"
16
}
17
}
18
}
19
20
digitalriver.createSource(cardCVV, payload).then(function(result) {
21
if (result.error) {
22
//handle errors
23
} else {
24
var source = result.source;
25
//send source to back end
26
sendToBackend(source);
27
}
28
});
Copied!

PayPal

For PayPal, you add sessionId to the payload and remove amount, currency, payPal.items, payPal.taxAmount, payPal.shippingAmount, payPal.amountsEstimated, payPal.requestShipping, and payPal.shipping.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
var payload = {
2
"type": "payPal",
3
"amount": 120.99,
4
"currency": "USD",
5
"payPal": {
6
"returnUrl": "http://mypage.com",
7
"cancelUrl": "https://mypage.com/cancel",
8
"items": [{
9
"name": "Cell Phone (Unlocked)",
10
"quantity": 1,
11
"unitAmount": 100
12
},
13
{
14
"name": "Headphones",
15
"quantity": 1,
16
"unitAmount": 15
17
}
18
],
19
"taxAmount": 0.99,
20
"shippingAmount": 5,
21
"amountsEstimated": true,
22
"requestShipping": true,
23
"shipping": {
24
"recipient": "John Doe",
25
"phoneNumber": "952-555-1212",
26
"address": {
27
"line1": "54321 Fake St.",
28
"line2": "Apt. 3C",
29
"city": "Minnetonka",
30
"state": "MN",
31
"country": "US",
32
"postalCode": "55341"
33
}
34
}
35
}
36
}
37
38
39
digitalriver.createSource(payload).then(function(result) {
40
if (result.error) {
41
//handle errors
42
} else {
43
var source = result.source;
44
//send source to back end
45
sendToBackend(source);
46
}
47
});
Copied!
1
var payload = {
2
"type": "payPal",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"payPal": {
5
"returnUrl": "http://mypage.com",
6
"cancelUrl": "https://mypage.com/cancel"
7
}
8
}
9
10
digitalriver.createSource(payload).then(function(result) {
11
if (result.error) {
12
//handle errors
13
} else {
14
var source = result.source;
15
//send source to back end
16
sendToBackend(source);
17
}
18
});
Copied!

PayPal Billing

For PayPal Billing, you add sessionId to the payload and remove amount, currency, payPalBilling.items, payPalBilling.taxAmount, payPalBilling.shippingAmount, payPalBilling.amountsEstimated, payPalBilling.requestShipping, and payPalBilling.shipping.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
var payload = {
2
"type": "payPalBilling",
3
"amount": 120.99,
4
"currency": "USD",
5
"payPal": {
6
"returnUrl": "http://mypage.com",
7
"cancelUrl": "https://mypage.com/cancel",
8
"items": [{
9
"name": "Cell Phone (Unlocked)",
10
"quantity": 1,
11
"unitAmount": 100
12
},
13
{
14
"name": "Headphones",
15
"quantity": 1,
16
"unitAmount": 15
17
}
18
],
19
"taxAmount": 0.99,
20
"shippingAmount": 5,
21
"amountsEstimated": true,
22
"requestShipping": true,
23
"shipping": {
24
"recipient": "John Doe",
25
"phoneNumber": "952-555-1212",
26
"address": {
27
"line1": "54321 Fake St.",
28
"line2": "Apt. 3C",
29
"city": "Minnetonka",
30
"state": "MN",
31
"country": "US",
32
"postalCode": "55341"
33
}
34
}
35
}
36
}
37
38
39
digitalriver.createSource(payload).then(function(result) {
40
if (result.error) {
41
//handle errors
42
} else {
43
var source = result.source;
44
//send source to back end
45
sendToBackend(source);
46
}
47
});
Copied!
1
var payload = {
2
"type": "payPalBilling",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"payPal": {
5
"returnUrl": "http://mypage.com",
6
"cancelUrl": "https://mypage.com/cancel"
7
}
8
}
9
10
digitalriver.createSource(payload).then(function(result) {
11
if (result.error) {
12
//handle errors
13
} else {
14
var source = result.source;
15
//send source to back end
16
sendToBackend(source);
17
}
18
});
Copied!

PayPal Credit

For PayPal Credit, you add sessionId to the payload and remove amount, currency, payPal.items, payPal.taxAmount, payPal.shippingAmount, payPal.amountsEstimated, payPal.requestShipping, and payPal.shipping.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
var payload = {
2
"type": "payPalCredit",
3
"amount": 120.99,
4
"currency": "USD",
5
"payPal": {
6
"returnUrl": "http://mypage.com",
7
"cancelUrl": "https://mypage.com/cancel",
8
"items": [{
9
"name": "Cell Phone (Unlocked)",
10
"quantity": 1,
11
"unitAmount": 100
12
},
13
{
14
"name": "Headphones",
15
"quantity": 1,
16
"unitAmount": 15
17
}
18
],
19
"taxAmount": 0.99,
20
"shippingAmount": 5,
21
"amountsEstimated": true,
22
"requestShipping": true,
23
"shipping": {
24
"recipient": "John Doe",
25
"phoneNumber": "952-555-1212",
26
"address": {
27
"line1": "54321 Fake St.",
28
"line2": "Apt. 3C",
29
"city": "Minnetonka",
30
"state": "MN",
31
"country": "US",
32
"postalCode": "55341"
33
}
34
}
35
}
36
}
37
38
39
digitalriver.createSource(payload).then(function(result) {
40
if (result.error) {
41
//handle errors
42
} else {
43
var source = result.source;
44
//send source to back end
45
sendToBackend(source);
46
}
47
});
Copied!
1
var payload = {
2
"type": "payPalCredit",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"payPal": {
5
"returnUrl": "http://mypage.com",
6
"cancelUrl": "https://mypage.com/cancel"
7
}
8
}
9
10
digitalriver.createSource(payload).then(function(result) {
11
if (result.error) {
12
//handle errors
13
} else {
14
var source = result.source;
15
//send source to back end
16
sendToBackend(source);
17
}
18
});
Copied!

SEPA Direct Debit

For SEPA Direct Debit, you add sessionId to the payload and remove amount and currency.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
let payload = {
2
"type": "directDebit",
3
"amount": 100,
4
"currency": "EUR",
5
"owner": {
6
firstName: "John",
7
lastName: "Doe",
8
9
phoneNumber: "000-000-0000",
10
address: {
11
line1: "123 Main Street",
12
line2: "",
13
city: "Paris",
14
postalCode: "14390",
15
country: "FR"
16
}
17
},
18
"directDebit": {
19
"returnUrl": "https://mypage.com"
20
}
21
}
22
23
digitalriver.createSource(payload).then(function(result) {
24
25
if (result.error) {
26
//handle errors
27
} else {
28
var source = result.source;
29
//send source to back end
30
sendToBackend(source);
31
}
32
});
Copied!
1
var payload = {
2
"type": "directDebit",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"owner": {
5
firstName: "John",
6
lastName: "Doe",
7
8
phoneNumber: "000-000-0000",
9
address: {
10
line1: "123 Main Street",
11
line2: "",
12
city: "Paris",
13
postalCode: "14390",
14
country: "FR"
15
}
16
},
17
"directDebit": {
18
"returnUrl": "https://mypage.com"
19
}
20
}
21
22
digitalriver.createSource(payload).then(function(result) {
23
if (result.error) {
24
//handle errors
25
} else {
26
var source = result.source;
27
//send source to back end
28
sendToBackend(source);
29
}
30
});
Copied!

Wire Transfer

For Wire Transfer, you add sessionIdto the payload and remove amount and currency.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
let payload = {
2
"type": "wireTransfer",
3
"amount": 100,
4
"currency": "EUR",
5
"owner": {
6
firstName: "John",
7
lastName: "Doe",
8
9
phoneNumber: "000-000-0000",
10
address: {
11
line1: "123 Main Street",
12
line2: "",
13
city: "Paris",
14
postalCode: "14390",
15
country: "FR"
16
}
17
},
18
"wireTransfer": {
19
}
20
}
21
22
digitalriver.createSource(payload).then(function(result) {
23
24
if (result.error) {
25
//handle errors
26
} else {
27
var source = result.source;
28
//send source to back end
29
sendToBackend(source);
30
}
31
});
Copied!
1
var data = {
2
"type": "wireTransfer",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"owner": {
5
firstName: "John",
6
lastName: "Doe",
7
8
phoneNumber: "000-000-0000",
9
address: {
10
line1: "123 Main Street",
11
line2: "",
12
city: "Paris",
13
postalCode: "14390",
14
country: "FR"
15
}
16
},
17
"wireTransfer": {
18
}
19
}
20
21
digitalriver.createSource(data).then(function(result) {
22
if (result.error) {
23
//handle errors
24
} else {
25
var source = result.source;
26
//send source to back end
27
sendToBackend(source);
28
}
29
});
Copied!

Cash on Delivery - Japan

For Cash on Delivery - Japan, you add sessionId to the payload and remove amount and currency.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
let payload = {
2
"type": "codJapan",
3
"amount": 100,
4
"currency": "EUR",
5
"owner": {
6
firstName: "John",
7
lastName: "Doe",
8
9
phoneNumber: "000-000-0000",
10
address: {
11
line1: "123 Main Street",
12
line2: "",
13
city: "Paris",
14
postalCode: "14390",
15
country: "FR"
16
}
17
},
18
"codJapan": {
19
}
20
}
21
22
digitalriver.createSource(payload).then(function(result) {
23
24
if (result.error) {
25
//handle errors
26
} else {
27
var source = result.source;
28
//send source to back end
29
sendToBackend(source);
30
}
31
});
Copied!
1
var payload = {
2
"type": "codJapan",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"owner": {
5
firstName: "John",
6
lastName: "Doe",
7
8
phoneNumber: "000-000-0000",
9
address: {
10
line1: "123 Main Street",
11
line2: "",
12
city: "Paris",
13
postalCode: "14390",
14
country: "FR"
15
}
16
},
17
"codJapan": {
18
}
19
}
20
21
digitalriver.createSource(payload).then(function(result) {
22
if (result.error) {
23
//handle errors
24
} else {
25
var source = result.source;
26
//send source to back end
27
sendToBackend(source);
28
}
29
});
Copied!

Payco - Korea Payments

For Payco - Korea Payments, you add sessionId to the payload and remove amount and currency.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
let payload = {
2
"type": "payco",
3
"amount": 100,
4
"currency": "KRW",
5
"owner": {
6
firstName: "John",
7
lastName: "Doe",
8
9
address: {
10
line1: "1234 Fake Street",
11
line2: "Yaum-dong",
12
city: "Ulsan-si",
13
state: "Kyongsangnamdo",
14
postalCode: "100-011",
15
country: "KR"
16
}
17
},
18
"payco": {
19
"returnUrl": "https://yourReturnUrl.com"
20
}
21
}
22
23
digitalriver.createSource(payload).then(function(result) {
24
25
if (result.error) {
26
//handle errors
27
} else {
28
var source = result.source;
29
//send source to back end
30
sendToBackend(source);
31
}
32
});
Copied!
1
var payload = {
2
"type": "payco",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"owner": {
5
firstName: "John",
6
lastName: "Doe",
7
8
address: {
9
line1: "1234 Fake Street",
10
line2: "Yaum-dong",
11
city: "Ulsan-si",
12
state: "Kyongsangnamdo",
13
postalCode: "100-011",
14
country: "KR"
15
}
16
},
17
"payco": {
18
"returnUrl": "https://yourReturnUrl.com"
19
}
20
}
21
22
digitalriver.createSource(payload).then(function(result) {
23
if (result.error) {
24
//handle errors
25
} else {
26
var source = result.source;
27
//send source to back end
28
sendToBackend(source);
29
}
30
});
Copied!

Bank Transfer - Korea Payments

For Bank Transfer - Korea Payments, you add sessionId to the payload and remove amount and currency.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
let payload = {
2
"type": "bankTransfer",
3
"amount": 100,
4
"currency": "KRW",
5
"owner": {
6
firstName: "John",
7
lastName: "Doe",
8
9
address: {
10
line1: "1234 Fake Street",
11
line2: "Yaum-dong",
12
city: "Ulsan-si",
13
state: "Kyongsangnamdo",
14
postalCode: "100-011",
15
country: "KR"
16
}
17
},
18
"bankTransfer": {
19
"returnUrl": "https://yourReturnUrl.com"
20
}
21
}
22
23
digitalriver.createSource(payload).then(function(result) {
24
25
if (result.error) {
26
//handle errors
27
} else {
28
var source = result.source;
29
//send source to back end
30
sendToBackend(source);
31
}
32
});
Copied!
1
var payload = {
2
"type": "bankTransfer",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"owner": {
5
firstName: "John",
6
lastName: "Doe",
7
8
address: {
9
line1: "1234 Fake Street",
10
line2: "Yaum-dong",
11
city: "Ulsan-si",
12
state: "Kyongsangnamdo",
13
postalCode: "100-011",
14
country: "KR"
15
}
16
},
17
"bankTransfer": {
18
"returnUrl": "https://yourReturnUrl.com"
19
}
20
}
21
22
digitalriver.createSource(payload).then(function(result) {
23
if (result.error) {
24
//handle errors
25
} else {
26
var source = result.source;
27
//send source to back end
28
sendToBackend(source);
29
}
30
});
Copied!

Online Banking - IBP

For Online Banking - IBP, you add sessionId to the payload and remove amount and currency.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
let payload = {
2
"type": "onlineBanking",
3
"amount": 100,
4
"currency": "EUR",
5
"owner": {
6
"firstName": "John",
7
"lastName": "Doe",
8
"email": "[email protected]",
9
"phoneNumber": "000-000-0000",
10
"address": {
11
"line1": "52-58 Neue Mainzer Straße",
12
"line2": "",
13
"city": "Frankfurt am Main",
14
"state": "HE",
15
"postalCode": "60311",
16
"country": "DE"
17
}
18
},
19
"onlineBanking": {
20
"returnUrl": "https://myurl.com/success",
21
"cancelUrl": "https://myurl.com/cancel",
22
"bankCode": "82"
23
}
24
}
25
26
digitalriver.createSource(payload).then(function(result) {
27
28
if (result.error) {
29
//handle errors
30
} else {
31
var source = result.source;
32
//send source to back end
33
sendToBackend(source);
34
}
35
});
Copied!
1
var payload = {
2
"type": "onlineBanking",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"owner": {
5
"firstName": "John",
6
"lastName": "Doe",
7
"email": "[email protected]",
8
"phoneNumber": "000-000-0000",
9
"address": {
10
"line1": "52-58 Neue Mainzer Straße",
11
"line2": "",
12
"city": "Frankfurt am Main",
13
"state": "HE",
14
"postalCode": "60311",
15
"country": "DE"
16
}
17
},
18
"onlineBanking": {
19
"returnUrl": "https://myurl.com/success",
20
"cancelUrl": "https://myurl.com/cancel",
21
"bankCode": "82"
22
}
23
}
24
25
26
digitalriver.createSource(payload).then(function(result) {
27
if (result.error) {
28
//handle errors
29
} else {
30
var source = result.source;
31
//send source to back end
32
sendToBackend(source);
33
}
34
});
Copied!

bPay

For bPay, you add sessionId to the payload and remove amount and currency.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
let payload = {
2
"type": "bPay",
3
"amount": 120.99,
4
"currency": "AUD",
5
"owner": {
6
"firstName": "John",
7
"lastName": "Doe",
8
"email": "[email protected]",
9
"phoneNumber": "000-000-0000",
10
"address": {
11
"line1": "3 Bridge Lane",
12
"line2": "",
13
"city": "Sydney",
14
"state": "NSW",
15
"postalCode": "2000",
16
"country": "AU"
17
}
18
},
19
"bPay": {}
20
}
21
22
digitalriver.createSource(payload).then(function(result) {
23
24
if (result.error) {
25
//handle errors
26
} else {
27
var source = result.source;
28
//send source to back end
29
sendToBackend(source);
30
}
31
});
Copied!
1
var payload = {
2
"type": "bPay",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"owner": {
5
"firstName": "John",
6
"lastName": "Doe",
7
"email": "[email protected]",
8
"phoneNumber": "000-000-0000",
9
"address": {
10
"line1": "3 Bridge Lane",
11
"line2": "",
12
"city": "Sydney",
13
"state": "NSW",
14
"postalCode": "2000",
15
"country": "AU"
16
}
17
},
18
"bPay": {}
19
}
20
21
22
digitalriver.createSource(payload).then(function(result) {
23
if (result.error) {
24
//handle errors
25
} else {
26
var source = result.source;
27
//send source to back end
28
sendToBackend(source);
29
}
30
});
Copied!

Konbini

For Konbini, you add sessionId to the payload and remove amount and currency.
The following tabs provide code examples of how sources are created without and with payment sessions.
Without payment sessions
With payment sessions
1
let payload = {
2
"type": "konbini",
3
"amount": 120.99,
4
"currency": "JPY",
5
"owner": {
6
"firstName": "John",
7
"lastName": "Doe",
8
"email": "[email protected]",
9
"phoneNumber": "000-000-0000",
10
"address": {
11
"line1": "6 Chome-10-1 Roppongi, Minato",
12
"state": "Tokyo",
13
"postalCode": "106-0032",
14
"country": "JP"
15
}
16
},
17
"konbini": {
18
"storeId": "010"
19
}
20
}
21
22
digitalriver.createSource(payload).then(function(result) {
23
24
if (result.error) {
25
//handle errors
26
} else {
27
var source = result.source;
28
//send source to back end
29
sendToBackend(source);
30
}
31
});
Copied!
1
var payload = {
2
"type": "konbini",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"owner": {
5
"firstName": "John",
6
"lastName": "Doe",