> For the complete documentation index, see [llms.txt](https://plexo.gitbook.io/rest-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://plexo.gitbook.io/rest-api/core-concepts/transaction-lifecycle.md).

# Payment and Transaction Lifecycle

## Overview

A `PaymentDto` is the top-level record for a payment attempt. Its `transactions` array records the individual operations performed on that payment, such as a purchase, an authorization, a capture, a cancellation, or a refund.

Use the payment `status` for the current overall state. Use `transactions` when you need the detailed history of what happened during processing.

## Canonical payment statuses

These are the current public payment status values exposed by the backend.

| Status               | Meaning                                                                  |
| -------------------- | ------------------------------------------------------------------------ |
| `created`            | The payment object was created and processing has not completed yet.     |
| `pending`            | The processor or a customer step is still in progress.                   |
| `authorized`         | Funds were authorized but not yet captured.                              |
| `approved`           | Funds were successfully captured, or the purchase completed in one step. |
| `denied`             | The payment was declined.                                                |
| `cancelled`          | An authorized payment was cancelled before capture.                      |
| `refunded`           | The full captured amount was refunded.                                   |
| `partially-refunded` | Part of the captured amount was refunded.                                |
| `expired`            | The authorization expired before capture.                                |
| `failed`             | Processing failed for a technical or processor-side reason.              |

## Canonical transaction statuses

These are the current transaction status values used in payment transaction records.

| Status     | Meaning                                                      |
| ---------- | ------------------------------------------------------------ |
| `created`  | The transaction record was created.                          |
| `pending`  | The transaction is still being processed.                    |
| `approved` | The transaction completed successfully.                      |
| `denied`   | The transaction was declined.                                |
| `expired`  | The transaction expired before completion.                   |
| `failed`   | The transaction failed due to a technical or upstream error. |

## Common flows

### Purchase flow

Use `POST /v1/payments` with `capture.method = automatic` when you want a single-step purchase.

```json
{
  "merchantId": 12345,
  "referenceId": "order-1001",
  "invoiceNumber": "1001",
  "amount": {
    "total": 100.00,
    "currency": "UYU"
  },
  "paymentMethod": {
    "source": "card",
    "card": {
      "number": "4111111111111111",
      "expMonth": 12,
      "expYear": 2028,
      "cvc": "123",
      "cardholder": {
        "firstName": "Test",
        "lastName": "User"
      }
    }
  },
  "browserDetails": {
    "ipAddress": "203.0.113.10",
    "userAgent": "Mozilla/5.0"
  },
  "capture": {
    "method": "automatic"
  }
}
```

Typical status path:

```
created -> pending -> approved
```

If the processor declines the request or a customer step fails, the payment can end in `denied` or `failed` instead.

### Authorization and later capture

Use `POST /v1/payments` with `capture.method = manual` when you want to authorize first and capture later.

```json
{
  "merchantId": 12345,
  "referenceId": "order-2001",
  "invoiceNumber": "2001",
  "amount": {
    "total": 250.00,
    "currency": "UYU"
  },
  "paymentMethod": {
    "source": "card",
    "card": {
      "number": "4111111111111111",
      "expMonth": 12,
      "expYear": 2028,
      "cvc": "123",
      "cardholder": {
        "firstName": "Test",
        "lastName": "User"
      }
    }
  },
  "browserDetails": {
    "ipAddress": "203.0.113.10",
    "userAgent": "Mozilla/5.0"
  },
  "capture": {
    "method": "manual"
  }
}
```

Typical status path after payment creation:

```
created -> pending -> authorized
```

Capture the authorized payment later with:

```
POST /v1/payments/{paymentId}/captures
```

After a successful capture, the payment moves to `approved`.

### Cancellation before capture

Cancel an authorized payment with:

```
POST /v1/payments/{paymentId}/cancellations
```

This route is for payments that are still in `authorized` state. After a successful cancellation, the payment moves to `cancelled`.

Typical status path:

```
authorized -> cancelled
```

Example cancellation request:

```json
{
  "referenceId": "cancel-order-2001",
  "reason": "order-cancelled",
  "description": "Order cancelled before shipment"
}
```

Use cancellation to release an authorization hold before settlement. If the payment was already captured, use the refund route instead.

### Refund after capture

Refund a captured payment with:

```
POST /v1/payments/{paymentId}/refunds
```

After a partial refund, the payment status becomes `partially-refunded`. After the full captured amount is refunded, the payment status becomes `refunded`.

Refunds apply after capture. They are not the replacement for cancelling an uncaptured authorization.

### Payment-method verification

Use `POST /v1/payments/verify` when you need to validate a card or token without creating a normal charge flow.

The backend performs a small authorization and then triggers a cancellation flow for that verification attempt. Treat this route as a validation operation, not a settled payment.

## How to read a payment object

When you retrieve a payment, read it in this order:

1. Check `status` for the overall current state.
2. Review `transactions` to see the operations that produced that state.
3. Inspect `actions` when the payer must complete a redirect or 3DS step.

Example:

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "referenceId": "order-1001",
  "status": "approved",
  "amount": {
    "total": 100.00,
    "currency": "UYU"
  },
  "transactions": [
    {
      "id": "660e8400-e29b-41d4-a716-446655440001",
      "type": "purchase",
      "status": "approved"
    }
  ]
}
```

In this example, the payment is complete because the payment `status` is `approved` and the recorded transaction was an approved `purchase`.

## Related resources

* [Payment Processing Guide](/rest-api/payments/payment-processing.md)
* [Accepting Your First Payment](/rest-api/payments/first-payment.md)
* [Verifying a Payment Method](/rest-api/payments/payment-method-verification.md)
* [Error Codes Reference](/rest-api/reference/error-codes.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://plexo.gitbook.io/rest-api/core-concepts/transaction-lifecycle.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
