Card Transactions

How card transactions settle against the Master Account.

Before You Start

Read the following guides before proceeding:

GuideWhy
OverviewUnderstand External Authorization model
Authorization APIHow transaction authorization works
Issue and Manage a CardStandard card issuance flow

Card Issuance

Both issuance flows work under External Authorization — see Issuing a Card. They issue the same cards and differ only in how the issuance fee is collected:

  • v1 (external fee) — you pay the fee yourself: transfer to the invoice recipient_address and pass payment_transaction_hash at issuance.
  • v2 (direct fee) — Wirex debits the fee automatically at issuance. In standard integration the fee comes from the cardholder's on-chain balance; under External Authorization cardholders have no on-chain balance, so the fee is debited from your Master Account instead.

All card management operations (block, unblock, close, set limits) work identically to standard integration.


Transaction Settlement

The difference is in how transactions are settled:

AspectStandard FlowExternal Authorization
Balance checkUser's AA walletYour authorization API
Settlement sourceUser's AA walletMaster Account
Balance updatesOn-chain per userYour external system

Standard Flow

1. User pays with card
2. Wirex checks user's on-chain balance
3. Wirex holds funds on user's AA wallet
4. Transaction settles from user's AA wallet
5. Webhook sent

External Authorization Flow

1. User pays with card
2. Wirex calls your authorization API
3. You check balance in your system
4. If approved, Wirex debits Master Account
5. Webhook sent
6. You update user's balance in your system

Transaction Flow Diagram

sequenceDiagram
    participant User
    participant Merchant
    participant Wirex
    participant Partner as Your System
    participant Master as Master Account

    User->>Merchant: Pay with card
    Merchant->>Wirex: Authorization request
    Wirex->>Partner: POST /external-authorization/...
    Partner->>Partner: Check user balance
    Partner-->>Wirex: { is_allowed: true }
    Wirex->>Master: Debit Master Account
    Wirex-->>Merchant: Approved
    Wirex->>Partner: Transaction webhook
    Partner->>Partner: Debit user balance

Webhooks

After transaction completion, Wirex sends a webhook notification. Use this to update your internal balance records.

Card Transaction Webhook

Endpoint: POST {your_webhook_base_url}/v2/webhooks/activities

The payload is the v2 activity. The same activity is
delivered again each time it changes.

{
  "id": "a7b2a4b3-2f61-41a7-9f5a-3f3f0b1a3d22",
  "user_address": "0xA7E41d5680dE394EaA2ed417169DFf56840Fb3EE",
  "chain_id": 8453,
  "type": "CardTransaction",
  "sub_type": "Pos",
  "direction": "Outbound",
  "status": "Completed",
  "rrn": "530112345678",
  "source": {
    "type": "Cards",
    "card": { "id": "64120850-73a1-4df5-a074-d463258c9deb", "pan_last": "4821", "payment_system": "Visa" }
  },
  "destination": {
    "type": "Merchant",
    "merchant": { "id": "0d6f1c2e-6b1a-4c55-9a4e-2f1b3c4d5e6f", "name": "Amazon UK", "mcc": "5942" }
  },
  "destination_amount": { "amount": 123.45, "amount_precise": "123450000000000000000", "decimals": 18, "currency": "USD" },
  "operations": [
    {
      "operation_id": "3b0c5f7e-2a1d-4e8f-9c6b-7d5e4f3a2b1c",
      "operation_reason": "Authorization",
      "transaction_amount": { "amount": -123.45, "amount_precise": "-123450000000000000000", "decimals": 18, "currency": "USD" },
      "status": "Completed"
    }
  ],
  "activity_steps": [],
  "created_at": "2024-01-01T10:00:00Z"
}
FieldDescription
user_addressThe cardholder's EOA
source.card.idThe card used
statusPending, Completed, or Failed. A purchase refunded or reversed in full reads Failed
operations[].operation_idOne ledger movement — the unique_operation_id of the authorization request
operations[].operation_reasonAuthorization, Clearing, Refund, Reversal, … — see Operations
operations[].transaction_amountThe movement in the transaction currency; negative debits the user

Handling Webhooks

Book each Completed operation once, keyed by operation_id — a refund or reversal arrives as a new
operation on the activity you already processed:

app.post('/v2/webhooks/activities', async (req, res) => {
  const activity = req.body;
  if (activity.type !== 'CardTransaction') return res.sendStatus(200);

  for (const operation of activity.operations) {
    if (operation.status !== 'Completed' || !operation.transaction_amount) continue;
    if (await db.isBooked(operation.operation_id)) continue;

    // negative amount debits the user, positive credits them
    await db.book(activity.user_address, operation.operation_id,
      operation.transaction_amount.amount_precise, operation.transaction_amount.currency);
  }

  res.sendStatus(200);
});
@app.post("/v2/webhooks/activities")
async def handle_activity_webhook(request: Request):
    activity = await request.json()
    if activity["type"] != "CardTransaction":
        return Response(status_code=200)

    for operation in activity["operations"]:
        if operation.get("status") != "Completed" or "transaction_amount" not in operation:
            continue
        if await db.is_booked(operation["operation_id"]):
            continue

        # negative amount debits the user, positive credits them
        await db.book(
            activity["user_address"],
            operation["operation_id"],
            operation["transaction_amount"]["amount_precise"],
            operation["transaction_amount"]["currency"]
        )

    return Response(status_code=200)
func handleActivityWebhook(w http.ResponseWriter, r *http.Request) {
    var activity ActivityItem
    json.NewDecoder(r.Body).Decode(&activity)

    if activity.Type == "CardTransaction" {
        for _, operation := range activity.Operations {
            if operation.Status != "Completed" || operation.TransactionAmount == nil {
                continue
            }
            if db.IsBooked(operation.OperationId) {
                continue
            }
            // negative amount debits the user, positive credits them
            db.Book(activity.UserAddress, operation.OperationId,
                operation.TransactionAmount.AmountPrecise, operation.TransactionAmount.Currency)
        }
    }

    w.WriteHeader(http.StatusOK)
}

Balance Reconciliation

Your system is the source of truth for user balances. Wirex only tracks the Master Account balance.

Reconciliation approach:

  1. Track all authorization requests you approve
  2. Match against transaction webhooks received
  3. The Master Account balance should equal the sum of all processed transactions

Discrepancies may occur when:

  • Mandatory transactions processed without your approval
  • Network timeouts where transaction actually succeeded
  • Chargebacks or reversals

Use unique_operation_id for idempotent authorization handling, and operations[].operation_id for booking settled movements from the activity webhook.


FAQ

Q: What if I approve a transaction but the Master Account has insufficient funds?
A: The transaction is declined. Monitor and maintain Master Account balance.

Q: How do refunds work?
A: Refunds are mandatory Credit transactions. The Master Account is credited, and you receive a webhook to credit the user's balance.

Q: Can I query transaction history?
A: Use the standard Activity History endpoints. Transactions are attributed to users by their EOA identifier.


Did this page help you?