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

# Process a test payment

> Creates a new payment. Requires an idempotency key to prevent duplicate payments on retry.
    
## Idempotency Key Best Practices

1. **Generate unique keys**: Use UUIDs or similar unique identifiers, prefixed with a descriptive operation name
2. **Store keys client-side**: Save the key with the original request so you can retry with the same key
3. **Key format**: Between 6-64 alphanumeric characters
4. **Expiration**: Keys expire after 24 hours by default
5. **Use case**: Perfect for ensuring payment operations are never processed twice, even during network failures

## Example Request (curl)

```bash
curl -X POST \
  https://api.example.com/rest-api/v0/test-payment \
  -H 'Content-Type: application/json' \
  -H 'Client-Key: your-api-key' \
  -H 'Client-Secret: your-api-secret' \
  -H 'Idempotency-Key: payment_123456_unique_key' \
  -d '{
    "amount": 100.00,
    "currency": "USD",
    "description": "Test payment for order #12345",
    "customerId": "cus_12345"
  }'
```

## Example Response (First Request)

```json
{
  "id": "pay_abc123xyz456",
  "amount": 100.00,
  "currency": "USD",
  "status": "succeeded",
  "timestamp": "2023-07-01T12:00:00.000Z"
}
```

## Example Response (Duplicate Request)

The exact same response will be returned for any duplicate request with the same idempotency key, without creating a new payment.

## Retry Scenario Example

Network failure during payment submission:
1. Client creates payment request with idempotency key: "payment_123456_unique_key"
2. Request begins processing, but network connection fails before response received
3. Client retries the exact same request with the same idempotency key
4. Server detects duplicate idempotency key and returns the result of the first request
5. No duplicate payment is created

If you retry with same key but different parameters (e.g., different amount), you'll receive a 409 Conflict error.



## OpenAPI

````yaml /swagger.yml post /api/v0/test-payment
openapi: 3.0.0
info:
  title: Devdraft AI Payment & Business Management API
  description: >-

    A comprehensive payment processing and business management API that enables
    seamless integration of cryptocurrency and traditional payment methods.
        
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.devdraft.ai
    description: Production Server
security: []
tags: []
paths:
  /api/v0/test-payment:
    post:
      tags:
        - Test Payments
      summary: Process a test payment
      description: >-
        Creates a new payment. Requires an idempotency key to prevent duplicate
        payments on retry.
            
        ## Idempotency Key Best Practices


        1. **Generate unique keys**: Use UUIDs or similar unique identifiers,
        prefixed with a descriptive operation name

        2. **Store keys client-side**: Save the key with the original request so
        you can retry with the same key

        3. **Key format**: Between 6-64 alphanumeric characters

        4. **Expiration**: Keys expire after 24 hours by default

        5. **Use case**: Perfect for ensuring payment operations are never
        processed twice, even during network failures


        ## Example Request (curl)


        ```bash

        curl -X POST \
          https://api.example.com/rest-api/v0/test-payment \
          -H 'Content-Type: application/json' \
          -H 'Client-Key: your-api-key' \
          -H 'Client-Secret: your-api-secret' \
          -H 'Idempotency-Key: payment_123456_unique_key' \
          -d '{
            "amount": 100.00,
            "currency": "USD",
            "description": "Test payment for order #12345",
            "customerId": "cus_12345"
          }'
        ```


        ## Example Response (First Request)


        ```json

        {
          "id": "pay_abc123xyz456",
          "amount": 100.00,
          "currency": "USD",
          "status": "succeeded",
          "timestamp": "2023-07-01T12:00:00.000Z"
        }

        ```


        ## Example Response (Duplicate Request)


        The exact same response will be returned for any duplicate request with
        the same idempotency key, without creating a new payment.


        ## Retry Scenario Example


        Network failure during payment submission:

        1. Client creates payment request with idempotency key:
        "payment_123456_unique_key"

        2. Request begins processing, but network connection fails before
        response received

        3. Client retries the exact same request with the same idempotency key

        4. Server detects duplicate idempotency key and returns the result of
        the first request

        5. No duplicate payment is created


        If you retry with same key but different parameters (e.g., different
        amount), you'll receive a 409 Conflict error.
      operationId: TestPaymentController_createPayment_v0
      parameters:
        - name: idempotency-key
          in: header
          description: >-
            Unique key to ensure the request is idempotent. If a request with
            the same key is sent multiple times, only the first will be
            processed, and subsequent requests will return the same response.
          required: true
          schema:
            type: string
            format: uuid
            example: payment_123456_unique_key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentRequestDto'
      responses:
        '201':
          description: Payment processed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentResponseDto'
        '400':
          description: |-
            Bad Request. The idempotency key is missing or invalid.
              
            Sample response:
            ```json
            {
              "statusCode": 400,
              "message": "The idempotency-key header is required for POST requests"
            }
            ```
        '401':
          description: Unauthorized. Client key or secret is invalid or missing.
        '409':
          description: >-
            Idempotency Conflict. The provided idempotency key was already used
            with different parameters.
              
            Sample response:

            ```json

            {
              "statusCode": 409,
              "message": "Conflict: Idempotency key already used with different request data"
            }

            ```
        '429':
          description: Too many requests, rate limit exceeded.
      security:
        - x-client-secret: []
        - x-client-key: []
components:
  schemas:
    PaymentRequestDto:
      type: object
      properties:
        amount:
          type: number
          description: The amount to charge
          example: 100.5
        currency:
          type: string
          description: The currency code
          example: USD
        description:
          type: string
          description: Description of the payment
          example: Test payment for API
        customerId:
          type: string
          description: Customer reference ID
          example: cus_12345
      required:
        - amount
        - currency
        - description
    PaymentResponseDto:
      type: object
      properties:
        id:
          type: string
          description: Payment ID
          example: pay_12345abcdef
        amount:
          type: number
          description: The amount charged
          example: 100.5
        currency:
          type: string
          description: The currency code
          example: USD
        status:
          type: string
          description: Payment status
          example: succeeded
        timestamp:
          type: string
          description: Timestamp of the payment
          example: '2023-07-01T12:00:00.000Z'
      required:
        - id
        - amount
        - currency
        - status
        - timestamp
  securitySchemes:
    x-client-secret:
      type: apiKey
      in: header
      name: x-client-secret
      description: >-
        Your secret API key. Keep this secure and never expose it in client-side
        code.
    x-client-key:
      type: apiKey
      in: header
      name: x-client-key
      description: Your unique client API key. Obtain this from your Devdraft AI dashboard.

````