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

# Create Payment

> Process a payment for an order or invoice

<Note>
  This endpoint processes payments through various payment methods and gateways. It supports credit cards, ACH, wire transfers, and digital wallets.
</Note>

## Authentication

This endpoint requires a valid API key with `payments:write` permissions.

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Request Body

<ParamField body="amount" type="integer" required>
  Payment amount in cents (e.g., 1000 for \$10.00)
</ParamField>

<ParamField body="currency" type="string" required>
  ISO 4217 currency code (e.g., "USD", "EUR")
</ParamField>

<ParamField body="payment_method" type="object" required>
  Payment method details

  <Expandable title="Payment method properties">
    <ParamField body="type" type="string" required>
      Payment type: "card", "ach", "wire", "paypal", "crypto"
    </ParamField>

    <ParamField body="card" type="object">
      Credit/debit card details (for type: "card")

      <Expandable title="Card properties">
        <ParamField body="number" type="string">
          Card number (will be tokenized)
        </ParamField>

        <ParamField body="exp_month" type="integer">
          Expiration month (1-12)
        </ParamField>

        <ParamField body="exp_year" type="integer">
          Expiration year (4 digits)
        </ParamField>

        <ParamField body="cvc" type="string">
          Card verification code
        </ParamField>

        <ParamField body="token" type="string">
          Pre-tokenized card token (alternative to raw card data)
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="ach" type="object">
      ACH bank transfer details (for type: "ach")

      <Expandable title="ACH properties">
        <ParamField body="account_number" type="string">
          Bank account number
        </ParamField>

        <ParamField body="routing_number" type="string">
          Bank routing number
        </ParamField>

        <ParamField body="account_type" type="string">
          Account type: "checking" or "savings"
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="order_id" type="string">
  Associated order ID
</ParamField>

<ParamField body="invoice_id" type="string">
  Associated invoice ID
</ParamField>

<ParamField body="customer_id" type="string" required>
  Customer ID making the payment
</ParamField>

<ParamField body="description" type="string">
  Payment description
</ParamField>

<ParamField body="statement_descriptor" type="string">
  Text to appear on customer's statement (max 22 chars)
</ParamField>

<ParamField body="capture" type="boolean">
  Whether to immediately capture the payment (default: true)
</ParamField>

<ParamField body="billing_address" type="object">
  Billing address for verification

  <Expandable title="Address properties">
    <ParamField body="line1" type="string">
      Street address
    </ParamField>

    <ParamField body="line2" type="string">
      Apartment/Suite number
    </ParamField>

    <ParamField body="city" type="string">
      City
    </ParamField>

    <ParamField body="state" type="string">
      State/Province code
    </ParamField>

    <ParamField body="postal_code" type="string">
      Postal/ZIP code
    </ParamField>

    <ParamField body="country" type="string">
      ISO 3166-1 alpha-2 country code
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="metadata" type="object">
  Additional custom fields
</ParamField>

### Response

Returns the created payment with processing status.

<RequestExample>
  ```bash cURL theme={null}
  curl --location --request POST 'https://api.stateset.com/v1/payments' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data-raw '{
      "amount": 15000,
      "currency": "USD",
      "payment_method": {
          "type": "card",
          "card": {
              "token": "tok_1234567890abcdef"
          }
      },
      "order_id": "order_123456",
      "customer_id": "cust_abc123",
      "description": "Payment for Order #123456",
      "capture": true
  }'
  ```

  ```javascript Node.js theme={null}
  const payment = await stateset.payments.create({
    amount: 15000,
    currency: "USD",
    payment_method: {
      type: "card",
      card: {
        token: "tok_1234567890abcdef"
      }
    },
    order_id: "order_123456",
    customer_id: "cust_abc123",
    description: "Payment for Order #123456",
    capture: true
  });
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "pay_0901f083-aa1c-43c5-af5c-0a9d2fc64e30",
    "object": "payment",
    "amount": 15000,
    "currency": "USD",
    "status": "succeeded",
    "captured": true,
    "created_at": "2024-01-19T15:30:00Z",
    "payment_method": {
      "type": "card",
      "card": {
        "last4": "4242",
        "brand": "visa",
        "exp_month": 12,
        "exp_year": 2025,
        "fingerprint": "Xt5EWLLDS7FJjR1c"
      }
    },
    "order_id": "order_123456",
    "customer_id": "cust_abc123",
    "description": "Payment for Order #123456",
    "receipt_url": "https://receipts.stateset.com/pay_0901f083-aa1c-43c5-af5c-0a9d2fc64e30",
    "processor_response": {
      "approved": true,
      "authorization_code": "123456",
      "avs_result": "Y",
      "cvv_result": "M",
      "network_transaction_id": "123456789"
    }
  }
  ```
</ResponseExample>
