Search…
DigitalRiver object
Learn how to use the DigitalRiver object.

Creating an instance of Drop-in

digitalriver.createDropin(configurationObject);

Use createDropin to create an instance of our Drop-in solution. This solution provides an all-in-one solution for accepting payments and ensuring compliance. Use this solution for a quick way to start accepting payments with little to no customization. For more information, see our page on Drop-in.

Creating Elements

digitalriver.createElement();

Use this method to create an instance of an element that you can use to capture payment details. You can use the following Elements in conjunction with createSource to create a payment source.
Element Type
Description
applepay
Apple Pay
cardCVV
A card security code field
cardExpiration
A credit card expiration field
cardNumber
A credit card number field
googlepay
Google Pay
konbini
A Konbini select
onlineBanking
An online banking select
offlineRefund
An offline refund data collection element
paypal
A PayPal element
Example
1
var options = {
2
classes: {
3
base: "DRElement",
4
complete: "complete",
5
empty: "empty",
6
focus: "focus",
7
invalid: "invalid",
8
webkitAutofill: "autofill"
9
},
10
style: {
11
base: {
12
color: "#fff",
13
fontFamily: "Arial, Helvetica, sans-serif",
14
fontSize: "20px",
15
fontSmoothing: "auto",
16
fontStyle: "italic",
17
fontVariant: "normal",
18
letterSpacing: "3px"
19
},
20
empty: {
21
color: "#fff"
22
},
23
complete: {
24
color: "green"
25
},
26
invalid: {
27
color: "red",
28
}
29
}
30
};
31
32
33
var cardNumber = digitalriver.createElement('cardnumber', options);
34
var cardExpiration = digitalriver.createElement('cardexpiration', options);
35
var cardCVV = digitalriver.createElement('cardcvv', options);
Copied!
JavaScript
1
<div id="card-number" class="DRElement">
2
<!-- The embedded Element iframe -->
3
<iframe src="cardnumber.html"></iframe>
4
</div>
5
6
7
<div id="card-number" class="DRElement--complete">
8
<!-- The embedded Element iframe -->
9
<iframe src="cardnumber.html"></iframe>
10
</div>
11
12
<div id="card-number" class="DRElement--empty">
13
<!-- The embedded Element iframe -->
14
<iframe src="cardnumber.html"></iframe>
15
</div>
16
17
<div id="card-number" class="DRElement--focus">
18
<!-- The embedded Element iframe -->
19
<iframe src="cardnumber.html"></iframe>
20
</div>
21
22
23
<div id="card-number" class="DRElement--invalid">
24
<!-- The embedded Element iframe -->
25
<iframe src="cardnumber.html"></iframe>
26
</div>
27
28
29
<div id="card-number" class="DRElement--autofilled">
30
<!-- The embedded Element iframe -->
31
<iframe src="cardnumber.html"></iframe>
32
</div>
Copied!

Options

Heading
State
Default Class
classes
base
DRElement
classes
complete
DRElement--complete
classes
empty
DRElement--empty
classes
focus
DRElement--focus
classes
invalid
DRElement--invalid
classes
autofilled
DRElement--autofilled

digitalriver.Compliance.getDetails(businessEntityCode [, locale]);

