{
    "schemes": [],
    "swagger": "2.0",
    "info": {
        "description": "Payment service API",
        "title": "CodeKriti Payment API",
        "contact": {},
        "version": "1.0"
    },
    "host": "",
    "basePath": "",
    "paths": {
        "/v1/payment/intents": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "List payment intents",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment permissions",
                        "name": "X-PAYMENT-PERMISSIONS",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "integer",
                        "description": "Limit",
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.PaymentIntentListResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            },
            "post": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "Create payment intent",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Idempotency key",
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true
                    },
                    {
                        "description": "Create intent request",
                        "name": "request",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/service.CreateIntentRequest"
                        }
                    }
                ],
                "responses": {
                    "201": {
                        "description": "Created",
                        "schema": {
                            "$ref": "#/definitions/service.CreateIntentResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    },
                    "409": {
                        "description": "Conflict",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        },
        "/v1/payment/intents/{id}": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "Get payment intent",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment permissions",
                        "name": "X-PAYMENT-PERMISSIONS",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment intent ID",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.PaymentIntentDTO"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        },
        "/v1/payment/intents/{id}/checkout": {
            "post": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "Start provider checkout",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Idempotency key",
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment intent ID",
                        "name": "id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Checkout request",
                        "name": "request",
                        "in": "body",
                        "schema": {
                            "$ref": "#/definitions/service.CheckoutRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.CheckoutResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    },
                    "409": {
                        "description": "Conflict",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        },
        "/v1/payment/ledger": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "List payment ledger entries",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment permissions",
                        "name": "X-PAYMENT-PERMISSIONS",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "integer",
                        "description": "Limit",
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.PaymentLedgerEntryListResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        },
        "/v1/payment/payments": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "List payments",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment permissions",
                        "name": "X-PAYMENT-PERMISSIONS",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "integer",
                        "description": "Limit",
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.PaymentListResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        },
        "/v1/payment/payments/{id}": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "Get payment",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment permissions",
                        "name": "X-PAYMENT-PERMISSIONS",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment ID",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.PaymentDTO"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        },
        "/v1/payment/payments/{id}/refunds": {
            "post": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "Create provider refund",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Idempotency key",
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment ID",
                        "name": "id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Refund request",
                        "name": "request",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/service.RefundCreateRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.RefundCreateResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    },
                    "409": {
                        "description": "Conflict",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        },
        "/v1/payment/providers": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "List payment provider accounts",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment permissions",
                        "name": "X-PAYMENT-PERMISSIONS",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "integer",
                        "description": "Limit",
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.PaymentProviderAccountListResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        },
        "/v1/payment/providers/{provider_account_code}/webhooks": {
            "post": {
                "tags": [
                    "payment"
                ],
                "summary": "Ingest provider payment webhook",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Provider account code",
                        "name": "provider_account_code",
                        "in": "path",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Provider signature",
                        "name": "X-Provider-Signature",
                        "in": "header"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.WebhookResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    },
                    "422": {
                        "description": "Unprocessable Entity",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        },
        "/v1/payment/refunds": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "List refunds",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment permissions",
                        "name": "X-PAYMENT-PERMISSIONS",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "integer",
                        "description": "Limit",
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.RefundListResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        },
        "/v1/payment/refunds/{id}": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "Get refund",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment permissions",
                        "name": "X-PAYMENT-PERMISSIONS",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Refund ID",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.RefundDTO"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        },
        "/v1/payment/webhook-events": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "tags": [
                    "payment"
                ],
                "summary": "List payment webhook events",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Tenant ID",
                        "name": "X-TENANT-ID",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Payment permissions",
                        "name": "X-PAYMENT-PERMISSIONS",
                        "in": "header",
                        "required": true
                    },
                    {
                        "type": "integer",
                        "description": "Limit",
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/service.PaymentWebhookEventListResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/httpapi.ErrorBody"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "httpapi.ErrorBody": {
            "type": "object",
            "properties": {
                "code": {
                    "type": "string"
                },
                "details": {},
                "message": {
                    "type": "string"
                },
                "request_id": {
                    "type": "string"
                }
            }
        },
        "service.CheckoutRequest": {
            "type": "object",
            "properties": {
                "actor_id": {
                    "type": "string"
                },
                "cancel_url": {
                    "type": "string"
                },
                "return_url": {
                    "type": "string"
                }
            }
        },
        "service.CheckoutResponse": {
            "type": "object",
            "properties": {
                "checkout_key": {
                    "type": "string"
                },
                "checkout_mode": {
                    "type": "string"
                },
                "checkout_url": {
                    "type": "string"
                },
                "client_token": {
                    "type": "string"
                },
                "expires_at": {
                    "type": "string"
                },
                "payment": {
                    "$ref": "#/definitions/service.PaymentDTO"
                },
                "payment_intent": {
                    "$ref": "#/definitions/service.PaymentIntentDTO"
                },
                "provider": {
                    "type": "string"
                },
                "provider_order_id": {
                    "type": "string"
                },
                "replayed": {
                    "type": "boolean"
                }
            }
        },
        "service.CreateIntentRequest": {
            "type": "object",
            "properties": {
                "actor_id": {
                    "type": "string"
                },
                "amount_minor": {
                    "type": "integer"
                },
                "currency": {
                    "type": "string"
                },
                "owner_id": {
                    "type": "string"
                },
                "owner_module": {
                    "type": "string"
                },
                "owner_type": {
                    "type": "string"
                },
                "provider_account_code": {
                    "type": "string"
                },
                "purpose": {
                    "type": "string"
                }
            }
        },
        "service.CreateIntentResponse": {
            "type": "object",
            "properties": {
                "payment_intent": {
                    "$ref": "#/definitions/service.PaymentIntentDTO"
                },
                "replayed": {
                    "type": "boolean"
                }
            }
        },
        "service.PaymentDTO": {
            "type": "object",
            "properties": {
                "amount_minor": {
                    "type": "integer"
                },
                "captured_amount_minor": {
                    "type": "integer"
                },
                "created_at": {
                    "type": "string"
                },
                "currency": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "intent_id": {
                    "type": "string"
                },
                "provider_account_code": {
                    "type": "string"
                },
                "provider_correlation_id": {
                    "type": "string"
                },
                "provider_order_id": {
                    "type": "string"
                },
                "provider_payment_id": {
                    "type": "string"
                },
                "refunded_amount_minor": {
                    "type": "integer"
                },
                "status": {
                    "type": "string"
                },
                "updated_at": {
                    "type": "string"
                }
            }
        },
        "service.PaymentIntentDTO": {
            "type": "object",
            "properties": {
                "amount_minor": {
                    "type": "integer"
                },
                "created_at": {
                    "type": "string"
                },
                "currency": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "owner_id": {
                    "type": "string"
                },
                "owner_module": {
                    "type": "string"
                },
                "owner_type": {
                    "type": "string"
                },
                "payment_id": {
                    "type": "string"
                },
                "provider_account_code": {
                    "type": "string"
                },
                "purpose": {
                    "type": "string"
                },
                "status": {
                    "type": "string"
                },
                "updated_at": {
                    "type": "string"
                }
            }
        },
        "service.PaymentIntentListResponse": {
            "type": "object",
            "properties": {
                "data": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/service.PaymentIntentDTO"
                    }
                },
                "limit": {
                    "type": "integer"
                },
                "order": {
                    "type": "string"
                }
            }
        },
        "service.PaymentLedgerEntryDTO": {
            "type": "object",
            "properties": {
                "amount_minor": {
                    "type": "integer"
                },
                "created_at": {
                    "type": "string"
                },
                "currency": {
                    "type": "string"
                },
                "entry_type": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "occurred_at": {
                    "type": "string"
                },
                "source_id": {
                    "type": "string"
                },
                "source_type": {
                    "type": "string"
                },
                "updated_at": {
                    "type": "string"
                }
            }
        },
        "service.PaymentLedgerEntryListResponse": {
            "type": "object",
            "properties": {
                "data": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/service.PaymentLedgerEntryDTO"
                    }
                },
                "limit": {
                    "type": "integer"
                },
                "order": {
                    "type": "string"
                }
            }
        },
        "service.PaymentListResponse": {
            "type": "object",
            "properties": {
                "data": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/service.PaymentDTO"
                    }
                },
                "limit": {
                    "type": "integer"
                },
                "order": {
                    "type": "string"
                }
            }
        },
        "service.PaymentProviderAccountDTO": {
            "type": "object",
            "properties": {
                "capabilities": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "created_at": {
                    "type": "string"
                },
                "display_name": {
                    "type": "string"
                },
                "enabled": {
                    "type": "boolean"
                },
                "id": {
                    "type": "string"
                },
                "provider_account_code": {
                    "type": "string"
                },
                "provider_code": {
                    "type": "string"
                },
                "status": {
                    "type": "string"
                },
                "updated_at": {
                    "type": "string"
                }
            }
        },
        "service.PaymentProviderAccountListResponse": {
            "type": "object",
            "properties": {
                "data": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/service.PaymentProviderAccountDTO"
                    }
                },
                "limit": {
                    "type": "integer"
                },
                "order": {
                    "type": "string"
                }
            }
        },
        "service.PaymentWebhookEventDTO": {
            "type": "object",
            "properties": {
                "created_at": {
                    "type": "string"
                },
                "event_type": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "provider_account_code": {
                    "type": "string"
                },
                "provider_event_id": {
                    "type": "string"
                },
                "raw_payload_hash": {
                    "type": "string"
                },
                "received_at": {
                    "type": "string"
                },
                "status": {
                    "type": "string"
                },
                "updated_at": {
                    "type": "string"
                }
            }
        },
        "service.PaymentWebhookEventListResponse": {
            "type": "object",
            "properties": {
                "data": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/service.PaymentWebhookEventDTO"
                    }
                },
                "limit": {
                    "type": "integer"
                },
                "order": {
                    "type": "string"
                }
            }
        },
        "service.RefundCreateRequest": {
            "type": "object",
            "properties": {
                "actor_id": {
                    "type": "string"
                },
                "amount_minor": {
                    "type": "integer"
                },
                "currency": {
                    "type": "string"
                },
                "metadata": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    }
                },
                "mode": {
                    "type": "string"
                },
                "reason": {
                    "type": "string"
                }
            }
        },
        "service.RefundCreateResponse": {
            "type": "object",
            "properties": {
                "payment": {
                    "$ref": "#/definitions/service.PaymentDTO"
                },
                "refund": {
                    "$ref": "#/definitions/service.RefundDTO"
                },
                "replayed": {
                    "type": "boolean"
                }
            }
        },
        "service.RefundDTO": {
            "type": "object",
            "properties": {
                "amount_minor": {
                    "type": "integer"
                },
                "created_at": {
                    "type": "string"
                },
                "currency": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "payment_id": {
                    "type": "string"
                },
                "provider_account_code": {
                    "type": "string"
                },
                "provider_correlation_id": {
                    "type": "string"
                },
                "provider_refund_id": {
                    "type": "string"
                },
                "reason": {
                    "type": "string"
                },
                "status": {
                    "type": "string"
                },
                "updated_at": {
                    "type": "string"
                }
            }
        },
        "service.RefundListResponse": {
            "type": "object",
            "properties": {
                "data": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/service.RefundDTO"
                    }
                },
                "limit": {
                    "type": "integer"
                },
                "order": {
                    "type": "string"
                }
            }
        },
        "service.WebhookResponse": {
            "type": "object",
            "properties": {
                "duplicate": {
                    "type": "boolean"
                },
                "event_type": {
                    "type": "string"
                },
                "payment_id": {
                    "type": "string"
                },
                "provider_event_id": {
                    "type": "string"
                },
                "status": {
                    "type": "string"
                }
            }
        }
    },
    "securityDefinitions": {
        "BearerAuth": {
            "description": "Bearer token",
            "type": "apiKey",
            "name": "Authorization",
            "in": "header"
        }
    }
}