{
  "openapi": "3.1.0",
  "info": {
    "title": "Thuprai Pay Merchant API",
    "version": "1.0.0",
    "description": "Server-to-server API for hosted checkout.\n\n**Amounts** are integers in minor units (paisa for NPR, cents for USD). `amount` is tax-inclusive.\n\n**Trust rule:** never fulfill from the browser redirect alone. Always call verify before fulfillment.\n\n**Awecount (optional):** when sync is on, Success posts a sales voucher. Create then requires products[].code and customer.name. See human docs `/docs#awecount` and `/llms-full.txt`."
  },
  "servers": [
    {
      "url": "https://pay.awecode.com",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Orders",
      "description": "Create, read, verify, cancel, cash, receipt, return, exchange."
    },
    {
      "name": "Webhooks",
      "description": "Outbound events to your server."
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "Merchant API key: `Authorization: Bearer ps_...`"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer",
            "example": 409
          },
          "statusMessage": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Product": {
        "type": "object",
        "required": [
          "name",
          "quantity",
          "amount"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1
          },
          "amount": {
            "type": "integer",
            "description": "Line gross total in minor units (tax-inclusive), not unit price."
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "maxLength": 64,
            "description": "Stable Awecount item code. Required on every line when merchant Awecount sync is on (unless awecountSync:false)."
          },
          "discount": {
            "type": "integer",
            "minimum": 0,
            "description": "Line discount in minor units (tax-inclusive), <= line amount."
          },
          "category": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "hsCode": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "tax": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "rate": {
                "type": "number",
                "description": "e.g. 13 for 13% VAT"
              }
            }
          }
        }
      },
      "CreateOrderRequest": {
        "type": "object",
        "required": [
          "amount"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "minimum": 0,
            "description": "Payable total in minor units (tax- and shipping-inclusive), already net of discount. Digital requires > 0. Zero only with method:cash and discount > 0.",
            "example": 150000
          },
          "tax": {
            "type": "integer",
            "minimum": 0,
            "default": 0
          },
          "shipping": {
            "type": "integer",
            "minimum": 0,
            "default": 0
          },
          "currency": {
            "type": "string",
            "minLength": 3,
            "maxLength": 3,
            "default": "NPR",
            "example": "NPR"
          },
          "orderId": {
            "type": [
              "string",
              "null"
            ]
          },
          "orderNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "Unique per merchant. Auto-set if omitted."
          },
          "terminalId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "message": {
            "type": [
              "string",
              "null"
            ],
            "description": "Shown on hosted checkout. Not Awecount remarks."
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Must be in the future."
          },
          "successRedirectUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Per-order override. Required (400) when the merchant has no success redirect default."
          },
          "failureRedirectUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Per-order override. Required (400) when the merchant has no failure redirect default."
          },
          "products": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/Product"
            }
          },
          "data": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true,
            "description": "Pass-through JSON. Not shown on checkout."
          },
          "tags": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string",
              "maxLength": 64
            },
            "maxItems": 20
          },
          "discount": {
            "type": "integer",
            "minimum": 0,
            "default": 0,
            "description": "Order-level commercial discount (tax-inclusive). Payable amount is already net."
          },
          "customer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Customer"
              },
              {
                "type": "null"
              }
            ],
            "description": "Buyer billing for Awecount. customer.name required when sync is on."
          },
          "remarks": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500,
            "description": "Awecount voucher remarks (not checkout message)."
          },
          "method": {
            "type": "string",
            "description": "Collect method from GET /api/payment-methods (e.g. Cash, Upaya). Legacy cash accepted. Create+record; checkoutUrl null."
          },
          "awecountSync": {
            "type": "boolean",
            "description": "false = skip Awecount for this order (no code/name gate). Omit/true = follow merchant awecountSyncEnabled."
          }
        }
      },
      "CreateOrderResponse": {
        "type": "object",
        "required": [
          "id",
          "reference"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "type": "string"
          },
          "checkoutUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Redirect here for digital checkout. null for method:cash."
          }
        }
      },
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "orderId": {
            "type": [
              "string",
              "null"
            ]
          },
          "orderNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "reference": {
            "type": "string"
          },
          "amount": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "Open",
              "Success",
              "Failed",
              "Canceled",
              "Expired"
            ]
          },
          "data": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "transactionId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "gateway": {
            "type": [
              "string",
              "null"
            ]
          },
          "gatewayReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "verified": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "customer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Customer"
              },
              {
                "type": "null"
              }
            ]
          },
          "remarks": {
            "type": [
              "string",
              "null"
            ]
          },
          "discount": {
            "type": "integer"
          },
          "receipt": {
            "$ref": "#/components/schemas/Receipt"
          },
          "fulfilled": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Present on cash create / verify / exchange faces."
          }
        }
      },
      "VerifyResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Order"
          },
          {
            "type": "object",
            "properties": {
              "fulfilled": {
                "type": "boolean",
                "description": "Fulfill only when true."
              },
              "verificationResult": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "Success",
                  "Failed",
                  "Error",
                  "Pending",
                  null
                ]
              }
            }
          }
        ]
      },
      "CancelResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "Canceled"
            ]
          }
        }
      },
      "WebhookPayload": {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "payment_success",
              "payment_failed",
              "receipt_synced",
              "exchange_fulfilled"
            ]
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Our order UUID. Use for POST /api/orders/{id}/verify."
          },
          "orderId": {
            "type": "string",
            "description": "Your create-time orderId if set, otherwise our order UUID."
          },
          "transactionId": {
            "type": "string",
            "format": "uuid"
          },
          "amount": {
            "type": "integer",
            "description": "Minor units (paisa / cents)."
          },
          "currency": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "gateway": {
            "type": "string"
          },
          "gatewayReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "data": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Refund": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Refund id."
          },
          "orderId": {
            "type": "string",
            "format": "uuid",
            "description": "Parent sale order id."
          },
          "reference": {
            "type": "string",
            "description": "Idempotency key, unique per merchant."
          },
          "gateway": {
            "type": "string",
            "example": "cash"
          },
          "amount": {
            "type": "integer",
            "description": "Refund in minor units (tax-inclusive)."
          },
          "tax": {
            "type": "integer"
          },
          "discount": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "Success",
              "Failed"
            ]
          },
          "receipt": {
            "type": [
              "object",
              "null"
            ],
            "description": "Credit-note receipt; billNo is the Awecount credit-note voucher_no."
          },
          "fulfilled": {
            "type": "boolean"
          },
          "verificationResult": {
            "type": "string"
          }
        }
      },
      "Customer": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120,
            "description": "Required when Awecount sync is on. No generic fallback."
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 254
          },
          "phone": {
            "type": "string",
            "maxLength": 32
          },
          "taxId": {
            "type": "string",
            "description": "Nepal PAN (9 digits; hyphens ok). VAT-claimable buyer. Wrong length ignored."
          }
        }
      },
      "Receipt": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "billNo": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "synced | pending | failed"
          },
          "syncedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "invoice": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true,
            "description": "Print subset (billNo, customerName, lines, \u2026)."
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/orders": {
      "post": {
        "tags": [
          "Orders"
        ],
        "operationId": "createOrder",
        "summary": "Create order",
        "description": "Creates a checkout order. Digital: returns checkoutUrl. Cash (method:cash): Success + optional Awecount receipt, checkoutUrl null.\n\nWhen merchant Awecount sync is on (and awecountSync is not false): every products[].code and customer.name are required.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOrderRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Order created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateOrderResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation failed / bad terminalId",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Merchant disabled"
          },
          "409": {
            "description": "Duplicate reference",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/orders/{id}": {
      "get": {
        "tags": [
          "Orders"
        ],
        "operationId": "getOrder",
        "summary": "Get order",
        "description": "Read order state. For fulfillment, call **verify** - do not fulfill from get alone.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/orders/{id}/verify": {
      "post": {
        "tags": [
          "Orders"
        ],
        "operationId": "verifyOrder",
        "summary": "Verify payment",
        "description": "**Required before fulfillment.** Confirms payment with the gateway. Fulfill only when `fulfilled` is `true`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Verification result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerifyResponse"
                },
                "examples": {
                  "paid": {
                    "summary": "Paid",
                    "value": {
                      "id": "019f8c2a-7b1e-7000-8000-abcdef012345",
                      "orderId": "1000123",
                      "status": "Success",
                      "verified": true,
                      "fulfilled": true,
                      "verificationResult": "Success",
                      "gateway": "esewa"
                    }
                  },
                  "pending": {
                    "summary": "Not paid yet",
                    "value": {
                      "id": "019f8c2a-7b1e-7000-8000-abcdef012345",
                      "status": "Open",
                      "verified": false,
                      "fulfilled": false,
                      "verificationResult": "Pending"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No payment attempt / cannot verify"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/orders/{id}/return": {
      "post": {
        "tags": [
          "Orders"
        ],
        "operationId": "returnOrder",
        "summary": "Cash sales return",
        "description": "Partial or full cash sales return against a Success order. Sync on \u2192 Awecount credit note. Sync off \u2192 local return only. Idempotent on reference. Product codes required when sync on; parent receipt must be synced.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Original payment-service order id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "method",
                  "amount",
                  "products",
                  "reference"
                ],
                "properties": {
                  "method": {
                    "type": "string",
                    "enum": [
                      "cash"
                    ]
                  },
                  "amount": {
                    "type": "integer"
                  },
                  "tax": {
                    "type": "integer"
                  },
                  "discount": {
                    "type": "integer"
                  },
                  "products": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Product"
                    }
                  },
                  "reference": {
                    "type": "string"
                  },
                  "remarks": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Refund with credit-note receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refund"
                }
              }
            }
          },
          "400": {
            "description": "Validation failed"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Cash not enabled"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Not returnable / duplicate reference / receipt not ready / exceeds order amount"
          }
        }
      }
    },
    "/api/orders/{id}/exchange": {
      "post": {
        "tags": [
          "Orders"
        ],
        "operationId": "exchangeOrder",
        "summary": "Order exchange (CN + INV + net settle)",
        "description": "Amend a Success order: optional cash credit note (return), optional cash tax invoice (sale), optional net settle. settleAmount = max(0, sale.amount \u2212 return.amount). Settle never posts a third sales voucher.\n\nReceipt timing (sync on): digital settle + net > 0 \u2192 CN/INV deferred until settle Success (POST returns fulfilled:false, receipt:null). Cash settle / net 0 / return-only \u2192 immediate. Confirm amend on fulfilled:true and/or exchange_fulfilled \u2014 not settle payment_success alone.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Original payment-service Success order id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "reference"
                ],
                "properties": {
                  "reference": {
                    "type": "string",
                    "description": "Idempotency key, unique per merchant."
                  },
                  "remarks": {
                    "type": "string",
                    "nullable": true
                  },
                  "return": {
                    "type": "object",
                    "required": [
                      "amount",
                      "products"
                    ],
                    "properties": {
                      "amount": {
                        "type": "integer"
                      },
                      "tax": {
                        "type": "integer"
                      },
                      "discount": {
                        "type": "integer"
                      },
                      "products": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/Product"
                        }
                      }
                    }
                  },
                  "sale": {
                    "type": "object",
                    "required": [
                      "amount",
                      "products"
                    ],
                    "properties": {
                      "amount": {
                        "type": "integer"
                      },
                      "tax": {
                        "type": "integer"
                      },
                      "discount": {
                        "type": "integer"
                      },
                      "products": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/Product"
                        }
                      }
                    }
                  },
                  "settle": {
                    "type": "object",
                    "required": [
                      "method"
                    ],
                    "properties": {
                      "method": {
                        "type": "string",
                        "enum": [
                          "digital",
                          "cash"
                        ]
                      },
                      "successRedirectUrl": {
                        "type": "string",
                        "format": "uri",
                        "nullable": true
                      },
                      "failureRedirectUrl": {
                        "type": "string",
                        "format": "uri",
                        "nullable": true
                      },
                      "expiresAt": {
                        "type": "string",
                        "format": "date-time"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Exchange face with optional nested return/sale and settle checkoutUrl",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "reference": {
                      "type": "string"
                    },
                    "parentOrderId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "Open",
                        "Fulfilled",
                        "Failed"
                      ]
                    },
                    "settleAmount": {
                      "type": "integer"
                    },
                    "settleOrderId": {
                      "type": "string",
                      "format": "uuid",
                      "nullable": true
                    },
                    "checkoutUrl": {
                      "type": "string",
                      "nullable": true
                    },
                    "fulfilled": {
                      "type": "boolean"
                    },
                    "return": {
                      "nullable": true,
                      "$ref": "#/components/schemas/Refund"
                    },
                    "sale": {
                      "nullable": true,
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation failed"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Cash not enabled"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Not exchangeable / duplicate reference / receipt not ready / refund exceeds order"
          }
        }
      }
    },
    "/api/orders/{id}/cancel": {
      "post": {
        "tags": [
          "Orders"
        ],
        "operationId": "cancelOrder",
        "summary": "Cancel order",
        "description": "Cancel an `Open` order. Already paid orders cannot be canceled.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Canceled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CancelResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Not cancelable"
          }
        }
      }
    },
    "/api/payment-methods": {
      "get": {
        "tags": [
          "Orders"
        ],
        "operationId": "listPaymentMethods",
        "summary": "List collect payment methods",
        "description": "Names the merchant can pass to record-payment (Cash when cashEnabled, record-flagged gateways, custom methods).",
        "responses": {
          "200": {
            "description": "Collect method names",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["methods"],
                  "properties": {
                    "methods": {
                      "type": "array",
                      "items": { "type": "string" }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/orders/{id}/record-payment": {
      "post": {
        "tags": [
          "Orders"
        ],
        "operationId": "recordPayment",
        "summary": "Record payment on Open order",
        "description": "Mark an existing Open order Success with a collect method name from GET /api/payment-methods. Awaits Awecount when sync on.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["method"],
                "properties": {
                  "method": {
                    "type": "string",
                    "description": "Name from GET /api/payment-methods (e.g. Cash, Fonepay QR, Upaya)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success face (may include receipt)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerifyResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Method not enabled"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Not Open / already paid / expired"
          }
        }
      }
    },
    "/api/orders/{id}/receipt": {
      "post": {
        "tags": [
          "Orders"
        ],
        "operationId": "issueOrderReceipt",
        "summary": "Force / repair Awecount receipt",
        "description": "Backfill or retry Awecount sales voucher on a Success order. Body may supply products/tax/discount/customer/remarks/shipping. Payable amount is never rewritten. Requires awecountSyncEnabled; needs product codes and customer.name.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "products": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Product"
                    }
                  },
                  "tax": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "shipping": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "discount": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "customer": {
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/Customer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "remarks": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Order face with receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerifyResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing codes / customer.name / tax bounds"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Awecount sync not enabled"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Not Success / sync pending / state changed"
          }
        }
      }
    }
  },
  "webhooks": {
    "paymentEvent": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Merchant webhook events",
        "description": "Delivered to your configured success/failure webhook URL (payment_success / receipt_synced / exchange_fulfilled \u2192 success URL; payment_failed \u2192 failure URL). Same URL for both is fine.\n\nHeaders:\n- `X-Event-ID` - stable across retries (idempotency)\n- `X-Webhook-Signature: sha256=<hex>` - HMAC-SHA256 of raw body with your signing secret (UTF-8)\n\nRetries: max 6 attempts; backoff 1m, 5m, 15m, 1h, 4h, then Exhausted.\n\nBody includes `id` (our order UUID) for verify. Respond `2xx`. Still call **verify** before fulfillment. For digital exchange, confirm the amend on `exchange_fulfilled` / fulfilled:true \u2014 not payment_success alone.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookPayload"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledge receipt"
          }
        }
      }
    }
  }
}
