Building checkouts
Learn the basics of how to sequence the checkout process as well as define, create, update, and use checkouts
On this page, you’ll find information on how to:

Sequencing the checkout process

During the initial stages of an ecommerce transaction, customers land on your storefront, review products, build a cart, confirm the cart's details, and initiate checkout. Digital River is typically not involved during these early pre-checkout interactions.
As a result, this section doesn't provide guidance on how to structure these early transaction stages. Instead, it focuses on how to initiate the checkout process. And then, for shopping carts that contain physical products, it explains how to sequence the create and update checkout requests, along with the create and authenticate source requests that you send to Digital River.

Initiating the checkout process

Once customers start adding items to their cart, we recommend you activate a proceed to checkout button. We recommend a similar button on your review cart page. Each button’s click event handler should direct customers to your initial checkout page.
On all your checkout pages, make sure to display Digital River’s required disclosures.

Sending the create checkout request

Once customers click the proceed to checkout button, we recommend that you use your checkout pages to obtain their shipping and billing address. Once customers enter new address information or confirm saved information, retrieve and save that data.
You can then use this saved address data, along with product data in the customer's cart to define items[], shipTo and billTo and then submit the create checkout request.
Since you can’t update a checkout with additional items[] or modify the quantity of existing items[], this sequence reduces the probability that customers will add products to their cart after you submit the create checkout request.
It also provides Digital River the data we need to generate a tax estimate that you can display to the customer.

Handling guest and registered customers

If your integration only allows registered checkouts, at some point during the checkout process you'll need to prompt customers to sign in or create an account. When customers create an account, use the Customers API to create a record for them in Digital River’s system.
In registered checkouts, you can use the same API to get a customer and retrieve previously saved shipping information. To expedite the checkout process, you may decide to present this saved shipping address to the customer as an available option.
If you decide to allow guest checkouts, make sure you collect and send us the customer's email address. For more information, refer to address requirements on the Providing address information page.

Handling shipping quotes

If the shopping cart contains physical products, once you have the customer's ship to information, you’ll typically make a shipping quote request to your logistics partner. In most cases, your partner replies with an array of quotes, each containing an eligible shipping method, the shipping method's cost, and one or more ship from addresses.
You should present these quotes to customers and, once they make a selection, send an update checkout request that contains shippingChoice and shipFrom. We can then use this information to generate a more precise tax calculation.
A checkout's shipFrom can be set at either the checkout-level or the line item-level.

Collecting payment

At this stage of the checkout process, you'll need to collect payment information from the customer and use it to either create or authenticate a source.
Before you can do that, however, the payment methods presented to the customer must be applicable to the transaction. In Drop-in, you accomplish this by building a configuration object and passing it to the createDropIn() method. With DigitalRiver.js, you'll need to configure and invoke retrieveAvailablePaymentMethods().
In registered checkouts, you can use this same method to filter the customer's saved sources by transaction applicability before presenting them to the customer. If the customer selects a saved source from this filtered list, you'll need to use authenticateSource(). This method first determines whether strong customer authentication (SCA) is required and then, if it is, opens a modal window that takes customers through the authentication process.
In both guest and registered checkouts, if customer's decide to provide new payment information, both of our primary source creation methods require a payment session identifier. You can retrieve this session identifier from the checkout.
Both methods also require the customer’s billing address. Unless the customer indicates otherwise, you can use the address you collected earlier in the checkout process.

Applying payment

Once the payment source is successfully created or authenticated, you'll need to apply it to the checkout.
If customers requested that a newly created source be saved to their account, wait until the source is chargeable, verify that it both supportsStorage and is readyForStorage, and then save the source to the customer before attaching the source to the checkout.
If the source is not scheduled for storage, once it's chargeable or pending_funds, you can attach the source to the checkout.
For more information on payments, refer to:

Submitting the order

After you verify that the checkout’s payment session state is valid, activate a place order button on your order review page. As part of handling this button’s click event, convert the checkout to an order.
For more information, refer to the Processing orders page.

Defining a checkout

