---
title: "Record or reverse an outside payment"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.nicer.travel/llms.txt
> Use this file to discover all available pages before exploring further.

# Record or reverse an outside payment

Path: Nicer API › Commerce

`POST /commerce/external-payments`

URL: `https://api.nicer.travel/commerce/external-payments`

Books a payment that happened outside the platform, by bank transfer, cash, cheque or card, against an order or an itinerary item, with a receipt asset and its checksum; or reverses a previously recorded one with a reason. Requires an authenticated company user and an `Idempotency-Key`.

## Authentication

- `bearerAuth`, http bearer, header `Authorization`, format `JWT`

## Header parameters

- `Idempotency-Key` (`commerce.externalPayments.create.header.Idempotency-Key`; string, required) — Unique key (8–255 chars) per request; replays return the original result.
- `x-nicer-company` (`commerce.externalPayments.create.header.x-nicer-company`; string, required) — Company context. Authentication and tenant membership are validated by the API.

## Request body

_Required._

Every option has:

- `type` (`<option>.type`; string, required)

One of the following, each adding:

- `object` (`commerce.externalPayments.create.1`)
  - `amount` (`commerce.externalPayments.create.1.amount`; object, required)
    - `amountMinor` (`commerce.externalPayments.create.1.amount.amountMinor`; integer, required)
      - maximum: `100000000`
    - `currency` (`commerce.externalPayments.create.1.amount.currency`; string, required)
      - pattern: `^[A-Z]{3}$`
  - `target` (`commerce.externalPayments.create.1.target`; one of, required)
    - every option has:
      - `kind` (`<option>.kind`; string, required)
    - one of the following, each adding:
      - `object` (`commerce.externalPayments.create.1.target.1`)
        - `orderId` (`commerce.externalPayments.create.1.target.1.orderId`; string, required)
          - minLength: `1`
      - `object` (`commerce.externalPayments.create.1.target.2`)
        - `itineraryItemId` (`commerce.externalPayments.create.1.target.2.itineraryItemId`; string, required)
          - minLength: `1`
        - `travelersTripId` (`commerce.externalPayments.create.1.target.2.travelersTripId`; string, required)
          - minLength: `1`
  - `paidAt` (`commerce.externalPayments.create.1.paidAt`; string, required)
    - format: `date-time` · pattern: `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$`
  - `payee` (`commerce.externalPayments.create.1.payee`; string, required)
    - maxLength: `200` · minLength: `1`
  - `paymentMethod` (`commerce.externalPayments.create.1.paymentMethod`; string, required)
    - one of `"BANK_TRANSFER"`, `"CARD"`, `"CASH"`, `"CHECK"`, `"OTHER"`
  - `providerReference` (`commerce.externalPayments.create.1.providerReference`; string, required)
    - maxLength: `255` · minLength: `1`
  - `purpose` (`commerce.externalPayments.create.1.purpose`; string, required)
    - one of `"DEPOSIT"`, `"FULL_PAYMENT"`, `"GUARANTEE"`, `"OTHER"`
  - `receipt` (`commerce.externalPayments.create.1.receipt`; object, required)
    - `assetKey` (`commerce.externalPayments.create.1.receipt.assetKey`; string, required)
      - maxLength: `1024` · minLength: `1`
    - `checksumSha256` (`commerce.externalPayments.create.1.receipt.checksumSha256`; string, required)
      - pattern: `^[a-f0-9]{64}$`
- `object` (`commerce.externalPayments.create.2`)
  - `externalPaymentId` (`commerce.externalPayments.create.2.externalPaymentId`; string, required)
    - minLength: `1`
  - `reason` (`commerce.externalPayments.create.2.reason`; string, required)
    - maxLength: `500` · minLength: `1`

## Example request

```json
{
  "amount": {
    "amountMinor": 100000000,
    "currency": "string"
  },
  "target": {
    "kind": "ORDER",
    "orderId": "string"
  },
  "paidAt": "2019-08-24T14:15:22Z",
  "payee": "string",
  "paymentMethod": "BANK_TRANSFER",
  "providerReference": "string",
  "purpose": "DEPOSIT",
  "receipt": {
    "assetKey": "string",
    "checksumSha256": "string"
  },
  "type": "RECORD"
}
```

## Code samples

### JavaScript SDK

```javascript
import { createClient } from "@nicertravel/sdk";

const nicer = createClient({
  baseUrl: "https://api.nicer.travel",
  token: process.env.NICER_TOKEN,
  headers: { "Idempotency-Key": process.env.NICER_IDEMPOTENCY_KEY, "x-nicer-company": process.env.NICER_COMPANY },
});

await nicer.commerce.externalPayments.create({
  "amount": {
    "amountMinor": 100000000,
    "currency": "string"
  },
  "target": {
    "kind": "ORDER",
    "orderId": "string"
  },
  "paidAt": "2019-08-24T14:15:22Z",
  "payee": "string",
  "paymentMethod": "BANK_TRANSFER",
  "providerReference": "string",
  "purpose": "DEPOSIT",
  "receipt": {
    "assetKey": "string",
    "checksumSha256": "string"
  },
  "type": "RECORD"
});
```

### Nicer CLI

