{
  "openapi": "3.1.0",
  "info": {
    "title": "PayConsults API",
    "version": "0.1.0",
    "summary": "One integration, many local payment providers.",
    "description": "Merchants integrate once. PayConsults routes each payment to an eligible\nprovider based on country, currency, payment method and what that merchant\nis approved to use, then normalises the provider's statuses, errors and\nwebhooks into one shape.\n\n**Amounts are integers in minor units.** 15000 is 150.00 BRL. Zero-decimal\ncurrencies exist — 15000 IDR really is 15000.\n\n**Test and live are separate.** A `pc_test_` key reaches only the built-in\nsandbox; a `pc_live_` key never does.\n\n**The webhook is what proves payment**, not the customer arriving back on\nyour return_url — anyone can visit that URL.\n\n**Recurring is explicit.** A payment is a recurring charge only when it was\ntaken against a mandate — a standing authorisation the customer agreed to.\nA customer who buys the same thing twice in two months has made two one-off\npayments, and both will report `is_recurring: false`. Nothing is inferred\nfrom the customer, the payment method, the amount or the interval."
  },
  "servers": [
    {
      "url": "https://api.payconsults.com",
      "description": "Production"
    },
    {
      "url": "http://localhost:8099",
      "description": "Local"
    }
  ],
  "tags": [
    {
      "name": "Payments",
      "description": "Take, look up and cancel payments."
    },
    {
      "name": "Refunds",
      "description": "Send money back, in full or in part."
    },
    {
      "name": "Payouts",
      "description": "Disburse funds and query payout status."
    },
    {
      "name": "Recurring",
      "description": "Standing authorisations and the subscriptions billed against them."
    },
    {
      "name": "Capabilities",
      "description": "What this merchant may actually use."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/payments": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "Create a payment",
        "description": "Returns a `redirect_url` — send the customer there. Omit `payment_method` to use provider-hosted checkout, where the customer chooses on the provider's page and no method-specific fields are required.",
        "operationId": "createPayment",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Replaying a key returns the first response instead of acting twice. Reusing one with a different body is an error. 8–255 characters.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentCreateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "This reference already existed, or the Idempotency-Key was replayed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            }
          },
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "The provider declined the payment outright.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "This merchant is not enabled for that country or method.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "A payment for this reference is already being created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The request was understood but cannot be fulfilled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Obey `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Payments"
        ],
        "summary": "List payments",
        "operationId": "listPayments",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1–100.",
            "schema": {
              "type": "integer",
              "default": 25
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "description": "A `next_cursor` from a previous page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only this status.",
            "schema": {
              "type": "string",
              "enum": [
                "created",
                "pending",
                "processing",
                "succeeded",
                "failed",
                "cancelled",
                "expired",
                "refunded",
                "partially_refunded"
              ]
            }
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "description": "ISO-4217, e.g. BRL.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "ISO-3166 alpha-3, e.g. BRA.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "provider",
            "in": "query",
            "required": false,
            "description": "Only payments routed to this provider.",
            "schema": {
              "type": "string",
              "enum": [
                "sandbox",
                "dukpay",
                "korapay"
              ]
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Match a merchant reference or provider transaction id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of payments, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentList"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payments/{merchant_reference}": {
      "get": {
        "tags": [
          "Payments"
        ],
        "summary": "Fetch a payment",
        "description": "Looks up by your own reference. If the payment has not reached a final state, the provider is asked for the latest before answering.",
        "operationId": "getPayment",
        "parameters": [
          {
            "name": "merchant_reference",
            "in": "path",
            "required": true,
            "description": "The reference you supplied when creating it.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "Set false to skip asking the provider.",
            "schema": {
              "type": "boolean",
              "default": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The payment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            }
          },
          "404": {
            "description": "No payment with that reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payments/{merchant_reference}/cancel": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "Cancel a payment",
        "description": "Only a payment that has not settled. Where the provider offers no cancel operation the payment is still marked cancelled here, and `provider_notified` is false.",
        "operationId": "cancelPayment",
        "parameters": [
          {
            "name": "merchant_reference",
            "in": "path",
            "required": true,
            "description": "The reference to cancel.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Payment"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "provider_notified": {
                          "type": "boolean",
                          "description": "Whether the provider was asked."
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "No payment with that reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Already settled, so no longer cancellable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/refunds": {
      "post": {
        "tags": [
          "Refunds"
        ],
        "summary": "Refund a payment",
        "description": "Omit `amount` to refund whatever is left. The payment moves to `partially_refunded`, then `refunded` once nothing remains.",
        "operationId": "createRefund",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Replaying a key returns the first response instead of acting twice. Reusing one with a different body is an error. 8–255 characters.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefundCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refund"
                }
              }
            }
          },
          "404": {
            "description": "No payment with that reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Not refundable, or more than remains.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payouts": {
      "post": {
        "tags": [
          "Payouts"
        ],
        "summary": "Create a payout",
        "description": "Disburse funds to a beneficiary. The payout moves to `processing`, then `succeeded` or `failed`.",
        "operationId": "createPayout",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Replaying a key returns the first response instead of acting twice. Reusing one with a different body is an error. 8–255 characters.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PayoutCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payout"
                }
              }
            }
          },
          "422": {
            "description": "No capable provider or invalid payout parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Payouts"
        ],
        "summary": "List payouts",
        "operationId": "listPayouts",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1 to 100.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by payout status.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payouts, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayoutList"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payouts/{merchant_reference}": {
      "get": {
        "tags": [
          "Payouts"
        ],
        "summary": "Fetch a payout",
        "operationId": "getPayout",
        "parameters": [
          {
            "name": "merchant_reference",
            "in": "path",
            "required": true,
            "description": "Your reference for the payout.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "false skips asking the PSP and serves from cache.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The payout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payout"
                }
              }
            }
          },
          "404": {
            "description": "No such payout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mandates": {
      "post": {
        "tags": [
          "Recurring"
        ],
        "summary": "Ask a customer to authorise future charges",
        "description": "Returns a `redirect_url` the customer must complete. Until they do, the mandate is `pending` and cannot be charged. This is the only way a payment ever becomes recurring.",
        "operationId": "createMandate",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MandateCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Mandate"
                }
              }
            }
          },
          "422": {
            "description": "The chosen provider does not support recurring charges.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Recurring"
        ],
        "summary": "List authorisations",
        "operationId": "listMandates",
        "responses": {
          "200": {
            "description": "Authorisations, newest first."
          }
        }
      }
    },
    "/v1/mandates/{merchant_reference}": {
      "get": {
        "tags": [
          "Recurring"
        ],
        "summary": "Fetch an authorisation",
        "operationId": "getMandate",
        "parameters": [
          {
            "name": "merchant_reference",
            "in": "path",
            "required": true,
            "description": "Your reference for the authorisation.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The authorisation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Mandate"
                }
              }
            }
          },
          "404": {
            "description": "No such authorisation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mandates/{merchant_reference}/cancel": {
      "post": {
        "tags": [
          "Recurring"
        ],
        "summary": "Withdraw an authorisation",
        "description": "Cancels every subscription billing against it too. Consent withdrawn must stop the money, not just the record of it.",
        "operationId": "cancelMandate",
        "parameters": [
          {
            "name": "merchant_reference",
            "in": "path",
            "required": true,
            "description": "The authorisation to withdraw.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Mandate"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions": {
      "post": {
        "tags": [
          "Recurring"
        ],
        "summary": "Start a subscription",
        "description": "Bills an existing mandate on a schedule. Where the provider runs its own scheduler we mirror it; otherwise PayConsults runs the clock, retries failed renewals, and gives up only after the dunning schedule is exhausted.",
        "operationId": "createSubscription",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                }
              }
            }
          },
          "404": {
            "description": "No such mandate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The mandate is cancelled or failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Recurring"
        ],
        "summary": "List subscriptions",
        "operationId": "listSubscriptions",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only this status.",
            "schema": {
              "type": "string",
              "enum": [
                "pending_mandate",
                "active",
                "past_due",
                "paused",
                "cancelled",
                "completed"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Subscriptions, newest first."
          }
        }
      }
    },
    "/v1/subscriptions/{merchant_reference}": {
      "get": {
        "tags": [
          "Recurring"
        ],
        "summary": "Fetch a subscription and its charges",
        "description": "Includes every charge billed against it, in order.",
        "operationId": "getSubscription",
        "parameters": [
          {
            "name": "merchant_reference",
            "in": "path",
            "required": true,
            "description": "Your reference for the subscription.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The subscription, with its charges.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                }
              }
            }
          },
          "404": {
            "description": "No such subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions/{merchant_reference}/cancel": {
      "post": {
        "tags": [
          "Recurring"
        ],
        "summary": "Cancel a subscription",
        "operationId": "cancelSubscription",
        "parameters": [
          {
            "name": "merchant_reference",
            "in": "path",
            "required": true,
            "description": "The subscription to cancel.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "at_period_end": {
                    "type": "boolean",
                    "description": "Let the paid period run out first."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions/{merchant_reference}/pause": {
      "post": {
        "tags": [
          "Recurring"
        ],
        "summary": "Pause billing",
        "operationId": "pauseSubscription",
        "parameters": [
          {
            "name": "merchant_reference",
            "in": "path",
            "required": true,
            "description": "The subscription to pause.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paused."
          },
          "422": {
            "description": "The provider runs this schedule, so it cannot be paused here.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions/{merchant_reference}/resume": {
      "post": {
        "tags": [
          "Recurring"
        ],
        "summary": "Resume billing",
        "operationId": "resumeSubscription",
        "parameters": [
          {
            "name": "merchant_reference",
            "in": "path",
            "required": true,
            "description": "The subscription to resume.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resumed."
          }
        }
      }
    },
    "/v1/payment-methods": {
      "get": {
        "tags": [
          "Capabilities"
        ],
        "summary": "What this merchant may use",
        "description": "The providers connected to this merchant, intersected with what they are approved for. Carries the limits and required fields for each, so a checkout page can be built without guessing.",
        "operationId": "listPaymentMethods",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "Filter by country.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "description": "Filter by currency.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Available methods.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentMethodList"
                }
              }
            }
          }
        }
      }
    },
    "/v1/routes": {
      "get": {
        "tags": [
          "Capabilities"
        ],
        "summary": "Which providers this key can reach",
        "operationId": "listRoutes",
        "responses": {
          "200": {
            "description": "Connected providers, in precedence order."
          }
        }
      }
    },
    "/v1/events": {
      "get": {
        "tags": [
          "Capabilities"
        ],
        "summary": "Recent webhook deliveries",
        "description": "Every attempt, successful or not, for debugging your endpoint.",
        "operationId": "listEvents",
        "responses": {
          "200": {
            "description": "Recent delivery attempts."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your API key: `Authorization: Bearer pc_test_…` or `pc_live_…`."
      }
    },
    "schemas": {
      "PaymentCreateRequest": {
        "type": "object",
        "required": [
          "merchant_reference",
          "amount",
          "currency",
          "country"
        ],
        "properties": {
          "merchant_reference": {
            "type": "string",
            "maxLength": 128,
            "description": "Your own order id. Must be unique for you, and is echoed on every webhook.",
            "examples": [
              "ORDER-1001"
            ]
          },
          "deposit_group": {
            "type": "string",
            "maxLength": 128,
            "description": "Optional. Your id for the underlying order or deposit, shared by every attempt at it. While an attempt in the group is still in flight a new one is refused with DEPOSIT_GROUP_IN_FLIGHT and the live attempt is returned in error.detail, so you can send the customer back to the checkout they already have instead of opening a second payable one. Once every attempt is failed, expired or cancelled, a retry is allowed. Omit it and nothing changes.",
            "examples": [
              "DEP-99312"
            ]
          },
          "amount": {
            "type": "integer",
            "minimum": 1,
            "description": "Minor units. 15000 is 150.00 BRL.",
            "examples": [
              15000
            ]
          },
          "currency": {
            "type": "string",
            "description": "ISO-4217.",
            "examples": [
              "BRL"
            ]
          },
          "country": {
            "type": "string",
            "description": "ISO-3166 alpha-3.",
            "examples": [
              "BRA"
            ]
          },
          "payment_method": {
            "type": "string",
            "enum": [
              "bank_transfer",
              "boleto",
              "card",
              "dana",
              "hosted_checkout",
              "ideal",
              "mobile_money",
              "mpesa",
              "ovo",
              "pay_with_bank",
              "pix",
              "qris",
              "sbp",
              "shopeepay",
              "stcpay",
              "tabby",
              "upi"
            ],
            "description": "Omit for provider-hosted checkout."
          },
          "payment_method_data": {
            "type": "object",
            "additionalProperties": true,
            "description": "Fields a specific method needs that the shared model does not own, e.g. `{\"vpa\":\"customer@upi\"}`."
          },
          "provider": {
            "type": "string",
            "enum": [
              "sandbox",
              "dukpay",
              "korapay"
            ],
            "description": "Pin to one provider. Fails rather than substituting if it cannot serve the request."
          },
          "return_url": {
            "type": "string",
            "format": "uri",
            "description": "Where the customer lands afterwards."
          },
          "statement_descriptor": {
            "type": "string",
            "description": "Shown on the checkout page and, where supported, the statement."
          },
          "customer": {
            "$ref": "#/components/schemas/Customer"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Yours. Stored and returned untouched."
          }
        }
      },
      "Customer": {
        "type": "object",
        "description": "Which fields are required depends on the method — see `/v1/payment-methods`.",
        "properties": {
          "id": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string",
            "description": "E.164, e.g. +5511999999999."
          },
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "full_name": {
            "type": "string",
            "description": "Use instead of first/last if you hold one name."
          },
          "tax_id": {
            "type": "string",
            "description": "CPF/CNPJ, PAN, and equivalents."
          },
          "address": {
            "type": "object",
            "properties": {
              "line1": {
                "type": "string"
              },
              "line2": {
                "type": "string"
              },
              "city": {
                "type": "string"
              },
              "state": {
                "type": "string"
              },
              "district": {
                "type": "string"
              },
              "number": {
                "type": "string"
              },
              "postal_code": {
                "type": "string"
              },
              "country": {
                "type": "string"
              }
            }
          }
        }
      },
      "Payment": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "payment"
          },
          "payment_id": {
            "type": "string",
            "description": "Ours. Quote this to support.",
            "examples": [
              "pay_9f2c…"
            ]
          },
          "merchant_reference": {
            "type": "string",
            "description": "Yours."
          },
          "status": {
            "type": "string",
            "enum": [
              "created",
              "pending",
              "processing",
              "succeeded",
              "failed",
              "cancelled",
              "expired",
              "refunded",
              "partially_refunded"
            ]
          },
          "amount": {
            "type": "integer",
            "description": "Minor units."
          },
          "currency": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "payment_method": {
            "type": [
              "string",
              "null"
            ]
          },
          "redirect_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Send the customer here."
          },
          "qr_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "failure_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "failure_message": {
            "type": [
              "string",
              "null"
            ]
          },
          "fees": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Fees"
              },
              {
                "type": "null"
              }
            ]
          },
          "amount_refunded": {
            "type": "integer",
            "description": "Minor units returned so far."
          },
          "deposit_group": {
            "type": [
              "string",
              "null"
            ],
            "description": "The order or deposit this attempt belongs to, if you sent one."
          },
          "expired_by": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "provider",
              "gateway",
              null
            ],
            "description": "Set only when `status` is `expired`. `provider` means the PSP closed the checkout session: final, nothing more will arrive. `gateway` means our clock gave up without a verdict, so a late settlement can still land and will still be webhooked. Providers differ — Korapay reports expiry, DukPay has no expired status at all and emits nothing for an abandoned checkout, which is why the clock exists."
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When this attempt stops being payable. Past it the status becomes `expired` and the deposit group reopens for a retry. `expired` means we stopped waiting, not that the payment was declined: a settlement arriving afterwards is still accepted and still webhooked."
          },
          "is_recurring": {
            "type": "boolean",
            "description": "True only when this charge was billed against a subscription. A repeat purchase by the same customer, with the same method, is false."
          },
          "mandate_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The standing authorisation used, if any."
          },
          "subscription_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The subscription billed, if any."
          },
          "initiator": {
            "type": "string",
            "enum": [
              "customer",
              "merchant"
            ],
            "description": "`customer` when they were present; `merchant` when a stored authorisation was charged."
          },
          "sequence": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Which period of the subscription this is."
          },
          "reconciliation_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "YYYY-MM-DD, where the provider reports one."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "provider": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProviderRef"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ProviderRef": {
        "type": "object",
        "description": "Who handled it. For support and reconciliation — you integrate against PayConsults either way.",
        "properties": {
          "name": {
            "type": "string"
          },
          "connection_id": {
            "type": "string"
          },
          "transaction_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The provider's own id."
          },
          "reference": {
            "type": "string",
            "description": "The reference we gave the provider."
          }
        }
      },
      "Fees": {
        "type": "object",
        "description": "What the provider charged. Not settlement — the provider pays you directly.",
        "properties": {
          "total": {
            "type": "number"
          },
          "currency": {
            "type": [
              "string",
              "null"
            ]
          },
          "breakdown": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string"
                },
                "amount": {
                  "type": "number"
                },
                "currency": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "RefundCreateRequest": {
        "type": "object",
        "required": [
          "payment_reference"
        ],
        "properties": {
          "payment_reference": {
            "type": "string",
            "description": "The merchant_reference of the payment."
          },
          "amount": {
            "type": "integer",
            "description": "Minor units. Omit to refund what remains."
          },
          "merchant_reference": {
            "type": "string",
            "description": "Your id for this refund."
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "Refund": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "refund"
          },
          "refund_id": {
            "type": "string"
          },
          "merchant_reference": {
            "type": "string"
          },
          "payment_reference": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "created",
              "pending",
              "processing",
              "succeeded",
              "failed",
              "cancelled",
              "expired",
              "refunded",
              "partially_refunded"
            ]
          },
          "amount": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PayoutCreateRequest": {
        "type": "object",
        "required": [
          "merchant_reference",
          "amount",
          "currency",
          "beneficiary"
        ],
        "properties": {
          "merchant_reference": {
            "type": "string",
            "description": "Your unique reference for this payout."
          },
          "amount": {
            "type": "integer",
            "description": "Minor units (e.g. 1500 for 15.00)."
          },
          "amount_decimal": {
            "type": "string",
            "description": "Human decimal string alternative (e.g. \"15.00\")."
          },
          "currency": {
            "type": "string",
            "description": "Three-letter ISO code."
          },
          "country": {
            "type": "string",
            "description": "Three-letter ISO country code."
          },
          "payment_method": {
            "type": "string",
            "description": "Disbursement method (e.g. pix, bank_transfer)."
          },
          "beneficiary": {
            "type": "object",
            "description": "Recipient account and identity information."
          },
          "provider": {
            "type": "string",
            "description": "Explicit provider override if desired."
          },
          "provider_options": {
            "type": "object",
            "description": "Pass-through provider options."
          }
        }
      },
      "Payout": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "payout"
          },
          "payout_id": {
            "type": "string"
          },
          "merchant_reference": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "created",
              "pending",
              "processing",
              "succeeded",
              "failed",
              "cancelled",
              "expired",
              "refunded",
              "partially_refunded"
            ]
          },
          "amount": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "payment_method": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProviderRef"
              },
              {
                "type": "null"
              }
            ]
          },
          "beneficiary": {
            "anyOf": [
              {
                "type": "object"
              },
              {
                "type": "null"
              }
            ]
          },
          "failure_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "failure_message": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PayoutList": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Payout"
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass as `starting_after`."
          }
        }
      },
      "PaymentList": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Payment"
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass as `starting_after`."
          }
        }
      },
      "PaymentMethodList": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "mode": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "provider": {
                  "type": "string"
                },
                "country": {
                  "type": "string"
                },
                "currency": {
                  "type": "string"
                },
                "payment_method": {
                  "type": "string"
                },
                "checkout": {
                  "type": "string",
                  "enum": [
                    "hosted",
                    "direct"
                  ]
                },
                "refunds": {
                  "type": "boolean"
                },
                "min_amount": {
                  "type": "integer"
                },
                "max_amount": {
                  "type": "integer"
                },
                "required_fields": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      "MandateCreateRequest": {
        "type": "object",
        "required": [
          "merchant_reference",
          "country",
          "currency"
        ],
        "properties": {
          "merchant_reference": {
            "type": "string",
            "description": "Your id for this authorisation."
          },
          "country": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "payment_method": {
            "type": "string",
            "enum": [
              "bank_transfer",
              "boleto",
              "card",
              "dana",
              "hosted_checkout",
              "ideal",
              "mobile_money",
              "mpesa",
              "ovo",
              "pay_with_bank",
              "pix",
              "qris",
              "sbp",
              "shopeepay",
              "stcpay",
              "tabby",
              "upi"
            ]
          },
          "provider": {
            "type": "string",
            "enum": [
              "sandbox",
              "dukpay",
              "korapay"
            ]
          },
          "customer": {
            "$ref": "#/components/schemas/Customer"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Mandate": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "mandate"
          },
          "mandate_id": {
            "type": "string"
          },
          "merchant_reference": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "active",
              "cancelled",
              "failed"
            ],
            "description": "Only `active` can be charged. `pending` means the customer has not finished authorising."
          },
          "provider": {
            "type": "string"
          },
          "payment_method": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency": {
            "type": [
              "string",
              "null"
            ]
          },
          "customer_ref": {
            "type": [
              "string",
              "null"
            ]
          },
          "redirect_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Send the customer here to authorise."
          },
          "failure_message": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_used_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SubscriptionCreateRequest": {
        "type": "object",
        "required": [
          "merchant_reference",
          "mandate_id",
          "amount",
          "currency",
          "interval"
        ],
        "properties": {
          "merchant_reference": {
            "type": "string"
          },
          "mandate_id": {
            "type": "string",
            "description": "An authorisation the customer has completed."
          },
          "amount": {
            "type": "integer",
            "description": "Minor units, charged each period."
          },
          "currency": {
            "type": "string"
          },
          "interval": {
            "type": "string",
            "enum": [
              "day",
              "week",
              "month",
              "year"
            ]
          },
          "interval_count": {
            "type": "integer",
            "default": 1,
            "description": "e.g. interval month, count 3 = quarterly."
          },
          "total_periods": {
            "type": "integer",
            "description": "Stop after this many. Omit to run until cancelled."
          },
          "start_now": {
            "type": "boolean",
            "default": true,
            "description": "False to bill at the end of the first period."
          },
          "description": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Subscription": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "subscription"
          },
          "subscription_id": {
            "type": "string"
          },
          "merchant_reference": {
            "type": "string"
          },
          "mandate_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_mandate",
              "active",
              "past_due",
              "paused",
              "cancelled",
              "completed"
            ],
            "description": "`past_due` means a renewal failed and is being retried."
          },
          "amount": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "interval": {
            "type": "string"
          },
          "interval_count": {
            "type": "integer"
          },
          "current_period_start": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "current_period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "next_charge_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Null when the provider runs the schedule."
          },
          "cancel_at_period_end": {
            "type": "boolean"
          },
          "periods_billed": {
            "type": "integer"
          },
          "total_periods": {
            "type": [
              "integer",
              "null"
            ]
          },
          "failed_attempts": {
            "type": "integer"
          },
          "scheduled_by": {
            "type": "string",
            "enum": [
              "gateway",
              "provider"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "request_id"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "INVALID_REQUEST",
                  "MISSING_REQUIRED_FIELD",
                  "INVALID_FIELD_FORMAT",
                  "INVALID_AMOUNT",
                  "AMOUNT_BELOW_MINIMUM",
                  "AMOUNT_ABOVE_MAXIMUM",
                  "UNSUPPORTED_CURRENCY",
                  "UNSUPPORTED_COUNTRY",
                  "UNSUPPORTED_PAYMENT_METHOD",
                  "UNAUTHENTICATED",
                  "PERMISSION_DENIED",
                  "PAYMENT_METHOD_NOT_ENABLED",
                  "COUNTRY_NOT_ENABLED",
                  "NO_ELIGIBLE_PROVIDER",
                  "PROVIDER_NOT_AVAILABLE",
                  "PROVIDER_DECLINED",
                  "PROVIDER_ERROR",
                  "PROVIDER_TIMEOUT",
                  "PSP_AUTHENTICATION_FAILED",
                  "PSP_CREDENTIALS_MISSING",
                  "PSP_CREDENTIALS_EXPIRED",
                  "PSP_TOKEN_REFRESH_FAILED",
                  "PSP_SIGNATURE_INVALID",
                  "PSP_CONFIGURATION_ERROR",
                  "PSP_INVALID_RESPONSE",
                  "PSP_UNAVAILABLE",
                  "PSP_RATE_LIMITED",
                  "PAYMENT_NOT_FOUND",
                  "DUPLICATE_PAYMENT",
                  "PAYMENT_IN_PROGRESS",
                  "DEPOSIT_GROUP_IN_FLIGHT",
                  "CANCEL_NOT_ALLOWED",
                  "IDEMPOTENCY_CONFLICT",
                  "RECURRING_NOT_SUPPORTED",
                  "MANDATE_NOT_ACTIVE",
                  "MANDATE_NOT_FOUND",
                  "SUBSCRIPTION_NOT_FOUND",
                  "SUBSCRIPTION_NOT_ACTIVE",
                  "REFUND_NOT_SUPPORTED",
                  "REFUND_NOT_ALLOWED",
                  "CANCEL_NOT_SUPPORTED",
                  "INTERNAL_ERROR",
                  "RATE_LIMITED"
                ],
                "description": "Stable. Branch on this, not on the message."
              },
              "type": {
                "type": "string",
                "description": "Coarser grouping of the code."
              },
              "message": {
                "type": "string",
                "description": "For humans. May be reworded."
              },
              "param": {
                "type": "string",
                "description": "The offending field, where one is identifiable."
              },
              "provider_code": {
                "description": "The provider's own code, kept for support."
              },
              "request_id": {
                "type": "string",
                "description": "Also in the PayConsults-Request-Id header."
              }
            }
          }
        }
      }
    }
  },
  "x-webhooks": {
    "description": "We POST to your configured URL, signed as\n`PayConsults-Signature: t=<unix>,v1=<hex hmac>` — an HMAC-SHA256 of\n`\"<timestamp>.<raw body>\"` using your webhook secret. Compare in constant\ntime, reject anything older than five minutes, and answer 200 quickly.\nFailures are retried with backoff, so make handling idempotent.\n\n`data` is the same shape this API returns, so one parser handles both.",
    "eventTypes": [
      "payment.succeeded",
      "payment.failed",
      "payment.cancelled",
      "payment.expired",
      "payment.refunded",
      "payment.partially_refunded",
      "payment.fees_available",
      "refund.succeeded",
      "refund.failed",
      "payout.succeeded",
      "payout.failed",
      "mandate.activated",
      "mandate.failed",
      "mandate.cancelled",
      "subscription.created",
      "subscription.activated",
      "subscription.renewed",
      "subscription.payment_failed",
      "subscription.paused",
      "subscription.resumed",
      "subscription.cancelled",
      "subscription.completed",
      "subscription.updated",
      "chargeback.opened",
      "chargeback.lost"
    ],
    "example": {
      "id": "evt_…",
      "type": "payment.succeeded",
      "created_at": "2026-09-08T09:00:00.000Z",
      "data": {
        "object": "payment",
        "payment_id": "pay_…",
        "merchant_reference": "ORDER-1001",
        "status": "succeeded"
      }
    }
  }
}