{
    "openapi": "3.0.3",
    "info": {
        "title": "ZexiPay API",
        "version": "2.0.0",
        "description": "Server-only credentials. Hosted and embedded UPI checkout. Payment.success webhooks use HMAC-SHA256; see docs.php#webhooks. Sandbox is nonpayable."
    },
    "servers": [
        {
            "url": "https://zexipay.com"
        }
    ],
    "paths": {
        "/api/create-order": {
            "post": {
                "operationId": "create_order",
                "summary": "Create an order idempotently. Production requires a connected account.",
                "security": [
                    {
                        "apiKey": [],
                        "apiSecret": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "order_id",
                                    "amount",
                                    "customer_name"
                                ],
                                "properties": {
                                    "order_id": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 100,
                                        "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,99}$"
                                    },
                                    "amount": {
                                        "oneOf": [
                                            {
                                                "type": "string",
                                                "pattern": "^(?:0|[1-9][0-9]{0,5})(?:\\.[0-9]{1,2})?$"
                                            },
                                            {
                                                "type": "number",
                                                "minimum": 0.01,
                                                "maximum": 500000,
                                                "multipleOf": 0.01
                                            }
                                        ],
                                        "description": "INR from 0.01 to 500000.00. Calculate on merchant server."
                                    },
                                    "customer_name": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 100
                                    },
                                    "description": {
                                        "type": "string",
                                        "maxLength": 2000
                                    },
                                    "customer_mobile": {
                                        "type": "string",
                                        "pattern": "^\\+?[0-9]{7,15}$"
                                    },
                                    "callback_url": {
                                        "type": "string",
                                        "maxLength": 500,
                                        "format": "uri"
                                    },
                                    "expiry_hours": {
                                        "type": "number",
                                        "minimum": 0,
                                        "maximum": 8760,
                                        "default": 24
                                    },
                                    "is_reusable": {
                                        "type": "boolean",
                                        "default": false
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successful operation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "status",
                                        "data"
                                    ],
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "enum": [
                                                "success"
                                            ]
                                        },
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "payment_url": {
                                                    "type": "string",
                                                    "format": "uri"
                                                },
                                                "order_id": {
                                                    "type": "string",
                                                    "minLength": 1,
                                                    "maxLength": 100,
                                                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,99}$"
                                                },
                                                "token": {
                                                    "type": "string"
                                                },
                                                "amount": {
                                                    "type": "number"
                                                },
                                                "currency": {
                                                    "type": "string",
                                                    "enum": [
                                                        "INR"
                                                    ]
                                                },
                                                "customer_name": {
                                                    "type": "string"
                                                },
                                                "expires_at": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "created_at": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "201": {
                        "description": "New order created",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "status",
                                        "data"
                                    ],
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "enum": [
                                                "success"
                                            ]
                                        },
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "payment_url": {
                                                    "type": "string",
                                                    "format": "uri"
                                                },
                                                "order_id": {
                                                    "type": "string",
                                                    "minLength": 1,
                                                    "maxLength": 100,
                                                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,99}$"
                                                },
                                                "token": {
                                                    "type": "string"
                                                },
                                                "amount": {
                                                    "type": "number"
                                                },
                                                "currency": {
                                                    "type": "string",
                                                    "enum": [
                                                        "INR"
                                                    ]
                                                },
                                                "customer_name": {
                                                    "type": "string"
                                                },
                                                "expires_at": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "created_at": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid JSON",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Invalid credentials",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Order not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "Conflict or account/checkout unavailable",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "413": {
                        "description": "Request exceeds 64 KiB",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validation failure",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Rate or plan limit",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "Temporarily unavailable",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/prepare-checkout": {
            "post": {
                "operationId": "prepare_checkout",
                "summary": "Prepare single-use production checkout. Display returned exact amount and payment_note.",
                "security": [
                    {
                        "apiKey": [],
                        "apiSecret": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "order_id"
                                ],
                                "properties": {
                                    "order_id": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 100,
                                        "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,99}$"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successful operation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "status",
                                        "data"
                                    ],
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "enum": [
                                                "success"
                                            ]
                                        },
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "order_id": {
                                                    "type": "string"
                                                },
                                                "amount": {
                                                    "type": "string"
                                                },
                                                "provider": {
                                                    "type": "string"
                                                },
                                                "payee_name": {
                                                    "type": "string"
                                                },
                                                "upi_uri": {
                                                    "type": "string"
                                                },
                                                "qr_image_url": {
                                                    "type": "string"
                                                },
                                                "payment_note": {
                                                    "type": "string"
                                                },
                                                "expires_at": {
                                                    "type": "string"
                                                },
                                                "requested_amount": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "currency": {
                                                    "type": "string",
                                                    "enum": [
                                                        "INR"
                                                    ]
                                                },
                                                "expires_at_unix": {
                                                    "type": "integer"
                                                },
                                                "payment_status": {
                                                    "type": "string",
                                                    "enum": [
                                                        "pending"
                                                    ]
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid JSON",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Invalid credentials",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Order not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "Conflict or account/checkout unavailable",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "413": {
                        "description": "Request exceeds 64 KiB",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validation failure",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Rate or plan limit",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "Temporarily unavailable",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/check-status": {
            "post": {
                "operationId": "check_status",
                "summary": "Read data.payment_status. Top-level success never confirms a payment.",
                "security": [
                    {
                        "apiKey": [],
                        "apiSecret": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "order_id"
                                ],
                                "properties": {
                                    "order_id": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 100,
                                        "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,99}$"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successful operation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "status",
                                        "data"
                                    ],
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "enum": [
                                                "success"
                                            ]
                                        },
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "customer_name": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "customer_mobile": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "utr": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "payment_method": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "provider": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "gateway_txn_id": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "paid_at": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "payment_url": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "callback_url": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "expires_at": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "created_at": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "order_id": {
                                                    "type": "string",
                                                    "minLength": 1,
                                                    "maxLength": 100,
                                                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,99}$"
                                                },
                                                "amount": {
                                                    "type": "number"
                                                },
                                                "requested_amount": {
                                                    "oneOf": [
                                                        {
                                                            "type": "string"
                                                        },
                                                        {
                                                            "type": "number"
                                                        }
                                                    ],
                                                    "nullable": true
                                                },
                                                "currency": {
                                                    "type": "string",
                                                    "enum": [
                                                        "INR"
                                                    ]
                                                },
                                                "payment_status": {
                                                    "type": "string",
                                                    "enum": [
                                                        "pending",
                                                        "success",
                                                        "failed",
                                                        "refunded"
                                                    ]
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid JSON",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Invalid credentials",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Order not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "Conflict or account/checkout unavailable",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "413": {
                        "description": "Request exceeds 64 KiB",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validation failure",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Rate or plan limit",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "Temporarily unavailable",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        },
                                        "details": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "apiKey": {
                "type": "apiKey",
                "in": "header",
                "name": "X-API-Key"
            },
            "apiSecret": {
                "type": "apiKey",
                "in": "header",
                "name": "X-API-Secret"
            }
        }
    }
}