# Payment results and refunds

Answer status checks, wake Tringify when your provider notifies you, and refund payments.

Your app never reports a payment or refund result. Tringify asks: your status endpoint for a payment attempt, your refund-status endpoint for a refund. Read the answer live from the provider every time, so a lost, late or repeated request can never record something the provider doesn't hold. Your app keeps no payment or refund outcomes of its own.

## When Tringify checks an attempt

- After it opens the attempt for the shopper, at intervals of 15 seconds, 30 seconds, 1 minute, 2 minutes and 5 minutes, each counted from the previous check, then every 5 minutes until `expires_at`, also after a capture was recorded, because the provider object can take another one.
- When your app sends a wake for it, when the shopper returns from the provider, and while the shopper waits on the payment status page (at most every 3 seconds).
- After `expires_at`, it sends cancel with reason `expired`, then checks at intervals of 5 minutes, 30 minutes, 2 hours, 12 hours and 24 hours, so a payment completed late is still recorded. The attempt is final after the last check.

A `failed` answer ends the checks for that attempt. Answer `failed` only when the provider object can no longer be paid; while it can still take a payment, answer `pending`.

## Answer a status request

```json
{
  "session_id": "session_…",
  "protocol_version": "1",
  "store_id": "store_…",
  "order_id": "order_…",
  "binding_id": "binding_…",
  "connection_key": "default",
  "provider_session_id": "provider_session_…",
  "amount": "1499.00",
  "currency_code": "USD"
}
```

Read the attempt from the provider by `provider_session_id` with the account of the connection named, capture an authorised payment first, and answer what the provider holds now. The request is read-only apart from that capture and is safe to repeat.

```json
{
  "status": "paid",
  "payments": [
    {
      "transaction_id": "provider_payment_…",
      "amount": "1499.00",
      "currency_code": "USD",
      "captured_at": "2026-07-13T12:04:31Z"
    }
  ]
}
```

```json
{
  "status": "failed",
  "error_code": "CARD_DECLINED",
  "error_message": "The card was declined."
}
```

| Answer | What Tringify does |
| --- | --- |
| `pending`, without `payments` | Checks again on the schedule. |
| `paid`, listing every captured payment on the attempt | Records each capture once, by `transaction_id`. The first capture pays the order. A capture the order doesn't need (a second capture on the attempt, a capture after the order was paid another way or cancelled, or a late capture after the attempt closed) is recorded and refunded through your refund endpoint. |
| `failed`, without `payments` | Fails the attempt with your `error_code` and releases the checkout's stock hold. The shopper can try again with a new attempt. |

Each capture's `currency_code` must be the attempt's and its `amount` a positive decimal; a capture that breaks this, or whose `transaction_id` is already recorded for a different attempt, is not recorded. A `paid` answer without captures, or a `pending` or `failed` answer with captures, is not an answer. A timeout, a 408, 429 or 5xx, or a body that is not one of the three answers is asked again at the next check: it never fails the attempt.

## Wake Tringify

When your provider notifies your app about an attempt or a refund, verify the notification with the provider, then ask Tringify to check now. A wake carries no result and changes nothing by itself, so a lost, late, repeated or forged wake is harmless: Tringify asks your status or refund-status endpoint as usual. Without wakes, the scheduled checks still find every outcome, only later.

| Purpose | Request | Required scope |
| --- | --- | --- |
| Check a payment attempt now | `POST /api/2025-01/payment-sessions/{session_id}/wake` | `write_payment_sessions` |
| Check a refund now | `POST /api/2025-01/payment-refunds/{refund_id}/wake` | `write_payment_sessions` |
| Read a payment attempt assigned to your app | `GET /api/2025-01/payment-sessions/{session_id}` | `read_payment_sessions` |

Send a wake with the installation token and no body, or `{}`. It answers `{"success":true,"data":{"scheduled":true}}`; a wake for a refund that is no longer pending schedules nothing. Reading a session returns its state, amount and currency, provider references and times; its `created_at`, `updated_at`, `expires_at` and `resolved_at` are RFC 3339 in the store's timezone with its offset.

