# Standard flow

The following sequence diagrams outline a standard [Direct Integrations](https://docs.digitalriver.com/digital-river-api/integration-options/checkouts) flow. They depict interactions between the customer, your commerce platform, the Digital River APIs, and Digital River. These diagrams are meant to outline Digital River's core capabilities, focusing specifically on:

* Important states in an [order's life cycle](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/orders/order-basics#the-order-lifecycle)
* The sequence of major [events](https://docs.digitalriver.com/digital-river-api/order-management/events-and-webhooks-1/events-1)
* The data you must provide to use Digital River's [authorized reseller of record](https://docs.digitalriver.com/digital-river-api/readme) business model
* How checkouts, orders, events, and fulfillments work

Refer to the [Sequence diagrams](https://docs.digitalriver.com/digital-river-api/general-resources/standards-and-certifications/integration-checklists#sequence-diagram) section on the [Integration checklists](https://docs.digitalriver.com/digital-river-api/general-resources/standards-and-certifications/integration-checklists) page to learn about other flows.

## Product management

You can use several approaches when identifying and describing your products in the Digital River APIs.

For details on your product management options, refer to the [Product basics](https://docs.digitalriver.com/digital-river-api/product-management/skus) page.

## Pre-checkout

Digital River is typically not involved in initial pre-checkout interactions between customers and your commerce platform. During this stage, customers land on your storefront, build a cart, confirm the cart's details, and initiate checkout. Your commerce platform typically presents them with the option of checking out as either a [guest or registered customer](https://docs.digitalriver.com/digital-river-api/integration-options/checkouts/creating-checkouts/using-the-checkout-identifier).

![](https://334437993-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LqH4RJfLVLuHPXuJyTZ%2F-McFTW1XWli3ADUfQ-IN%2F-McFVYs04UqQQxo9hvRD%2FPart%201%20\(1\).png.png?alt=media\&token=2c094042-ba93-4808-a321-0b0b7f3dc866)

## Building a checkout <a href="#creating-a-checkout" id="creating-a-checkout"></a>

When a new customer checks out on your storefront, you can use the Digital River APIs to create a [customer ](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/customers)and a [checkout](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/checkouts). The [checkout](https://docs.digitalriver.com/digital-river-api/integration-options/checkouts/creating-checkouts) contains the transaction's tax details and assigned [selling entity](https://docs.digitalriver.com/digital-river-api/integration-options/checkouts/creating-checkouts/selling-entities). Your commerce platform should update the user interface with this tax information and use the selling entity to [display compliance disclosures](https://docs.digitalriver.com/digital-river-api/developer-resources/reference/elements/compliance-elements).

![](https://334437993-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LqH4RJfLVLuHPXuJyTZ%2F-MbhQuYxcpMEHpolSP6C%2F-MbhRGbYDQ56oURzK6VA%2FPart%202.png?alt=media\&token=cdfbd9dc-d755-442d-9f10-daafec45b0e0)

## Creating an order <a href="#creating-a-source-and-order" id="creating-a-source-and-order"></a>

When customers enter the payment entry stage, your commerce platform must render [Drop-in payments](https://docs.digitalriver.com/digital-river-api/payments/payment-integrations-1/drop-in). Customers submit their payment details, and [Drop-in payments](https://docs.digitalriver.com/digital-river-api/payments/payment-integrations-1/drop-in/drop-in-integration-guide) use that information to create a payment [source](https://docs.digitalriver.com/digital-river-api/payments/payment-sources).

{% hint style="success" %}
Explore the [Drop-in payments builder](https://drapi.io/drop-in-builder/) to better understand of how sources are created.
{% endhint %}

If customers opt to save the payment [source ](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/sources)for future purchases, and that source is [ready for storage](https://docs.digitalriver.com/digital-river-api/payments/payment-integrations-1/drop-in/drop-in-integration-guide#optional-allowing-the-customer-to-save-their-payment-details), you should [attach it to the customer](https://docs.digitalriver.com/digital-river-api/payments/payment-sources/using-the-source-identifier#attaching-sources-to-customers) and then [apply it to the checkout](https://docs.digitalriver.com/digital-river-api/payments/payment-sources/using-the-source-identifier#attaching-sources-to-checkouts). Otherwise, simply apply the source to the checkout for use in this [single transaction](https://docs.digitalriver.com/digital-river-api/payments/payment-sources#reusable-or-single-use).

Once payment is applied, use the [checkout ](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/checkouts)to update the commerce platform with the transaction's final tax information and [selling entity](https://docs.digitalriver.com/digital-river-api/integration-options/checkouts/creating-checkouts/selling-entities). The commerce platform should render an order review page with the appropriate [compliance information](https://docs.digitalriver.com/digital-river-api/developer-resources/reference/digitalriver-object#digitalriver-compliance-getdetails-businessentitycode-locale).

![](https://334437993-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LqH4RJfLVLuHPXuJyTZ%2F-MbhRIZgPJ3YzrrDFkAu%2F-MbhRdbjKUF1U14-d8wU%2FPart%203%20\(2\).png?alt=media\&token=ed1dbf6a-a0f4-44bb-bb01-f3975dfe3697)

At this point, customers typically confirm the transaction's details and submit the order. This event should trigger a [create order request](https://docs.digitalriver.com/digital-river-api/order-management/creating-and-updating-an-order#creating-an-order-with-the-checkout-identifier). This request primarily acts as a [fraud review](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/orders/order-basics#fraud-review) and [payment authorization call](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/charges/charge-basics).

The [immediate response](https://docs.digitalriver.com/digital-river-api/order-management/creating-and-updating-an-order#processing-the-post-orders-response) contains either a `409 Conflict` or `201 Created` status code. In the event of an error, update the status of the commerce platform and render the appropriate message to storefront customers. If an [order ](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/orders)is created, update commerce platform's order statis by using the response's data.

For [immediately accepted orders](https://docs.digitalriver.com/digital-river-api/order-management/creating-and-updating-an-order#accepted), move the commerce platform's order into a ready to fulfill state and direct customers to a "Thank You" page.

![](https://334437993-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LqH4RJfLVLuHPXuJyTZ%2F-MbhRf7fqdxYXrqRwnkz%2F-MbhRwZdkG5PNybAV29O%2FPart%204.png?alt=media\&token=611ab86c-c1bb-4a17-b205-84283dfed0e7)

If an [order's](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/orders) [`state`](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/orders/order-basics#order-states-and-events) is immediately returned as [pending payment authorization](https://docs.digitalriver.com/digital-river-api/order-management/creating-and-updating-an-order#pending-payment) or [in fraud review](https://docs.digitalriver.com/digital-river-api/order-management/creating-and-updating-an-order#in-review), you'll need to handle [asynchronous, order-related events](https://docs.digitalriver.com/digital-river-api/order-management/creating-and-updating-an-order#listening-for-and-handling-order-related-webhook-events) sent by Digital River.

Once an [order ](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/orders)is successfully screened for fraud or customers complete the steps necessary to [push payment](https://docs.digitalriver.com/digital-river-api/payments/payment-sources#pull-or-push), Digital River creates the [order accepted and ready to fulfill event](https://docs.digitalriver.com/digital-river-api/order-management/creating-and-updating-an-order#listening-for-the-order-accepted-event). If an [order ](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/orders)asynchronously fails due to suspected fraud or because the payment window closes without funds, we create an [order blocked](https://docs.digitalriver.com/digital-river-api/order-management/creating-and-updating-an-order#the-fraud-review-failure-event) or [charged failed](https://docs.digitalriver.com/digital-river-api/order-management/creating-and-updating-an-order#the-payment-failure-event) event, respectively.

When you're notified of one of these [events](https://docs.digitalriver.com/digital-river-api/order-management/events-and-webhooks-1/events-1), retrieve the order's [`state`](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/orders/order-basics#order-states-and-events) from the event's payload and, depending on that value, move the commerce platform's order into an accepted, blocked, or payment failed state.

![](https://334437993-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LqH4RJfLVLuHPXuJyTZ%2F-MbhRy49hpao3ouOqi_c%2F-MbhSHHKjCY4ZTauPZSM%2FPart%205.png?alt=media\&token=db39b13b-5b08-4b2a-bc99-41632aac9da2)

## Fulfilling an order

Once an [order's](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/orders) [`state`](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/orders/order-basics#order-states-and-events) is [`accepted`](https://docs.digitalriver.com/digital-river-api/order-management/creating-and-updating-an-order#handling-accepted-orders), the client can initiate fulfillment. As products are fulfilled or cancelled, the commerce platform updates the status of those line items and emits status change events. These events should trigger a [`POST/fulfillments`](https://docs.digitalriver.com/digital-river-api/order-management/informing-digital-river-of-a-fulfillment) request that specifies the fulfilled quantity, the cancelled quantity, or both. Depending on the configuration of that request, Digital River initiates a [funds capture](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/charges/charge-basics#captures) and/or [authorization reversal](https://app.gitbook.com/s/x8fSFzVR3sg0TsNWwwVz/charges/charge-basics#refunds).

![](https://334437993-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LqH4RJfLVLuHPXuJyTZ%2F-McFTW1XWli3ADUfQ-IN%2F-McFW_Qjh4uCknpHrIEC%2FPart%206%20\(3\).png%20\(1\).png?alt=media\&token=260679eb-d602-4161-a15c-2793e76a2339)
