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 (requires API credentials).
Before ingesting card payments, make sure the cardholder has already been ingested as a client. See the Ingesting Clients guide.
How card payments work
- The payment is identified by your
referenceId(for example, your issuer-processor’s payment ID). The first message for a newreferenceIdcreates 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 includeinitiatedBy, 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
201 Created with the payment as it is after that message.
Payment fields
Message fields
Step 2: Send the following messages
Send each later message for the same paymentreferenceId. You only need the payment referenceId and the message; the payment fields from the first message are kept.
CLEARED and its amount is 45.9. Its transaction is updated in place: it is still one transaction, now at 45.9.
Response
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.
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
DECLINEDat 0. A later accepted authorization moves it toAUTHORIZED. - 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 itsmessage.referenceId.
- Sending the same message again returns
200 OKwith the stored payment andreplayed: 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 Conflictmeans another message for the same payment is still being processed, or thereferenceIdis already used by a different payment or transaction. Retry concurrent messages; fix the IDs in the second case.
Refunds and adjustments
Send a refund as its own card payment withpaymentType: "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.
Synchronous evaluation
SetevaluateSynchronously: 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.
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 yourreferenceId.
Endpoint: GET /v1/operations/card-payments/{id}
Card payments on transactions
The payment’s transaction has typeCARD_PAYMENT and payment method CARD. When you get the 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. Usetype in ["CARD_PAYMENT"] to limit a rule to card payments.
These properties also work as 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.
Rule testing and backtesting don’t include card properties yet.
Card rule templates
The rule template catalog includes templates for card payments:Errors
What’s next?
Building rules
Create rules on card properties and aggregations.
Managing transactions
Look up the transaction behind each card payment.