{
  "openapi": "3.1.0",
  "info": {
    "title": "Chainquay Payments API",
    "version": "1.0.0",
    "summary": "Accept Bitcoin, Litecoin, Ethereum, BNB, USDT and USDC with a hosted checkout and automatic settlement to your wallet.",
    "description": "Create a payment, send the customer to `checkoutUrl`, and fulfil the order when the `payment.confirmed` webhook arrives. Funds are settled automatically to the payout address configured in the dashboard, minus a 1% platform fee. Use `cq_test_…` keys while integrating.",
    "contact": {
      "name": "Chainquay",
      "email": "hello@chainquay.com",
      "url": "https://chainquay.com/contact"
    },
    "termsOfService": "https://chainquay.com/terms"
  },
  "externalDocs": {
    "description": "Developer guide",
    "url": "https://chainquay.com/developers"
  },
  "servers": [
    {
      "url": "https://api.chainquay.com",
      "description": "Production"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Payments"
    },
    {
      "name": "Refunds"
    },
    {
      "name": "Rates"
    },
    {
      "name": "Public"
    }
  ],
  "paths": {
    "/v1/payments": {
      "post": {
        "tags": [
          "Payments"
        ],
        "operationId": "createPayment",
        "summary": "Create a payment",
        "description": "Provide either `priceAmount` + `priceCurrency` (the crypto amount is locked at the current rate) or an exact `cryptoAmount`. Requires a payout address for the asset in the dashboard.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePayment"
              },
              "example": {
                "asset": "USDT_TRC20",
                "priceAmount": "49.99",
                "priceCurrency": "USD",
                "orderId": "order-1001",
                "successUrl": "https://shop.example/thanks"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Payment created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Payments"
        ],
        "operationId": "listPayments",
        "summary": "List payments",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/PaymentStatus"
            }
          },
          {
            "name": "asset",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "BTC",
                "LTC",
                "USDT_TRC20",
                "ETH",
                "USDC_ERC20",
                "USDT_ERC20",
                "BNB",
                "USDC_BEP20",
                "USDT_BEP20"
              ],
              "description": "BTC (Bitcoin), LTC (Litecoin), USDT_TRC20 (Tether on TRON), ETH (Ether), USDC_ERC20 / USDT_ERC20 (USDC / Tether on Ethereum), BNB, USDC_BEP20 / USDT_BEP20 (USDC / Tether on BNB Smart Chain)."
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Matches id, orderId, deposit address or customer email"
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of payments",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "page",
                    "pageSize",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Payment"
                      }
                    },
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payments/{id}": {
      "get": {
        "tags": [
          "Payments"
        ],
        "operationId": "getPayment",
        "summary": "Retrieve a payment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Payment id"
          }
        ],
        "responses": {
          "200": {
            "description": "The payment with deposits, settlement and refunds",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payments/{id}/cancel": {
      "post": {
        "tags": [
          "Payments"
        ],
        "operationId": "cancelPayment",
        "summary": "Cancel an unpaid payment",
        "description": "Only for status PENDING or EXPIRED.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Payment id"
          }
        ],
        "responses": {
          "201": {
            "description": "Cancelled payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payments/{id}/refunds": {
      "post": {
        "tags": [
          "Refunds"
        ],
        "operationId": "refundPayment",
        "summary": "Refund a payment",
        "description": "On-chain refund: allowed while the funds are still on the deposit address (UNDERPAID, late EXPIRED, SWEEP_BLOCKED, SWEEP_FAILED); everything on the address is sent to `address` minus the network fee. Manual refund: for CONFIRMED, SWEEPING or SETTLED payments, send the refund yourself and record it with `manualTxid` and `amount`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Payment id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRefund"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Refund created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refund"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/refunds": {
      "get": {
        "tags": [
          "Refunds"
        ],
        "operationId": "listRefunds",
        "summary": "List refunds",
        "responses": {
          "200": {
            "description": "Refunds, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Refund"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/rates": {
      "get": {
        "tags": [
          "Rates"
        ],
        "operationId": "getRates",
        "summary": "Current exchange rates",
        "parameters": [
          {
            "name": "fiat",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "USD",
                "EUR",
                "GBP"
              ],
              "default": "USD"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rate per asset: 1 unit of the asset = `rate` fiat",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "rate": {
                        "type": "number"
                      },
                      "source": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "BTC": {
                    "rate": 68250.12,
                    "source": "coingecko"
                  },
                  "LTC": {
                    "rate": 71.3,
                    "source": "coingecko"
                  },
                  "USDT_TRC20": {
                    "rate": 1,
                    "source": "coingecko"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/public/payments/{id}": {
      "get": {
        "tags": [
          "Public"
        ],
        "operationId": "getPublicPayment",
        "summary": "Public payment status (no auth)",
        "description": "What the hosted checkout shows; use it to build your own payment UI.",
        "security": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Payment id"
          }
        ],
        "responses": {
          "200": {
            "description": "Public status"
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "payment.detected": {
      "post": {
        "summary": "Transaction seen on-chain, 0 confirmations.",
        "description": "Sent to every enabled endpoint configured in Dashboard → Settings → Webhooks. Verify the `CQ-Signature` header: `t=<unix seconds>,v1=<hex>` where v1 = HMAC-SHA256(secret, \"<t>.<raw body>\"); reject if the timestamp is older than 5 minutes. Respond with any 2xx; failed deliveries are retried with backoff for up to 8 attempts. The same event may arrive more than once.",
        "parameters": [
          {
            "name": "CQ-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "CQ-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "payment.detected"
            }
          },
          {
            "name": "CQ-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged"
          }
        }
      }
    },
    "payment.confirming": {
      "post": {
        "summary": "At least one confirmation, fewer than required.",
        "description": "Sent to every enabled endpoint configured in Dashboard → Settings → Webhooks. Verify the `CQ-Signature` header: `t=<unix seconds>,v1=<hex>` where v1 = HMAC-SHA256(secret, \"<t>.<raw body>\"); reject if the timestamp is older than 5 minutes. Respond with any 2xx; failed deliveries are retried with backoff for up to 8 attempts. The same event may arrive more than once.",
        "parameters": [
          {
            "name": "CQ-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "CQ-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "payment.confirming"
            }
          },
          {
            "name": "CQ-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged"
          }
        }
      }
    },
    "payment.confirmed": {
      "post": {
        "summary": "Required confirmations reached. Fulfil the order.",
        "description": "Sent to every enabled endpoint configured in Dashboard → Settings → Webhooks. Verify the `CQ-Signature` header: `t=<unix seconds>,v1=<hex>` where v1 = HMAC-SHA256(secret, \"<t>.<raw body>\"); reject if the timestamp is older than 5 minutes. Respond with any 2xx; failed deliveries are retried with backoff for up to 8 attempts. The same event may arrive more than once.",
        "parameters": [
          {
            "name": "CQ-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "CQ-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "payment.confirmed"
            }
          },
          {
            "name": "CQ-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged"
          }
        }
      }
    },
    "payment.underpaid": {
      "post": {
        "summary": "Confirmed amount is below the requested amount; the customer can top up.",
        "description": "Sent to every enabled endpoint configured in Dashboard → Settings → Webhooks. Verify the `CQ-Signature` header: `t=<unix seconds>,v1=<hex>` where v1 = HMAC-SHA256(secret, \"<t>.<raw body>\"); reject if the timestamp is older than 5 minutes. Respond with any 2xx; failed deliveries are retried with backoff for up to 8 attempts. The same event may arrive more than once.",
        "parameters": [
          {
            "name": "CQ-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "CQ-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "payment.underpaid"
            }
          },
          {
            "name": "CQ-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged"
          }
        }
      }
    },
    "payment.settled": {
      "post": {
        "summary": "Funds arrived in the merchant payout wallet.",
        "description": "Sent to every enabled endpoint configured in Dashboard → Settings → Webhooks. Verify the `CQ-Signature` header: `t=<unix seconds>,v1=<hex>` where v1 = HMAC-SHA256(secret, \"<t>.<raw body>\"); reject if the timestamp is older than 5 minutes. Respond with any 2xx; failed deliveries are retried with backoff for up to 8 attempts. The same event may arrive more than once.",
        "parameters": [
          {
            "name": "CQ-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "CQ-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "payment.settled"
            }
          },
          {
            "name": "CQ-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged"
          }
        }
      }
    },
    "payment.expired": {
      "post": {
        "summary": "Payment window closed with nothing received (late payments are still detected).",
        "description": "Sent to every enabled endpoint configured in Dashboard → Settings → Webhooks. Verify the `CQ-Signature` header: `t=<unix seconds>,v1=<hex>` where v1 = HMAC-SHA256(secret, \"<t>.<raw body>\"); reject if the timestamp is older than 5 minutes. Respond with any 2xx; failed deliveries are retried with backoff for up to 8 attempts. The same event may arrive more than once.",
        "parameters": [
          {
            "name": "CQ-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "CQ-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "payment.expired"
            }
          },
          {
            "name": "CQ-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged"
          }
        }
      }
    },
    "payment.sweep_blocked": {
      "post": {
        "summary": "Stablecoin settlement is waiting for gas (TRX, ETH or BNB) in the merchant gas account.",
        "description": "Sent to every enabled endpoint configured in Dashboard → Settings → Webhooks. Verify the `CQ-Signature` header: `t=<unix seconds>,v1=<hex>` where v1 = HMAC-SHA256(secret, \"<t>.<raw body>\"); reject if the timestamp is older than 5 minutes. Respond with any 2xx; failed deliveries are retried with backoff for up to 8 attempts. The same event may arrive more than once.",
        "parameters": [
          {
            "name": "CQ-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "CQ-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "payment.sweep_blocked"
            }
          },
          {
            "name": "CQ-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged"
          }
        }
      }
    },
    "payment.refunded": {
      "post": {
        "summary": "Refund confirmed on-chain or recorded manually.",
        "description": "Sent to every enabled endpoint configured in Dashboard → Settings → Webhooks. Verify the `CQ-Signature` header: `t=<unix seconds>,v1=<hex>` where v1 = HMAC-SHA256(secret, \"<t>.<raw body>\"); reject if the timestamp is older than 5 minutes. Respond with any 2xx; failed deliveries are retried with backoff for up to 8 attempts. The same event may arrive more than once.",
        "parameters": [
          {
            "name": "CQ-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "CQ-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "payment.refunded"
            }
          },
          {
            "name": "CQ-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "cq_live_… / cq_test_…",
        "description": "API key from Dashboard → Settings → API keys. `X-Api-Key` header is also accepted."
      }
    },
    "schemas": {
      "Asset": {
        "type": "string",
        "enum": [
          "BTC",
          "LTC",
          "USDT_TRC20",
          "ETH",
          "USDC_ERC20",
          "USDT_ERC20",
          "BNB",
          "USDC_BEP20",
          "USDT_BEP20"
        ],
        "description": "BTC (Bitcoin), LTC (Litecoin), USDT_TRC20 (Tether on TRON), ETH (Ether), USDC_ERC20 / USDT_ERC20 (USDC / Tether on Ethereum), BNB, USDC_BEP20 / USDT_BEP20 (USDC / Tether on BNB Smart Chain)."
      },
      "PaymentStatus": {
        "type": "string",
        "enum": [
          "PENDING",
          "DETECTED",
          "CONFIRMING",
          "CONFIRMED",
          "UNDERPAID",
          "SWEEPING",
          "SWEEP_BLOCKED",
          "SWEEP_FAILED",
          "SETTLED",
          "EXPIRED",
          "CANCELLED",
          "REFUNDED"
        ],
        "description": "PENDING → DETECTED → CONFIRMING → CONFIRMED (paid) → SWEEPING → SETTLED. Also UNDERPAID, EXPIRED, CANCELLED, SWEEP_BLOCKED, SWEEP_FAILED, REFUNDED."
      },
      "CreatePayment": {
        "type": "object",
        "required": [
          "asset"
        ],
        "additionalProperties": false,
        "properties": {
          "asset": {
            "type": "string",
            "enum": [
              "BTC",
              "LTC",
              "USDT_TRC20",
              "ETH",
              "USDC_ERC20",
              "USDT_ERC20",
              "BNB",
              "USDC_BEP20",
              "USDT_BEP20"
            ],
            "description": "BTC (Bitcoin), LTC (Litecoin), USDT_TRC20 (Tether on TRON), ETH (Ether), USDC_ERC20 / USDT_ERC20 (USDC / Tether on Ethereum), BNB, USDC_BEP20 / USDT_BEP20 (USDC / Tether on BNB Smart Chain)."
          },
          "priceAmount": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d+)?$",
            "description": "Price in fiat; requires priceCurrency."
          },
          "priceCurrency": {
            "type": "string",
            "enum": [
              "USD",
              "EUR",
              "GBP"
            ]
          },
          "cryptoAmount": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d+)?$",
            "description": "Exact crypto amount; alternative to priceAmount."
          },
          "orderId": {
            "type": "string",
            "maxLength": 128
          },
          "description": {
            "type": "string",
            "maxLength": 500
          },
          "customerEmail": {
            "type": "string",
            "format": "email"
          },
          "successUrl": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "cancelUrl": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Deposit": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "txid": {
            "type": "string"
          },
          "vout": {
            "type": [
              "integer",
              "null"
            ]
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d+)?$",
            "description": "Decimal amount as a string, in whole units."
          },
          "confirmations": {
            "type": "integer"
          },
          "blockHeight": {
            "type": [
              "integer",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "MEMPOOL",
              "CONFIRMING",
              "CONFIRMED",
              "ORPHANED"
            ]
          },
          "detectedAt": {
            "type": "string",
            "format": "date-time"
          },
          "confirmedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Sweep": {
        "type": "object",
        "description": "Settlement to the merchant payout wallet",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "QUEUED",
              "FUNDING_GAS",
              "BROADCAST",
              "CONFIRMED",
              "BLOCKED",
              "FAILED",
              "CANCELLED"
            ]
          },
          "txid": {
            "type": [
              "string",
              "null"
            ]
          },
          "feeTxid": {
            "type": [
              "string",
              "null"
            ]
          },
          "gasFundTxid": {
            "type": [
              "string",
              "null"
            ]
          },
          "grossAmount": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d+)?$",
            "description": "Decimal amount as a string, in whole units."
          },
          "platformFee": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d+)?$",
            "description": "Decimal amount as a string, in whole units."
          },
          "networkFee": {
            "type": [
              "string",
              "null"
            ]
          },
          "netAmount": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d+)?$",
            "description": "Decimal amount as a string, in whole units."
          },
          "attempts": {
            "type": "integer"
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Refund": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "paymentId": {
            "type": "string"
          },
          "asset": {
            "type": "string",
            "enum": [
              "BTC",
              "LTC",
              "USDT_TRC20",
              "ETH",
              "USDC_ERC20",
              "USDT_ERC20",
              "BNB",
              "USDC_BEP20",
              "USDT_BEP20"
            ],
            "description": "BTC (Bitcoin), LTC (Litecoin), USDT_TRC20 (Tether on TRON), ETH (Ether), USDC_ERC20 / USDT_ERC20 (USDC / Tether on Ethereum), BNB, USDC_BEP20 / USDT_BEP20 (USDC / Tether on BNB Smart Chain)."
          },
          "status": {
            "type": "string",
            "enum": [
              "QUEUED",
              "FUNDING_GAS",
              "BROADCAST",
              "CONFIRMED",
              "FAILED",
              "MANUAL"
            ]
          },
          "address": {
            "type": "string"
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d+)?$",
            "description": "Decimal amount as a string, in whole units."
          },
          "networkFee": {
            "type": [
              "string",
              "null"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "txid": {
            "type": [
              "string",
              "null"
            ]
          },
          "gasFundTxid": {
            "type": [
              "string",
              "null"
            ]
          },
          "attempts": {
            "type": "integer"
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CreateRefund": {
        "type": "object",
        "required": [
          "address"
        ],
        "properties": {
          "address": {
            "type": "string",
            "description": "Customer address for the refund"
          },
          "reason": {
            "type": "string",
            "maxLength": 500
          },
          "manualTxid": {
            "type": "string",
            "description": "Record a refund you already sent (settled payments)"
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d+)?$",
            "description": "Required with manualTxid"
          }
        }
      },
      "Payment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "merchantId": {
            "type": "string"
          },
          "asset": {
            "type": "string",
            "enum": [
              "BTC",
              "LTC",
              "USDT_TRC20",
              "ETH",
              "USDC_ERC20",
              "USDT_ERC20",
              "BNB",
              "USDC_BEP20",
              "USDT_BEP20"
            ],
            "description": "BTC (Bitcoin), LTC (Litecoin), USDT_TRC20 (Tether on TRON), ETH (Ether), USDC_ERC20 / USDT_ERC20 (USDC / Tether on Ethereum), BNB, USDC_BEP20 / USDT_BEP20 (USDC / Tether on BNB Smart Chain)."
          },
          "chain": {
            "type": "string",
            "enum": [
              "BITCOIN",
              "LITECOIN",
              "TRON",
              "ETHEREUM",
              "BSC"
            ]
          },
          "status": {
            "$ref": "#/components/schemas/PaymentStatus"
          },
          "priceAmount": {
            "type": [
              "string",
              "null"
            ]
          },
          "priceCurrency": {
            "type": [
              "string",
              "null"
            ]
          },
          "cryptoAmount": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d+)?$",
            "description": "Decimal amount as a string, in whole units."
          },
          "rate": {
            "type": [
              "string",
              "null"
            ]
          },
          "rateLockedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "receivedAmount": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d+)?$",
            "description": "Decimal amount as a string, in whole units."
          },
          "confirmations": {
            "type": "integer"
          },
          "requiredConfirmations": {
            "type": "integer"
          },
          "depositAddress": {
            "type": "string"
          },
          "orderId": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "customerEmail": {
            "type": [
              "string",
              "null"
            ]
          },
          "successUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "cancelUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "type": [
              "object",
              "null"
            ]
          },
          "overpaid": {
            "type": "boolean"
          },
          "late": {
            "type": "boolean"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "detectedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "confirmedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "settledAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "checkoutUrl": {
            "type": "string",
            "format": "uri",
            "description": "Hosted checkout page for the customer"
          },
          "deposits": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Deposit"
            }
          },
          "sweep": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Sweep"
              },
              {
                "type": "null"
              }
            ]
          },
          "refunds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Refund"
            }
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "required": [
          "id",
          "event",
          "createdAt",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "event": {
            "type": "string",
            "enum": [
              "payment.detected",
              "payment.confirming",
              "payment.confirmed",
              "payment.underpaid",
              "payment.settled",
              "payment.expired",
              "payment.sweep_blocked",
              "payment.refunded"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/Payment"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer"
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}