Authorize a payment
Learn to authorize a payment.
The Digital River Drop-in Checkout feature is used to authorize a payment handled. Use the following steps to set up a cart and then hand it over to Digital River for payment authorization:
Prepare your cart
Make sure your cart locale and country are set. The connector passes the
{cart.locale}_{cart.country}
value to Digital River to be used for the locale when creating a Drop-in Checkout session.Set the
customerEmail
field on the cart to the customer's email address.Set the value of
custom.fields.drWarehouse
to a reference pointing to the warehouse that this order will ship from. This step is optional if your cart contains only digital products. ThetypeId
for this reference iskey-value-document
and theid
is the id of the warehouse that has been set when saving it. If you have only one warehouse location, this can be hardcoded. Otherwise, you are responsible for determining the value to use.Optionally, set the custom field
drBusinessCustomer
. When this is set totrue,
the Digital RivercustomerType
field is set tobusiness
when creating the checkout session. When it isfalse
or not set thecustomerType
field is set toindividual.
You can optionally set the shipping addresses on the cart. The mapping of commercetools address fields to Digital River fields is as follows:
commercetools fieldDigital River field to map toNotesfirstName and lastName
name
Concatenated with space separator
streetName
address.line1
additionalStreetInfo
address.line2
city
address.city
postalCode
address.postal_code
country
address.country
region or state
address.state
Source depends on value of connector.mapping.address-state-from which defaults to REGION but can be set to STATE
phone
phone
email
email
company
company
Create a commercetools payment
You must next create a commercetools payment and populate the following:
customerId
Reference to commercetools customer
See notes
Required for non-guest checkout. If using MyPayments API this will automatically be set to the logged in customer. One of customerId or anonymousId must be populated
anonymousId
Id for tracking guest checkout
See notes
Required for guest checkout. If using MyPayments API this will automatically be set. One of customerId or anonymousId must be populated
paymentMethodInfo.paymentInterface
DigitalRiver
Yes
This triggers creation of the drop-in checkout session
custom.fields.drClientIpAddress
IP address of the client device. For browsers you may need to the public-ip npm package to determine this
Yes
Required for fraud checking.
The payment object that is returned contains the following additional fields:
custom.fields.drCheckoutSessionId
The Digital River checkout session id
Complete the payment authorization process
Finally, use the following steps to complete the payment authorization process:
Add the payment to the cart.
Create the Drop-in Checkout modal.
To do this, You need your Digital River public API key. This is configured in the Digital River > API Keys section of the commercetools Merchant Center. It can be retrieved using the custom objects API with container
digital_river
and keypublic_api_key.
Load the checkout library from
https://checkout.digitalriverws.com/v1/DigitalRiverCheckout.js
.Render the Drop-in Checkout modal. The following Javascript provides an example of how this is done:
When the user successfully completes a payment, the connector receives an order.created
webhook and calls commercetools to create an order for you from the cart.
In locations where your prices are tax exclusive, Digital River calculates the appropriate tax for you and updates the commercetools cart and order. The amount on the final order, therefore, may not match the amount on the cart before the checkout.
The creation of the order occurs asynchronously so if you need the order to display a confirmation page you need to poll for it using the cart ID until it is available.
Last updated