> Index of every page: https://docs.merchantservicedepot.com/llms.txt

# Create a payment


`POST /v1/payments`

Create a payment using exactly one funding source: a single-use payment token or a stored payment method. Capture immediately for a sale, or authorize now and capture later.

Auth: a secret key with the `payments.create` permission. Returns `201` with Payment.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `amount` | body | integer · integer · minor units | Yes | A non-negative integer in the currency’s minor unit. 4999 represents $49.99. |
| `currency` | body | string · ISO 4217 | Yes | A three-letter ISO 4217 currency code. |
| `capture` | body | boolean | No | When true, authorize and capture in one request. When false, authorize only. |
| `paymentToken` | body | string | No | A single-use token returned by Myela Elements or an approved card-capture field. |
| `paymentMethodId` | body | string | No | The reusable identifier of a stored payment method. |
| `amountBase` | body | integer · integer · minor units | No | The goods-or-service part of amount. Omit it to derive amount less the other parts; send it and all parts must sum to amount. |
| `amountSurcharge` | body | integer · integer · minor units | No | The surcharge part of amount. Recorded, not computed. |
| `amountTax` | body | integer · integer · minor units | No | The tax part of amount. Recorded, not computed. |
| `amountTip` | body | integer · integer · minor units | No | The tip part of amount. Recorded, not computed. |

## Request

**curl**

```curl
curl -X POST "https://payments-api-sandbox.merchantservicedepot.com/v1/payments" \
  -H "Authorization: Bearer $MYELA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "amount": 2500,
  "currency": "USD",
  "paymentToken": "{{PAYMENT_TOKEN}}",
  "capture": false
}'
```

**Node**

```node
const res = await fetch("https://payments-api-sandbox.merchantservicedepot.com/v1/payments", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MYELA_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    "amount": 2500,
    "currency": "USD",
    "paymentToken": "{{PAYMENT_TOKEN}}",
    "capture": false
  }),
});

if (!res.ok) {
  const { error } = await res.json();
  // Branch on error.code — never on error.message.
  throw new Error(error.code);
}
const data = await res.json();
```

**Python**

```python
import os
import uuid
import requests

res = requests.post(
    "https://payments-api-sandbox.merchantservicedepot.com/v1/payments",
    headers={
        "Authorization": f"Bearer {os.environ['MYELA_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "amount": 2500,
        "currency": "USD",
        "paymentToken": "{{PAYMENT_TOKEN}}",
        "capture": False
    },
)

if not res.ok:
    # Branch on error["code"] — never on error["message"].
    raise RuntimeError(res.json()["error"]["code"])
data = res.json()
```

## Response

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique payment identifier. |
| `object` | "payment" | Stable resource discriminator. |
| `status` | string | One of: requires_capture, pending_settlement, settled, declined, voided, refunded, partially_refunded, failed. pending_settlement means approved and captured — the dashboard shows this as 'Approved'. |
| `settled` | boolean | Has settlement completed — true from the moment it is reported, and it stays true through later refunds. Branch on this for reconciliation instead of comparing status strings. |
| `amount` | integer | Requested amount in minor units. |
| `amountAuthorized` | integer | Amount authorized in minor units. |
| `amountApproved` | integer | Present only when the issuer approved less than requested: the approved total in minor units. |
| `amountCaptured` | integer | Amount captured in minor units. |
| `amountRefunded` | integer | Amount refunded in minor units. |
| `currency` | string | Three-letter currency code. |
| `amountBase` | integer | Present only when the charge was composed of parts. With amountSurcharge, amountTax and amountTip it sums to amount, in minor units. |
| `amountSurcharge` | integer | Surcharge part, in minor units. |
| `amountTax` | integer | Tax part, in minor units. |
| `amountTip` | integer | Tip part, in minor units. |
| `failureCode` | string | Why the payment did not succeed. One of: card_declined, payment_declined, authentication_required, payment_method_invalid, payment_method_unsupported, payment_failed. |
| `failureMessage` | string | A safe, human-readable explanation. Present only alongside failureCode; branch on the code. |
| `amountAdjustable` | boolean | Whether the authorized total can still be adjusted, when the account reports it. |
| `authentication` | object | 3-D Secure outcome when reported: type, status and version only, never an authentication value. |
| `customerId` | string | Customer associated with the payment. |
| `paymentMethodId` | string | Stored payment method used. |
| `card` | object | Card brand and last four only. |
| `createdAt` | string | ISO 8601 creation timestamp. |

```json
{
  "id": "pay_01JEXAMPLE",
  "object": "payment",
  "status": "pending_settlement",
  "settled": false,
  "amount": 1299,
  "amountAuthorized": 1299,
  "amountApproved": 1000,
  "amountCaptured": 1299,
  "amountRefunded": 0,
  "currency": "USD",
  "amountBase": 1199,
  "amountSurcharge": 0,
  "amountTax": 100,
  "amountTip": 0,
  "failureCode": "card_declined",
  "failureMessage": "The payment was declined.",
  "amountAdjustable": false,
  "authentication": {
    "type": "three_d_secure",
    "status": "Y",
    "version": "2.2.0"
  },
  "customerId": "cus_01JEXAMPLE",
  "paymentMethodId": "pm_01JEXAMPLE",
  "card": {
    "brand": "visa",
    "last4": "4242"
  },
  "createdAt": "2026-08-10T20:49:51.653Z"
}
```

Source: https://docs.merchantservicedepot.com/api-reference/create-a-payment/
