Using the source identifier

Learn how a Source identifier can be used to update a Checkout, attach a Source to a Customer, or select a different default payment method.

The sourceId attribute in the Checkout resource and the sources[].id attribute in the Customer resource uniquely identify a Source object. The following sections describe common scenarios in which you might use these identifier values.

Checking out a guest customer

Your storefront may be configured so that customers are not required to create an account or sign-in to make a purchase. In that case, after the customer submits payment details in a POST Checkout request, DigitalRiver.js will create a Source and return the sourceId . You can then use an update Checkout request to set the sourceId attribute.

cURL
cURL
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"
}'

Since the Source is not attached to a Customer, this payment method object cannot be re-used for future purchases.

Attaching a source to a customer

You may decide to create a Customer object to represent one of your customers. The most likely reason being that you are registering a Customer or attaching a Source to a Customer.

In the latter case, after the customer submits payment details in a POST Checkout request, DigitalRiver.js will create a Source and return a sourceId. You can then use that sourceId to attach the Source to the Customer using a POST request.

curl --location --request POST 'https://api.digitalriver.com/customers/08161945/sources/7a3ce24c-5e18-4b8d-a667-d64a513ed33f' \
--header 'Authorization: Bearer <API_key> \

Selecting another payment source

Registered customers may have multiple saved payment methods associated with their account. These Source objects are stored in the sources array of the Customer resource. The first Source added to the array is automatically assigned as the default payment instrument for the customer. However, if a customer decides to apply a different method to an order, you can simply assign the id of the selected Source to the defaultSourceId attribute in an update Customer request.