The following lists some of the key parameters to use when defining checkouts. The table also indicates whether these parameters are available in POST/checkouts and POST/checkouts/{id}, and provides links to additional information on how to use these features. For comprehensive specifications, refer to the Checkouts API reference docs.
Parameter
Request type availability
Documentation
sourceId
Both
currency
Both
creditAmount*
Both
locale
Both
browserIp
Both
shipTo
Both
billTo
Both
shippingChoice
Both
discount
Create
items
Both
shippingDiscount
Create
taxInclusive
Create
chargeType
Both
taxIdentifiers
Both
customerType
Create
purchaseLocation
Both
*The creditAmountparameter is only available in versions 2020-09-30, 2020-12-17, and 2021-02-23
☨ In a POST/checkouts/{id} request, you're restricted to modifying certain line item attributes.

Creating and updating the checkout

To create a checkout, submit a POST/checkouts request. Once you've created the object, and you want to update it, retrieve its unique identifier, and then pass it as a path parameter in a POST/checkouts/{id}.
The following POST/checkouts creates a registered checkout that contains physical products and meets all of our address requirements.
POST/checkouts request
1
curl --location --request POST 'https://api.digitalriver.com/checkouts' \
2
--header 'Content-Type: application/json' \
3
--header 'Authorization: Bearer <API_key>' \
4
...
5
--data-raw '{
6
"currency": "USD",
7
"customerId": 529861350336,
8
"taxInclusive": false,
9
"email": "[email protected]",
10
"shipTo": {
11
"address": {
12
"line1": "10380 Bren Road W",
13
"city": "Minnetonka",
14
"postalCode": "55343",
15
"state": "MN",
16
"country": "US"
17
},
18
"name": "John Doe"
19
},
20
"shipFrom": {
21
"address": {
22
"country": "US"
23
}
24
},
25
"shippingChoice": {
26
"amount": 5,
27
"description": "standard",
28
"serviceLevel": "SG"
29
},
30
"items": [
31
{
32
"skuId": "6b04ac06-0858-456c-90aa-235772dea9e2",
33
"quantity": 2,
34
"price": 10
35
}
36
]
37
}'
Copied!

Using the checkout