Use this method to retrieve localized strings that can be used to create the various disclosures required by Digital River.
Parameter
Required/Optional
Description
Accepted Values
businessEntityCode
Required
The business entity code of the entity facilitating the transaction.
DRES_INC-ENTITY, DR_WP-ENTITY, DR_WPAB-ENTITY, C5_INC-ENTITY, DR_BRAZIL-ENTITY, DR_BRAZIL2-ENTITY, DR_CHINA-ENTITY, DR_GMBH-ENTITY, DR_INC-ENTITY, DR_INDIA-ENTITY, DR_IRELAND-ENTITY, DR_JAPAN-ENTITY, DR_KOREA-ENTITY, DR_MEXICO-ENTITY, DR_RUSSIA-ENTITY, DR_TAIWAN-ENTITY, DR_SARL-ENTITY, DR_UK-ENTITY
locale
Optional
The language associated with the returned data. If you do not provide a locale and you provided a default locale when you started the DigitalRiver.js library, the strings will be localized to that default value. If you did not provide a default locale, the default language is English.
ar-EG, cs-CZ, da-DK, de-AT, de-CH, de-DE, el-GR, en-AU, en-BE, en-CA, en-CH, en-DK, en-FI, en-GB, en-IE, en-IN, en-MY, en-NL, en-NO, en-NZ, en-PR, en-SE, en-SG, en-US, en-ZA, es-AR, es-CL, es-CO, es-EC, es-ES, es-MX, es-PE, es-VE, et-EE, fi-FI, fr-BE, fr-CA, fr-CH, fr-FR, hu-HU, it-CH, it-IT, iw-IL, ja-JP, ko-KR, lt-LT, lv-LV, nl-BE, nl-NL, no-NO, pl-PL, pt-BR, pt-PT, ro-RO, ru-RU, sk-SK, sl-SI, sr-YU, sv-SE, th-TH, tr-TR, zh-CN, zh-HK, zh-TW
This method returns an object with various compliance strings and links that can be used to create a legal footer with various resources.
Example
1
{
2
"disclosure": {
3
"businessEntity": {
4
"name": "Digital River Inc.",
5
"id": "DR_INC-ENTITY"
6
},
7
"resellerDisclosure": {
8
"localizedText": "<a href=\"https://store.digitalriver.com/store/defaults/en_US/DisplayDRAboutDigitalRiverPage/eCommerceProvider.Digital%20River%20Inc.\" target=\"_blank\" class=\"dr_resellerDisclosure\">Digital River Inc.</a> is the authorized reseller and merchant of the products and services offered within this store.",
9
"url": "https://store.digitalriver.com/store/defaults/en_US/DisplayDRAboutDigitalRiverPage/eCommerceProvider.Digital%20River%20Inc."
10
},
11
"termsOfSale": {
12
"localizedText": "Terms of Sale",
13
"url": "https://store.digitalriver.com/store/defaults/en_US/DisplayDRTermsAndConditionsPage/eCommerceProvider.Digital%20River%20Inc."
14
},
15
"privacyPolicy": {
16
"localizedText": "Privacy Policy",
17
"url": "https://store.digitalriver.com/store/defaults/en_US/DisplayDRPrivacyPolicyPage/eCommerceProvider.Digital%20River%20Inc."
18
},
19
"cookiePolicy": {
20
"localizedText": "Cookies",
21
"url": "https://store.digitalriver.com/store/defaults/en_US/DisplayDRCookiesPolicyPage/eCommerceProvider.Digital%20River%20Inc."
22
},
23
"cancellationRights": {
24
"localizedText": "Cancellation Right",
25
"url": "https://store.digitalriver.com/store/defaults/en_US/DisplayDRTermsAndConditionsPage/eCommerceProvider.Digital%20River%20Inc.#cancellationRight"
26
},
27
"legalNotice": {
28
"localizedText": "Legal Notice",
29
"url": "https://store.digitalriver.com/store/defaults/en_US/DisplayDRContactInformationPage/eCommerceProvider.Digital%20River%20Inc."
30
},
31
"confirmDisclosure": {
32
"localizedText": "By submitting my order, I agree to the <a href=\"https://store.digitalriver.com/store/defaults/en_US/DisplayDRTermsAndConditionsPage/eCommerceProvider.Digital%20River%20Inc.\" target=\"_blank\" class=\"dr_termsAndConditions\">Terms of Sale</a> and the <a href=\"https://store.digitalriver.com/store/defaults/en_US/DisplayDRPrivacyPolicyPage/eCommerceProvider.Digital%20River%20Inc.\" target=\"_blank\" class=\"dr_privacyPolicy\">Privacy Policy</a> of Digital River Inc.."
33
},
34
"autorenewalPlanTerms": {
35
"localizedText": "By checking the box below and completing your purchase, you expressly authorize and permit Digital River to automatically renew your purchased license or subscription for successive renewal terms each equal in length to the initial term specified above, at the purchase price for your initial term (plus taxes and fees, less any applicable discounts) using the payment information you provided for your initial purchase, until you cancel. At least one email will be sent to you to remind you of each upcoming renewal. We may change the renewal price as of the next renewal date if we provide you with prior notice of the change by email (you can elect to cancel automatic renewal as described below if you do not agree to the change). The Digital River <a href=\"https://store.digitalriver.com/store/defaults/en_US/DisplayDRTermsAndConditionsPage/eCommerceProvider.Digital%20River%20Inc.\" target=\"_blank\" class=\"dr_termsAndConditions\">Terms of Sale</a> and <a href=\"https://store.digitalriver.com/store/defaults/en_US/DisplayDRPrivacyPolicyPage/eCommerceProvider.Digital%20River%20Inc.\" target=\"_blank\" class=\"dr_privacyPolicy\">Privacy Policy</a> will apply to each renewal transaction. You may cancel your auto-renewal plan at any time by logging into the account interface (access information will be included in your order confirmation email or on the Customer Service Help page), selecting your product, and selecting the option to disable automatic renewal.<br/><br/>I agree that Digital River may store my payment information for future purchases including the processing of any subsequent subscription renewals which may occur following the date of this order."
36
},
37
"saveCardMandate": {
38
"localizedText": "Yes, please save this account and payment information for future purchases."
39
},
40
"californiaPrivacyRights": {
41
"localizedText": "Your California Privacy Rights",
42
"url": "https://store.digitalriver.com/store/defaults/en_US/DisplayCCPAPage"
43
}
44
}
45
}
Copied!
Attribute
Description
businessEntity
Details about the business entity.
resellerDisclosure
Digital River reseller statement and links.
termsOfSale
Localized Terms of Sale and a link to the Digital River terms and conditions page.
privacyPolicy
Localized Privacy Policy and a link to the Digital River privacy policy page.
cookiePolicy
Localized Cookie Policy and a link to the Digital River cookie policy page.
cancellationRights
Localized Cancellation Rights and a link to the Digital River page explaining the shopper's cancellation rights.
legalNotice
Localized Legal Notice and a link to the Digital River page with our legal notice details.
confirmDisclosure
A localized string with our confirmation disclosure statement. This should be placed next to your confirm order button.
autorenewalPlanTerms
Localized Autorenewal Plan Terms and a link to the Digital River page with our Terms of Sale.
saveCardMandate
The save payment agreement for future purchases
californiaPrivacyRights
California Privacy Rights identifier in English and a link to the Digital River page explaining the shopper's rights in California. This is only applicable to the en-US locale.
warrantyInformation
Warranty Information in Italian and a link to the Digital River page explaining warranty information to residents of Italy. This is only applicable to the it-IT locale.

