DigitalRiver object

Learn how to use the DigitalRiver object.

Creating a DigitalRiver object

For details, refer to the Digital River publishable API key page.

let digitalRiver = new DigitalRiver("pk_test_fh9861t8b7384b7dke9e8dn4fb79808192", {
     "locale": "en-US"
});

Creating an instance of Drop-in

createDropin(configuration)

Use createDropin(configuration) to create an instance of Drop-in Payments. For details, refer to the Drop-in Payments integration guide.

Creating elements

createElement(element, config)

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

cardCVV

A card security code field

cardExpiration

A credit card expiration field

cardNumber

A credit card number field

konbini

A Konbini select

onlineBanking

An online banking select

offlineRefund

An offline refund data collection element

paypal

A PayPal element

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.

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 a payment request

Refer to the Payment request object in the Digital River payment objects article for details.

Creating sources

When creating sources, you can select a method that accepts an element or use 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 specify a future source use.

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 creating a source again.

createSource(sourceData)

Use the createSource(sourceData) method to create a payment source that contains information you can safely use with other Commerce APIs. This includes immediate sources (if PCI compliant), redirect sources, or delayed sources. See Configuring 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.

A successful response returns a source with a unique id.

An unsuccessful response returns an error with information on what needs to be corrected.

createSource(element, sourceData)

Use the createSource(element, sourceData) method to create a tokenized source to 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.

This method uses source data and an element argument in the following example.

A successful response returns a source with a unique id.

An unsuccessful response returns an error with information on what needs to be corrected.

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 most 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.

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. With the exception of the returnUrl, you can set the parameters of this object by retrieving the source and then getting the required data.

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.

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)

This method can authenticate a payment source before it is applied to a transaction.

The following is an example response when a source is successfully authenticated:

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.

The following is an example response when a source is successfully authenticated:

Updating sources

digitalriver.updateSource([element,] sourceData);

Use this method to update details on a source.

This method takes two parameters:‌

  • element—An optional card expiration element for using the Elements portion of this library.

  • sourceData—A required data object containing 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. Note: You can only update the owner information for Credit Cards.

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

Updating only address information

Updating only card expiration information

Update error‌

If there is a problem with the update request, an error object will be returned in the response.

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.

The following response includes all payment methods that you configured for your account.

Retrieve available payment methods response using filters

The following example shows a request using filters.

The following response only returns payment methods available in the US, using the USD currency, and supporting recurring payments.

Retrieve available payment methods response with a Session ID

If you specify a Payment Session ID, you will only receive the payment methods which apply to your transaction.

Credit card logos

If you want to display the credit card payment logo on your website, you can use the following URLs to add the appropriate brand logo image to your website:

Best Practices: To ensure you always use the latest logo, link to the URL instead of downloading the image to your website.

Retrieving available banks for Online Banking

digitalriver.retrieveOnlineBankingBanks(countryCode, currency)

Use this method to retrieve an array of available banks for a combination of ISO 3166-1 alpha-2 country code and ISO 4217 currency code.‌

This method returns an array that will either be empty if no banks are available or contain objects with Issuer IDs and Bank Names. DigitalRiver.js uses this data when creating an Online Banking source. This method is useful if you want to build a bank selector instead of using the Online Banking element.

Last updated

Was this helpful?