Each time you submit a POST/checkouts or POST/checkouts/{id}, use the data contained in the response to update the data in the upstream commerce platform. This ensures that the values in your system stay in sync with those in ours.
At both the checkout and line item level, the response contains price, tax, landed cost, and fees information. During the checkout process, display this information to customers in your UI.
Checkout
1
{
2
...
3
"totalAmount": 48.4,
4
"subtotal": 45.0,
5
"totalFees": 0.0,
6
"totalTax": 3.4,
7
"totalImporterTax": 0.0,
8
"totalDuty": 0.0,
9
"totalDiscount": 0.0,
10
"totalShipping": 5.0,
11
"items": [
12
{
13
"id": "4e0afb3e-39d1-4b94-a775-cdce3f521fa1",
14
"skuId": "0ce492d2-e616-47ac-ad63-6df027577c12",
15
"amount": 20.0,
16
"quantity": 2,
17
"tax": {
18
"rate": 0.07525,
19
"amount": 1.51
20
},
21
"importerTax": {
22
"amount": 0.0
23
},
24
"duties": {
25
"amount": 0.0
26
},
27
"fees": {
28
"amount": 0.0,
29
"taxAmount": 0.0
30
}
31
},
32
...
33
}
Copied!
Make sure you save the checkout's unique identifier and unique line item identifiers because they're required when submitting downstream requests. Additionally, the checkout contains payment session details that you use to create payment sources and determine when to submit an order request.

Checkout identifier

Every checkout contains a unique identifier. You can use this identifier to update, retrieve, search for, and delete the checkout. You can also use the identifier to attach a source to the checkout and then, if the customer wants to apply a different payment method, detach the payment source.
When you're ready to convert the checkout to an order, pass this identifier in the body of a POST/orders.
Checkout
1
{
2
"id": "f2cd50e5-355d-42d3-8bb7-0c14d8b777e4",
3
...
4
}
Copied!

Item information

Each element in a checkout's items array is returned with a unique identifier. During the checkout process, use these identifiers to modify items.
Checkout
1
{
2
"id": "f2cd50e5-355d-42d3-8bb7-0c14d8b777e4",
3
...
4
"items": [
5
{
6
"id": "c9f8d629-e01d-4c89-8c0a-0a0715a07d52",
7
...
8
}
9
],
10
...
11
}
Copied!

Payment session

During the checkout process, we return a unique payment session identifier and other payment information.

Payment session identifier

In versions 2021-02-23 and lower, you find this identifier in the paymentSessionId attribute. In versions 2021-03-23 and higher, it's contained in payment.session.id.

Payment session information

In the payment.session, we return amountContributed, amountRemainingToBeContributed, and state. You can use these values to determine when to create an order.
This information is only returned in versions 2021-03-23 and higher.
Checkout
1
{
2
"id": "f2cd50e5-355d-42d3-8bb7-0c14d8b777e4",
3
"createdTime": "2021-03-23T17:34:17Z",
4
"customerId": "530359580336",
5
"currency": "USD",
6
"email": "[email protected]",
7
"shipTo": {
8
"address": {
9
"line1": "10380 Bren Road W",
10
"city": "Minnetonka",
11
"postalCode": "55343",
12
"state": "MN",
13
"country": "US"
14
},
15
"name": "John Doe"
16
},
17
"shipFrom": {
18
"address": {
19
"country": "US"
20
}
21
},
22
"totalAmount": 26.89,
23
"subtotal": 25.0,
24
"totalFees": 0.0,
25
"totalTax": 1.89,
26
"totalImporterTax": 0.0,
27
"totalDuty": 0.0,
28
"totalDiscount": 0.0,
29
"totalShipping": 5.0,
30
"items": [
31
{
32
"id": "c9f8d629-e01d-4c89-8c0a-0a0715a07d52",
33
"skuId": "6b04ac06-0858-456c-90aa-235772dea9e2",
34
"amount": 20.0,
35
"quantity": 2,
36
"tax": {
37
"rate": 0.07525,
38
"amount": 1.51
39
},
40
"importerTax": {
41
"amount": 0.0
42
},
43
"duties": {
44
"amount": 0.0
45
},
46
"subscriptionInfo": {
47
"terms": "These are the terms",
48
"autoRenewal": false,
49
"freeTrial": false
50
},
51
"fees": {
52
"amount": 0.0,
53
"taxAmount": 0.0
54
}
55
}
56
],
57
"shippingChoice": {
58
"amount": 5.0,
59
"description": "standard",
60
"serviceLevel": "SG",
61
"taxAmount": 0.38
62
},
63
"updatedTime": "2021-03-23T17:34:17Z",
64
"locale": "en_US",
65
"customerType": "individual",
66
"sellingEntity": {
67
"id": "C5_INC-ENTITY",
68
"name": "DR globalTech Inc."
69
},
70
"liveMode": false,
71
"payment": {
72
"sources": [
73
{
74
"id": "bea8171b-d2bc-44e4-8d7f-1700e65b09ab",
75
"type": "creditCard",
76
"amount": 16.89,
77
"owner": {
78
"firstName": "William",
79
"lastName": "Brown",
80
"email": "[email protected]",
81
"address": {
82
"line1": "10380 Bren Rd W",
83
"city": "Minnetonka",
84
"postalCode": "55343",
85
"state": "MN",
86
"country": "US"
87
}
88
},
89
"creditCard": {
90
"brand": "Visa",
91
"expirationMonth": 7,
92
"expirationYear": 2027,
93
"lastFourDigits": "1111"
94
}
95
},
96
{
97
"id": "38818373-7db9-41d9-8895-5667fea13a0b",
98
"type": "customerCredit",
99
"amount": 10.0,
100
"customerCredit": {}
101
}
102
],
103
"session": {
104
"id": "89bd1d59-1ba0-439f-af96-29230421725c",
105
"amountContributed": 26.89,
106
"amountRemainingToBeContributed": 0.0,
107
"state": "requires_confirmation",
108
"clientSecret": "89bd1d59-1ba0-439f-af96-29230421725c_5ca86d31-3b21-4d50-b730-9f992b260226"
109
}
110
}
111
}
Copied!
Last modified 2mo ago