{
    "openapi": "3.1.0",
    "info": {
        "title": "GSM Pay Merchant API",
        "version": "1.0",
        "description": "Server-side hosted checkout and merchant invoice API."
    },
    "servers": [
        {
            "url": "https://pay.gsmpk.com"
        }
    ],
    "components": {
        "securitySchemes": {
            "MerchantApiKey": {
                "type": "apiKey",
                "in": "header",
                "name": "X-API-KEY"
            }
        },
        "schemas": {
            "CreateInvoiceRequest": {
                "type": "object",
                "required": [
                    "amount",
                    "currency"
                ],
                "properties": {
                    "amount": {
                        "type": "string",
                        "examples": [
                            "12.50000000"
                        ]
                    },
                    "currency": {
                        "type": "string",
                        "examples": [
                            "USDT"
                        ]
                    },
                    "customer_name": {
                        "type": "string"
                    },
                    "cus_email": {
                        "type": "string",
                        "format": "email"
                    },
                    "additional_id": {
                        "type": "string"
                    },
                    "callback_url": {
                        "type": "string",
                        "format": "uri"
                    }
                }
            }
        }
    },
    "paths": {
        "/api/payment.php": {
            "post": {
                "summary": "Create a pending hosted-payment invoice",
                "security": [
                    {
                        "MerchantApiKey": []
                    }
                ],
                "parameters": [
                    {
                        "name": "X-Idempotency-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CreateInvoiceRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Invoice created or idempotently replayed."
                    },
                    "401": {
                        "description": "Authentication failed."
                    },
                    "409": {
                        "description": "State or idempotency conflict."
                    },
                    "422": {
                        "description": "Validation failed."
                    }
                }
            }
        },
        "/api/ascertain.php": {
            "get": {
                "summary": "Read merchant-scoped invoice status",
                "security": [
                    {
                        "MerchantApiKey": []
                    }
                ],
                "parameters": [
                    {
                        "name": "invoice_id",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Current invoice state."
                    },
                    "401": {
                        "description": "Authentication failed."
                    },
                    "404": {
                        "description": "Invoice unavailable to authenticated merchant."
                    }
                }
            }
        }
    }
}