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

# Ingest Card Payments

> Send card network messages (authorizations, clearings, reversals, expiries and failures) to Corsa and monitor each card payment through its whole lifecycle.

A card payment moves through several network messages: an authorization, maybe an incremental authorization or a reversal, then one or more clearings. In Corsa, **one card payment is one operation with a single `CARD_PAYMENT` transaction**. You send every network message as it happens. Corsa keeps the messages, derives the payment's state and amount from them, and runs your rules on every message.

Full API endpoint details are available in the [API Reference](https://api.corsa.finance/api-spec.json) (requires API credentials).

> [!NOTE]
>
> Before ingesting card payments, make sure the cardholder has already been ingested as a client. See the [Ingesting Clients](https://docs.corsa.finance/api/ingesting-clients.md) guide.

> [!WARNING]
>
> Never send a full card number (PAN). Identify cards by your own card ID, and optionally the BIN and last four digits.

***

## How card payments work

* **The payment** is identified by your `referenceId` (for example, your issuer-processor's payment ID). The first message for a new `referenceId` creates the payment.
* **Each message** has its own `message.referenceId`. Corsa stores every message once, so you can safely retry.
* **State and amount are derived** from all of the payment's messages, never set directly. The payment's transaction always carries the current effective amount, so velocity and volume rules count each payment once, at its current amount.
* **Rules run on every message.** A rule that already matched an earlier message of the same payment does not raise a second alert for it.

***

## Step 1: Send the first message

The first message of a payment must include `initiatedBy`, `paymentType` and `direction`. Snapshot fields such as `card`, `merchant` and `cardPresent` describe the payment; send them on the first message and again on later messages only when they change.

**Endpoint:** `POST /v1/operations/card-payments`

```json REST API theme={null}
POST /v1/operations/card-payments
Content-Type: application/json

{
  "referenceId": "pay_8f31c2",
  "paymentType": "PURCHASE",
  "direction": "DEBIT",
  "initiatedBy": "cardholder-client-uuid",
  "card": {
    "id": "card_77a1",
    "type": "virtual",
    "bin": "445500",
    "last4": "1234"
  },
  "merchant": {
    "id": "4445001234567",
    "name": "ACME STORE",
    "city": "Berlin",
    "countryCode": "DE",
    "categoryCode": "5411"
  },
  "acquirerAmount": { "amount": 42.5, "currency": "EUR" },
  "cardPresent": false,
  "tokenRequestor": "apple-pay",
  "message": {
    "referenceId": "msg_0001",
    "type": "AUTHORIZATION",
    "outcome": "ACCEPTED",
    "amount": { "amount": 46.1, "currency": "USD" },
    "occurredAt": "2026-12-01T09:14:03Z"
  },
  "evaluateSynchronously": true
}
```

```typescript Javascript theme={null}
const payment = await corsa.cardPayments.ingestCardPaymentMessage({
  referenceId: "pay_8f31c2",
  paymentType: "PURCHASE",
  direction: "DEBIT",
  initiatedBy: "cardholder-client-uuid",
  card: {
    id: "card_77a1",
    type: "virtual",
    bin: "445500",
    last4: "1234",
  },
  merchant: {
    id: "4445001234567",
    name: "ACME STORE",
    city: "Berlin",
    countryCode: "DE",
    categoryCode: "5411",
  },
  acquirerAmount: { amount: 42.5, currency: "EUR" },
  cardPresent: false,
  tokenRequestor: "apple-pay",
  message: {
    referenceId: "msg_0001",
    type: "AUTHORIZATION",
    outcome: "ACCEPTED",
    amount: { amount: 46.1, currency: "USD" },
    occurredAt: "2026-12-01T09:14:03Z",
  },
  evaluateSynchronously: true,
});
```

```python Python theme={null}
from corsa_sdk.api.card_payments.ingest_card_payment_message import _get_kwargs
from corsa_sdk.models.create_card_payment_message_dto import CreateCardPaymentMessageDto

resp = http.request(**_get_kwargs(
    body=CreateCardPaymentMessageDto.from_dict({
        "referenceId": "pay_8f31c2",
        "paymentType": "PURCHASE",
        "direction": "DEBIT",
        "initiatedBy": "cardholder-client-uuid",
        "card": {"id": "card_77a1", "type": "virtual", "bin": "445500", "last4": "1234"},
        "merchant": {
            "id": "4445001234567",
            "name": "ACME STORE",
            "city": "Berlin",
            "countryCode": "DE",
            "categoryCode": "5411",
        },
        "acquirerAmount": {"amount": 42.5, "currency": "EUR"},
        "cardPresent": False,
        "tokenRequestor": "apple-pay",
        "message": {
            "referenceId": "msg_0001",
            "type": "AUTHORIZATION",
            "outcome": "ACCEPTED",
            "amount": {"amount": 46.1, "currency": "USD"},
            "occurredAt": "2026-12-01T09:14:03Z",
        },
        "evaluateSynchronously": True,
    }),
))
payment = resp.json()
```

A new message returns `201 Created` with the payment as it is after that message.

### Payment fields

| Field | Required | Description |
| - | - | - |
| `referenceId` | Yes | Your payment ID, unique per platform. |
| `paymentType` | First message | `PURCHASE`, `REFUND` or `ADJUSTMENT`. |
| `direction` | First message | Cardholder side: `DEBIT` takes money from the cardholder, `CREDIT` gives it back. |
| `initiatedBy` | First message | Corsa client ID or `referenceId` of the cardholder. |
| `card` | No | `id` (your card ID), `type` (`virtual` or `physical`), `bin` (6–8 digits), `last4`. |
| `merchant` | No | `id`, `name`, `city`, `countryCode` (ISO 3166 alpha-2 or alpha-3), `categoryCode` (MCC), `terminalId`. |
| `acquirerAmount` | No | Amount and currency at the merchant. |
| `feeAmount` | No | Fee in the billing currency. |
| `cardPresent` | No | Whether the card was physically present. |
| `tokenRequestor` | No | Wallet token requestor, for example `apple-pay`. |
| `initiator` | No | Who initiated the payment, for example `cardholder`. |
| `cashOperation` | No | `true` for ATM and other cash operations. |
| `securityChallengeOutcome` | No | 3DS outcome, for example `challenge-confirmed`. |
| `relatedPaymentReferenceId` | No | Refunds and adjustments: the original payment's `referenceId`. |
| `retrievalReference`, `posEntryMode`, `acquirerId`, `avsResult`, `cvvResult` | No | Network details, stored on the payment. |
| `customFields` | No | Custom fields of the payment's transaction, merged by key. |
| `message` | Yes | The network message (see below). |
| `evaluateSynchronously` | No | Evaluate rules on this message before responding and return `evaluationResult`. Works on every message. |

### Message fields

| Field | Required | Description |
| - | - | - |
| `referenceId` | Yes | Your message ID, unique per platform. A repeated value is a replay. |
| `type` | Yes | `AUTHORIZATION`, `CLEARING`, `AUTHORIZATION_REVERSAL`, `CLEARING_REVERSAL`, `EXPIRY` or `FAILURE`. |
| `outcome` | Yes | `ACCEPTED` or `DECLINED`. |
| `amount` | Yes | Message amount in the billing currency. Always zero or positive; the message type gives the direction. |
| `occurredAt` | Yes | When the message happened at the network. Corsa orders a payment's messages by this time. |
| `declineReason` | No | Decline reason as your issuer-processor sends it, for example `insufficient-funds`. |
| `failureReason` | No | `FAILURE` messages: why the payment failed. |
| `forced` | No | A forced (force post or offline) authorization. It always counts as accepted. |
| `final` | No | Clearings only, default `true`. A non-final clearing leaves the payment authorized. |
| `networkReference` | No | The network's reference for the message. |

***

## Step 2: Send the following messages

Send each later message for the same payment `referenceId`. You only need the payment `referenceId` and the `message`; the payment fields from the first message are kept.

```json REST API theme={null}
POST /v1/operations/card-payments
Content-Type: application/json

{
  "referenceId": "pay_8f31c2",
  "message": {
    "referenceId": "msg_0002",
    "type": "CLEARING",
    "outcome": "ACCEPTED",
    "amount": { "amount": 45.9, "currency": "USD" },
    "final": true,
    "occurredAt": "2026-12-02T03:00:00Z"
  }
}
```

```typescript Javascript theme={null}
const payment = await corsa.cardPayments.ingestCardPaymentMessage({
  referenceId: "pay_8f31c2",
  message: {
    referenceId: "msg_0002",
    type: "CLEARING",
    outcome: "ACCEPTED",
    amount: { amount: 45.9, currency: "USD" },
    final: true,
    occurredAt: "2026-12-02T03:00:00Z",
  },
});
```

```python Python theme={null}
from corsa_sdk.api.card_payments.ingest_card_payment_message import _get_kwargs
from corsa_sdk.models.create_card_payment_message_dto import CreateCardPaymentMessageDto

resp = http.request(**_get_kwargs(
    body=CreateCardPaymentMessageDto.from_dict({
        "referenceId": "pay_8f31c2",
        "message": {
            "referenceId": "msg_0002",
            "type": "CLEARING",
            "outcome": "ACCEPTED",
            "amount": {"amount": 45.9, "currency": "USD"},
            "final": True,
            "occurredAt": "2026-12-02T03:00:00Z",
        },
    }),
))
payment = resp.json()
```

After this clearing, the payment is `CLEARED` and its amount is `45.9`. Its transaction is updated in place: it is still one transaction, now at 45.9.

### Response

```json theme={null}
{
  "id": "card-payment-uuid",
  "referenceId": "pay_8f31c2",
  "transactionId": "transaction-uuid",
  "paymentType": "PURCHASE",
  "direction": "DEBIT",
  "initiatedBy": "cardholder-client-uuid",
  "state": "CLEARED",
  "amount": 45.9,
  "currency": "USD",
  "authorizedAmount": 46.1,
  "clearedAmount": 45.9,
  "reversedAmount": 0,
  "card": { "id": "card_77a1", "type": "virtual", "bin": "445500", "last4": "1234" },
  "merchant": { "id": "4445001234567", "name": "ACME STORE", "countryCode": "DE", "categoryCode": "5411" },
  "messages": [
    {
      "id": "message-uuid-1",
      "referenceId": "msg_0001",
      "sequence": 0,
      "type": "AUTHORIZATION",
      "outcome": "ACCEPTED",
      "amount": { "amount": 46.1, "currency": "USD" },
      "occurredAt": "2026-12-01T09:14:03Z",
      "evaluationDecision": "ALLOW"
    },
    {
      "id": "message-uuid-2",
      "referenceId": "msg_0002",
      "sequence": 1,
      "type": "CLEARING",
      "outcome": "ACCEPTED",
      "amount": { "amount": 45.9, "currency": "USD" },
      "final": true,
      "occurredAt": "2026-12-02T03:00:00Z"
    }
  ]
}
```

| Field | Description |
| - | - |
| `state` | Current state of the payment (see below). |
| `amount` | Effective amount in the billing currency. This is the transaction amount your rules aggregate. |
| `authorizedAmount` | Sum of accepted authorizations. |
| `clearedAmount` | Sum of accepted clearings. |
| `reversedAmount` | Sum of accepted authorization and clearing reversals. |
| `messages` | All messages, ordered by `occurredAt`, then by when Corsa received them. |
| `messages[].evaluationDecision` | `ALLOW`, `FREEZE` or `EVALUATION_FAILED`, when the message was evaluated synchronously. `matchedRuleIds`, `matchedRuleNames` and `alertIds` are returned with it. |
| `replayed` | `true` when the message was already stored (see [Replays and retries](#replays-and-retries)). |
| `evaluationResult` | Present when the message was sent with `evaluateSynchronously: true`. |

***

## Card payment states

Corsa derives the state and the effective amount from all accepted messages of the payment. Declined messages are stored and shown, but they don't change the totals.

| State | When | Effective amount | Transaction status |
| - | - | - | - |
| `AUTHORIZED` | Accepted authorizations, not fully reversed, and no final clearing yet. | Authorized minus reversed. With only non-final clearings, never less than what has cleared. | `PENDING` |
| `CLEARED` | A final clearing was accepted, or an expired payment had cleared in part. A clearing without an earlier authorization is cleared directly. | Cleared minus clearing reversals. | `SUCCESS` |
| `REVERSED` | Authorizations were fully reversed before clearing. | 0 | `CANCELLED` |
| `EXPIRED` | The authorization expired with nothing cleared. | 0 | `CANCELLED` |
| `CLEARING_REVERSED` | The clearings were fully reversed. | 0 | `CANCELLED` |
| `DECLINED` | No message of the payment was accepted. | 0 | `FAILED` |
| `FAILED` | A `FAILURE` message arrived with nothing cleared. After a clearing, the clearing wins. | 0 | `FAILED` |

Some consequences of these rules:

* **Incremental authorizations add up.** Authorizing 100 and then 20 gives an authorized payment at 120.
* **Partial reversals reduce the amount.** Authorizing 100 and reversing 30 gives an authorized payment at 70.
* **Clearing replaces the authorized amount.** Authorizing 100 and clearing 98 gives one cleared payment at 98, not two transactions.
* **A declined first authorization still creates the payment**, as `DECLINED` at 0. A later accepted authorization moves it to `AUTHORIZED`.
* **A forced authorization is always accepted**, even if it was sent with `outcome: DECLINED`.
* **Messages can arrive out of order.** The result depends only on the set of messages, so a late message is placed in order by its `occurredAt`.

***

## Replays and retries

Each message is stored once, keyed by its `message.referenceId`.

* **Sending the same message again** returns `200 OK` with the stored payment and `replayed: true`. Nothing changes and rules are not evaluated again. If the first request stored the message but failed before finishing, the retry completes it once.
* **`409 Conflict`** means another message for the same payment is still being processed, or the `referenceId` is already used by a different payment or transaction. Retry concurrent messages; fix the IDs in the second case.

> [!TIP]
>
> If a request times out at your network or gateway, retry it with the same message `referenceId`. A replay can never count a message twice.

***

## Refunds and adjustments

Send a refund as its own card payment with `paymentType: "REFUND"` and `direction: "CREDIT"`. Set `relatedPaymentReferenceId` to the original purchase's `referenceId`. Corsa links the two payments as soon as both exist, so the refund can arrive before or after the purchase.

```json REST API theme={null}
POST /v1/operations/card-payments
Content-Type: application/json

{
  "referenceId": "pay_9a02d7",
  "paymentType": "REFUND",
  "direction": "CREDIT",
  "initiatedBy": "cardholder-client-uuid",
  "relatedPaymentReferenceId": "pay_8f31c2",
  "merchant": { "id": "4445001234567", "name": "ACME STORE", "countryCode": "DE", "categoryCode": "5411" },
  "message": {
    "referenceId": "msg_0101",
    "type": "CLEARING",
    "outcome": "ACCEPTED",
    "amount": { "amount": 20, "currency": "USD" },
    "occurredAt": "2026-12-05T11:00:00Z"
  }
}
```

```typescript Javascript theme={null}
const refund = await corsa.cardPayments.ingestCardPaymentMessage({
  referenceId: "pay_9a02d7",
  paymentType: "REFUND",
  direction: "CREDIT",
  initiatedBy: "cardholder-client-uuid",
  relatedPaymentReferenceId: "pay_8f31c2",
  merchant: { id: "4445001234567", name: "ACME STORE", countryCode: "DE", categoryCode: "5411" },
  message: {
    referenceId: "msg_0101",
    type: "CLEARING",
    outcome: "ACCEPTED",
    amount: { amount: 20, currency: "USD" },
    occurredAt: "2026-12-05T11:00:00Z",
  },
});
```

```python Python theme={null}
from corsa_sdk.api.card_payments.ingest_card_payment_message import _get_kwargs
from corsa_sdk.models.create_card_payment_message_dto import CreateCardPaymentMessageDto

resp = http.request(**_get_kwargs(
    body=CreateCardPaymentMessageDto.from_dict({
        "referenceId": "pay_9a02d7",
        "paymentType": "REFUND",
        "direction": "CREDIT",
        "initiatedBy": "cardholder-client-uuid",
        "relatedPaymentReferenceId": "pay_8f31c2",
        "merchant": {"id": "4445001234567", "name": "ACME STORE", "countryCode": "DE", "categoryCode": "5411"},
        "message": {
            "referenceId": "msg_0101",
            "type": "CLEARING",
            "outcome": "ACCEPTED",
            "amount": {"amount": 20, "currency": "USD"},
            "occurredAt": "2026-12-05T11:00:00Z",
        },
    }),
))
refund = resp.json()
```

***

## Synchronous evaluation

Set `evaluateSynchronously: true` on any message to evaluate your rules before Corsa responds, for example to decide whether to approve an authorization. The response includes `evaluationResult`, and the decision is stored on the message.

Without it, Corsa evaluates the message asynchronously right after storing it.

> [!NOTE]
>
> A forced authorization has already been approved by the network. If a rule returns `FREEZE` on a forced message, Corsa records the decision on the message but doesn't apply it.

***

## Retrieve a card payment

Get a card payment with all of its messages by its Corsa ID or your `referenceId`.

**Endpoint:** `GET /v1/operations/card-payments/{id}`

```bash REST API theme={null}
GET /v1/operations/card-payments/pay_8f31c2
```

```typescript Javascript theme={null}
const payment = await corsa.cardPayments.getCardPayment("pay_8f31c2");
```

```python Python theme={null}
from corsa_sdk.api.card_payments.get_card_payment import _get_kwargs

resp = http.request(**_get_kwargs(id="pay_8f31c2"))
payment = resp.json()
```

### Card payments on transactions

The payment's transaction has type `CARD_PAYMENT` and payment method `CARD`. When you [get the transaction](https://docs.corsa.finance/api/managing-transactions.md#get-a-transaction), it includes a `card` object with the payment's state, totals, card and merchant details.

Because a card payment's amount and status are derived from its messages, you can't change them through the generic transaction endpoints. `PUT /v1/transactions/{id}` with an amount, and status updates (single or bulk), return `400` with code `CARD_PAYMENT_DERIVED_FIELD`. Send a new message instead. Other transaction fields, such as custom fields, can still be updated.

***

## Monitoring card payments

Rules run on every message of a card payment, so a rule can match the clearing even if the authorization looked fine. For example, a $500 pre-authorization that clears at $15,000 is evaluated again at \$15,000. Each rule alerts at most once per payment, and every alert names the message that triggered it.

### Card properties

These transaction properties are available in rule conditions. Use `type` `in ["CARD_PAYMENT"]` to limit a rule to card payments.

| Property | Type | Description |
| - | - | - |
| `cardState` | String | Current payment state (`AUTHORIZED`, `CLEARED`, …). |
| `cardPaymentType` | String | `PURCHASE`, `REFUND` or `ADJUSTMENT`. |
| `cardDirection` | String | `DEBIT` or `CREDIT`. |
| `cardAuthorizedAmount`, `cardClearedAmount`, `cardReversedAmount` | Number | The payment's totals in the billing currency. |
| `merchantCategoryCode` | String | Merchant category code (MCC). |
| `merchantCountryCode` | String | Merchant country. |
| `merchantId`, `merchantName` | String | Merchant identifiers. |
| `cardPresent` | Boolean | Card-present payment. |
| `cardTokenRequestor` | String | Wallet token requestor. |
| `cardInitiator` | String | Who initiated the payment. |
| `cardCashOperation` | Boolean | ATM or cash operation. |
| `cardSecurityChallengeOutcome` | String | 3DS outcome. |
| `cardId` | String | Your card ID. |
| `cardRelatedPaymentReferenceId` | String | Original payment of a refund or adjustment. |

These properties also work as [aggregation filters](https://docs.corsa.finance/transaction-monitoring/conditions-reference.md#aggregation-filters), for example "sum of card payments at MCC 7995 that are `AUTHORIZED` or `CLEARED` in the last 7 days". Each payment counts once, at its current amount.

The following properties describe the message being evaluated. They can be used in conditions on the current transaction, but not in aggregations.

| Property | Type | Description |
| - | - | - |
| `cardMessageType` | String | Type of the message being evaluated. |
| `cardMessageOutcome` | String | `ACCEPTED` or `DECLINED`. |
| `cardDeclineReason` | String | Decline reason of the message. |
| `cardMessageForced` | Boolean | Forced authorization. |
| `cardClearedOverAuthorizedAmount` | Number | How far the cleared amount is above the authorized amount. |

> [!NOTE]
>
> Rule testing and backtesting don't include card properties yet.

### Card rule templates

The [rule template](https://docs.corsa.finance/transaction-monitoring/rule-templates.md) catalog includes templates for card payments:

| Template | Detects |
| - | - |
| Card Spend at High-Risk Merchants | Card spend at high-risk merchant categories (gambling, money transfer, quasi-cash) above a threshold in 7 days. |
| Card Declined Authorizations Velocity | Many declined authorizations in a short window, on one card or across a cardholder's cards. |
| Card-Present Spend Outside Cardholder Country | Card-present authorizations at merchants outside the cardholder's country. |
| Card Clearing Above Authorized Amount | Clearings that take a payment above its authorized total by more than a tolerance. |
| Card Refund Without Earlier Purchase | Refunds from a merchant where the cardholder has no purchase in the last 90 days. |
| Card Testing: Rapid Small Authorizations | Rapid small authorizations on one card at one merchant. |
| Card ATM and Cash Withdrawals Above Daily Total | ATM and cash withdrawals above a total within 24 hours. |

***

## Errors

| Status | Code | Meaning |
| - | - | - |
| `400` | | Invalid message, or a first message without `initiatedBy`, `paymentType` and `direction`. |
| `403` | `CARD_PAYMENTS_DISABLED` | Card payment ingestion isn't enabled for your platform. Contact Corsa support. |
| `404` | | `GET`: no card payment with that ID or `referenceId`. |
| `409` | | A message for the same payment is still being processed, or the `referenceId` is used by another payment or transaction. |

***

## What's next?

> [card] [Building rules](https://docs.corsa.finance/transaction-monitoring/building-rules.md)
>
> Create rules on card properties and aggregations.

> [card] [Managing transactions](https://docs.corsa.finance/api/managing-transactions.md)
>
> Look up the transaction behind each card payment.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.