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 payment collection flows and to comply with PSD2 and SCA regulations.
During the checkout process, you can use payment sessions to create payment sources and to determine when to create an order.
Migrating to payment sessions is relatively straightforward and mostly involves updating the code for each of your approved payment methods.
Payment sessions allow you to comply with PSD2 and SCA regulations. When using payment sessions to create credit card sources, authentication data is automatically collected from the customer during applicable PSD2 transactions.
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 checkout response and ensure it's properly formatted. When you're using payment sessions, however, you simply retrieve its identifier from the checkout response and then pass that value to the create source method. This minimizes 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.
When creating a payment source, you need to retrieve the payment session identifier from the checkout or invoice resource. The details required to create the source are retrieved from that session.
let payload = {"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","type": "payPal","payPal": {"returnUrl": "https://yourReturnUrl.com","cancelUrl": "https://yourCancelUrl.com"}}digitalriver.createSource(payload).then(function(result) {if(result.state === "chargeable") {sendToBackEnd(result);} else {doErrorScenario();}});
The attributes described in this section are only contained in versions 2021-03-23
and higher.
A checkout's payment session information can be used to determine when to submit an order. Specifically, we provide you information on the session state and the amount contributed and amount remaining to be contributed.
A payment session can be in one of the following states: requires_source
, requires_confirmation
, or complete
.
The session state must be requires_confirmation
before you convert a checkout to an order. This state indicates that the payment sources attached to the checkout are sufficient to fund the transaction. For example, when you attach a chargeable primary source to a checkout, the amount remaining to contribute drops to zero and the session state transitions to requires_confirmation
.
The payment session state can be requires_source
for either of the following reasons:
No primary or secondary payment sources are applied to the transaction.
No primary payment source is applied and there's not enough secondary payment sources to fully fund the transaction.
In both of these scenarios, we won't be able to generate a charge amount large enough to cover the checkout's totalAmount
. So the amount remaining to contribute remains greater than zero and any attempt to create an order is blocked.
The session state typically transitions to complete
when you successfully convert the checkout to an order.
Once a primary payment source is attached to a checkout, we use it to fully fund the transaction.
But when only secondary payment sources are attached, you need to confirm sufficient funds exist to cover the transaction amount. If this isn't the case, when you convert the checkout to an order, you receive the following error:
{"type": "bad_request","errors": [{"code": "order_submit_failed","message": "Payment session status is invalid."}]}
By comparing values in the payment.session
hash table, you can determine how much additional funding, if any, is still required. The amountContributed
is the aggregated amount of all the applied payment sources. The amountRemainingToBeContributed
is how much is needed to fully fund the transaction.
If the amountContributed
is equal to the checkout's totalAmount
or the amountRemainingToBeContributed
is zero, then you don't need to request any more payment methods from the customer . This means that once the payment session is in the correct state, and all other requirements are met, the order can be submitted.
But if the amountContributed
is less than the checkout's totalAmount
or the amountRemainingToBeContributed
is greater than zero, then the customer needs to supply additional payment methods before an order can be successfully submitted. However, this will only be the case when a primary payment source is not yet attached to the checkout. Once that's done, we use it to fully fund the transaction and amountRemainingToBeContributed
drops to zero.
In DigitalRiver.js, you can use the payment session identifier to return the payment methods available for each transaction and present them 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.
digitalriver.retrieveAvailablePaymentMethods({"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f"}).then(function(result) {//do something with the data});
Although we generally recommend that you use Drop-in to handle payments, you can also migrate your existing integration directly to payment sessions. In the Digital River API, payment sessions are automatically enabled. Each time you create a checkout, the response returns a payment session identifier that can be used to create a source.
You will however 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, Direct Debit, Wire Transfer, Cash on Delivery - Japan, Payco - Korea Payments, Bank Transfer - Korea Payments, Online Banking - IBP, bPay, Konbini, Klarna, Klarna Recurring, TreviPay.
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.
var payload = {"type": "creditCard","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",phoneNumber: "000-000-0000",address: {line1: "10380 Bren Road West",line2: "Suite 123",city: "Minnetonka",state: "MN",postalCode: "55343",country: "US"}}}digitalriver.createSource(cardCVV, payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","type": "creditCard","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",phoneNumber: "000-000-0000",address: {line1: "10380 Bren Road West",line2: "Suite 123",city: "Minnetonka",state: "MN",postalCode: "55343",country: "US"}}}digitalriver.createSource(cardCVV, payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
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.
var payload = {"type": "payPal","amount": 120.99,"currency": "USD","payPal": {"returnUrl": "http://mypage.com","cancelUrl": "https://mypage.com/cancel","items": [{"name": "Cell Phone (Unlocked)","quantity": 1,"unitAmount": 100},{"name": "Headphones","quantity": 1,"unitAmount": 15}],"taxAmount": 0.99,"shippingAmount": 5,"amountsEstimated": true,"requestShipping": true,"shipping": {"recipient": "John Doe","phoneNumber": "952-555-1212","address": {"line1": "54321 Fake St.","line2": "Apt. 3C","city": "Minnetonka","state": "MN","country": "US","postalCode": "55341"}}}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type": "payPal","sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","payPal": {"returnUrl": "http://mypage.com","cancelUrl": "https://mypage.com/cancel"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
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.
var payload = {"type": "payPalBilling","amount": 120.99,"currency": "USD","payPal": {"returnUrl": "http://mypage.com","cancelUrl": "https://mypage.com/cancel","items": [{"name": "Cell Phone (Unlocked)","quantity": 1,"unitAmount": 100},{"name": "Headphones","quantity": 1,"unitAmount": 15}],"taxAmount": 0.99,"shippingAmount": 5,"amountsEstimated": true,"requestShipping": true,"shipping": {"recipient": "John Doe","phoneNumber": "952-555-1212","address": {"line1": "54321 Fake St.","line2": "Apt. 3C","city": "Minnetonka","state": "MN","country": "US","postalCode": "55341"}}}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type": "payPalBilling","sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","payPal": {"returnUrl": "http://mypage.com","cancelUrl": "https://mypage.com/cancel"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
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.
var payload = {"type": "payPalCredit","amount": 120.99,"currency": "USD","payPal": {"returnUrl": "http://mypage.com","cancelUrl": "https://mypage.com/cancel","items": [{"name": "Cell Phone (Unlocked)","quantity": 1,"unitAmount": 100},{"name": "Headphones","quantity": 1,"unitAmount": 15}],"taxAmount": 0.99,"shippingAmount": 5,"amountsEstimated": true,"requestShipping": true,"shipping": {"recipient": "John Doe","phoneNumber": "952-555-1212","address": {"line1": "54321 Fake St.","line2": "Apt. 3C","city": "Minnetonka","state": "MN","country": "US","postalCode": "55341"}}}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type": "payPalCredit","sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","payPal": {"returnUrl": "http://mypage.com","cancelUrl": "https://mypage.com/cancel"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
For 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.
let payload = {"type": "directDebit","amount": 100,"currency": "EUR","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",phoneNumber: "000-000-0000",address: {line1: "123 Main Street",line2: "",city: "Paris",postalCode: "14390",country: "FR"}},"directDebit": {"returnUrl": "https://mypage.com"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type": "directDebit","sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",phoneNumber: "000-000-0000",address: {line1: "123 Main Street",line2: "",city: "Paris",postalCode: "14390",country: "FR"}},"directDebit": {"returnUrl": "https://mypage.com"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
For Wire Transfer, 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.
let payload = {"type": "wireTransfer","amount": 100,"currency": "EUR","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",phoneNumber: "000-000-0000",address: {line1: "123 Main Street",line2: "",city: "Paris",postalCode: "14390",country: "FR"}},"wireTransfer": {}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var data = {"type": "wireTransfer","sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",phoneNumber: "000-000-0000",address: {line1: "123 Main Street",line2: "",city: "Paris",postalCode: "14390",country: "FR"}},"wireTransfer": {}}digitalriver.createSource(data).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
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.
let payload = {"type": "codJapan","amount": 100,"currency": "EUR","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",phoneNumber: "000-000-0000",address: {line1: "123 Main Street",line2: "",city: "Paris",postalCode: "14390",country: "FR"}},"codJapan": {}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type": "codJapan","sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",phoneNumber: "000-000-0000",address: {line1: "123 Main Street",line2: "",city: "Paris",postalCode: "14390",country: "FR"}},"codJapan": {}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
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.
let payload = {"type": "payco","amount": 100,"currency": "KRW","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",address: {line1: "1234 Fake Street",line2: "Yaum-dong",city: "Ulsan-si",state: "Kyongsangnamdo",postalCode: "100-011",country: "KR"}},"payco": {"returnUrl": "https://yourReturnUrl.com"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type": "payco","sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",address: {line1: "1234 Fake Street",line2: "Yaum-dong",city: "Ulsan-si",state: "Kyongsangnamdo",postalCode: "100-011",country: "KR"}},"payco": {"returnUrl": "https://yourReturnUrl.com"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
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.
let payload = {"type": "bankTransfer","amount": 100,"currency": "KRW","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",address: {line1: "1234 Fake Street",line2: "Yaum-dong",city: "Ulsan-si",state: "Kyongsangnamdo",postalCode: "100-011",country: "KR"}},"bankTransfer": {"returnUrl": "https://yourReturnUrl.com"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type": "bankTransfer","sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","owner": {firstName: "John",lastName: "Doe",email: "[email protected]",address: {line1: "1234 Fake Street",line2: "Yaum-dong",city: "Ulsan-si",state: "Kyongsangnamdo",postalCode: "100-011",country: "KR"}},"bankTransfer": {"returnUrl": "https://yourReturnUrl.com"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
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.
let payload = {"type": "onlineBanking","amount": 100,"currency": "EUR","owner": {"firstName": "John","lastName": "Doe","email": "[email protected]","phoneNumber": "000-000-0000","address": {"line1": "52-58 Neue Mainzer Straße","line2": "","city": "Frankfurt am Main","state": "HE","postalCode": "60311","country": "DE"}},"onlineBanking": {"returnUrl": "https://myurl.com/success","cancelUrl": "https://myurl.com/cancel","bankCode": "82"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type": "onlineBanking","sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","owner": {"firstName": "John","lastName": "Doe","email": "[email protected]","phoneNumber": "000-000-0000","address": {"line1": "52-58 Neue Mainzer Straße","line2": "","city": "Frankfurt am Main","state": "HE","postalCode": "60311","country": "DE"}},"onlineBanking": {"returnUrl": "https://myurl.com/success","cancelUrl": "https://myurl.com/cancel","bankCode": "82"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
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.
let payload = {"type": "bPay","amount": 120.99,"currency": "AUD","owner": {"firstName": "John","lastName": "Doe","email": "[email protected]","phoneNumber": "000-000-0000","address": {"line1": "3 Bridge Lane","line2": "","city": "Sydney","state": "NSW","postalCode": "2000","country": "AU"}},"bPay": {}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type": "bPay","sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","owner": {"firstName": "John","lastName": "Doe","email": "[email protected]","phoneNumber": "000-000-0000","address": {"line1": "3 Bridge Lane","line2": "","city": "Sydney","state": "NSW","postalCode": "2000","country": "AU"}},"bPay": {}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
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.
let payload = {"type": "konbini","amount": 120.99,"currency": "JPY","owner": {"firstName": "John","lastName": "Doe","email": "[email protected]","phoneNumber": "000-000-0000","address": {"line1": "6 Chome-10-1 Roppongi, Minato","state": "Tokyo","postalCode": "106-0032","country": "JP"}},"konbini": {"storeId": "010"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type": "konbini","sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f","owner": {"firstName": "John","lastName": "Doe","email": "[email protected]","phoneNumber": "000-000-0000","address": {"line1": "6 Chome-10-1 Roppongi, Minato","state": "Tokyo","postalCode": "106-0032","country": "JP"}},"konbini": {"storeId": "010"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
For Klarna, you add sessionId
to the payload and remove amount
, currency
, klarnaCredit.items
, klarnaCredit.locale
, klarnaCredit.discountAmount
, klarnaCredit.taxAmount
, klarnaCredit.shippingAmount
, klarnaCredit.shipping
, klarnaCredit.accountId
, klarnaCredit.accountCreatedDate
, klarnaCredit.accountUpdatedDate
, klarnaCredit.hasPaidBefore
, klarnaCredit.subscriptionDescription
, klarnaCredit.subscriptionStartDate
, klarnaCredit.subscriptionEndDate
, klarnaCredit.autoRenewal
, and klarnaCredit.affiliateName
.
The following tabs provide code examples of how sources are created without and with payment sessions.
let payload = {"type": "klarnaCredit","owner": {"firstName": "John","lastName": "Doe","email": "[email protected]","phoneNumber": "9522253720","address": {"line1": "line1","line2": "line2","city": "Minnetonka","state": "MN","country": "US","postalCode": "55410"}},"amount": "101.50","currency": "USD","klarnaCredit": {"returnUrl": "http://example.com/return","cancelUrl": "http://example.com/cancel","taxAmount": 0,"shippingAmount": 5.75,"items": [{"name": "Happy Ball","quantity": "1","unitAmount": "94.25","subscriptionInfo": {"autoRenewal": true,"freeTrial": false}},{"name": "Happy Ball1","quantity": "2","unitAmount": "0.75"}],"locale": "en_US","shipping": {"recipient": "Guy Incognito","phoneNumber": "9522253720","address": {"line1": "line1","line2": "line2","city": "Minnetonka","state": "MN","country": "US","postalCode": "55410"},"email": "[email protected]"},"accountId": "456789","accountCreatedDate": "2020-11-24T15:20:00.000Z","accountUpdatedDate": "2012-11-25T15:30:00.001Z","hasPaidBefore": false,"subscriptionDescription": "Klarna Credit Recurring","subscriptionStartDate": "2019-10-24T15:00:00.030Z","subscriptionEndDate": "2021-10-24T15:00:00.030Z","autoRenewal": "false","affiliateName": "Sample Affiliate"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type" : "klarnaCredit","owner" : {"firstName" : "firstName","lastName" : "lastName","email" : "[email protected]","phoneNumber" : "9522253720","address" : {"line1" : "line1","line2" : "line2","city" : "Minnetonka","state" : "MN","country" : "US","postalCode" : "55410"}},"sessionId" : "3aa75613-9596-438a-9604-67e20016aa96","klarnaCredit" : {"returnUrl" : "http://example.org/return","cancelUrl" : "http://example.org/cancel"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
For Klarna Recurring, you add sessionId
to the payload and remove amount
, currency
, klarnaCreditRecurring.items
, klarnaCreditRecurring.locale
, klarnaCreditRecurring.discountAmount
, klarnaCreditRecurring.taxAmount
, klarnaCreditRecurring.shippingAmount
, klarnaCreditRecurring.shipping
, klarnaCreditRecurring.accountId
, klarnaCreditRecurring.accountCreatedDate
, klarnaCreditRecurring.accountUpdatedDate
, klarnaCreditRecurring.hasPaidBefore
, klarnaCreditRecurring.subscriptionDescription
, klarnaCreditRecurring.subscriptionStartDate
, klarnaCreditRecurring.subscriptionEndDate
, klarnaCreditRecurring.autoRenewal
, and klarnaCreditRecurring.affiliateName
.
The following tabs provide code examples of how sources are created without and with payment sessions.
let payload = {"type": "klarnaCreditRecurring","owner": {"firstName": "John","lastName": "Doe","email": "[email protected]","phoneNumber": "9522253720","address": {"line1": "line1","line2": "line2","city": "Minnetonka","state": "MN","country": "US","postalCode": "55410"}},"amount": "101.50","currency": "USD","klarnaCreditRecurring": {"returnUrl": "http://example.com/return","cancelUrl": "http://example.com/cancel","taxAmount": 0,"shippingAmount": 5.75,"items": [{"name": "Happy Ball","quantity": "1","unitAmount": "94.25","subscriptionInfo": {"autoRenewal": true,"freeTrial": false}},{"name": "Happy Ball1","quantity": "2","unitAmount": "0.75"}],"locale": "en_US","shipping": {"recipient": "Guy Incognito","phoneNumber": "9522253720","address": {"line1": "line1","line2": "line2","city": "Minnetonka","state": "MN","country": "US","postalCode": "55410"},"email": "[email protected]"},"accountId": "456789","accountCreatedDate": "2020-11-24T15:20:00.000Z","accountUpdatedDate": "2012-11-25T15:30:00.001Z","hasPaidBefore": false,"subscriptionDescription": "Klarna Credit Recurring","subscriptionStartDate": "2019-10-24T15:00:00.030Z","subscriptionEndDate": "2021-10-24T15:00:00.030Z","autoRenewal": "false","affiliateName": "Sample Affiliate"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});
var payload = {"type" : "klarnaCreditRecurring","owner" : {"firstName" : "firstName","lastName" : "lastName","email" : "[email protected]","phoneNumber" : "9522253720","address" : {"line1" : "line1","line2" : "line2","city" : "Minnetonka","state" : "MN","country" : "US","postalCode" : "55410"}},"sessionId" : "3aa75613-9596-438a-9604-67e20016aa96","klarnaCreditRecurring" : {"returnUrl" : "http://example.org/return","cancelUrl" : "http://example.org/cancel"}}digitalriver.createSource(payload).then(function(result) {if (result.error) {//handle errors} else {var source = result.source;//send source to back endsendToBackend(source);}});