# API reference: Payments

> The Payments endpoints (4 operations), generated from the OpenAPI document (https://faraatarjomeh.com/api/v1/openapi.json). For task-level walkthroughs use the guides; for error handling use /api/v1/docs/errors. The full reference: /api/v1/docs/reference.

## At a glance

- Auth on every call: `Authorization: Bearer $FARA_API_KEY`
- `scope`: `read` for GET/HEAD, `write` for the rest
- **spends Fara**: the call holds or charges Fara; get the price first and send `Idempotency-Key`
- Path parameters in the examples are shell variables (`$JOB_ID`, `$ID` …)
- Errors: `application/problem+json` with a stable `code` (not repeated per endpoint below)

## Index

- **Payments**: [GET /api/v1/payment/packages](#listFaraPackages), [GET /api/v1/payment/packages/public](#listPublicFaraPackages), [GET /api/v1/payment/status/{authority}](#getPaymentStatus), [GET /api/v1/payment/history](#listPayments)

## Payments

Fara packages and past payments. Buying happens on the website.

<a id="listFaraPackages"></a>
### GET /api/v1/payment/packages

List Fara packages

- operationId `listFaraPackages` · scope `read` · free

Buying happens on the website; it is not available over the API.

**Response `200`**

[`PaymentPackages`](#schema-payment-packages)

**Responses**

- `200` Packages. (`application/json`)
- Errors: `401`, `403`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/payment/packages" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="listPublicFaraPackages"></a>
### GET /api/v1/payment/packages/public

List Fara packages (public copy)

- operationId `listPublicFaraPackages` · scope `read` · free

**Response `200`**

[`PaymentPackages`](#schema-payment-packages)

**Responses**

- `200` Packages. (`application/json`)
- Errors: `401`, `403`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/payment/packages/public" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="getPaymentStatus"></a>
### GET /api/v1/payment/status/{authority}

Get the status of a payment

- operationId `getPaymentStatus` · scope `read` · free

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `authority` | path | string | yes | Payment authority code from the payment gateway. |

**Response `200`**

[`PaymentStatus`](#schema-payment-status)

**Responses**

- `200` Status. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/payment/status/$AUTHORITY" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="listPayments"></a>
### GET /api/v1/payment/history

List payments

- operationId `listPayments` · scope `read` · free

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `page` | query | integer | no | Page number, starting at 1. — default: `1`; min 1 |
| `limit` | query | integer | no | Items per page (1-100). — default: `20`; min 1; max 100 |

**Response `200`**

[`PaymentHistory`](#schema-payment-history)

**Responses**

- `200` One page. (`application/json`)
- Errors: `401`, `403`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/payment/history" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

## Schemas

Named request and response objects used above. Nested objects are flattened as `parent.child`; arrays as `parent[].child`.

<a id="schema-payment-history"></a>
### PaymentHistory

| Field | Type | Required | Notes |
|---|---|---|---|
| `payments` | object[] | yes |  |
| `total` | integer | yes |  |
| `page` | integer | yes |  |
| `limit` | integer | no |  |
| `totalPages` | integer | yes |  |

<a id="schema-payment-packages"></a>
### PaymentPackages

| Field | Type | Required | Notes |
|---|---|---|---|
| `vatRate` | number | no | Value added tax added at checkout, as a fraction (0.1 means 10%). |
| `packages` | object[] | yes |  |
| `packages[].id` | string | no |  |
| `packages[].priceTomans` | number | no | Listed pack price in toman, before value added tax. |
| `packages[].vatTomans` | number | no | Value added tax on this pack in toman (price × `vatRate`, rounded to the nearest toman, halves up). |
| `packages[].totalTomans` | number | no | What you pay on the website: `priceTomans` + `vatTomans`. |
| `packages[].creditFara` | number | no | Fara you get. VAT does not change it. |
| `packages[].perFara` | number | no |  |
| `packages[].discount` | number | no |  |
| `packages[].shelf` | string | no |  |
| `packages[].description` | string | no |  |
| `gatewayEnabled` | boolean | no | Whether buying is open right now (on the website). |

<a id="schema-payment-status"></a>
### PaymentStatus

| Field | Type | Required | Notes |
|---|---|---|---|
| `authority` | string | no |  |
| `status` | string | no |  |
| `refId` | string \| null | no | Bank reference, when completed. — may be null |
