# Handling completed checkout-sessions

If you're using either of our [low-code checkout solutions](/digital-river-api/integration-options/low-code-checkouts.md), we recommend that you [configure a webhook](/digital-river-api/order-management/events-and-webhooks-1/webhooks/creating-a-webhook.md) to listen for the [event ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/events)with a [`type`](/digital-river-api/order-management/events-and-webhooks-1/events-1.md#event-types) of [`checkout_session.order.created`](https://docs.digitalriver.com/digital-river-api/integration-options/low-code-checkouts/pages/okHqAQ9d1PaLPLjq6nZF#checkout_session.order.created).

This [event](/digital-river-api/order-management/events-and-webhooks-1/events-1.md) occurs when customers complete their purchase, and Digital River converts the [checkout-session](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions) to an [order](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders). Its [`data.object`](/digital-river-api/order-management/events-and-webhooks-1/events-1.md#event-data) allows you to:

* [Determine whether the customer's address information should be saved for later](#determine-whether-to-save-addresses)
* [Determine what disclosures customers accepted](#determine-what-disclosures-customers-accepted)
* [Access price formatting rules](#access-price-formatting-rules)
* [Check whether customers used their store credit](#determine-whether-customers-applied-store-credit)
* Save a copy of our [order](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders) in your database
* Retrieve `id` and add that value to the order in your system

We don’t recommend that you use `checkout_session.order.created` to trigger order fulfillment or customer notifications. Instead, listen for [`order.accepted`](https://docs.digitalriver.com/digital-river-api/integration-options/low-code-checkouts/pages/okHqAQ9d1PaLPLjq6nZF#order.accepted) and use it to trigger downstream fulfillment processes and order confirmation emails. For details, refer to:

* [Handling accepted orders](/digital-river-api/order-management/creating-and-updating-an-order.md#handling-accepted-orders) on the [Processing orders](/digital-river-api/order-management/creating-and-updating-an-order.md) page
* [Order confirmation](/digital-river-api/order-management/customer-notifications.md#order-confirmation) on the [Customer notifications](/digital-river-api/order-management/customer-notifications.md) page

## Determine whether to save addresses

In the [`data.object`](/digital-river-api/order-management/events-and-webhooks-1/events-1.md#event-data) of [`checkout_session.order.created`](https://docs.digitalriver.com/digital-river-api/integration-options/low-code-checkouts/pages/okHqAQ9d1PaLPLjq6nZF#checkout_session.order.created), both `shipTo` and `billTo` contain the `saveForLater` boolean indicates whether customers requested that their shipping and/or billing information be saved for future transactions.

```json
{
    "id": "b927e8ef-fd8e-41a5-af29-04206b24dbb8",
    "type": "checkout_session.order.created",
    "data": {
        "object": {
            "id": "262957510336",
            "checkoutId": "3a71cfd1-da2b-4378-833f-3c9ad6fcf447",
            "checkoutSessionId": "fa701918-4f4c-45a9-8f72-88064070b927",
            ...
            "shipTo": {
                "address": {
                    "line1": "10380 Bren Rd W",
                    "city": "Minnetonka",
                    "postalCode": "55129",
                    "country": "MN"
                },
                "name": "John Smith",
                "phone": "952-111-1111",
                "email": "jsmith@digitalriver.com",
                "additionalAddressInfo": {
                    "neighborhood": "Centro",
                    "phoneticName": "ヤマダ タロ"
                },
                "saveForLater": true
            },
            ...
            "billTo": {
                "address": {
                    "line1": "10380 Bren Rd W",
                    "city": "Minnetonka",
                    "postalCode": "55129",
                    "country": "FR"
                },
                "name": "John Smith",
                "phone": "09521111111",
                "email": "jsmith@digitalriver.com",
                "saveForLater": false
            },
            ...
        }
    },
    ...
}
```

If `true`, you can call a method that saves `address`, `name`, `phone`, `email`, and (assuming it exists) `additionalAddressInfo` in your system so that the next time this customer checks out, you can pass this data in [`options.addresses[]`](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions/checkout-sessions-basics).

## Determine what disclosures customers accepted

The [`data.object`](/digital-river-api/order-management/events-and-webhooks-1/events-1.md#event-data) of [`checkout_session.order.created`](https://docs.digitalriver.com/digital-river-api/integration-options/low-code-checkouts/pages/okHqAQ9d1PaLPLjq6nZF#checkout_session.order.created) contains `consents`.

{% hint style="info" %}
Both [`onCheckoutComplete`](/digital-river-api/developer-resources/digitalrivercheckout.js-reference/digitalrivercheckout-object/configuring-prebuilt-checkout.md#oncheckoutcomplete) and [`onSuccess`](/digital-river-api/developer-resources/digitalrivercheckout.js-reference/digitalrivercheckout-object/components/configuring-components.md#success-event) also, return `consents`.
{% endhint %}

```javascript
{
    "id": "1ebfd13c-4ef6-443c-b58a-cb119f1c24fd",
    "type": "checkout_session.order.created",
    "data": {
        "object": {
            "id": "1038474530082",
            ...
            "consents": {
                "termsOfService": true,
                "eula": true,
                "termsOfSale": true
            },
            ...
        }
    },
    ...
}
```

In this object, the `termsOfSale` boolean references Digital River's terms of sale. The `eula` and `termsOfService` reference your company's unique end-user license agreement and terms of service, respectively.

{% hint style="info" %}
For details on appending your company's disclosures to ours, refer to [Create a Prebuilt Checkout configuration](/digital-river-api/administration/dashboard/settings/prebuilt-checkout.md#create-a-prebuilt-checkout-configuration) in the [Digital River Dashboard](/digital-river-api/administration/dashboard.md) documentation.
{% endhint %}

If any of these attributes are `true`, it signifies that customers were presented with that specific disclosure during the payment stage and actively accepted it.

## Access price formatting rules

For details, refer to [Access price formatting rules](/digital-river-api/integration-options/low-code-checkouts/offering-local-pricing.md#access-price-formatting-rules) on the [Offering local pricing](/digital-river-api/integration-options/low-code-checkouts/offering-local-pricing.md) page.

## Determine whether customers applied store credit

For details, refer to [Processing store credit in orders](/digital-river-api/integration-options/low-code-checkouts/offering-store-credit.md#processing-store-credit-in-orders) on the [Offering store credit](/digital-river-api/integration-options/low-code-checkouts/offering-store-credit.md) page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalriver.com/digital-river-api/integration-options/low-code-checkouts/handling-completed-checkout-sessions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
