Drop-in payments integration guide
Create a payment form using Drop-in payments.
This page explains how to get started integrating Drop-in payments into both cart flows and account management flows.
Getting started
You can set up Drop-in payments in seven steps:
Step 1: Include DigitalRiver.js
Include the following script on the pages where you want Drop-in payments to appear (for example, the cart or My Account page):
Step 2: Include the base CSS file
Include the following link to the Drop-in payments CSS file on the same pages. If you'd like to customize the styles, override the CSS file with your own.
Step 3: Initialize DigitalRiver.js with your public key
Initialize the DigitalRiver.js library with your public API key. If you provide a locale
, Drop-in Payments is localized based on that value.
Step 4: Create a Drop-in payments container
Create a container element on the page where you want the Drop-in payments to appear.
Step 5: Create a Drop-in payments configuration object
Create a configuration
object. For details, refer to Configuring drop-in payments.
Field | Required | Description |
---|---|---|
| Required for the Optional for the | The payment session identifier returned by Digital River. Important: The |
| Optional | |
| Required | The customer's billing address. |
| Required | The customer's first name. |
| Required | The customer's last name. |
| Required | The customer's email address. |
| Optional | The business customer's organization. |
| Required | The customer's phone number. |
| Required | The first line of the address. |
| Optional | The second line of the address |
| Optional | City or town. |
| Optional | The state, county, province, or region. |
| Required | ZIP or postal code. |
| Required | A two-letter Alpha-2 country code as described in the ISO 3166 international standard. |
| Optional | Additional address information that may be useful or required for some addresses. |
| Optional | Additional configuration details. |
Content | The function called when the shopper has authorized payment and a payment source has been successfully created. Returns a | |
Content | The function called when the shopper cancels the payment process before authorizing payment. | |
Content | The function called when an error has occurred. | |
Content | The function called when Drop-in payments is ready for user interaction. |
Step 6: Use the configuration object to create an instance of Drop-in payments
Create an instance of Drop-in payments by passing the configuration object to createDropin()
.
Step 7: Mount Drop-in payments on your cart or account management page
Add the following statement to the appropriate cart or account management page:
Once invoked, mount()
displays Drop-in payments in the designated container.
Using Drop-in payments in a cart
Finalize your cart
Create a cart and provide the necessary information to have a final total for all amounts, including taxes, shipping, duties, and fees.
Initialize and place Drop-in payments within your application
Customers select how they want to pay from the experience page where you added the Drop-in payments container. Drop-in payments provide what is needed, including redirects to return a payment source that can be used in downstream API calls with the Commerce API.
The customer provides payment details
The customer may be redirected to authorize their payment.
The onSuccess event returns the source
The following source object contains the customer's payment details for a one-time charge.
Optional. Allowing the customer to save their payment details
During the cart flow, you can also give customers the opportunity to save their payment details for use in future transactions by enabling showSavePaymentAgreement
.
This feature ensures that a customer's payment details are collected in a PSD2 and SCA-compliant manner.
When you enable this feature, each displayed reusable payment method is accompanied by a box that customers must check if they want that payment information saved to their account.
If the customers select the checkbox and click the configurable button, Drop-in payments performs the required authentication and, assuming that process is successful, the data
object of onSuccess contains a source that is readyForStorage
.
In this case, handle onSuccess
by passing the source.id
. Use your secret API key to your back end to associate the source with the customer before you associate the source with the cart.
Using Drop-in payments in an account management portal
If your integration allows customers to save payment methods outside of a cart flow, you can add Drop-in payments to their account management portal.
In this flow, the Drop-in payments' configuration object doesn't require a sessionId
. Instead, you should set options.flow
to managePaymentMethods
. The managePaymentMethods
informs Digital River that you're collecting and saving payment information in an account management setting.
Because this is a managePaymentMethods
flow, and there's no payment session to reference, you need to use the configuration object's billingAddress
to pass the billing information you collect from customers.
There's no need to enable showComplianceSection
, showTermsOfSaleDisclosure
, and showSavePaymentAgreement
since those features only need to be turned on in cart flows.
Configure and mount Drop-in payments
Once the create and mount methods are invoked, Drop-in payments open on the container element's experience page. For more details on this process, refer to the Getting started section.
Customers then select the payment method to add to their account and agree to specific storage terms. They may also be required to complete SCA, a process that Drop-in payments handles.
Handle onSuccess
onSuccess
If Digital River successfully creates a payment source, the data
object of onSuccess
contains a source that is readyForStorage
. Handle the event by sending source.id
to your back end and using your secret API key to associate the source with the customer.
The Customer provides payment details
As part of collecting payment details for future use, the customer may be presented with Strong Customer Authentication and may also be required to agree to specific terms of storage. These details will automatically be displayed and collected to ensure compliance.
The onSuccess event returns the source
This flow presents and collects any required authentications and opt-ins. When the source collects the customer's payment details, authentication details, and opt-ins, the onSuccess
event will return this information with a "readyForStorage": true
parameter.
The readyForStorage
identifier signifies the creation of the source with the intention of storage, and any necessary authentications have occurred. Attach the source to a Shopper by calling the appropriate API with your secret key to reuse the source.
Drop-in options
When creating your Drop-in Payments instance, you can specify options to trigger different features or functionality.
Option | Value | Description | Is Default |
---|---|---|---|
|
| Use this option to specify a different Drop-in Payments mode of operation. Enable this flow if you are using Drop-in Payments as part of a My Account page where your customer is managing their stored payment methods. | False |
|
| Use this option if you are using Drop-in Payments within a standard checkout flow. | True |
|
| When enabled, presents the customer with an option to save their payment details for future use within Drop-in Payments. Enabling this feature will show the appropriate check boxes and localized disclosure statements and facilitate any necessary Strong Customer Authentication. | False |
|
| If disabled, Drop-in Payments will not present the customer with an option to save their payment details. | True |
|
| Will show a localized compliance link section as part of Drop-in Payments. This is an important piece for accessing the Digital River business model. | True |
|
| Disables the compliance section within Drop-in Payments. | |
| An object which specifies a | Use this option to customize the text of the Drop-in button. | |
|
| Use this option to specify the future use of a source. | |
|
| Use this option to show the required terms of sale disclosure. These localized terms automatically update if recurring products are purchased. | |
|
| Hides the terms of sale disclosure. | True |
| An object that specifies the options you want to use to disable the automatic redirect functionality built into Drop-in Payments. | Use this option if you would like to handle redirecting the customer yourself to the payment provider. See Disabling redirects within Drop-in Payments. |
Disabling redirects within Drop-in Payments
Enable the disableAutomaticRedirects
attribute if you do not want Drop-in Payments to redirect your customer to the payment provider. Use this setting in your checkout flow if you do not want to create the order from Drop-in Payments. In this scenario, you can allow your customer to choose their payment method, review and then authorize it later by redirecting the customer to the redirect.returnUrl
when the customer has reviewed the order totals and is ready to create their order.
Key | Required/Optional | Description |
---|---|---|
| Required if using the redirect object. | Set to true to disable automatic redirects within Drop-in Payments. |
| Required if using the redirect object. | The URL where the customer should be returned after successfully authorizing payment at the payment provider. |
| Required if using the redirect object. | The URL where the customer should be returned after cancelling at the payment provider. |
Customizing the text of the Drop-in payments button
The Drop-in payments button is customizable. You can either display pre-configured text, or you can specify a unique text. In both cases, how the text is localized is determined by the locale
you used when initializing DigitalRiver.js.
Type | Description |
| Use the following configuration to create a Continue button:
|
| Use the following configuration to create a Pay Now button:
|
| Use the following configuration to create a Buy Now button:
|
| Use the following configuration to create a Submit and Complete Payment button:
|
| Use the following configuration to create a Submit Order button:
|
| In the following configuration, use
|
Specifying a source's future use
Set options.usage
to indicate how the payment source will likely be used in future transactions. Passing this value increases the probability that payment providers will approve future authorization requests. The accepted values are subscription
, convenience
, and unscheduled
.
When creating a source using Drop-in payments, you should identify the types of future transactions the source will use to increase the probability of approval... 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
: The source is to be used for recurring transactions, made at regular intervals, for a product or a service.convenience
: Applies mainly to saved payment sources that are used for one-off transactions. These are scenarios where customers are typically present during checkout and want to access their payment information quickly. Always select this option if you don't offer subscriptions or don't have unscheduled merchant-initiated transactions.unscheduled
: The source is to be used in unscheduled merchant-initiated transactions. These are contracts that occur on a non-fixed schedule using saved card information. Automatic top-ups are one such example. They occur whenever a customer's balance drops below a pre-defined amount.
Show terms of sale disclosure
The options.showTermsOfSaleDisclosure
attribute determines whether Drop-in payments display the terms of sale to customers.
If set to true
(default), then the terms of sale disclosure are displayed, and customers must accept them.
The terms are localized based on how you initialize DigitalRiver.js.
The terms depend on whether customers make a one-time purchase or buy a subscription product.
If set to false
, no terms of sale are displayed.
Add disclosures
You can use options.consents
to add your end-user license agreement and terms of use to Digital River's disclosures. To make this feature work, showTermsOfSaleDisclosure
must be true
.
If you pass consents
, then companyName
is required. You're not required to provide either eula
or termsOfUse
, but if you do, you must specify a url
that links to the relevant document.
Once you create and mount Drop-in payments, your consents
are appended to Digital River's disclosures.
Disabling redirects
The options.redirect
object specifies the options you want to use to turn off the automatic redirect functionality built into Drop-in payments. Use this option if you would like to handle redirecting the customer yourself to the payment provider.
Enable the disableAutomaticRedirects
attribute if you do not want Drop-in payments to redirect your customer to the payment provider. Use this setting in your checkout flow if you do not want to create the order from Drop-in. In this scenario, you can allow your customer to choose their payment method, review and then authorize later by redirecting the customer to the redirect.returnUrl
when the customer has reviewed the order totals and is ready to create their order.
Key | Required/Optional | Description |
---|---|---|
| Required if using the redirect object. | Choose one of the following options:
|
| Required if using the redirect object. | The URL where the customer should be returned after successfully authorizing payment at the payment provider. |
| Required if using the redirect object. | The URL where the customer should be returned after cancelling at the payment provider. |
Expand first payment method
When Drop-in payments loads options.expandFirstPaymentMethod
determines whether the first payment method in the accordion control element is expanded or collapsed.
If expandFirstPaymentMethod
is true
(default) then the first displayed payment method is expanded.
Set usage
to unscheduled
when you create sources for unscheduled merchant-initiated transactions. These are contracts that occur on a non-fixed schedule using saved 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.
Configuring Drop-in Payment methods
Configuring payment methods within Drop-in Payments
Drop-in Payments uses DigitalRiver.js elements to capture secure payment details. Drop-in Payments come with a predefined style that should meet most use cases. If you would like to customize the look and feel, you should familiarize yourself with the Styling an element container in the DigitalRiver.js documentation.
Here is an example of customizing several payment methods:
Drop-in Payments specific configurations
Use the following fields to configure payment methods.
creditCard |
| The placeholder that appears in the card number field. If you specify a different value for |
| The placeholder that appears in the card expiration field. If you specify a different value for | |
| The placeholder that appears in the card expiration field. If you specify a different value for | |
| A Style object created following the Styling an element container instructions. | |
| Indicates whether the card number and card security code fields will automatically mask the input details after successful validation. | |
onlineBanking |
| A Style object created following the Styling an element container instructions. |
| The placeholder text appears in the online banking selector. | |
googlePay |
| A Style object created following the Google Pay element styles and customization instructions. |
applePay |
| A Style object created following the Apple Pay styles and customization instructions. |
payPal |
| A Style object created following the PayPal element style option instructions. |
|
| An enrollment URL created following the TreviPay enrollment URL instructions. |
Filtering payment methods shown in Drop-in payments
In the Drop-in Payments configuration, you can add a list of enabled payment methods, disabled payment methods, or both. If the list of enabled or disabled payment methods is absent, Drop-in Payments displays all the payment methods available for the payment session. The enabled list will not add unavailable payment methods for the payment session.
Drop-in payments events
Learn how to receive real-time updates on the state of your payment methods in Drop-in Payment.
Drop-in Payment supports the following events:
onSuccess–This occurs whenever a source is successfully created.
onError–This occurs whenever there is a validation error.
onCancel–This occurs whenever a payment method is cancelled.
onReady–This occurs whenever Drop-in payments have successfully mounted.
onSuccess
When your customer has provided the necessary details for payment and followed any necessary redirects, you will receive an event.