> ## Documentation Index
> Fetch the complete documentation index at: https://developer.fabric.inc/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring Payment

This feature in Carts API allows users to add, update, and delete payment details. The cart maintains the state of each payment—pending, authorized, captured, and failed—as provided by the user, but it doesn't store tokens, which are expected from the System Integrator (SI).

## Prerequisites

The following prerequisites must be completed sequentially to configure a payment.

1. [Create a cart](/v3/cart-and-checkout/api-reference/carts-v3/carts/carts).
2. [Add an item](/v3/cart-and-checkout/api-reference/carts-v3/items/items) to the cart.

## Payments Initialization

The cart displays authorized amounts and allows updates or removals of payments. Payments can be purged or held when the cart changes such as, price changes. The cart also verifies the authorized payment amount against the cart total.

The following code sample provides an example of the structure of payment information and status in the response:

<Accordion title="Click to expand the JSON example.">
  ```json theme={null}
  {
      "provider": "fabricmock",
      "processor": "fabricmock",
      "method": "CREDIT_CARD",
      "methodType": "VISA", 
      "state": "PENDING",
      "authorization": {
      "amount": 520.0,
      "expiry": "",
      "verifier": {
          "type": "PAYMENT_TOKEN",
          "key": "{{payment_token}}"
      }
      },
      "billToAddress": "{{addressId}}",
      "cardDetails": null,
      "attributes":{
          "orderSource": "ecommerce",
          "expirationDate": "0224",
          "requestedDate": "2022-01-27T16:15:58-05:00",
          "paymentDate": "2022-01-27T16:15:58-05:00",
          "billToId": "213321"
      }
  }
  ```
</Accordion>

As the cart can contain multiple payments, they are shown as a collection. The authorized amount is the sum of all payments with the **AUTHORIZED** state added to the cart as in the following example:

<Accordion title="Click to expand the JSON example.">
  ```json theme={null}
  "payments": {
      "authorized": 0,
      "collection": [
          {
              "provider": "fabricmock",
              "processor": "fabricmock",
              "method": "CREDIT_CARD",
              "methodType": "VISA", 
              "state": "PENDING",
              "authorization": {
                  "amount": 520.0,
                  "expiry": "",
                  "verifier": {
                      "type": "PAYMENT_TOKEN",
                      "key": "{{payment_token}}"
                  }
              },
              "billToAddress": "{{addressId}}",
              "cardDetails": null,
              "attributes":{
                  "orderSource": "ecommerce",
                  "expirationDate": "0224",
                  "requestedDate": "2022-01-27T16:15:58-05:00",
                  "paymentDate": "2022-01-27T16:15:58-05:00",
                  "billToId": "213321"
              }
          }
      ]
  }

  ```
</Accordion>

## Examples

### Adding payments with the `CAPTURED` status to the cart

Use the [create a payment](/v3/cart-and-checkout/api-reference/carts-v3/payments/create-payments) endpoint to add a `CAPTURED` payment method to the cart as in the following example:

<Accordion title="Click to expand the curl and JSON response example.">
  ```curl theme={null}
      curl --location '{{modular_cart_domain}}/carts/ba0e93f5-e47f-4b0d-bac8-6233b67ef65f/payments' \
      --header 'Content-Type: application/json' \
      --header 'x-fabric-tenant-id:  {tenantId}' \
      --header 'Authorization: {authToken}' \
      --data '{
          "provider": "fabricmock",
          "processor": "fabricmock",
          "method": "CREDIT_CARD",
          "methodType": "VISA", 
          "state": "CAPTURED",
          "authorization": {
              "amount": 500.0,
              "expiry": "",
              "verifier": {
              "type": "PAYMENT_TOKEN",
              "key": "{{payment_token}}"
              }
          },
          "billToAddress": "46622c9c-604c-4f8c-8bcf-2a393a572839",
          "cardDetails": null,
          "attributes": {
                  "orderSource": "ecommerce",
                  "expirationDate": "0224",
                  "requestedDate": "2022-01-27T16:15:58-05:00",
                  "paymentDate": "2022-01-27T16:15:58-05:00",
                  "billToId": "213321"
          }
      }
      '
  ```

  A successful response to `carts/{cartId}/payments` provides a payments object as the following example:

  ```json theme={null}
  "payments": {
      "authorized": 0,
      "collection": [
          {
              "provider": "fabricmock",
              "processor": "fabricmock",
              "method": "CREDIT_CARD",
              "methodType": "VISA", 
              "state": "CAPTURED",
              "authorization": {
                  "amount": 500.0,
                  "expiry": "",
                  "verifier": {
                      "type": "PAYMENT_TOKEN",
                      "key": "{{payment_token}}"
                  }
              }
          },
          "billToAddress": "46622c9c-604c-4f8c-8bcf-2a393a572839",
          "cardDetails": null,
          "attributes":{
              "orderSource": "ecommerce",
              "expirationDate": "0224",
              "requestedDate": "2022-01-27T16:15:58-05:00",
              "paymentDate": "2022-01-27T16:15:58-05:00",
              "billToId": "213321"
          }
      ]
  }
  ```
</Accordion>

### Adding payments with the `AUTHORIZED` status to the cart

Use the [create a payment](/v3/cart-and-checkout/api-reference/carts-v3/payments/create-payments) endpoint to add `AUHTORIZED` payments to the cart as in the following example:

<Accordion title="Click to expand the curl and JSON response example.">
  ```curl theme={null}
  curl --location '{{modular_cart_domain}}/carts/ba0e93f5-e47f-4b0d-bac8-6233b67ef65f/payments' \
  --header 'Content-Type: application/json' \
  --header 'x-fabric-tenant-id:  {tenantId}' \
  --header 'Authorization: {authToken}' \
  --data '{
      "provider": "fabricmock",
      "processor": "fabricmock",
      "method": "CREDIT_CARD",
      "methodType": "VISA", 
      "state": "AUTHORIZED",
      "authorization": {
          "amount": 500.0,
          "expiry": "",
          "verifier": {
          "type": "PAYMENT_TOKEN",
          "key": "{{payment_token}}"
          }
      },
      "billToAddress": "46622c9c-604c-4f8c-8bcf-2a393a572839",
      "cardDetails": null,
      "attributes": {
              "orderSource": "ecommerce",
              "expirationDate": "0224",
              "requestedDate": "2022-01-27T16:15:58-05:00",
              "paymentDate": "2022-01-27T16:15:58-05:00",
              "billToId": "213321"
      }
  }
  '
  ```

  A successful response to `carts/{cartId}/payments` provides a payments object as in the following example:

  ```json theme={null}
  "payments": {
      "authorized": 500.0,
      "collection": [
      {
          "provider": "fabricmock",
          "processor": "fabricmock",
          "method": "CREDIT_CARD",
          "methodType": "VISA", 
          "state": "AUTHORIZED",
          "authorization": {
          "amount": 500.0,
          "expiry": "",
          "verifier": {
              "type": "PAYMENT_TOKEN",
              "key": "{{payment_token}}"
          }
          }
      },
          "billToAddress": "46622c9c-604c-4f8c-8bcf-2a393a572839",
          "cardDetails": null,
          "attributes":{
              "orderSource": "ecommerce",
              "expirationDate": "0224",
              "requestedDate": "2022-01-27T16:15:58-05:00",
              "paymentDate": "2022-01-27T16:15:58-05:00",
              "billToId": "213321"
          }
      ]
  }
  ```
</Accordion>