Creating sources

When creating sources, you have the option of selecting a method that accepts an element or using a method that doesn't require an element. Both methods however require that you provide source data to tokenize. When configuring this data, you can also specify a future use for the source.
For both versions, the createSource() method returns a promise that contains a Result object. The Result object, in turn, contains one of two possible objects:‌
  • source — A Source object created by Digital River.
  • error — An error object that indicates a problem with the tokenization request. It provides the data you must correct before attempting to create a source again.

createSource(sourceData);

Use the createSource(sourceData) method to create a payment source that contains information you can safely use with other Digital River APIs. This includes immediate sources (if PCI compliant), redirect sources, or delayed sources. See Payment methods for more information on the structure of these requests.‌
In the following example, the method takes a single argument. The sourceData contains the data that you want Digital River to tokenize.
Example
1
var sourceData = {
2
"type": "creditCard",
3
"owner": {
4
"firstName": "firstName",
5
"lastName": "lastName",
6
"email": "[email protected]",
7
"address": {
8
"line1": "1234 First St.",
9
"city": "Minnetonka",
10
"state": "MN",
11
"country": "US",
12
"postalCode": 55410
13
}
14
},
15
"creditCard": {
16
"number": "4444333322221111",
17
"expirationMonth": 12,
18
"expirationYear": 2025,
19
"cvv": "123"
20
}
21
}
22
23
24
digitalriver.createSource(sourceData).then(function(result) {
25
if(result.error) {
26
//handle error message
27
var errorMessage = result.error.errors[0].message;
28
} else {
29
30
//send source to back end for processing
31
var source = result.source;
32
}
33
});
Copied!
A successful response returns a source with a unique id.
Source response
1
{
2
"error": undefined,
3
"source": {
4
"id": "775d3ff1-99a3-4640-bd2c-24e4b6b13324",
5
"type": "creditCard",
6
"owner": {
7
"firstName": "John",
8
"lastName": "Doe",
9
"email": "[email protected]",
10
"referenceId": "",
11
"address": {
12
"line1": "10380 Bren Road W.",
13
"line2": "Suite 929",
14
"city": "Minnetonka",
15
"state": "MN",
16
"country": "US",
17
"postalCode": "55343"
18
}
19
},
20
"status": "chargeable",
21
"creationIp": "67.256.231.1",
22
"creationDate": "2018-08-22T19:21:59.26Z",
23
"flow": "standard",
24
"creditCard": {
25
"brand": "Visa",
26
"expirationMonth": 10,
27
"expirationYear": 2019,
28
"lastFourDigits": "1111"
29
}
30
}
31
}
Copied!
An unsuccessful response returns an error with information on what needs to be corrected.
Error response
1
{
2
"error": {
3
"type": "bad_request",
4
"errors": [{
5
"code": "invalid_parameter",
6
"parameter": "owner.firstName",
7
"message": "'' is not a valid owner.firstname."
8
},
9
{
10
"code": "currency_unsupported",
11
"parameter": "currency",
12
"message": "currency 'xyz' is not supported."
13
}]
14
},
15
source: undefined
16
}
Copied!

