---
title: "Submit a payment for an order"
---

> 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.

# Submit a payment for an order

Path: Nicer API › Commerce

`POST /commerce/orders/{orderId}/payments`

URL: `https://api.nicer.travel/commerce/orders/{orderId}/payments`

Submits a payment attempt against the order and returns the outcome, including any next action the client must perform, such as card authentication. Requires an `Idempotency-Key`. Reachable without a token so a traveler can pay from a checkout link.

## Authentication

Requires one of the following:

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

## Path parameters

- `orderId` (`commerce.orders.payments.create.path.orderId`; string, required)

## Header parameters

- `Idempotency-Key` (`commerce.orders.payments.create.header.Idempotency-Key`; string, required) — Unique key (8–255 chars) per request; replays return the original result.

## Request body

_Required._

- `method` (`commerce.orders.payments.create.method`; one of, required)
  - every option has:
    - `kind` (`<option>.kind`; string, required)
  - one of the following, each adding:
    - `object` (`commerce.orders.payments.create.method.1`)
    - `object` (`commerce.orders.payments.create.method.2`)
      - `paymentMethodId` (`commerce.orders.payments.create.method.2.paymentMethodId`; string, required)
        - maxLength: `255` · minLength: `1`
    - `object` (`commerce.orders.payments.create.method.3`)
      - `paymentCredentialId` (`commerce.orders.payments.create.method.3.paymentCredentialId`; string, required)
        - maxLength: `255` · minLength: `1`
- `saveFor` (`commerce.orders.payments.create.saveFor`; one of, optional)
  - default: `{"kind":"NONE"}`
  - every option has:
    - `kind` (`<option>.kind`; string, required)
  - one of the following, each adding:
    - `object` (`commerce.orders.payments.create.saveFor.1`)
    - `object` (`commerce.orders.payments.create.saveFor.2`)
    - `object` (`commerce.orders.payments.create.saveFor.3`)
      - `consentAccepted` (`commerce.orders.payments.create.saveFor.3.consentAccepted`; boolean, required)
      - `travelersTripId` (`commerce.orders.payments.create.saveFor.3.travelersTripId`; string, required)
        - minLength: `1`
    - `object` (`commerce.orders.payments.create.saveFor.4`)
      - `consentAccepted` (`commerce.orders.payments.create.saveFor.4.consentAccepted`; boolean, required)
      - `consentCopy` (`commerce.orders.payments.create.saveFor.4.consentCopy`; string, required) — The statement the payer accepted: the order's saveCardConsentCopy exactly as shown. The server refuses the payment's save when it is no longer the statement for the order's advisor.
        - minLength: `1`

## Example request

```json
{
  "method": {
    "kind": "NEW"
  },
  "saveFor": {
    "kind": "NONE"
  }
}
```

## 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 },
});

await nicer.commerce.orders.payments.create({
  "orderId": "string",
  "method": {
    "kind": "NEW"
  }
});
```

### Nicer CLI

```bash
nicer commerce orders payments create --order-id 'string' --input - <<'JSON'
{
  "method": {
    "kind": "NEW"
  }
}
JSON
```

### cURL

```bash
curl --request POST \
  --url 'https://api.nicer.travel/commerce/orders/<orderId>/payments' \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: string' \
  --data '
{
  "method": {
    "kind": "NEW"
  },
  "saveFor": {
    "kind": "NONE"
  }
}
'
```

### TypeScript

```typescript
const url = 'https://api.nicer.travel/commerce/orders/<orderId>/payments';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', 'Idempotency-Key': 'string'},
  body: JSON.stringify({method: {kind: 'NEW'}, saveFor: {kind: 'NONE'}})
};

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/orders/<orderId>/payments"

payload = {
    "method": { "kind": "NEW" },
    "saveFor": { "kind": "NONE" }
}
headers = {
    "Content-Type": "application/json",
    "Idempotency-Key": "string"
}

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

