# Managing 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`](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/shoppers/payment-options#v1-shoppers-me-payment-options-1) 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`. See the [Query parameters](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/shoppers/payment-options#v1-shoppers-me-payment-options-1) for more information. Here is an example of how to make the request using cURL:

{% tabs %}
{% tab title="cURL" %}

```http
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}}"
  }
}
```

{% endtab %}

{% tab title="201 Created" %}

```json
{
  "uri": "https://api.digitalriver.com/v1/shoppers/me/payment-options/740865108",
  "id": 740865108,
  "nickName": "Default",
  "isDefault": "true",
  "type": "creditCard",
  "sourceId": "{{sourceId}}",
  "sourceClientSecret": "{{clientSecret}}",
  "creditCard": {
    "expirationYear": "2030",
    "lastFourDigits": "0000",
    "clientSecret": "{{clientSecret}}",
    "expirationMonth": "08",
    "fundingSource": "debit",
    "brand": "Visa",
    "reusable": "true"
  }
}
```

{% endtab %}
{% endtabs %}

The response will include the payment option details, such as `id`, `nickName`, `isDefault`, and the `creditCard` information.&#x20;

## Getting the shopper's payment options

You can get the shopper's payment options by sending a [`GET /v1/shoppers/me/payment-options`](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/shoppers/payment-options#v1-shoppers-me-payment-options) request with the authorization bearer token. See the [Query parameters](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/shoppers/payment-options#v1-shoppers-me-payment-options) for more information.&#x20;

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

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

{% endcode %}
{% endtab %}

{% tab title="200 OK response" %}
{% code overflow="wrap" %}

```json
{
  "paymentOptions": {
    "uri": "https://api.digitalriver.com/v1/shoppers/me/payment-options",
    "paymentOption": [
      {
        "sourceId": "{{sourceId}}",
        "uri": "https://api.digitalriver.com/v1/shoppers/me/payment-options/740865108",
        "id": 15699113789,
        "nickName": "Default",
        "isDefault": "true"
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

Use the [`GET /v1/shoppers/me/payment-options`](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/shoppers/payment-options#v1-shoppers-me-payment-options) request to retrieve all payment options configured for a shopper.&#x20;

## 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 [`POST /v1/shoppers/me/payment-options/{paymentOptionId}`](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/shoppers/payment-options#v1-shoppers-me-payment-options-paymentoptionid-1) request with the specific `paymentOptionId`. Ensure you include the authorization bearer token in the request header. See the [Query parameters](https://app.gitbook.com/s/X2fWaY1Kp5sXA1fmOL7z/shoppers/payment-options#v1-shoppers-me-payment-options-paymentoptionid-1) for more information.&#x20;

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

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

{% endcode %}
{% endtab %}

{% tab title="200 OK response" %}
{% code overflow="wrap" %}

```json
{
  "paymentOption": {
    "sourceId": "{{sourceId}}",
    "sourceClientSecret": "a231f38d-3a07-4a13-96ed-89693ba7d56c_f6d8c951-59c9-4ef3-ac45-9f33c77d2f46",
    "uri": "https://api.digitalriver.com/v1/shoppers/me/payment-options/740865108",
    "id": 740865108,
    "nickName": "Default",
    "isDefault": "true",
    "type": "CreditCardMethod",
    "creditCard": {
      "expirationMonth": "1",
      "expirationYear": "2030",
      "brand": "Visa",
      "lastFourDigits": "1234"
    }
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

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