createSource(element, sourceData);

Use the createSource(element, sourceData) method to create a tokenized source that you can safely transmit to the backend for use in downstream API calls. This method requests two parameters:‌
  • element — A Element object created using the Elements portion of this library.
  • sourceData — The source data that you want Digital River to tokenize. See Common payment sources for more information on the required source data.
In the following example, the method takes both a source data and element argument.
Example
1
var sourceData = {
2
"type": "creditCard",
3
"owner": {
4
"firstName": "firstName",
5
"lastName": "lastName",
6
"email": "[email protected]",
7
"address": {
8
"line1": "1234 First St.",
9
"city": "Minnetonka",
10
"state": "MN",
11
"country": "US",
12
"postalCode": 55410
13
}
14
}
15
}
16
17
18
digitalriver.createSource(cardNumber, sourceData).then(function(result) {
19
if(result.error) {
20
//handle error messages
21
var errorMessage = result.error.errors[0].message;
22
} else {
23
//send source to back end for processing
24
var source = result.source;
25
}
26
});
Copied!
A successful response returns a source with a unique id.
Source response
1
{
2
"error": undefined,
3
"source": {
4
"id": "775d3ff1-99a3-4640-bd2c-24e4b6b13324",
5
"clientId": "gc",
6
"channelId": "drdod15",
7
"type": "creditCard",
8
"owner": {
9
"firstName": "Gwen",
10
"lastName": "Sawayn",
11
"email": "[email protected]",
12
"referenceId": "",
13
"address": {
14
"line1": "04644 Altenwerth Drives",
15
"line2": "Suite 929",
16
"city": "North Aurelia",
17
"state": "NV",
18
"country": "US",
19
"postalCode": "93414-6991"
20
}
21
},
22
"amount": "100.00",
23
"currency": "USD",
24
"status": "chargeable",
25
"creationIp": "67.216.237.4",
26
"creationDate": "2018-08-22T19:21:59.26Z",
27
"flow": "standard",
28
"creditCard": {
29
"brand": "Visa",
30
"expirationMonth": 10,
31
"expirationYear": 2019,
32
"lastFourDigits": "1111"
33
}
34
}
35
}
Copied!
An unsuccessful response returns an error with information on what needs to be corrected.
Error response
1
{
2
"error": {
3
"type": "validation_error",
4
"errors": [{
5
"code": "incomplete_card_number",
6
"message": "Your card number is incomplete."
7
}]
8
},
9
source: undefined
10
}
Copied!

Specifying a source's future use

When creating a source using DigitalRiver.js, you should identify the types of transactions it will likely be used for in the future. This increases the probability that these future transactions will be approved. The usage value you select should be the one that mostly closely corresponds to your business model. The available options are subscription, convenience, and unscheduled.

