Managing payment options

Learn how to manage payment options.

Managing payment options is essential for any eCommerce platform, ensuring shoppers a seamless and flexible checkout experience. The Commerce API allows you to add, update, and delete payment methods, giving your customers the convenience they need to complete their transactions efficiently. This section explores how to handle these operations using the API, ensuring that your shoppers have various payment options.

Creating the shopper payment options

In this section, you'll learn how to create shopping payment options using the Commerce API. This process involves sending a POST request to the appropriate endpoint with the necessary details and authorization. The result of this request will be a new payment option that can be used by the shopper for their transactions.

To create payment options for shoppers, send a POST /v1/shoppers/me/payment-options request. You will need to provide your access token in the header and details such as the payment option nickname, whether it is the default payment option, and the sourceId. Here is an example of how to make the request using cURL:

curl --location --request POST 'https://api.digitalriver.com/v1/shoppers/me/payment-options' \
--header 'authorization: bearer [Your_Access_Token]'\
...
--data-raw '{
  "paymentOption": {
    "nickName": "DRBank",
    "isDefault": "true",
    "sourceId": "{{sourceId}}"
  },
  "shopper": {
    "ipAddress": "{{ipAddress}}"
  }
}

The response will include the payment option details, such as id, nickName, isDefault, and the creditCard information.

See Retrieving sources and Payment options for more information.

Getting the shopper's payment options

You can get the shopper's payment options by sending a GET /v1/shoppers/me/payment-options request with the authorization bearer token. See Payment options query parameters for a description of the query parameters.

curl --location --request GET 'https://api.digitalriver.com/v1/shoppers/me/payment-options' \
--header 'authorization: bearer [Your_Access_Token]'\
...

Use GET /v1/shoppers/me/payment-options request to retrieve all payment options configured for a shopper. See Payment options query parameters for a description of the query parameters.

Getting the shopper's payment option by identifier

When you need to retrieve a specific payment option for a shopper, you can use the API to get details by providing the payment option's unique identifier. This allows you to access detailed information such as payment type, credit card details, and whether it's set as the default option.

To get a shopper's payment option by identifier, send a GET /v1/shoppers/me/payment-options/{paymentOptionId} request with the specific paymentOptionId. Ensure you include the authorization bearer token in the request header. See Payment options query parameters for a description of the query parameters.

curl --location --request GET 'https://api.digitalriver.com/v1/shoppers/me/payment-options/{paymentOptionId}' \
--header 'authorization: bearer [Your_Access_Token]'\
...

The response will provide details about the specified payment option, including its type, credit card information, and whether it is the default option.

Last updated