{
 "openapi": "3.1.0",
 "x-source-sha256": "9248d12db0b7ada3ea6c91a4c00a505430cb56f0f172ad93a4362dd50a73bfc0",
 "x-generated-by": "tools/openapi2json.py (do not edit; edit the YAML and regenerate)",
 "info": {
  "title": "RazPay API",
  "version": "1.0",
  "description": "RazPay Public REST API (v1). JSON over HTTPS. Amounts are integers in the smallest currency unit (cents in your currency, e.g. USD 250.00 = 25000). The default minimum payment amount is 100 (1.00); RazPay may change it.\nTimes are UTC ISO 8601. Authenticate with `Authorization: Bearer <api key>` (rz_test_… on the test environment, rz_live_… in production).\nPOST requests that create something require an `Idempotency-Key` header: the same key and body return the original response;\na different body (or the same key on another object, e.g. expiring another session) returns 409. Up to 120 requests per minute per key.\nError messages (`error.message` and `error.fields`) are in English by default; send `Accept-Language: ja` to get them in Japanese.\n`error.code` values are the same in every language, so branch on `code`, not on `message`.\nEvery response of an authenticated request carries `X-RateLimit-Limit` (120) and `X-RateLimit-Remaining`; a 429 also carries `Retry-After` (seconds).\nRequest bodies must be a JSON object (`Content-Type: application/json`, UTF-8); a body that is not valid JSON or not an object returns 400 `invalid_json`.\nText fields must not contain control characters (descriptions, notes, reasons and metadata values may contain line breaks and tabs). Leading and trailing spaces are removed.\nQuery parameters take a single value (`?status[]=…` returns 422). A method that an endpoint does not support returns 405 `method_not_allowed` with an `Allow` header.\n\n**Checkout Sessions** (recommended integration): create a session on your server with `POST /checkout-sessions`, redirect the customer to its `url`\n(the RazPay hosted payment page; card details are entered on the payment processor's page, never on your site or on RazPay),\nand fulfil the order when you receive the `payment.succeeded` (or `checkout_session.completed`) webhook. After a successful payment the customer's browser\nis sent to your `success_url` (`{CHECKOUT_SESSION_ID}` is replaced with the session id); the payment page shows a \"Cancel and return to the shop\" link to your `cancel_url`.\nThe redirect is a convenience only: always confirm the payment by webhook or `GET /checkout-sessions/{id}` before fulfilling.\n\n**Lists** return `{object: \"list\", data, has_more, url}`, newest first. Paginate with `limit` (1-100, default 10; settlements default 25),\n`starting_after` (the last id of the current page, for older items) or `ending_before` (the first id, for newer items). Filter with\n`created[gte|gt|lte|lt]` (Unix seconds or ISO 8601) and the filters listed on each endpoint.\n\n**metadata**: up to 20 key-value pairs; keys 1-40 characters `[A-Za-z0-9_.-]`, values strings up to 500 characters (numbers are converted to strings).\n`metadata` and `client_reference_id` (up to 200 characters) set on a Checkout Session or a Payment Link are copied to its payments and returned on\npayments, transactions, refunds and their webhooks.\n\nEvery object has `object`, `id`, `created_at` and `livemode` (true for rz_live_ keys).\n"
 },
 "servers": [
  {
   "url": "https://www.raz-pay.com/api/v1"
  }
 ],
 "security": [
  {
   "bearer": []
  }
 ],
 "paths": {
  "/payment-links": {
   "post": {
    "summary": "Create a Payment Link",
    "operationId": "createPaymentLink",
    "x-summary-ja": "Payment Link を作成する",
    "x-scope": "payment_links:write",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "example": {
        "name": "Consulting (1 hour)",
        "amount_minor": 25000,
        "quantity": 1,
        "max_uses": 1,
        "client_reference_id": "order-1001",
        "metadata": {
         "customer_id": "c_42"
        }
       },
       "schema": {
        "type": "object",
        "description": "Give product_id (+ quantity) or name + amount_minor.",
        "properties": {
         "product_id": {
          "type": "string",
          "description": "Product id (26 chars)"
         },
         "name": {
          "type": "string",
          "maxLength": 100
         },
         "description": {
          "type": "string",
          "maxLength": 1000
         },
         "amount_minor": {
          "type": "integer",
          "minimum": 100,
          "maximum": 99999999,
          "description": "Unit price in minor units (1/100 of your account currency) when no product_id"
         },
         "quantity": {
          "type": "integer",
          "minimum": 1,
          "maximum": 999,
          "default": 1
         },
         "currency": {
          "type": "string",
          "enum": [
           "MYR",
           "USD",
           "AED"
          ],
          "description": "Your account currency (set by the payment processor of your account). Other values are rejected"
         },
         "display_currency": {
          "type": "string",
          "enum": [
           "MYR",
           "USD",
           "AED",
           "JPY"
          ],
          "description": "Reference display only; customers pay in your account currency"
         },
         "expires_at": {
          "type": "string",
          "format": "date-time"
         },
         "max_uses": {
          "type": "integer",
          "minimum": 1,
          "description": "1 = single use"
         },
         "auto_eligible_hours": {
          "type": "integer",
          "minimum": 0,
          "maximum": 168,
          "default": 0,
          "description": "Hours after payment until the transaction becomes eligible for settlement without the buyer's receipt confirmation. 0 = immediately (the buyer can confirm receipt on the order page right after paying)"
         },
         "client_reference_id": {
          "type": "string",
          "maxLength": 200,
          "description": "Your own reference (e.g. order number). Copied to the payments of this link"
         },
         "metadata": {
          "$ref": "#/components/schemas/Metadata"
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Created",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentLink"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   },
   "get": {
    "summary": "List Payment Links",
    "operationId": "listPaymentLinks",
    "x-summary-ja": "Payment Link の一覧",
    "x-description-ja": "すべての種類のリンク（API で作成したリンク・メールのリンク・商品ページ・請求書）。Checkout Session のリンクは含みません。",
    "x-scope": "payment_links:read",
    "description": "Links of every kind (purpose link, email, product, invoice). Links of Checkout Sessions are not included.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/StartingAfter"
     },
     {
      "$ref": "#/components/parameters/EndingBefore"
     },
     {
      "$ref": "#/components/parameters/Created"
     },
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "active",
        "disabled"
       ]
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "allOf": [
          {
           "$ref": "#/components/schemas/List"
          },
          {
           "type": "object",
           "properties": {
            "data": {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/PaymentLink"
             }
            }
           }
          }
         ]
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/payment-links/{id}": {
   "get": {
    "summary": "Retrieve a Payment Link",
    "operationId": "getPaymentLink",
    "x-summary-ja": "Payment Link を取得する",
    "x-scope": "payment_links:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Id"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentLink"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/payment-links/{id}/deactivate": {
   "post": {
    "summary": "Deactivate a Payment Link",
    "operationId": "deactivatePaymentLink",
    "x-summary-ja": "Payment Link を使えなくする",
    "x-description-ja": "リンクを使えなくします。繰り返し呼び出すと同じリンクを返します。対象は API で作成したリンク（link）とメールのリンク（email）だけで、商品ページ・請求書のリンクは 409 payment_link_not_deactivatable です。",
    "x-scope": "payment_links:write",
    "description": "The link can no longer be used. Repeating the call returns the same link. Only links of purpose link and email; links of product pages and invoices return 409 payment_link_not_deactivatable.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Id"
     },
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentLink"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/products": {
   "post": {
    "summary": "Create a product",
    "operationId": "createProduct",
    "x-summary-ja": "商品を作成する",
    "x-scope": "products:write",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "example": {
        "name": "Premium plan (1 month)",
        "price_minor": 2500,
        "kind": "service"
       },
       "schema": {
        "type": "object",
        "required": [
         "name",
         "price_minor"
        ],
        "properties": {
         "name": {
          "type": "string",
          "maxLength": 100
         },
         "description": {
          "type": "string",
          "maxLength": 1000
         },
         "kind": {
          "type": "string",
          "enum": [
           "service",
           "goods",
           "other"
          ],
          "default": "service"
         },
         "price_minor": {
          "type": "integer",
          "minimum": 100,
          "maximum": 99999999
         },
         "currency": {
          "type": "string",
          "enum": [
           "MYR",
           "USD",
           "AED"
          ],
          "description": "Your account currency (set by the payment processor of your account). Other values are rejected"
         },
         "display_currency": {
          "type": "string",
          "enum": [
           "MYR",
           "USD",
           "AED",
           "JPY"
          ]
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Created",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Product"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   },
   "get": {
    "summary": "List products",
    "operationId": "listProducts",
    "x-summary-ja": "商品の一覧",
    "x-scope": "products:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/StartingAfter"
     },
     {
      "$ref": "#/components/parameters/EndingBefore"
     },
     {
      "$ref": "#/components/parameters/Created"
     },
     {
      "name": "active",
      "in": "query",
      "schema": {
       "type": "boolean"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "allOf": [
          {
           "$ref": "#/components/schemas/List"
          },
          {
           "type": "object",
           "properties": {
            "data": {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/Product"
             }
            }
           }
          }
         ]
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/products/{id}": {
   "get": {
    "summary": "Retrieve a product",
    "operationId": "getProduct",
    "x-summary-ja": "商品を取得する",
    "x-scope": "products:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Id"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Product"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/invoices": {
   "post": {
    "summary": "Create (and by default issue) an invoice",
    "operationId": "createInvoice",
    "x-summary-ja": "請求書を作成する（既定ですぐに発行）",
    "x-scope": "invoices:write",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "example": {
        "bill_to": "Sample Trading Ltd.",
        "bill_to_email": "billing@example.com",
        "items": [
         {
          "description": "Consulting (1 hour)",
          "quantity": 2,
          "unit_price_minor": 25000
         }
        ],
        "due_date": "2026-11-30",
        "locale": "en"
       },
       "schema": {
        "type": "object",
        "required": [
         "bill_to",
         "due_date"
        ],
        "description": "Send either `items` (line items; subtotal, tax and total are calculated) or `amount_minor` (one line, tax included).",
        "properties": {
         "bill_to": {
          "type": "string",
          "maxLength": 100
         },
         "bill_to_email": {
          "type": "string",
          "format": "email",
          "description": "If set, the invoice is emailed when issued, with the PDF attached and the payment link"
         },
         "bill_to_address": {
          "type": "string",
          "maxLength": 500
         },
         "description": {
          "type": "string",
          "maxLength": 150
         },
         "amount_minor": {
          "type": "integer",
          "minimum": 100,
          "maximum": 99999999,
          "description": "Tax included. Required when items is not sent"
         },
         "items": {
          "type": "array",
          "minItems": 1,
          "maxItems": 20,
          "items": {
           "type": "object",
           "required": [
            "description",
            "quantity",
            "unit_price_minor"
           ],
           "properties": {
            "description": {
             "type": "string",
             "maxLength": 191
            },
            "quantity": {
             "type": "integer",
             "minimum": 1,
             "maximum": 100000
            },
            "unit_price_minor": {
             "type": "integer",
             "minimum": 0
            }
           }
          }
         },
         "tax_rate_bp": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10000,
          "default": 0,
          "description": "Tax rate in basis points (600 = 6%). Tax = subtotal × rate, rounded to the nearest minor unit (1/100)"
         },
         "currency": {
          "type": "string",
          "enum": [
           "MYR",
           "USD",
           "AED"
          ],
          "description": "Your account currency (set by the payment processor of your account). Other values are rejected"
         },
         "issue_date": {
          "type": "string",
          "format": "date"
         },
         "due_date": {
          "type": "string",
          "format": "date"
         },
         "notes": {
          "type": "string",
          "maxLength": 1000
         },
         "auto_eligible_hours": {
          "type": "integer",
          "minimum": 0,
          "maximum": 168,
          "default": 0,
          "description": "Hours after payment until the transaction becomes eligible for settlement without the buyer's receipt confirmation. 0 = immediately (the buyer can confirm receipt on the order page right after paying)"
         },
         "issue": {
          "type": "boolean",
          "default": true
         },
         "locale": {
          "type": "string",
          "enum": [
           "en",
           "ja"
          ]
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Created",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Invoice"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   },
   "get": {
    "summary": "List invoices",
    "operationId": "listInvoices",
    "x-summary-ja": "請求書の一覧",
    "x-scope": "invoices:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/StartingAfter"
     },
     {
      "$ref": "#/components/parameters/EndingBefore"
     },
     {
      "$ref": "#/components/parameters/Created"
     },
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "draft",
        "issued",
        "paid",
        "void",
        "refunded"
       ]
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "allOf": [
          {
           "$ref": "#/components/schemas/List"
          },
          {
           "type": "object",
           "properties": {
            "data": {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/Invoice"
             }
            }
           }
          }
         ]
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/invoices/{id}": {
   "get": {
    "summary": "Retrieve an invoice",
    "operationId": "getInvoice",
    "x-summary-ja": "請求書を取得する",
    "x-scope": "invoices:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Id"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Invoice"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/checkout-sessions": {
   "post": {
    "summary": "Create a Checkout Session",
    "operationId": "createCheckoutSession",
    "x-summary-ja": "Checkout Session を作成する",
    "x-description-ja": "1 回だけ使えるお支払い画面（RazPay のホスト型決済ページ）を作成します。お客様を url へ移してください。product_id（と quantity）、または name と amount_minor を指定します。",
    "x-scope": "checkout_sessions:write",
    "description": "Creates a single-use hosted payment page. Redirect the customer to url. Give product_id (+ quantity) or name + amount_minor.",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "example": {
        "name": "Premium plan (1 month)",
        "amount_minor": 2500,
        "quantity": 1,
        "client_reference_id": "order-1001",
        "metadata": {
         "customer_id": "c_42"
        },
        "success_url": "https://shop.example.com/thanks?session={CHECKOUT_SESSION_ID}",
        "cancel_url": "https://shop.example.com/cart",
        "customer": {
         "email": "buyer@example.com",
         "lock_email": true
        },
        "locale": "en"
       },
       "schema": {
        "type": "object",
        "properties": {
         "product_id": {
          "type": "string",
          "description": "Product id (26 chars)"
         },
         "name": {
          "type": "string",
          "maxLength": 100,
          "description": "Item name shown on the payment page (required without product_id)"
         },
         "description": {
          "type": "string",
          "maxLength": 1000
         },
         "amount_minor": {
          "type": "integer",
          "minimum": 100,
          "maximum": 99999999,
          "description": "Unit price in minor units (required without product_id). The total (× quantity) must be within your minimum and maximum per payment"
         },
         "quantity": {
          "type": "integer",
          "minimum": 1,
          "maximum": 999,
          "default": 1
         },
         "currency": {
          "type": "string",
          "enum": [
           "MYR",
           "USD",
           "AED"
          ],
          "description": "Your account currency. Other values are rejected"
         },
         "display_currency": {
          "type": "string",
          "enum": [
           "MYR",
           "USD",
           "AED",
           "JPY"
          ],
          "description": "Reference display only"
         },
         "client_reference_id": {
          "type": "string",
          "maxLength": 200,
          "description": "Your own reference (e.g. order number). Filter with GET /checkout-sessions?client_reference_id= and GET /payments?client_reference_id="
         },
         "metadata": {
          "$ref": "#/components/schemas/Metadata"
         },
         "success_url": {
          "type": "string",
          "format": "uri",
          "maxLength": 2000,
          "description": "Where the customer's browser goes after a successful payment. https only in production (http is accepted on the test environment); javascript:, data: and other schemes are rejected. {CHECKOUT_SESSION_ID} is replaced with the session id. Without it, the customer stays on the RazPay order page"
         },
         "cancel_url": {
          "type": "string",
          "format": "uri",
          "maxLength": 2000,
          "description": "Target of the \"Cancel and return to the shop\" link on the payment page (also shown when the session can no longer be used). Same rules as success_url"
         },
         "customer": {
          "type": "object",
          "description": "Prefill the payment form. The customer can change name and phone. These values are never returned by the API or webhooks",
          "properties": {
           "name": {
            "type": "string",
            "maxLength": 100
           },
           "email": {
            "type": "string",
            "format": "email",
            "maxLength": 150
           },
           "phone": {
            "type": "string",
            "description": "International format recommended (+819012345678)"
           },
           "lock_email": {
            "type": "boolean",
            "default": false,
            "description": "true = the email cannot be changed and only this email can pay (requires customer.email)"
           }
          }
         },
         "locale": {
          "type": "string",
          "enum": [
           "ja",
           "en"
          ],
          "description": "Language of the payment page (default English; the customer can switch)"
         },
         "expires_at": {
          "oneOf": [
           {
            "type": "integer",
            "description": "Unix seconds"
           },
           {
            "type": "string",
            "format": "date-time"
           }
          ],
          "description": "30 minutes to 7 days from now. Default: 24 hours"
         },
         "auto_eligible_hours": {
          "type": "integer",
          "minimum": 0,
          "maximum": 168,
          "default": 0
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Created",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CheckoutSession"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   },
   "get": {
    "summary": "List Checkout Sessions",
    "operationId": "listCheckoutSessions",
    "x-summary-ja": "Checkout Session の一覧",
    "x-scope": "checkout_sessions:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/StartingAfter"
     },
     {
      "$ref": "#/components/parameters/EndingBefore"
     },
     {
      "$ref": "#/components/parameters/Created"
     },
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "open",
        "complete",
        "expired"
       ]
      }
     },
     {
      "name": "client_reference_id",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "payment_id",
      "in": "query",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "allOf": [
          {
           "$ref": "#/components/schemas/List"
          },
          {
           "type": "object",
           "properties": {
            "data": {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/CheckoutSession"
             }
            }
           }
          }
         ]
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/checkout-sessions/{id}": {
   "get": {
    "summary": "Retrieve a Checkout Session",
    "operationId": "getCheckoutSession",
    "x-summary-ja": "Checkout Session を取得する",
    "x-scope": "checkout_sessions:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Id"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CheckoutSession"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/checkout-sessions/{id}/expire": {
   "post": {
    "summary": "Expire a Checkout Session",
    "operationId": "expireCheckoutSession",
    "x-summary-ja": "Checkout Session を終了する",
    "x-description-ja": "open のセッションの受付を止めます（status は expired、url は null。Webhook checkout_session.expired）。complete・expired のときは 409 checkout_session_not_open、決済代行会社が支払いを処理している間は 409 checkout_session_in_progress です。",
    "x-scope": "checkout_sessions:write",
    "description": "Stops accepting payments on an open session (status becomes expired, url becomes null; webhook checkout_session.expired). 409 checkout_session_not_open if it is already complete or expired; 409 checkout_session_in_progress while the payment processor is processing a payment for it.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Id"
     },
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CheckoutSession"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/payments": {
   "get": {
    "summary": "List payments",
    "operationId": "listPayments",
    "x-summary-ja": "決済の一覧",
    "x-scope": "payments:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/StartingAfter"
     },
     {
      "$ref": "#/components/parameters/EndingBefore"
     },
     {
      "$ref": "#/components/parameters/Created"
     },
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "created",
        "payment_pending",
        "psp_processing",
        "psp_success",
        "failed",
        "cancelled"
       ]
      }
     },
     {
      "name": "client_reference_id",
      "in": "query",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "allOf": [
          {
           "$ref": "#/components/schemas/List"
          },
          {
           "type": "object",
           "properties": {
            "data": {
             "type": "array",
             "items": {
              "allOf": [
               {
                "$ref": "#/components/schemas/Payment"
               },
               {
                "type": "object",
                "properties": {
                 "transaction": {
                  "oneOf": [
                   {
                    "$ref": "#/components/schemas/Transaction"
                   },
                   {
                    "type": "null"
                   }
                  ],
                  "description": "The transaction of a successful payment (null otherwise), as in GET /payments/{id}"
                 }
                }
               }
              ]
             }
            }
           }
          }
         ]
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/transactions": {
   "get": {
    "summary": "List transactions (successful payments)",
    "operationId": "listTransactions",
    "x-summary-ja": "取引（成功した決済）の一覧",
    "x-description-ja": "取引の ID は決済の ID です。starting_after・ending_before にも決済の ID を指定します。",
    "x-scope": "transactions:read",
    "description": "The id of a transaction is the payment id; starting_after / ending_before also take payment ids.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/StartingAfter"
     },
     {
      "$ref": "#/components/parameters/EndingBefore"
     },
     {
      "$ref": "#/components/parameters/Created"
     },
     {
      "name": "status",
      "in": "query",
      "description": "sale_status",
      "schema": {
       "type": "string",
       "enum": [
        "pending_sale",
        "fulfillment",
        "actual_sale",
        "cancelled"
       ]
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "allOf": [
          {
           "$ref": "#/components/schemas/List"
          },
          {
           "type": "object",
           "properties": {
            "data": {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/Transaction"
             }
            }
           }
          }
         ]
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/events": {
   "get": {
    "summary": "List events",
    "operationId": "listEvents",
    "x-summary-ja": "イベントの一覧",
    "x-description-ja": "Webhook と同じイベントを新しい順に返します（Webhook の送信先が無くても記録します）。受け取れなかった Webhook の照合に使ってください。接続確認の ping は含みません。",
    "x-scope": "events:read",
    "description": "The same events as the webhooks (also recorded when you have no webhook endpoint), newest first. Use it to reconcile webhooks you could not receive. Test pings are not included.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "name": "starting_after",
      "in": "query",
      "schema": {
       "type": "string",
       "pattern": "^evt_[0-9a-z]{26}$"
      }
     },
     {
      "name": "ending_before",
      "in": "query",
      "schema": {
       "type": "string",
       "pattern": "^evt_[0-9a-z]{26}$"
      }
     },
     {
      "$ref": "#/components/parameters/Created"
     },
     {
      "name": "type",
      "in": "query",
      "description": "Exact type, or a prefix ending with .* (e.g. payment.*)",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "resource_id",
      "in": "query",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "allOf": [
          {
           "$ref": "#/components/schemas/List"
          },
          {
           "type": "object",
           "properties": {
            "data": {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/EventObject"
             }
            }
           }
          }
         ]
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/events/{id}": {
   "get": {
    "summary": "Retrieve an event",
    "operationId": "getEvent",
    "x-summary-ja": "イベントを取得する",
    "x-scope": "events:read",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^evt_[0-9a-z]{26}$"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/EventObject"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/payments/{id}": {
   "get": {
    "summary": "Retrieve a payment",
    "operationId": "getPayment",
    "x-summary-ja": "決済を取得する",
    "x-scope": "payments:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Id"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "allOf": [
          {
           "$ref": "#/components/schemas/Payment"
          },
          {
           "type": "object",
           "properties": {
            "transaction": {
             "oneOf": [
              {
               "$ref": "#/components/schemas/Transaction"
              },
              {
               "type": "null"
              }
             ]
            }
           }
          }
         ]
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/transactions/{id}": {
   "get": {
    "summary": "Retrieve a transaction (id = payment id)",
    "operationId": "getTransaction",
    "x-summary-ja": "取引を取得する（ID は決済の ID）",
    "x-scope": "transactions:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Id"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Transaction"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/vouchers/{id}": {
   "get": {
    "summary": "Retrieve a voucher",
    "operationId": "getVoucher",
    "x-summary-ja": "Voucher を取得する",
    "x-scope": "vouchers:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Id"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Voucher"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/refunds": {
   "post": {
    "summary": "Request a cancellation or a direct refund of a payment",
    "description": "What happens depends on the payment processor of the payment. (1) Processor that can cancel payments: a cancellation request. It is accepted (202) and RazPay cancels the payment with the processor; refund.completed or refund.rejected is sent when done. Allowed within the processor's cancellation period (409 cancellation_period_passed after it). If the transaction is already included in a settlement, its payout amount is deducted from a later settlement. Partial cancellation is not supported. The 202 body has no id or type. (2) Processor that cannot cancel payments: a direct refund is created (type direct). The sale and settlement stay unchanged; the merchant refunds the customer directly and records it in the Merchant Console. Partial amounts are allowed (up to the remaining refundable amount, 422 amount_invalid otherwise). Webhooks: refund.requested, refund.recorded (the merchant recorded the refund), refund.completed, refund.withdrawn (the request was withdrawn). The 202 body is the refund (id, type, status, amount_minor, currency, reason, due_on, refunded_on, method, created_at) plus the transaction.",
    "operationId": "requestRefund",
    "x-summary-ja": "決済の取消、または直接の返金を申請する",
    "x-description-ja": "動きは決済の決済代行会社によって変わります。(1) 取消ができる決済代行会社：取消の申請です。202 で受け付け、RazPay が決済代行会社で取り消した後に refund.completed（できなければ refund.rejected）を送ります。決済代行会社の取消可能期間内だけ申請でき、過ぎると 409 cancellation_period_passed です。精算に入った後なら、その支払額を後の精算から差し引きます。一部の取消はできません。202 の本文に id・type はありません。(2) 取消ができない決済代行会社：直接の返金（type direct）を作成します。売上・精算はそのままで、加盟店がお客様へ直接返金し、Merchant Console で記録します。一部の額も指定できます（返金できる残りの額まで。超えると 422 amount_invalid）。Webhook：refund.requested、refund.recorded（加盟店が返金を記録）、refund.completed、refund.withdrawn（申請の取り下げ）。202 の本文は返金（id・type・status・amount_minor・currency・reason・due_on・refunded_on・method・created_at）と取引です。",
    "x-scope": "refunds:write",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "example": {
        "payment_id": "01jbz6x0d3k8h2m5n7p9q4r6s8",
        "reason": "Customer request"
       },
       "schema": {
        "type": "object",
        "required": [
         "payment_id",
         "reason"
        ],
        "properties": {
         "payment_id": {
          "type": "string"
         },
         "amount_minor": {
          "type": "integer",
          "description": "Optional. Cancellation: must equal the payment amount. Direct refund: 1 to the remaining refundable amount (default: all)"
         },
         "reason": {
          "type": "string",
          "maxLength": 1000
         }
        }
       }
      }
     }
    },
    "responses": {
     "202": {
      "description": "Accepted",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "object",
          "payment_id",
          "status",
          "amount_minor",
          "currency",
          "transaction"
         ],
         "properties": {
          "object": {
           "const": "refund"
          },
          "id": {
           "type": "string",
           "description": "Direct refund only: the refund ID (resource_id of refund.* webhooks for direct refunds). Absent for a cancellation request"
          },
          "type": {
           "type": "string",
           "enum": [
            "direct"
           ],
           "description": "Direct refund only. Absent for a cancellation request"
          },
          "payment_id": {
           "type": "string"
          },
          "status": {
           "type": "string",
           "enum": [
            "requested"
           ],
           "description": "Always requested in this response. Later states of a direct refund (webhook data.refund.status): refunded, completed, cancelled"
          },
          "amount_minor": {
           "type": "integer"
          },
          "currency": {
           "type": "string"
          },
          "reason": {
           "type": [
            "string",
            "null"
           ],
           "description": "Direct refund only"
          },
          "due_on": {
           "type": [
            "string",
            "null"
           ],
           "format": "date",
           "description": "Direct refund only: planned refund date (Japan time), if set"
          },
          "refunded_on": {
           "type": [
            "string",
            "null"
           ],
           "format": "date",
           "description": "Direct refund only: date the merchant refunded the customer; null until recorded"
          },
          "method": {
           "type": [
            "string",
            "null"
           ],
           "enum": [
            "bank_transfer",
            "crypto_wallet",
            "cash",
            "other",
            null
           ],
           "description": "Direct refund only: how the merchant refunded; null until recorded"
          },
          "created_at": {
           "type": "string",
           "format": "date-time",
           "description": "Direct refund only"
          },
          "livemode": {
           "type": "boolean",
           "description": "Direct refund only"
          },
          "transaction": {
           "$ref": "#/components/schemas/Transaction"
          }
         }
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   },
   "get": {
    "summary": "List direct refunds",
    "operationId": "listRefunds",
    "x-summary-ja": "直接の返金の一覧",
    "x-description-ja": "直接の返金（type direct）の一覧です。取消ができる決済代行会社の取消の申請は、取引の refund_status で確認してください。",
    "x-scope": "refunds:read",
    "description": "Direct refunds (type direct). Cancellation requests of processors that can cancel are shown on the transaction (refund_status).",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/StartingAfter"
     },
     {
      "$ref": "#/components/parameters/EndingBefore"
     },
     {
      "$ref": "#/components/parameters/Created"
     },
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "requested",
        "refunded",
        "completed",
        "cancelled"
       ]
      }
     },
     {
      "name": "payment_id",
      "in": "query",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "allOf": [
          {
           "$ref": "#/components/schemas/List"
          },
          {
           "type": "object",
           "properties": {
            "data": {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/Refund"
             }
            }
           }
          }
         ]
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/refunds/{id}": {
   "get": {
    "summary": "Retrieve a direct refund",
    "operationId": "getRefund",
    "x-summary-ja": "直接の返金を取得する",
    "x-scope": "refunds:read",
    "parameters": [
     {
      "$ref": "#/components/parameters/Id"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Refund"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/settlements": {
   "get": {
    "summary": "List settlements (newest first)",
    "operationId": "listSettlements",
    "x-summary-ja": "精算の一覧（新しい順）",
    "x-scope": "settlements:read",
    "parameters": [
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 25
      }
     },
     {
      "$ref": "#/components/parameters/StartingAfter"
     },
     {
      "$ref": "#/components/parameters/EndingBefore"
     },
     {
      "$ref": "#/components/parameters/Created"
     },
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "draft",
        "confirmed",
        "paid"
       ]
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "object": {
           "const": "list"
          },
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Settlement"
           }
          },
          "has_more": {
           "type": "boolean"
          },
          "url": {
           "type": "string",
           "examples": [
            "/v1/settlements"
           ]
          }
         }
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  }
 },
 "webhooks": {
  "event": {
   "post": {
    "summary": "Event sent to your endpoint",
    "description": "Headers: X-RazPay-Event-Id, X-RazPay-Timestamp, X-RazPay-Signature (v1=HMAC-SHA256 of \"timestamp.body\" with your signing secret).\nRespond 2xx. Retries after 1m, 5m, 30m, 2h, 12h, 24h on timeout/429/5xx. Order and exactly-once delivery are not guaranteed.\nEvery event is also available from GET /events (same id and data), so you can reconcile events you did not receive.\n",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Event"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Received"
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  },
  "parameters": {
   "Id": {
    "name": "id",
    "in": "path",
    "required": true,
    "schema": {
     "type": "string",
     "pattern": "^[0-9a-z]{26}$"
    }
   },
   "IdempotencyKey": {
    "name": "Idempotency-Key",
    "in": "header",
    "required": true,
    "schema": {
     "type": "string",
     "pattern": "^[A-Za-z0-9_\\-:.]{8,100}$"
    }
   },
   "Limit": {
    "name": "limit",
    "in": "query",
    "schema": {
     "type": "integer",
     "minimum": 1,
     "maximum": 100,
     "default": 10
    }
   },
   "StartingAfter": {
    "name": "starting_after",
    "in": "query",
    "description": "Id of the last object of the current page; returns older objects",
    "schema": {
     "type": "string"
    }
   },
   "EndingBefore": {
    "name": "ending_before",
    "in": "query",
    "description": "Id of the first object of the current page; returns newer objects. Not together with starting_after",
    "schema": {
     "type": "string"
    }
   },
   "Created": {
    "name": "created",
    "in": "query",
    "style": "deepObject",
    "explode": true,
    "description": "created[gte], created[gt], created[lte], created[lt]: Unix seconds or ISO 8601 (UTC if no offset)",
    "schema": {
     "type": "object",
     "properties": {
      "gte": {
       "type": "string"
      },
      "gt": {
       "type": "string"
      },
      "lte": {
       "type": "string"
      },
      "lt": {
       "type": "string"
      }
     }
    }
   }
  },
  "responses": {
   "Error": {
    "description": "Error",
    "content": {
     "application/json": {
      "schema": {
       "type": "object",
       "properties": {
        "error": {
         "type": "object",
         "properties": {
          "code": {
           "type": "string",
           "examples": [
            "unauthorized",
            "insufficient_scope",
            "not_found",
            "validation_failed",
            "invalid_json",
            "idempotency_key_required",
            "idempotency_conflict",
            "request_in_progress",
            "rate_limited",
            "not_refundable",
            "cancellation_period_passed",
            "partial_refund_not_supported",
            "amount_invalid",
            "payments_not_enabled",
            "merchant_suspended",
            "merchant_closed",
            "merchant_unavailable",
            "checkout_session_not_open",
            "checkout_session_in_progress",
            "payment_link_not_deactivatable",
            "method_not_allowed",
            "internal_error"
           ]
          },
          "message": {
           "type": "string",
           "description": "Human-readable message. English by default; Japanese when the request sends Accept-Language: ja"
          },
          "fields": {
           "type": "object",
           "additionalProperties": {
            "type": "array",
            "items": {
             "type": "string"
            }
           }
          }
         }
        },
        "request_id": {
         "type": "string"
        }
       }
      }
     }
    },
    "headers": {
     "X-RateLimit-Limit": {
      "schema": {
       "type": "integer"
      },
      "description": "Requests allowed per minute per key (120)"
     },
     "X-RateLimit-Remaining": {
      "schema": {
       "type": "integer"
      }
     },
     "Retry-After": {
      "schema": {
       "type": "integer"
      },
      "description": "Seconds to wait (429 only)"
     }
    }
   }
  },
  "schemas": {
   "Metadata": {
    "type": "object",
    "maxProperties": 20,
    "description": "Up to 20 pairs. Keys: 1-40 characters [A-Za-z0-9_.-]. Values: strings up to 500 characters (numbers are converted to strings; null or empty removes the key). Returned as an object ({} when empty)",
    "propertyNames": {
     "pattern": "^[A-Za-z0-9_.\\-]{1,40}$"
    },
    "additionalProperties": {
     "type": "string",
     "maxLength": 500
    }
   },
   "List": {
    "type": "object",
    "properties": {
     "object": {
      "const": "list"
     },
     "data": {
      "type": "array",
      "items": {}
     },
     "has_more": {
      "type": "boolean",
      "description": "true if there are more objects in the direction you paginate"
     },
     "url": {
      "type": "string",
      "examples": [
       "/v1/payments"
      ]
     }
    }
   },
   "CheckoutSession": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "object": {
      "const": "checkout_session"
     },
     "url": {
      "type": [
       "string",
       "null"
      ],
      "format": "uri",
      "description": "RazPay hosted payment page. null when the session is no longer open"
     },
     "status": {
      "type": "string",
      "enum": [
       "open",
       "complete",
       "expired"
      ]
     },
     "payment_status": {
      "type": "string",
      "enum": [
       "unpaid",
       "paid"
      ]
     },
     "payment_id": {
      "type": [
       "string",
       "null"
      ],
      "description": "The successful payment"
     },
     "name": {
      "type": "string"
     },
     "description": {
      "type": [
       "string",
       "null"
      ]
     },
     "product_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "quantity": {
      "type": "integer"
     },
     "amount_minor": {
      "type": "integer",
      "description": "Total (unit price × quantity)"
     },
     "currency": {
      "type": "string"
     },
     "display_currency": {
      "type": "string"
     },
     "client_reference_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "metadata": {
      "$ref": "#/components/schemas/Metadata"
     },
     "success_url": {
      "type": [
       "string",
       "null"
      ],
      "description": "As sent (with the {CHECKOUT_SESSION_ID} placeholder)"
     },
     "cancel_url": {
      "type": [
       "string",
       "null"
      ]
     },
     "customer_prefilled": {
      "type": "boolean",
      "description": "Customer details were sent (they are never returned)"
     },
     "lock_email": {
      "type": "boolean"
     },
     "locale": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "ja",
       "en",
       null
      ]
     },
     "auto_eligible_hours": {
      "type": "integer"
     },
     "expires_at": {
      "type": "string",
      "format": "date-time"
     },
     "completed_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "expired_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "livemode": {
      "type": "boolean"
     }
    }
   },
   "Refund": {
    "type": "object",
    "properties": {
     "object": {
      "const": "refund"
     },
     "id": {
      "type": "string"
     },
     "payment_id": {
      "type": "string"
     },
     "type": {
      "type": "string",
      "enum": [
       "direct"
      ]
     },
     "status": {
      "type": "string",
      "enum": [
       "requested",
       "refunded",
       "completed",
       "cancelled"
      ]
     },
     "amount_minor": {
      "type": "integer"
     },
     "currency": {
      "type": "string"
     },
     "reason": {
      "type": [
       "string",
       "null"
      ]
     },
     "due_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date"
     },
     "refunded_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date"
     },
     "method": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "bank_transfer",
       "crypto_wallet",
       "cash",
       "other",
       null
      ]
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "livemode": {
      "type": "boolean"
     },
     "checkout_session_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "client_reference_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "metadata": {
      "$ref": "#/components/schemas/Metadata"
     }
    }
   },
   "EventObject": {
    "description": "The webhook body (Event) plus object, created_at and livemode",
    "allOf": [
     {
      "$ref": "#/components/schemas/Event"
     },
     {
      "type": "object",
      "properties": {
       "object": {
        "const": "event"
       },
       "created_at": {
        "type": "string",
        "format": "date-time"
       },
       "livemode": {
        "type": "boolean"
       }
      }
     }
    ]
   },
   "PaymentLink": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "object": {
      "const": "payment_link"
     },
     "url": {
      "type": "string",
      "format": "uri"
     },
     "name": {
      "type": "string"
     },
     "description": {
      "type": [
       "string",
       "null"
      ]
     },
     "amount_minor": {
      "type": "integer"
     },
     "currency": {
      "type": "string"
     },
     "display_currency": {
      "type": "string"
     },
     "quantity": {
      "type": "integer"
     },
     "product_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "status": {
      "type": "string",
      "enum": [
       "active",
       "disabled"
      ]
     },
     "usable": {
      "type": "boolean"
     },
     "state": {
      "type": "string",
      "enum": [
       "ok",
       "disabled",
       "expired",
       "used",
       "unavailable"
      ]
     },
     "max_uses": {
      "type": [
       "integer",
       "null"
      ]
     },
     "uses_count": {
      "type": "integer"
     },
     "auto_eligible_hours": {
      "type": "integer"
     },
     "expires_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "purpose": {
      "type": "string",
      "enum": [
       "link",
       "email",
       "product",
       "invoice"
      ],
      "description": "link = created by the API, email = email payment link, product = product page, invoice = invoice"
     },
     "client_reference_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "metadata": {
      "$ref": "#/components/schemas/Metadata"
     },
     "livemode": {
      "type": "boolean"
     }
    }
   },
   "Product": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "object": {
      "const": "product"
     },
     "name": {
      "type": "string"
     },
     "description": {
      "type": [
       "string",
       "null"
      ]
     },
     "kind": {
      "type": "string"
     },
     "price_minor": {
      "type": "integer"
     },
     "currency": {
      "type": "string"
     },
     "display_currency": {
      "type": "string"
     },
     "active": {
      "type": "boolean"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "livemode": {
      "type": "boolean"
     }
    }
   },
   "Invoice": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "object": {
      "const": "invoice"
     },
     "invoice_number": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "enum": [
       "draft",
       "issued",
       "paid",
       "void",
       "refunded"
      ]
     },
     "bill_to": {
      "type": "string"
     },
     "description": {
      "type": [
       "string",
       "null"
      ]
     },
     "items": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "description": {
         "type": "string"
        },
        "quantity": {
         "type": "integer"
        },
        "unit_price_minor": {
         "type": "integer"
        },
        "amount_minor": {
         "type": "integer"
        }
       }
      }
     },
     "subtotal_minor": {
      "type": "integer"
     },
     "tax_rate_bp": {
      "type": "integer"
     },
     "tax_minor": {
      "type": "integer"
     },
     "amount_minor": {
      "type": "integer",
      "description": "Total (tax included)"
     },
     "currency": {
      "type": "string"
     },
     "locale": {
      "type": "string",
      "enum": [
       "en",
       "ja"
      ]
     },
     "issue_date": {
      "type": [
       "string",
       "null"
      ],
      "format": "date"
     },
     "due_date": {
      "type": "string",
      "format": "date"
     },
     "auto_eligible_hours": {
      "type": "integer"
     },
     "pay_url": {
      "type": [
       "string",
       "null"
      ],
      "format": "uri"
     },
     "payment_link_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "issued_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "paid_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "livemode": {
      "type": "boolean"
     }
    }
   },
   "Payment": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "order_id": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "enum": [
       "created",
       "payment_pending",
       "psp_processing",
       "psp_success",
       "failed",
       "cancelled"
      ]
     },
     "amount_minor": {
      "type": "integer"
     },
     "currency": {
      "type": "string"
     },
     "fee_minor": {
      "type": "integer"
     },
     "net_minor": {
      "type": "integer"
     },
     "item_name": {
      "type": "string"
     },
     "quantity": {
      "type": "integer"
     },
     "payment_link_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "invoice_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "succeeded_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "object": {
      "const": "payment"
     },
     "livemode": {
      "type": "boolean"
     },
     "checkout_session_id": {
      "type": [
       "string",
       "null"
      ],
      "description": "Checkout Session the payment was made from"
     },
     "client_reference_id": {
      "type": [
       "string",
       "null"
      ],
      "description": "Copied from the Checkout Session or Payment Link"
     },
     "metadata": {
      "$ref": "#/components/schemas/Metadata"
     }
    }
   },
   "Transaction": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "payment_id": {
      "type": "string"
     },
     "order_id": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "description": "pending_sale / fulfillment = payment completed, not yet eligible for settlement (before / after delivery); awaiting_settlement = eligible, included in the next month-end settlement; settled = settlement confirmed",
      "enum": [
       "pending_sale",
       "fulfillment",
       "awaiting_settlement",
       "settled",
       "cancelled",
       "refunded",
       "on_hold"
      ]
     },
     "settlement_status": {
      "type": "string",
      "enum": [
       "not_eligible",
       "awaiting_settlement",
       "settlement_confirmed",
       "excluded"
      ]
     },
     "sale_status": {
      "type": "string",
      "enum": [
       "pending_sale",
       "fulfillment",
       "actual_sale",
       "cancelled"
      ]
     },
     "hold": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "cancel_requested",
       "dispute",
       "manual_review",
       null
      ]
     },
     "refund_status": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "requested",
       "refunded",
       "rejected",
       null
      ]
     },
     "amount_minor": {
      "type": "integer"
     },
     "fee_minor": {
      "type": "integer"
     },
     "net_minor": {
      "type": "integer"
     },
     "currency": {
      "type": "string"
     },
     "pending_at": {
      "type": "string",
      "format": "date-time"
     },
     "auto_eligible_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "Becomes eligible for settlement at this time unless on hold"
     },
     "fulfilled_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "actual_sale_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "cancelled_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "settlement_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "voucher_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "version": {
      "type": "integer"
     },
     "object": {
      "const": "transaction"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "livemode": {
      "type": "boolean"
     },
     "checkout_session_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "client_reference_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "metadata": {
      "$ref": "#/components/schemas/Metadata"
     }
    }
   },
   "Voucher": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "voucher_ref": {
      "type": "string"
     },
     "payment_id": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "enum": [
       "reserved",
       "redeemed",
       "void"
      ]
     },
     "amount_minor": {
      "type": "integer"
     },
     "currency": {
      "type": "string"
     },
     "blockchain_state": {
      "type": "string",
      "description": "not_created until NFT issuance is enabled"
     },
     "mint_address": {
      "type": [
       "string",
       "null"
      ]
     },
     "reserved_at": {
      "type": "string",
      "format": "date-time"
     },
     "redeemed_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "voided_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "object": {
      "const": "voucher"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "livemode": {
      "type": "boolean"
     }
    }
   },
   "Settlement": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "period": {
      "type": "string",
      "examples": [
       "2026-10"
      ]
     },
     "status": {
      "type": "string",
      "enum": [
       "draft",
       "confirmed",
       "paid"
      ]
     },
     "currency": {
      "type": "string"
     },
     "item_count": {
      "type": "integer"
     },
     "gross_minor": {
      "type": "integer"
     },
     "fee_minor": {
      "type": "integer"
     },
     "adjustment_minor": {
      "type": "integer",
      "description": "Offsets deducted from this settlement (negative), e.g. transactions cancelled after an earlier settlement"
     },
     "carried_minor": {
      "type": "integer",
      "description": "Amount that could not be offset and is carried to a later settlement (negative)"
     },
     "net_minor": {
      "type": "integer"
     },
     "pay_date": {
      "type": "string",
      "format": "date"
     },
     "payout_asset": {
      "type": "string",
      "enum": [
       "USDC"
      ],
      "description": "Asset the settlement is paid in (always USDC)"
     },
     "payout_network": {
      "type": "string",
      "enum": [
       "polygon"
      ],
      "description": "Network the payout is sent on (always polygon)"
     },
     "usdc_amount": {
      "type": [
       "string",
       "null"
      ],
      "description": "USDC amount sent, as a decimal string with 6 decimals (truncated); null until the settlement is confirmed",
      "examples": [
       "237.231039"
      ]
     },
     "usdc_rate": {
      "type": [
       "string",
       "null"
      ],
      "description": "Rate fixed when RazPay confirms the settlement: 1 USDC in the settlement currency, as a decimal string with 6 decimals; null until confirmed"
     },
     "rate_source": {
      "type": [
       "string",
       "null"
      ],
      "description": "Where the rate came from: the public rate source for automatic rates, or manual for a rate entered by RazPay; null until confirmed"
     },
     "payout_address": {
      "type": [
       "string",
       "null"
      ],
      "description": "Polygon address (0x + 40 hex characters); null until the settlement is confirmed"
     },
     "txid": {
      "type": [
       "string",
       "null"
      ],
      "description": "Polygon transaction hash (0x + 64 hex characters), viewable on PolygonScan"
     },
     "paid_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "object": {
      "const": "settlement"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "livemode": {
      "type": "boolean"
     }
    }
   },
   "Event": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "description": "evt_… (same on retries)"
     },
     "type": {
      "type": "string",
      "description": "transaction.pending_sale = payment completed (not yet eligible for settlement); transaction.actual_sale = eligible for settlement (awaiting settlement). Refund events have two data shapes. Cancellation (processor that can cancel): refund.requested, refund.completed, refund.rejected (the cancellation request was declined); resource_id = payment ID, resource_version = transaction version, data = Transaction. Direct refund (processor that cannot cancel): refund.requested, refund.recorded (the merchant recorded the refund to the customer), refund.completed, refund.withdrawn (the refund request was withdrawn); resource_id = refund ID, resource_version = refund version (increases on every state change), data = RefundEventData. checkout_session.completed (the payment of a Checkout Session succeeded) and checkout_session.expired (expired by time or by the API): resource_id = session ID, data = CheckoutSession. payment.*, transaction.* and refund.* data include checkout_session_id, client_reference_id and metadata.",
      "enum": [
       "ping",
       "payment.succeeded",
       "payment.failed",
       "transaction.pending_sale",
       "transaction.fulfillment",
       "transaction.actual_sale",
       "transaction.on_hold",
       "transaction.hold_released",
       "refund.requested",
       "refund.recorded",
       "refund.rejected",
       "refund.completed",
       "refund.withdrawn",
       "dispute.opened",
       "dispute.resolved",
       "settlement.created",
       "settlement.confirmed",
       "settlement.reverted",
       "settlement.paid",
       "checkout_session.completed",
       "checkout_session.expired"
      ]
     },
     "occurred_at": {
      "type": "string",
      "format": "date-time"
     },
     "environment": {
      "type": "string",
      "enum": [
       "test",
       "live"
      ]
     },
     "resource_id": {
      "type": "string"
     },
     "resource_version": {
      "type": "integer",
      "description": "Increases with each change of the resource. Ignore an event whose resource_version is lower than one you already processed for the same resource_id"
     },
     "data": {
      "type": "object",
      "description": "Transaction, Settlement, etc. depending on type; RefundEventData for direct-refund events"
     }
    }
   },
   "RefundEventData": {
    "type": "object",
    "description": "data of refund.* events for a direct refund",
    "properties": {
     "payment_id": {
      "type": "string"
     },
     "checkout_session_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "client_reference_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "metadata": {
      "$ref": "#/components/schemas/Metadata"
     },
     "refund": {
      "type": "object",
      "properties": {
       "object": {
        "const": "refund"
       },
       "id": {
        "type": "string"
       },
       "payment_id": {
        "type": "string"
       },
       "type": {
        "type": "string",
        "enum": [
         "direct"
        ]
       },
       "status": {
        "type": "string",
        "enum": [
         "requested",
         "refunded",
         "completed",
         "cancelled"
        ]
       },
       "amount_minor": {
        "type": "integer"
       },
       "currency": {
        "type": "string"
       },
       "reason": {
        "type": [
         "string",
         "null"
        ]
       },
       "due_on": {
        "type": [
         "string",
         "null"
        ],
        "format": "date"
       },
       "refunded_on": {
        "type": [
         "string",
         "null"
        ],
        "format": "date"
       },
       "method": {
        "type": [
         "string",
         "null"
        ],
        "enum": [
         "bank_transfer",
         "crypto_wallet",
         "cash",
         "other",
         null
        ]
       },
       "created_at": {
        "type": "string",
        "format": "date-time"
       },
       "livemode": {
        "type": "boolean"
       }
      }
     },
     "transaction": {
      "$ref": "#/components/schemas/Transaction"
     }
    }
   }
  }
 }
}