| HTTP status | Code | When |
| --- | --- | --- |
| 403 | `PAYMENT_SESSION_APP_TOKEN_REQUIRED` | The request does not use an app installation token. |
| 403 | `PAYMENT_SESSION_WRONG_APP` | The attempt or refund belongs to another app. |
| 404 | `PAYMENT_SESSION_NOT_FOUND` | There is no such payment attempt in this store. |
| 404 | `NOT_FOUND` | There is no such refund in this store. |
| 400 | `STORE_API_BODY_PROPERTY_UNKNOWN` | The wake has a body with a property in it. |

## Expiry and late settlement

`expires_at` ends the shopper's attempt in checkout, not the provider's ability to settle it. Do not assume a fixed limit: honor the `expires_at` in each charge request. Without a checkout stock hold it is 30 minutes after the charge request; when the checkout holds stock, it is the end of that hold, which follows the store's configured checkout duration and can be up to 120 minutes away. Where the provider allows it, make the provider payment stop accepting payment at `expires_at`. If the provider still captures it, the late checks find it: Tringify records the money and, when the order no longer needs it, refunds it through your refund endpoint. Your app cannot be uninstalled for 7 days after an attempt's last activity, so Tringify can still ask about it.

## Receive a refund request

Tringify sends a signed request to your refund endpoint for one captured payment, named by `provider_transaction_id`, with the connection that took it. `refund_id` is the idempotency key: use it as the provider's idempotency key on every call, so a repeated request returns the same provider refund. The exact amount and currency come from Tringify's refund record and may be a full or partial refund.

```json
{
  "refund_id": "refund_…",
  "protocol_version": "1",
  "session_id": "session_…",
  "store_id": "store_…",
  "binding_id": "binding_…",
  "connection_key": "default",
  "order_id": "order_…",
  "provider_transaction_id": "provider_payment_…",
  "amount": "499.00",
  "currency_code": "USD",
  "reason": "Customer return"
}
```

```json
{
  "success": true,
  "provider_refund_id": "provider_refund_…",
  "status": "refunded"
}
```

Answer 2xx with `status`: `refunded` when the provider completed it, `pending` when the provider accepted it without a final result, or `failed` when the provider refused it. Refuse a refund you cannot make with a definite 4xx and `error_code` and `error_message`; it becomes `failed` without another request. Never answer HTTP 200 with `success: false`. A 2xx whose `status` is missing or unreadable counts as `pending`.

## Refund retries and deadlines

Tringify sends a refund request again, with the same `refund_id`, amount and currency, after a timeout before response headers, a transport failure, a refused redirect, a 408, 429 or 5xx. It sends at most 10 requests; the waits between them are 2, 4, 8, 16, 32, 64, 128, 256, 256 minutes, about 13 hours in all. If none is answered, the refund stays `pending`, marked as needing reconciliation, and its amount stays reserved.

## Answer a refund status request

While a refund is `pending`, Tringify asks your refund-status endpoint at intervals of 15 seconds, 30 seconds, 1 minute, 2 minutes and 5 minutes from when it became pending, then every 5 minutes until it is final, and also when your app sends a wake for it. Refunds have no expiry.

```json
{
  "refund_id": "refund_…",
  "protocol_version": "1",
  "session_id": "session_…",
  "store_id": "store_…",
  "binding_id": "binding_…",
  "connection_key": "default",
  "provider_transaction_id": "provider_payment_…",
  "provider_refund_id": "provider_refund_…"
}
```

Look the refund up at the provider by `refund_id` and answer in the shape of a refund response: `refunded`, `pending` or `failed`. Answer `pending` for a refund the provider does not know yet: a request may still be on its way. Answer `failed` only when the provider confirms the refund failed or never happened; Tringify stops asking after `refunded` or `failed`, and `refunded` is final. A timeout or non-2xx is asked again at the next check.

If the customer was refunded another way, the store owner can mark a refund that needs reconciliation as settled outside Tringify. It then completes as `refunded`.