```bash
nicer commerce external-payments create --company "$NICER_COMPANY" --input - <<'JSON'
{
  "amount": {
    "amountMinor": 100000000,
    "currency": "string"
  },
  "target": {
    "kind": "ORDER",
    "orderId": "string"
  },
  "paidAt": "2019-08-24T14:15:22Z",
  "payee": "string",
  "paymentMethod": "BANK_TRANSFER",
  "providerReference": "string",
  "purpose": "DEPOSIT",
  "receipt": {
    "assetKey": "string",
    "checksumSha256": "string"
  },
  "type": "RECORD"
}
JSON
```

### cURL

```bash
curl --request POST \
  --url https://api.nicer.travel/commerce/external-payments \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: string' \
  --header 'x-nicer-company: string' \
  --data '
{
  "amount": {
    "amountMinor": 100000000,
    "currency": "string"
  },
  "target": {
    "kind": "ORDER",
    "orderId": "string"
  },
  "paidAt": "2019-08-24T14:15:22Z",
  "payee": "string",
  "paymentMethod": "BANK_TRANSFER",
  "providerReference": "string",
  "purpose": "DEPOSIT",
  "receipt": {
    "assetKey": "string",
    "checksumSha256": "string"
  },
  "type": "RECORD"
}
'
```

### TypeScript

```typescript
const url = 'https://api.nicer.travel/commerce/external-payments';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Idempotency-Key': 'string',
    'x-nicer-company': 'string',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({
    amount: {amountMinor: 100000000, currency: 'string'},
    target: {kind: 'ORDER', orderId: 'string'},
    paidAt: '2019-08-24T14:15:22Z',
    payee: 'string',
    paymentMethod: 'BANK_TRANSFER',
    providerReference: 'string',
    purpose: 'DEPOSIT',
    receipt: {assetKey: 'string', checksumSha256: 'string'},
    type: 'RECORD'
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.nicer.travel/commerce/external-payments"

payload = {
    "amount": {
        "amountMinor": 100000000,
        "currency": "string"
    },
    "target": {
        "kind": "ORDER",
        "orderId": "string"
    },
    "paidAt": "2019-08-24T14:15:22Z",
    "payee": "string",
    "paymentMethod": "BANK_TRANSFER",
    "providerReference": "string",
    "purpose": "DEPOSIT",
    "receipt": {
        "assetKey": "string",
        "checksumSha256": "string"
    },
    "type": "RECORD"
}
headers = {
    "Content-Type": "application/json",
    "Idempotency-Key": "string",
    "x-nicer-company": "string",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

OK

#### Example

```json
{
  "amount": {
    "amountMinor": 100000000,
    "currency": "string"
  },
  "externalPaymentId": "string",
  "itineraryItemId": "string",
  "orderId": "string",
  "paidAt": "2019-08-24T14:15:22Z",
  "recordedAt": "2019-08-24T14:15:22Z",
  "status": "RECORDED",
  "travelersTripId": "string"
}
```

Every option has:

- `externalPaymentId` (`<option>.externalPaymentId`; string, required)
  - minLength: `1`
- `status` (`<option>.status`; string, required)

One of the following, each adding:

- `object` (`commerce.externalPayments.create.response.200.1`)
  - `amount` (`commerce.externalPayments.create.response.200.1.amount`; object, required)
    - `amountMinor` (`commerce.externalPayments.create.response.200.1.amount.amountMinor`; integer, required)
      - maximum: `100000000`
    - `currency` (`commerce.externalPayments.create.response.200.1.amount.currency`; string, required)
      - pattern: `^[A-Z]{3}$`
  - `itineraryItemId` (`commerce.externalPayments.create.response.200.1.itineraryItemId`; any of, required)
    - any of the following: `string`, `null`
  - `orderId` (`commerce.externalPayments.create.response.200.1.orderId`; any of, required)
    - any of the following: `string`, `null`
  - `paidAt` (`commerce.externalPayments.create.response.200.1.paidAt`; string, required)
    - format: `date-time` · pattern: `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$`
  - `recordedAt` (`commerce.externalPayments.create.response.200.1.recordedAt`; string, required)
    - format: `date-time` · pattern: `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$`
  - `travelersTripId` (`commerce.externalPayments.create.response.200.1.travelersTripId`; any of, required)
    - any of the following: `string`, `null`
- `object` (`commerce.externalPayments.create.response.200.2`)
  - `reversedAt` (`commerce.externalPayments.create.response.200.2.reversedAt`; string, required)
    - format: `date-time` · pattern: `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$`
  - `reversalEntryId` (`commerce.externalPayments.create.response.200.2.reversalEntryId`; string, required)
    - minLength: `1`

### 400

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`commerce.externalPayments.create.response.400.errorCode`; string, required)
- `errorMessage` (`commerce.externalPayments.create.response.400.errorMessage`; string, required)

### 401

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`commerce.externalPayments.create.response.401.errorCode`; string, required)
- `errorMessage` (`commerce.externalPayments.create.response.401.errorMessage`; string, required)

### 403

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`commerce.externalPayments.create.response.403.errorCode`; string, required)
- `errorMessage` (`commerce.externalPayments.create.response.403.errorMessage`; string, required)


Source: https://docs.nicer.travel/api/Commerce/commerce.externalPayments.create/index.md