Subscription

Set usage to subscription when you create sources that are used primarily for recurring transactions, made at regular intervals for a product or a service.

Convenience

The convenience setting applies mainly to saved payment sources that are used for one-off transactions. These are sources where customers are typically present during the checkout flow and want to quickly access their payment information. Select this option if you don't offer subscriptions or don't have unscheduled merchant initiated transactions

Unscheduled

Set usage to unscheduled when you create sources for unscheduled merchant initiated transactions. These are contracts that occur on a non-fixed schedule using stored card information. Automatic top-ups are an example of one such transaction. They occur whenever a customer's balance drops below a pre-defined amount.

Retrieving sources

digitalriver.retrieveSource(sourceId, sourceClientSecret);

Use this method to retrieve a source with the front-end DigitalRiver.js library. This method takes two parameters:‌
  • sourceId—The unique ID of the source you want to retrieve.
  • sourceClientSecret—The clientSecret value of the source you are trying to retrieve. This is specific to the source.
The digitalriver.createSource() returns a Promise that includes a Result object. (See the following source response example.) The Result object will have either:‌
  • result.source—If this object is not null, it will contain the Source object you requested.
  • result.error— If this object is not null, it will contain an Error object with details on the specific error.
Example
1
digitalriver.retrieveSource("ee90c07c-5549-4a6b-aa5f-aabe29b1e97a","ee90c07c-5549-4a6b-aa5f-aabe29b1e97a_51afe818-0e7f-46d7-8257-b209b20f4d8").then(function(result) {
2
if(result.error) {
3
//handle error messages
4
var errorMessage = result.error.errors[0].message;
5
} else {
6
//do something with the source
7
var source = result.source;
8
}
9
});
Copied!
Source response
1
{
2
"error": undefined,
3
"source": {
4
"id": "775d3ff1-99a3-4640-bd2c-24e4b6b13324",
5
"clientId": "gc",
6
"channelId": "drdod15",
7
"type": "creditCard",
8
"usage": "single",
9
"owner": {
10
"firstName": "Gwen",
11
"lastName": "Sawayn",
12
"email": "[email protected]",
13
"referenceId": "",
14
"address": {
15
"line1": "04644 Altenwerth Drives",
16
"line2": "Suite 929",
17
"city": "North Aurelia",
18
"state": "NV",
19
"country": "US",
20
"postalCode": "93414-6991"
21
}
22
},
23
"amount": "100.00",
24
"currency": "USD",
25
"status": "chargeable",
26
"creationIp": "67.216.237.4",
27
"creationDate": "2018-08-22T19:21:59.26Z",
28
"flow": "standard",
29
"creditCard": {
30
"brand": "Visa",
31
"expirationMonth": 10,
32
"expirationYear": 2019,
33
"lastFourDigits": "1111"
34
}
35
}
36
}
Copied!

Authenticating sources

The authenticate source method determines whether the saved payment source selected by a customer during the checkout process requires Strong Customer Authentication (SCA).
You can use this method when building workflows that allow customers to retrieve saved payment information during one-off purchases and subscription acquisitions.
The standard version of the method accepts a configuration object that contains the data we need to authenticate the source.
Parameter
Required/Optional
Description
sessionId
Required
The payment session identifier of this transaction.
sourceId
Required
The identifier of the payment source used in this transaction.
sourceClientSecret
Required
The source client secret for this transaction.
returnUrl
Required
The return URL where the customer is directed when 3D Secure 1 is required. If the value is not provided, we use the current page location.
Do not log, embed in URLs, or expose the sourceClientSecret to anyone other than the customer. On any page that includes the secret, ensure that TLS is enabled.
The other version of the authenticate source method accepts this same data plus an optional CVV Element type.
After you call either version of this method, Digital River automatically handles the SCA requirements. Once the customer completes the necessary authentication or we determine that authentication isn't required, the method resolves and the checkout flow can continue.
More specifically, the method returns a promise which is resolved by a source authentication result object. The following are the possible results and the recommended actions:
status
Description
complete
The customer successfully completed the steps necessary to authenticate the source. You can now submit the order.
authentication_not_required
Digital River determined that the payment source didn't require authentication for this particular payment session. You can now submit the order.
failed
Source authentication failed. The source can still be used in the transaction but may be declined. You should attempt to authenticate the source again.