print(response.text)
```

## Responses

### 200

OK

#### Example

```json
{
  "amount": {
    "amountMinor": 9007199254740991,
    "currency": "string"
  },
  "createdAt": "2019-08-24T14:15:22Z",
  "nextAction": {
    "clientSecret": "string",
    "type": "CONFIRM_NICER_PAYMENT"
  },
  "paymentAttemptId": "string",
  "purpose": "NICER_CHARGE",
  "reason": {
    "code": "string",
    "message": "string",
    "retryable": true
  },
  "status": "REQUIRES_ACTION",
  "usedMethod": {
    "brand": "string",
    "funding": "string",
    "last4": "string",
    "wallet": "string"
  }
}
```

Any of the following:

- `PaymentAttempt`
  - `amount` (`PaymentAttempt.amount`; object, required)
    - `amountMinor` (`PaymentAttempt.amount.amountMinor`; integer, required)
      - maximum: `9007199254740991` · minimum: `0`
    - `currency` (`PaymentAttempt.amount.currency`; string, required)
      - pattern: `^[A-Z]{3}$`
  - `createdAt` (`PaymentAttempt.createdAt`; 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))$`
  - `nextAction` (`PaymentAttempt.nextAction`; any of, required)
    - any of the following:
      - `Option 1`
        - one of the following:
          - `object`
            - `type` (`PaymentAttempt.nextAction.1.1.type`; string, required)
            - `clientSecret` (`PaymentAttempt.nextAction.1.1.clientSecret`; string, optional) — Stripe's client secret, to finish the action (3-D Secure) in the browser. Only the payer gets it: the caller who submitted the payment, and on the order a caller on its pay flow (through the order's payment link or checkout session) or the signed-in user the order records as its payer.
              - minLength: `1`
      - `null`
  - `paymentAttemptId` (`PaymentAttempt.paymentAttemptId`; string, required)
    - minLength: `1`
  - `purpose` (`PaymentAttempt.purpose`; string, required)
    - one of `"NICER_CHARGE"`, `"PROVIDER_GUARANTEE"`, `"PROVIDER_PAYMENT"`
  - `reason` (`PaymentAttempt.reason`; any of, required)
    - any of the following:
      - `object`
        - `code` (`PaymentAttempt.reason.1.code`; string, required)
          - minLength: `1`
        - `message` (`PaymentAttempt.reason.1.message`; string, required)
          - minLength: `1`
        - `retryable` (`PaymentAttempt.reason.1.retryable`; boolean, required)
      - `null`
  - `status` (`PaymentAttempt.status`; string, required)
    - one of `"REQUIRES_ACTION"`, `"AUTHORIZED"`, `"PROCESSING"`, `"SUCCEEDED"`, `"DECLINED"`, `"UNKNOWN"`, `"CANCELLED"`
  - `usedMethod` (`PaymentAttempt.usedMethod`; any of, optional)
    - any of the following:
      - `object`
        - `brand` (`PaymentAttempt.usedMethod.1.brand`; any of, required)
          - any of the following: `string`, `null`
        - `last4` (`PaymentAttempt.usedMethod.1.last4`; any of, required)
          - any of the following: `string`, `null`
        - `funding` (`PaymentAttempt.usedMethod.1.funding`; any of, optional) — Credit, debit or prepaid. Only the order's payer and Nicer staff get it.
          - any of the following: `string`, `null`
        - `wallet` (`PaymentAttempt.usedMethod.1.wallet`; any of, optional) — The wallet that paid (Apple Pay, Google Pay). Only the order's payer and Nicer staff get it.
          - any of the following: `string`, `null`
      - `null`
- `object`
  - `action` (`commerce.orders.payments.create.response.200.2.action`; object, required)
    - `token` (`commerce.orders.payments.create.response.200.2.action.token`; string, required)
      - minLength: `1`
    - `url` (`commerce.orders.payments.create.response.200.2.action.url`; string, required)
      - minLength: `1`
  - `collectionId` (`commerce.orders.payments.create.response.200.2.collectionId`; string, required)
    - minLength: `1`
  - `expiresAt` (`commerce.orders.payments.create.response.200.2.expiresAt`; 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))$`
  - `status` (`commerce.orders.payments.create.response.200.2.status`; string, required)
  - `type` (`commerce.orders.payments.create.response.200.2.type`; string, required)

### 400

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

#### Example

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

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

### 401

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

#### Example

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

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

### 403

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

#### Example

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

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


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