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

# Create Payment

> Create a new payment request

Create a new payment request for cryptocurrency payment.

<ParamField path="amount" type="string" required>
  Payment amount in fiat currency
</ParamField>

<ParamField path="currency" type="string" required>
  Fiat currency code (USD, EUR, etc.)
</ParamField>

<ParamField path="customerId" type="string" required>
  Customer ID for the payment
</ParamField>

<ParamField path="orderId" type="string" required>
  Unique order identifier
</ParamField>

<ParamField path="metadata" type="object">
  Additional payment metadata
</ParamField>

<ParamField path="webhookUrl" type="string">
  Webhook URL for payment notifications
</ParamField>

<ParamField path="successUrl" type="string">
  URL to redirect on successful payment
</ParamField>

<ParamField path="returnUrl" type="string">
  URL to redirect on payment cancellation
</ParamField>

<ParamField path="allowedCryptos" type="array">
  Array of allowed cryptocurrencies (BTC, ETH, LTC, SOL)
</ParamField>

<ParamField path="customFields" type="object">
  Custom fields for the payment
</ParamField>

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="data.id" type="string">
  Payment ID for tracking
</ResponseField>

<ResponseField name="data.expiresAt" type="string">
  Payment expiration timestamp
</ResponseField>

## Example Request

```bash theme={null}
curl -X POST https://api.transaction.gg/payment/create \
  -H "Authorization: Bearer pk_your_public_key" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "29.99",
    "currency": "USD",
    "customerId": "cus_V6n6SN2KnsIFCuQU",
    "orderId": "order_123",
    "metadata": {
      "description": "Premium subscription"
    },
    "webhookUrl": "https://mystore.com/webhook",
    "successUrl": "https://mystore.com/success",
    "returnUrl": "https://mystore.com/cancel",
    "allowedCryptos": ["BTC", "ETH"],
    "customFields": {
      "customer_name": "John Doe"
    }
  }'
```

## Alternative with Product/Price

```bash theme={null}
curl -X POST https://api.transaction.gg/payment/create \
  -H "Authorization: Bearer pk_your_public_key" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": "prod_X4dUuzsMaruQ4UsX",
    "priceId": "price_i62wKFQ8sGnLxQ5G",
    "customerId": "cus_V6n6SN2KnsIFCuQU",
    "orderId": "order_123"
  }'
```

## Example Response

```json theme={null}
{
  "success": true,
  "data": {
    "id": "pay_abc123def456",
    "expiresAt": "2024-01-01T01:00:00Z"
  }
}
```

## Error Responses

<ResponseExample name="Invalid API Key">
  ```json theme={null}
  {
    "success": false,
    "error": {
      "status": 401,
      "code": "UNAUTHORISED",
      "message": "Invalid API key"
    },
    "data": null
  }
  ```
</ResponseExample>

<ResponseExample name="Customer Not Found">
  ```json theme={null}
  {
    "success": false,
    "error": {
      "status": 404,
      "code": "CUSTOMER_NOT_FOUND",
      "message": "Customer not found"
    },
    "data": null
  }
  ```
</ResponseExample>