authenticateSource(data)

You can use this method to authenticate a payment source before it is applied to a transaction.
1
digitalriver.authenticateSource({
2
"sessionId": "65b1e2c2-632c-4240-8897-195ca22ce108",
3
"sourceId": "ee90c07c-5549-4a6b-aa5f-aabe29b1e97a",
4
"sourceClientSecret": "ee90c07c-5549-4a6b-aa5f-aabe29b1e97a_51afe818-0e7f-46d7-8257-b209b20f4d8",
5
"returnUrl": "https://returnurl.com"
6
});
Copied!
The following is an example response when a source is successfully authenticated:
1
{
2
"status": "complete"
3
}
Copied!

authenticateSource([cvvElement], data)

In this alternative version of the method to authenticate sources, you can provide an optional CVV Element type (assuming it is correctly created and mounted). By setting this parameter, the value contained in the field of the CVV Element is included in the authentication request.
1
digitalriver.authenticateSource(cvvElement, {
2
"sessionId": "65b1e2c2-632c-4240-8897-195ca22ce108",
3
"sourceId": "ee90c07c-5549-4a6b-aa5f-aabe29b1e97a",
4
"sourceClientSecret": "ee90c07c-5549-4a6b-aa5f-aabe29b1e97a_51afe818-0e7f-46d7-8257-b209b20f4d8",
5
"returnUrl": "https://returnurl.com"
6
});
Copied!
The following is an example response when a source is successfully authenticated:
1
{
2
"status": "complete"
3
}
Copied!

Updating sources

digitalriver.updateSource([element,] sourceData);

Use this method to update details on a source. When updating a source, you may update the Owner or in the case of a Credit Card source, the card expiration details. This method takes two parameters:‌
  • element—An optional card expiration element created using the Elements portion of this library.
  • sourceData—A required data object which contains additional data required to update the payment source.
Field
Required
Type
Description
clientSecret
Required
String
The Client Secret of the source you are updating.
id
Required
String
The ID of the source you are updating.
owner
Optional
An Owner Object
An object containing the Owner details.
digitalriver.updateSource() returns a Promise that returns a result object. The result object will have either:‌
  • result.source—A source object that was updated in the Payments Service
  • result.error—An error occurred that must be corrected to update the source.

Updating expiration and address information

