# Managing sources

In the Digital River API, [payment sources](/digital-river-api/payments/payment-sources.md) fall into two broad categories: [primary and secondary](#primary-versus-secondary-sources).

For both categories, after [creating a source](#creating-payment-sources), you can always [attach a source to a checkout](#attaching-sources-to-checkouts) so that Digital River can attempt to generate a [charge ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges/charge-basics)after you [create the order](/digital-river-api/order-management/creating-and-updating-an-order.md#creating-an-order-with-the-checkout-identifier). You can also [detach sources from checkouts](#detaching-sources-from-checkouts).

If a [primary source](#primary-payment-sources) supports [reusability](/digital-river-api/payments/payment-sources.md#reusable-or-single-use), you may also be able to [save it to a customer's account](#attaching-sources-to-customers). For [customers ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers)with multiple `sources[]`, we also provide you the ability to [set the default one](#setting-the-default-payment-source).

You can [combine primary and secondary sources](#combining-primary-and-secondary-payment-sources), but how you sequence their application depends on whether or not the primary source is [reusable](/digital-river-api/payments/payment-sources.md#reusable-or-single-use).

When [building payment flows](/digital-river-api/integration-options/checkouts/building-you-workflows.md), the [Digital River object](/digital-river-api/developer-resources/reference/digitalriver-object.md) exposes methods for [authenticating](#authenticating-sources) and [updating](#updating-sources) sources useful in the purchase and account management scenarios.

## Primary versus secondary sources

When [building your payment workflows](/digital-river-api/integration-options/checkouts/building-you-workflows.md), you should know the differences between [primary](#primary-payment-sources) and [secondary](#secondary-payment-sources) payment sources and how they affect the [payment session](/digital-river-api/integration-options/checkouts/creating-checkouts/payment-sessions.md).

### Primary payment sources

Primary payment [sources ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources)are created from traditional [payment methods](/digital-river-api/payments/supported-payment-methods.md) such as [credit cards](/digital-river-api/payments/supported-payment-methods/credit-cards.md), [Google Pay](/digital-river-api/payments/supported-payment-methods/google-pay.md), [PayPal](/digital-river-api/payments/supported-payment-methods/paypal.md), and [wire transfers](/digital-river-api/payments/supported-payment-methods/wire-transfer.md). Most customers use a primary source when making a purchase, but a [checkout's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts)`sources[]`can only contain one primary source.

Primary sources created from [payment methods that support reusability](/digital-river-api/payments/supported-payment-methods.md) may be able to be [associated with a customer](#attaching-sources-to-customers) and then [reused](/digital-river-api/payments/payment-sources.md#reusable-or-single-use) in future transactions.

Alternatively, you can simply [attach a primary source to a checkout](#attaching-sources-to-checkouts), thereby enabling Digital River to submit a [charge authorization request](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges/charge-basics#how-a-charge-is-created) after you [create the order](/digital-river-api/order-management/creating-and-updating-an-order.md#creating-an-order-with-the-checkout-identifier).

Once a [checkout ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts)contains a primary source, the [necessary payment preconditions](/digital-river-api/integration-options/checkouts/creating-checkouts/payment-sessions.md#how-to-determine-when-to-create-an-order) are met to [convert that checkout to an order](/digital-river-api/order-management/creating-and-updating-an-order.md#creating-an-order-with-the-checkout-identifier).

### Secondary payment sources

Secondary payment [sources ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources)are typically used to supplement a [primary source](#primary-payment-sources).

In the Digital River APIs, secondary sources have a [`type`](/digital-river-api/payments/payment-sources.md#supported-payment-methods) of [`customerCredit`](/digital-river-api/integration-options/checkouts/creating-checkouts/applying-a-store-credit.md).

If a [checkout ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts)only contains secondary `sources[]`, you may be able to successfully [create the order](/digital-river-api/order-management/creating-and-updating-an-order.md#creating-an-order-with-the-checkout-identifier), but before doing so, you must ensure the [necessary payment preconditions are met](/digital-river-api/integration-options/checkouts/creating-checkouts/payment-sessions.md#how-to-determine-when-to-create-an-order).

Secondary sources do not support [reusability](/digital-river-api/payments/payment-sources.md#reusable-or-single-use). Therefore, they [cannot be saved to a customer's account](#restrictions-on-saving-sources). They can only be [attached to a checkout](#attaching-sources-to-checkouts) to create a one-time [charge ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges)upon [order ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders)creation.

## Creating payment sources

We provide multiple options for [creating primary sources](#creating-primary-sources) and [creating secondary sources](#creating-secondary-sources).

### Creating primary sources

[Primary sources](#primary-payment-sources) are created with your [public API key](/digital-river-api/administration/dashboard/developers/api-keys.md#standard-keys) using [Drop-in payments](/digital-river-api/payments/payment-integrations-1/drop-in/drop-in-integration-guide.md) or [DigitalRiver.js with elements](/digital-river-api/payments/payment-integrations-1/digitalriver.js/quick-start.md). Once created, you can [attach the source to a checkout](#attaching-sources-to-checkouts) or, in some cases, [save the source to a customer](#attaching-sources-to-customers).

### Creating secondary sources

How you create [sources ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources)with a [`type`](/digital-river-api/payments/payment-sources.md#supported-payment-methods) of `customerCredit` depends on the [version](/digital-river-api/general-resources/versioning.md) you're using.

For versions:

* `2021-03-23` and higher, refer to [Applying store credit](/digital-river-api/integration-options/checkouts/creating-checkouts/applying-a-store-credit.md).
* `2020-09-30`, `2020-12-17`, and `2021-02-23`, refer to [Applying store credit (legacy)](/digital-river-api/integration-options/checkouts/creating-checkouts/applying-store-credit-legacy.md).

## Combining primary and secondary payment sources

A [checkout's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts)`sources[]` can hold a single [primary source](#primary-payment-sources) and/or one or more [secondary sources](#secondary-payment-sources).

In [checkouts](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts), you can combine a secondary source with any primary source that has one of the following [`type`](/digital-river-api/payments/payment-sources.md#supported-payment-methods) values: `alipayCn`, `creditCard`, `googlePay`, `applePay`, `payPal`, `payPalCredit`, `payPalBilling`, `wireTransfer`, `klarnaCredit`, `klarnaCreditRecurring`, `alipay`, `konbini`, `directDebit` and `onlineBanking`.

You can also use secondary sources with any primary payment sources in [invoices](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/invoices). Just make sure you turn off [billing optimization](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/invoices/invoice-basics#invoice-billing). For details, refer to [Supported payment methods with invoices](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/invoices/invoice-basics#supported-payment-methods).

When [building your workflows](/digital-river-api/integration-options/checkouts/building-you-workflows.md), ensure you're properly sequencing the application of primary and secondary sources. The sequence depends on whether you use [secondary sources with a single-use primary source](#using-secondary-sources-with-a-single-use-primary-source) or [secondary sources with a saved primary source](#using-secondary-sources-with-a-saved-primary-source).

Also, you should be aware of [how Digital River handle captures, cancels, and refunds](#how-we-handle-captures-cancels-and-refunds) when an [order ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders)contains multiple [`charges[]`](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges/charge-basics).

### Using secondary sources with a single-use primary source

If a primary source is created during the checkout process and then not [associated with a customer](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers) (perhaps because the customer is checking out as a [guest](/digital-river-api/integration-options/checkouts/creating-checkouts/using-the-checkout-identifier.md#guest-checkouts-or-invoices), the customer is [registered](/digital-river-api/integration-options/checkouts/creating-checkouts/using-the-checkout-identifier.md#registered-checkouts-or-invoices) but chooses not to save the [source](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources), or the source's [`type`](/digital-river-api/payments/payment-sources.md#supported-payment-methods) doesn’t support [reusability](/digital-river-api/payments/payment-sources.md#reusable-or-single-use)), you must attach all [secondary sources](#secondary-payment-sources) to the [checkout ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts)before attaching the primary source.

If a [checkout's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts)primary `sources[]` has a [`reusable`](/digital-river-api/payments/payment-sources.md#reusable-or-single-use) value that is `false`, then any attempt to [associate a secondary source with the checkout](#attaching-sources-to-checkouts) returns the following error:

{% code title="409 Conflict" %}

```
{
    "type": "conflict",
    "errors": [
        {
            "code": "session_update_not_allowed",
            "message": "Updating source is not allowed for the current session state."
        }
    ]
}
```

{% endcode %}

### Using secondary sources with a saved primary source

If a checkout's primary [`sources[]`](/digital-river-api/payments/payment-sources.md) is saved to the [customer making the purchase](/digital-river-api/integration-options/checkouts/creating-checkouts/using-the-checkout-identifier.md#registered-checkouts-or-invoices), then you have more flexibility in how you sequence the application of [primary](#primary-payment-sources) and [secondary](#secondary-payment-sources) sources.

More specifically, if a checkout's primary `sources[]` has a [`reusable`](/digital-river-api/payments/payment-sources.md#reusable-or-single-use) value of `true`, then you can request to [associate a secondary source with the checkout](#attaching-sources-to-checkouts). Each time this request is successfully submitted, the checkout's primary `sources[].amount` gets reduced by the secondary [source's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources)`amount`.

### How we handle captures, cancels, and refunds

When [combining secondary sources with a primary source](#combining-primary-and-secondary-payment-sources), you should be aware of how Digital River processes [captures](#captures), [cancels](#cancels), and [refunds](#refunds) on an [order's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders)`charges[]`.

#### Captures

Digital River first [captures ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges/charge-basics#captures)the [charges](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges/charge-basics) created from [secondary sources](#secondary-payment-sources) and then the single charge from the [primary source](#primary-payment-sources).

#### Cancels

Digital River first [cancels ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges/charge-basics#cancels)the single [charge ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges/charge-basics)created from the [primary source](#primary-payment-sources) and then the charge(s) created from [secondary sources](#secondary-payment-sources).

#### Refunds

Digital River first [refunds ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges/charge-basics#refunds)the single [charge ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges/charge-basics)created from the [primary source](#primary-payment-sources) and then the charge(s) created from [secondary sources](#secondary-payment-sources).

## Attaching sources to checkouts

After you [create](#creating-payment-sources) or [authenticate](#authenticating-sources) a payment [source ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources)and retrieve its unique identifier, you can use that value to associate the source with a [checkout](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts).

You do this by [sending the source's identifier in the request's payload](#sending-a-source-identifier-in-the-request-payload) or [passing its identifier as a path parameter](#passing-the-source-identifier-as-a-path-parameter). This is true for both [primary and secondary sources](#primary-versus-secondary-sources).

You're only allowed to associate one [primary source](#primary-payment-sources) with a checkout. If a checkout's `sources[]` contains a primary source, and you submit a request to attach a different primary source, using either the [payload](#sending-a-source-identifier-in-the-request-payload) or [path parameter](#passing-the-source-identifier-as-a-path-parameter) approach, then the existing source is replaced.

However, as long as the aggregated `amount` of all of a checkout's `sources[]` doesn't exceed the checkout's `totalAmount`, there's no limit to the number of [secondary sources](#secondary-payment-sources) you can attach to a checkout.

### Passing a source's identifier in the request body <a href="#sending-a-source-identifier-in-the-request-payload" id="sending-a-source-identifier-in-the-request-payload"></a>

To associate a payment [source](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources) with a [checkout](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts), you can send its `sourceId` in the body of a [`POST /checkouts`](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts#checkouts-1) or [`POST /checkouts/{id}`](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts#checkouts-id-1) request.

```
curl --location --request POST 'https://api.digitalriver.com/checkouts/177642590336' \
--header 'Authorization: <API_key>' \
--header 'Content-Type: text/plain' \
--data-raw '{
   "sourceId": "7a3ce24c-5e18-4b8d-a667-d64a513ed33f"
}'
```

### Passing a source's identifier as a path parameter <a href="#passing-the-source-identifier-as-a-path-parameter" id="passing-the-source-identifier-as-a-path-parameter"></a>

To associate a payment source with a [checkout](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts), you can pass the checkout's identifier and the source's identifier as path parameters in a [`POST /checkouts/{id}/sources/{sourceId}`](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts#checkouts-id-sources-sourceid).

## Detaching sources from checkouts

When you need to remove a payment source from a checkout, you can send a [`DELETE /checkouts/{id}/sources/{sourceId}`](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts#checkouts-id-sources-sourceid-1). A successful request returns a `204 No Content` status code and an empty body.

If the source's [`reusable`](/digital-river-api/payments/payment-sources.md#reusable-or-single-use) value is `false` when you submit the detach request, then the source's [`state`](/digital-river-api/payments/payment-sources.md#source-state) transitions to `cancelled`, and any attempt to [reattach the source to a checkout](#attaching-sources-to-checkouts) returns the following error:

{% tabs %}
{% tab title="409 Conflict" %}

```javascript
{
    "type": "conflict",
    "errors": [
        {
            "code": "source_status_invalid_for_session",
            "message": "The source status is invalid for this session."
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Saving sources to customers <a href="#attaching-sources-to-customers" id="attaching-sources-to-customers"></a>

In some cases, after you [create a primary payment source](#creating-primary-sources), you can save it to a customer for use in future checkouts.

Attaching [sources ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources)to [customers ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers)can be useful when [building workflows](/digital-river-api/integration-options/checkouts/building-you-workflows.md) that allow customers to save their payment information during [one-off purchases](/digital-river-api/integration-options/checkouts/building-you-workflows.md#credit-card-details-saved-by-customer-during-checkout), [subscription acquisitions](/digital-river-api/integration-options/checkouts/building-you-workflows.md#customer-enters-credit-card-details-during-subscription-acquisition-checkout), or on [account management pages](/digital-river-api/integration-options/checkouts/building-you-workflows.md#saving-a-credit-card-for-future-use).

As long as the [necessary preconditions](#restrictions-on-saving-sources) are satisfied, you can save a [primary source](#primary-payment-sources) to a [customer ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers)by sending their unique identifiers as path parameters in a [`POST /customers/{customerId}/sources/{sourceId}`](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts#checkouts-id-sources-sourceid) request.

```
curl --location --request POST 'https://api.digitalriver.com/customers/544671250336/sources/05642ad9-d227-4250-a73e-92514ef68620' \
...
--data-raw ''
```

A successful request flips the source's [`reusable`](/digital-river-api/payments/payment-sources.md#reusable-or-single-use) value to `true` and returns the source.

{% tabs %}
{% tab title="200 OK" %}

```javascript
{
    "id": "05642ad9-d227-4250-a73e-92514ef68620",
    "createdTime": "2021-09-16T14:29:45Z",
    "type": "creditCard",
    "reusable": true,
    "state": "chargeable",
    "customerId": "544671250336",
    "owner": {
        ...
    },
    "clientSecret": "05642ad9-d227-4250-a73e-92514ef68620_be853d8e-0422-436e-af3e-45f8a92b25e9",
    "creditCard": {
        "brand": "Visa",
        "expirationMonth": 7,
        "expirationYear": 2027,
        "lastFourDigits": "1111"
    },
    "liveMode": false
}
```

{% endtab %}
{% endtabs %}

At this point, you can update your system and notify customers that the payment method has been saved to their account.

### Restrictions on saving sources

Before sending a [save source to customer request](#attaching-sources-to-customers), make sure that the [source ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources)doesn't have any [reusability](#reusability-restrictions) and [chargeability](#chargeability-restrictions) restrictions.

#### Reusability restrictions

If a [source ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources)doesn't support [reusability](/digital-river-api/payments/payment-sources.md#reusable-or-single-use) and you pass its identifier in a [`POST /customers/{customerId}/sources/{sourceId}`](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers#customers-id-sources-sourceid), then the following error is returned:

{% tabs %}
{% tab title="409 Conflict" %}

```javascript
{
    "type": "conflict",
    "errors": [
        {
            "code": "nonreusable_source",
            "message": "Only a reusable source may be attached to a customer."
        }
    ]
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
For a list of payment methods that can be used in recurring transactions, refer to the [Supported payment methods](/digital-river-api/payments/supported-payment-methods.md) page.

With [Drop-in payments](/digital-river-api/payments/payment-integrations-1/drop-in.md), you can also use `supportsStorage` in the [`onSuccess`](/digital-river-api/payments/payment-integrations-1/drop-in/drop-in-integration-guide.md#onsuccess) event's `data` to make this determination.
{% endhint %}

#### Chargeability restrictions

Only [source's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources)whose [`state`](/digital-river-api/payments/payment-sources.md#source-state) is `chargeable` can successfully be saved to a [customer](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers). If the [source ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources)isn't `chargeable` (perhaps because it has a `redirect` payment [`flow`](/digital-river-api/payments/payment-sources.md#authentication-flow), the customer has yet to successfully authorize payment, and, as a result, its [`state`](/digital-river-api/payments/payment-sources.md#source-state) is still `pending_redirect`), and you attempt to [save the source to a customer](#attaching-sources-to-customers), you'll receive the following error:

{% code title="409 Conflict" %}

```
{
    "type": "conflict",
    "errors": [
        {
            "code": "source_not_chargeable",
            "parameter": "sourceId",
            "message": "Source 'ea6b3297-d05f-4d5d-a12d-95234e93d450' is not chargeable."
        }
    ]
}
```

{% endcode %}

{% hint style="info" %}
With [Drop-in payments](/digital-river-api/payments/payment-integrations-1/drop-in.md), you can use `readyForStorage` in the [`onSuccess`](/digital-river-api/payments/payment-integrations-1/drop-in/drop-in-integration-guide.md#onsuccess) event's `data` to determine whether a [source](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources) can be associated with a [customer](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers).
{% endhint %}

### Restrictions on using saved sources

A [source](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources) saved to a [customer](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers) can't be used to [generate a charge](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges/charge-basics#how-a-charge-is-created) unless you associate the [customer](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers) with the [checkout](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts).

If a [customer ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers)has a saved `sources[]`, and you [associate that source with the checkout](#attaching-sources-to-checkouts) but neglect to [associate that customer with the checkout](/digital-river-api/integration-options/checkouts/creating-checkouts/using-the-checkout-identifier.md#registered-checkouts-or-invoices), you'll receive the following error when you [convert the checkout to an order](/digital-river-api/order-management/creating-and-updating-an-order.md#creating-an-order-with-the-checkout-identifier).

{% tabs %}
{% tab title="409 Conflict" %}

```javascript
{
    "type": "conflict",
    "errors": [
        {
            "code": "source_in_use",
            "parameter": "sourceId",
            "message": "Source '37dcb9dc-c1ea-4295-b787-7d872e94cefd' is attached to a different customer."
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Removing sources from customers <a href="#detaching-sources-from-customers" id="detaching-sources-from-customers"></a>

If you'd like to detach a payment [source](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/sources) saved to a customer, you can send a [`DELETE/customers/{id}/sources/{sourcesId}`](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers#customers-id-sources-sourceid-1) request. When you do so, the source's [`state`](/digital-river-api/payments/payment-sources.md#source-state) becomes `cancelled` and the resource can't be used to [create any future charges](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/charges/charge-basics#how-a-charge-is-created).

If you attempt to reattach this source to a customer, you'll receive the following error:

{% tabs %}
{% tab title="409 Conflict" %}

```javascript
{
    "type": "conflict",
    "errors": [
        {
            "code": "source_not_chargeable",
            "parameter": "sourceId",
            "message": "Source '24f4f281-9613-4d6d-8831-808952ed4915' is not chargeable."
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Setting the default payment source

Customers can store multiple payment `sources[]`.

The first [source you attach to a customer](#attaching-sources-to-customers) automatically becomes its default, and its identifier is assigned to the customer's `defaultSourceId` attribute. If you'd like to assign a customer a different default payment source, you must first ensure it's [attached to the customer](#attaching-sources-to-customers). Once that's done, you can set its identifier as the `defaultSourceId` in an [update customer request](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/customers#customers-id-1).

## Authenticating sources

After you [retrieve a source](/digital-river-api/payments/payment-sources/retrieving-sources.md), you can pass its identifier, [payment session](/digital-river-api/integration-options/checkouts/creating-checkouts/payment-sessions.md) identifier, and client secret to the [authenticate source method](/digital-river-api/developer-resources/reference/digitalriver-object.md#authenticating-sources) in the [DigitalRiver.js](/digital-river-api/developer-resources/reference.md) library. This operation is especially helpful when [building workflows](/digital-river-api/integration-options/checkouts/building-you-workflows.md) that allow customers to retrieve saved credit card information during [one-off purchases](/digital-river-api/integration-options/checkouts/building-you-workflows.md#customer-selects-saved-credit-card-during-checkout) or [subscription acquisitions](/digital-river-api/integration-options/checkouts/building-you-workflows.md#customer-saves-credit-card-details-during-subscription-acquisition-checkout).

## Updating sources

After you [retrieve a source](/digital-river-api/payments/payment-sources/retrieving-sources.md), you can pass its identifier, [payment session](/digital-river-api/integration-options/checkouts/creating-checkouts/payment-sessions.md) identifier, and client secret to the [update source method](/digital-river-api/developer-resources/reference/digitalriver-object.md#updating-sources) in the [DigitalRiver.js](/digital-river-api/developer-resources/reference.md) library. This operation is useful when [building workflows](/digital-river-api/integration-options/checkouts/building-you-workflows.md) that allow customers to [update a credit card's expiration date or billing address](/digital-river-api/integration-options/checkouts/building-you-workflows.md#updating-a-credit-cards-expiration-date-or-billing-address).


---

# 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/payments/payment-sources/using-the-source-identifier.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.