Example
1
//Create the element using DigitalRiver.js and place it on the page.
2
var options = {
3
style: {
4
base: {
5
color: "#fff",
6
fontFamily: "Arial, Helvetica, sans-serif",
7
fontSize: "20px",
8
fontSmoothing: "auto",
9
fontStyle: "italic",
10
fontVariant: "normal",
11
letterSpacing: "3px"
12
}
13
...
14
}
15
var cardExpiration = digitalriver.createElement('cardexpiration', options);
16
cardExpiration.mount('card-expiration');
17
18
19
var sourceData = {
20
"id": "14381d1c-8bff-4350-aeea-82b36f3a196c",
21
"clientSecret": "14381d1c-8bff-4350-aeea-82b36f3a196c_14381d1c-8bff-4350-aeea-82b36f3a196c",
22
"owner": {
23
"firstName": "firstName",
24
"lastName": "lastName",
25
"email": "[email protected]",
26
"address": {
27
"line1": "1234 First St.",
28
"city": "Minnetonka",
29
"state": "MN",
30
"country": "US",
31
"postalCode": 55410
32
}
33
}
34
}
35
36
37
digitalriver.updateSource(cardExpiration, sourceData).then(function(result) {
38
if(result.error) {
39
//handle error messages
40
var errorMessage = result.error.errors[0].message;
41
} else {
42
//the source has been updated with new details
43
var source = result.source;
44
}
45
});
Copied!
Source Response
1
{
2
"error": undefined,
3
"source": {
4
"id": "775d3ff1-99a3-4640-bd2c-24e4b6b13324",
5
"clientId": "gc",
6
"channelId": "drdod15",
7
"type": "creditCard",
8
"usage": "single",
9
"owner": {
10
"firstName": "firstName",
11
"lastName": "lastName",
12
"email": "[email protected]",
13
"address": {
14
"line1": "1234 First St.",
15
"city": "Minnetonka",
16
"state": "MN",
17
"country": "US",
18
"postalCode": 55410
19
}
20
},
21
"status": "chargeable",
22
"creationIp": "67.216.237.4",
23
"creationDate": "2018-08-22T19:21:59.26Z",
24
"flow": "standard",
25
"creditCard": {
26
"brand": "Visa",
27
"expirationMonth": 10,
28
"expirationYear": 2019,
29
"lastFourDigits": "1111"
30
}
31
}
32
}
Copied!

Updating only address information

Example
1
var sourceData = {
2
"id": "14381d1c-8bff-4350-aeea-82b36f3a196c",
3
"clientSecret": "14381d1c-8bff-4350-aeea-82b36f3a196c_14381d1c-8bff-4350-aeea-82b36f3a196c",
4
"owner": {
5
"firstName": "firstName",
6
"lastName": "lastName",
7
"email": "[email protected]",
8
"address": {
9
"line1": "1234 First St.",
10
"city": "Minnetonka",
11
"state": "MN",
12
"country": "US",
13
"postalCode": 55410
14
}
15
}
16
}
17
18
19
digitalriver.updateSource(sourceData).then(function(result) {
20
if(result.error) {
21
//handle error messages
22
var errorMessage = result.error.errors[0].message;
23
} else {
24
//the source has been updated with new details
25
var source = result.source;
26
}
27
});
Copied!
Source Response
1
{
2
"error": undefined,
3
"source": {
4
"id": "775d3ff1-99a3-4640-bd2c-24e4b6b13324",
5
"clientId": "gc",
6
"channelId": "drdod15",
7
"type": "creditCard",
8
"usage": "single",
9
"owner": {
10
"firstName": "firstName",
11
"lastName": "lastName",
12
"email": "[email protected]",
13
"address": {
14
"line1": "1234 First St.",
15
"city": "Minnetonka",
16
"state": "MN",
17
"country": "US",
18
"postalCode": 55410
19
}
20
},
21
"status": "chargeable",
22
"creationIp": "67.216.237.4",
23
"creationDate": "2018-08-22T19:21:59.26Z",
24
"flow": "standard",
25
"creditCard": {
26
"brand": "Visa",
27
"expirationMonth": 10,
28
"expirationYear": 2019,
29
"lastFourDigits": "1111"
30
}
31
}
32
}
Copied!

Updating only card expiration information

Example
1
//Create the element using DigitalRiver.js and place it on the page.
2
var options = {
3
style: {
4
base: {
5
color: "#fff",
6
fontFamily: "Arial, Helvetica, sans-serif",
7
fontSize: "20px",
8
fontSmoothing: "auto",
9
fontStyle: "italic",
10
fontVariant: "normal",
11
letterSpacing: "3px"
12
}
13
14
...
15
}
16
var cardExpiration = digitalriver.createElement('cardexpiration', options);
17
18
cardExpiration.mount('card-expiration');
19
20
21
var sourceData = {
22
"id": "14381d1c-8bff-4350-aeea-82b36f3a196c",
23
"clientSecret": "14381d1c-8bff-4350-aeea-82b36f3a196c_14381d1c-8bff-4350-aeea-82b36f3a196c"
24
}
25
26
27
digitalriver.updateSource(cardExpiration, sourceData).then(function(result) {
28
if(result.error) {
29
//handle error messages
30
var errorMessage = result.error.errors[0].message;
31
} else {
32
//the source has been updated with new details
33
var source = result.source;
34
}
35
});
Copied!
Source Response
1
{
2
"error": undefined,
3
"source": {
4
"id": "775d3ff1-99a3-4640-bd2c-24e4b6b13324",
5
"clientId": "gc",
6
"channelId": "drdod15",
7
"type": "creditCard",
8
"usage": "single",
9
"owner": {
10
"firstName": "firstName",
11
"lastName": "lastName",
12
"email": "[email protected]",
13
"address": {
14
"line1": "1234 First St.",
15
"city": "Minnetonka",
16
"state": "MN",
17
"country": "US",
18
"postalCode": 55410
19
}
20
},
21
"status": "chargeable",
22
"creationIp": "67.216.237.4",
23
"creationDate": "2018-08-22T19:21:59.26Z",
24
"flow": "standard",
25
"creditCard": {
26
"brand": "Visa",
27
"expirationMonth": 10,
28
"expirationYear": 2019,
29
"lastFourDigits": "1111"
30
}
31
}
32
}
Copied!

Update error

If there is a problem with the update request, an error object will be returned in the response.
Source Errors
1
{
2
"error": {
3
"type": "validation_error",
4
"errors": [{
5
"code": "incomplete_card_number",
6
"message": "Your card number is incomplete."
7
}]
8
},
Copied!

Retrieving available payment methods

digitalriver.retrieveAvailablePaymentMethods([filters]);

Use this method to retrieve an array of available payment methods. You can use this to filter and determine applicable payment methods while building your checkout flows. The filters object is optional.
Attribute
Required/Optional
Description
currency
Optional
The currency of the transaction.
country
Optional
The country of the billing addresses associated with this transaction.
supportsStorage
Optional
Whether the payment supports storage.
supportsRecurring
Optional
Whether the payment method supports recurring payments.
supportsFreeTrial
Optional
Whether the payment method supports free trials.
sessionId
Optional
The Payment Session ID. If used, the response will return the payment methods which apply to your transaction.
Retrieve available payment methods response without using session ID
The following example shows a request with no filters applied.
Request Example
1
digitalriver.retrieveAvailablePaymentMethods().then(function(result) {
2
//do something with the result, this could include showing or hiding specific payment methods that are applicable to the display
3
});
Copied!
The following response includes all payment methods that you configured for your account.
Response Example
1
{
2
"paymentMethods": [
3
{
4
"type": "alipay",
5
"flow": "redirect",
6
"supportsRecurring": false,
7
"supportsFreeTrial": false,
8
"images": {
9
"iconImage": "https://ui1.img.digitalrivercontent.net/Storefront/images/paymentMethodLogos/alipay.png"
10
}
11
},
12
{
13
"type": "applePay",
14
"flow": "standard",
15
"supportsRecurring": false,
16
"supportsFreeTrial": false,
17
"images": {
18
"iconImage": "https://ui1.img.digitalrivercontent.net/Storefront/images/paymentMethodLogos/applepay.png"
19
}
20
},
21
{
22
"type": "bankTransfer",
23
"flow": "redirect",
24
"supportsRecurring": false,
25
"supportsFreeTrial": false,
26
"images": {
27
"iconImage": "https://ui1.img.digitalrivercontent.net/Storefront/images/paymentMethodLogos/bankTransfer.png"
28
}
29
},
30
{
31
"type": "bPay",
32
"flow": "receiver",
33
"supportsRecurring": false,
34
"supportsFreeTrial": false,
35
"images": {
36
"iconImage": "https://ui1.img.digitalrivercontent.net/Storefront/images/paymentMethodLogos/bpay.png"
37
}
38
},
39
{
40
"type": "carrierFinancing",
41
"flow": "standard",
42
"supportsRecurring": false,
43
"supportsFreeTrial": false,
44
"images": {}
45
},
46
{
47
"type": "codJapan",
48
"flow": "standard",
49
"supportsRecurring": false,
50
"supportsFreeTrial": false,
51
"images": {
52
"iconImage": "https://ui1.img.digitalrivercontent.net/Storefront/images/paymentMethodLogos/codJapan.png"
53
}
54
},
55
{
56
"type": "creditCard",
57
"flow": "standard",
58
"supportsRecurring": true,
59
"supportsFreeTrial": true,
60
"images": {
61
"iconImage": "https://ui1.img.digitalrivercontent.net/Storefront/images/paymentMethodLogos/creditcard.png"
62
}
63
},
64
{
65
"type": "creditInstallment",
66
"flow": "redirect",
67
"supportsRecurring": false,
68
"supportsFreeTrial": false,
69
"images": {},
70
"terms": [
71
{
72
"id": "8281"