openapi: 3.0.3
info:
  title: Fiatsend Partner API
  description: |
    The Fiatsend Partner API lets platforms integrate stablecoin-to-mobile-money payouts and hosted checkout for their users in Africa.

    Fiatsend converts stablecoins (USDC, USDT) into local fiat currency (GHS) and delivers funds directly to mobile money wallets (MTN MoMo, Telecel Cash, AirtelTigo Money) in seconds.

    ## Authentication

    All API requests require a Bearer token in the `Authorization` header:

    ```
    Authorization: Bearer your_api_key_here
    ```

    API keys are issued during partner onboarding. Contact partners@fiatsend.com to get started.

    ## Environments

    | Environment | Base URL |
    |-------------|----------|
    | Sandbox | `https://sandbox.fiatsend.com` |
    | Production | `https://api.fiatsend.com` |

    ## Rate Limits

    | Plan | Requests/min | Requests/day |
    |------|-------------|-------------|
    | Sandbox | 60 | 10,000 |
    | Production | 300 | 100,000 |

  version: 1.3.0
  contact:
    name: Fiatsend Engineering
    email: partners@fiatsend.com
    url: https://developer.fiatsend.com
  license:
    name: Proprietary
    url: https://fiatsend.com/terms

servers:
  - url: https://sandbox.fiatsend.com/v1
    description: Sandbox (testing)
  - url: https://api.fiatsend.com/v1
    description: Production

tags:
  - name: Withdrawals
    description: Create and manage stablecoin-to-mobile-money withdrawals
  - name: Checkout
    description: Take payments on your website or app with hosted checkout sessions
  - name: Rates
    description: Get real-time FX rates for stablecoin to GHS conversion
  - name: Networks
    description: Query supported mobile money networks and their status
  - name: Payment Intents
    description: "Beta: request a payment that the customer approves and pays, by Fiatsend app or Stellar wallet. Fields and events may still change."
  - name: Webhooks
    description: Register and manage webhook endpoints for status callbacks
  - name: Health
    description: Service health and status checks

paths:
  /withdrawals:
    post:
      tags: [Withdrawals]
      operationId: createWithdrawal
      summary: Create a withdrawal
      description: |
        Initiate a stablecoin-to-mobile-money withdrawal. Fiatsend locks the FX rate at the time of request, converts the stablecoin amount to GHS, and delivers funds to the specified mobile money wallet.

        The withdrawal goes through the following statuses:
        - `pending` — Request received, awaiting processing
        - `processing` — On-chain transaction submitted, mobile money transfer initiated
        - `completed` — Funds delivered to mobile money wallet
        - `failed` — Transaction failed (funds returned to source)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWithdrawalRequest'
            example:
              amount: "50.00"
              currency: "USDC"
              recipient_phone: "+233241234567"
              mobile_network: "MTN"
              reference_id: "acme-txn-abc123"
              metadata:
                contractor_id: "con_12345"
                invoice_id: "inv_67890"
      responses:
        '201':
          description: Withdrawal created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WithdrawalResponse'
              example:
                status: "success"
                data:
                  withdrawal_id: "wd_9f8e7d6c5b4a"
                  status: "pending"
                  amount: "50.00"
                  currency: "USDC"
                  ghs_amount: "750.00"
                  fx_rate: "15.00"
                  fee: "0.50"
                  recipient_phone: "+233241234567"
                  mobile_network: "MTN"
                  reference_id: "acme-txn-abc123"
                  estimated_completion: "2026-03-21T07:00:00Z"
                  created_at: "2026-03-21T06:59:30Z"
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: "error"
                code: "INVALID_PHONE"
                message: "Phone number must be a valid Ghana number starting with +233"
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          description: Unprocessable entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: "error"
                code: "BELOW_MINIMUM"
                message: "Minimum withdrawal amount is 5.00 USDC"
        '429':
          $ref: '#/components/responses/RateLimited'

  /withdrawals/{withdrawal_id}:
    get:
      tags: [Withdrawals]
      operationId: getWithdrawal
      summary: Get withdrawal status
      description: |
        Retrieve the current status and details of a withdrawal. Use this to poll for status updates or verify completion.

        For real-time updates, we recommend using webhooks instead of polling.
      parameters:
        - name: withdrawal_id
          in: path
          required: true
          schema:
            type: string
          example: "wd_9f8e7d6c5b4a"
      responses:
        '200':
          description: Withdrawal details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WithdrawalDetailResponse'
              example:
                status: "success"
                data:
                  withdrawal_id: "wd_9f8e7d6c5b4a"
                  status: "completed"
                  amount: "50.00"
                  currency: "USDC"
                  ghs_amount: "750.00"
                  fx_rate: "15.00"
                  fee: "0.50"
                  recipient_phone: "+233241234567"
                  mobile_network: "MTN"
                  reference_id: "acme-txn-abc123"
                  on_chain_tx_hash: "0x1234abcd..."
                  mobile_money_reference: "MOMO-REF-456789"
                  created_at: "2026-03-21T06:59:30Z"
                  processing_at: "2026-03-21T06:59:35Z"
                  completed_at: "2026-03-21T06:59:42Z"
        '404':
          description: Withdrawal not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /transactions:
    get:
      tags: [Withdrawals]
      operationId: listTransactions
      summary: List transactions
      description: Retrieve a paginated list of transactions with optional filters.
      parameters:
        - name: status
          in: query
          schema:
            type: string
            enum: [pending, processing, completed, failed]
        - name: from_date
          in: query
          schema:
            type: string
            format: date-time
        - name: to_date
          in: query
          schema:
            type: string
            format: date-time
        - name: reference_id
          in: query
          schema:
            type: string
        - name: page
          in: query
          schema:
            type: integer
            default: 1
        - name: per_page
          in: query
          schema:
            type: integer
            default: 25
            maximum: 100
      responses:
        '200':
          description: Paginated transaction list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionListResponse'

  /rates:
    get:
      tags: [Rates]
      operationId: getRates
      summary: Get current FX rate
      description: |
        Get a real-time quote for converting stablecoins to GHS. The returned rate includes a `valid_until` timestamp — the rate is guaranteed until that time.

        Use this before creating a withdrawal to show the contractor what they'll receive.
      parameters:
        - name: from_currency
          in: query
          required: true
          schema:
            type: string
            enum: [USDC, USDT]
          example: "USDC"
        - name: to_currency
          in: query
          required: true
          schema:
            type: string
            enum: [GHS]
          example: "GHS"
        - name: amount
          in: query
          required: true
          schema:
            type: string
          example: "100.00"
      responses:
        '200':
          description: Current rate quote
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateResponse'
              example:
                status: "success"
                data:
                  from_currency: "USDC"
                  to_currency: "GHS"
                  amount: "100.00"
                  rate: "15.02"
                  fee: "1.00"
                  total_ghs: "1486.98"
                  valid_until: "2026-03-21T07:05:00Z"

  /supported-networks:
    get:
      tags: [Networks]
      operationId: getSupportedNetworks
      summary: List supported networks
      description: Returns all available mobile money networks with their current operational status.
      responses:
        '200':
          description: List of supported networks
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NetworkListResponse'
              example:
                status: "success"
                data:
                  - network_id: "MTN"
                    name: "MTN MoMo"
                    country: "GH"
                    currency: "GHS"
                    status: "operational"
                    min_amount: "50.00"
                    max_amount: "15000.00"
                  - network_id: "TELECEL"
                    name: "Telecel Cash"
                    country: "GH"
                    currency: "GHS"
                    status: "operational"
                    min_amount: "50.00"
                    max_amount: "15000.00"
                  - network_id: "AIRTELTIGO"
                    name: "AirtelTigo Money"
                    country: "GH"
                    currency: "GHS"
                    status: "operational"
                    min_amount: "50.00"
                    max_amount: "15000.00"

  /limits:
    get:
      tags: [Networks]
      operationId: getLimits
      summary: Get transaction limits
      description: Returns transaction limits per KYC tier.
      responses:
        '200':
          description: Transaction limits
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LimitsResponse'

  /checkout/sessions:
    post:
      tags: [Checkout]
      operationId: createCheckoutSession
      summary: Create a checkout session
      description: |
        Create a hosted checkout for one customer's payment. Send the customer to the returned `url` (or open it in a popup with Fiatsend's embed script). The session stays `open` until it is paid or cancelled.

        **Keys.** Use a `fs_test_` key to create test checkouts (no real money; Fiatsend checkout uses the Stellar test network) and a `fs_live_` key for live checkouts, which require an activated account. The same address serves both. Keys are issued in the Fiatsend Console under Developers > API Keys; the shared demo key does not work for this endpoint.

        **Confirming payment.** Do not rely on a browser event. Confirm with the `checkout.session.completed` webhook (see below) or by retrieving the session.

        ### Webhook: `checkout.session.completed`
        Sent when a session is paid. Register an endpoint in the Console under Developers > Webhooks and select the event. Endpoints must be public `https://` URLs. The body is signed with HMAC-SHA256 (hex) using your webhook secret in the `X-Fiatsend-Signature` header; `X-Fiatsend-Event` carries the event name. Delivery is at-least-once with up to 3 attempts (about 1 s, then 4 s apart); de-duplicate on `id`.

        ```json
        {
          "id": "evt_9a8b7c6d5e4f3a2b1c0d9e8f",
          "event": "checkout.session.completed",
          "sentAt": "2026-10-08T09:02:11.000Z",
          "livemode": true,
          "data": { "object": { "id": "cs_5f1c...", "object": "checkout.session", "status": "complete" } }
        }
        ```

        Rate limit: 120 requests per minute per business.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCheckoutSessionRequest'
            example:
              amount: 50.00
              currency: "GHS"
              description: "Order 1042"
              client_reference_id: "order_1042"
              customer:
                email: "ama@example.com"
              success_url: "https://yourshop.com/thanks?session={SESSION_ID}"
              cancel_url: "https://yourshop.com/cart"
              metadata:
                plan: "basic"
      responses:
        '201':
          description: Checkout session created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutSession'
        '400':
          $ref: '#/components/responses/CheckoutInvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: A live key was used before the account was activated (`account_not_active`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutError'
        '422':
          description: The business can't take that payment yet, for example no Stellar wallet is connected for Fiatsend checkout (`account_not_ready`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutError'
        '429':
          description: Rate limit exceeded (`rate_limited`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutError'
    get:
      tags: [Checkout]
      operationId: listCheckoutSessions
      summary: List checkout sessions
      description: Your most recent checkout sessions, newest first, in the mode (test or live) of the key you use.
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
          description: Number of sessions to return
      responses:
        '200':
          description: A list of checkout sessions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutSessionList'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          description: Rate limit exceeded (`rate_limited`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutError'

  /checkout/sessions/{session_id}:
    get:
      tags: [Checkout]
      operationId: getCheckoutSession
      summary: Retrieve a checkout session
      description: Returns one checkout session. A `status` of `complete` means it has been paid.
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            pattern: '^cs_[a-f0-9]{48}$'
          description: The session ID returned when it was created
      responses:
        '200':
          description: The checkout session
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutSession'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: No such checkout session for this key's mode (`not_found`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutError'

  /payment-intents:
    post:
      tags: [Payment Intents]
      summary: Create a payment intent (beta)
      x-beta: true
      description: |
        Creates a payment request (`pending_approval`). `merchant_reference` is the idempotency key: re-posting it returns the original intent with HTTP 200.
        USDC intents pay straight to the business's bound Stellar wallet (connect one in the console first). Webhook events: `payment_intent.pending_approval`, `.approved`, `.completed`, `.rejected`, `.cancelled`, `.expired`, `.failed`.
      operationId: createPaymentIntent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePaymentIntentRequest'
            example:
              amount: "25.00"
              currency: "GHS"
              consumer_phone: "+233241234567"
              merchant_reference: "order-1042"
              description: "Order 1042"
      responses:
        '201':
          description: Payment intent created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentIntentResponse'
        '200':
          description: Existing intent returned for a repeated merchant_reference
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentIntentResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /payment-intents/{payment_intent_id}:
    get:
      tags: [Payment Intents]
      summary: Get a payment intent (beta)
      x-beta: true
      operationId: getPaymentIntent
      parameters:
        - name: payment_intent_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The payment intent (expired automatically once past `expires_at`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentIntentResponse'
        '404':
          description: Not found (or owned by another business)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /payment-intents/{payment_intent_id}/cancel:
    post:
      tags: [Payment Intents]
      summary: Cancel a payment intent (beta)
      x-beta: true
      description: Only intents in `pending_approval` can be cancelled.
      operationId: cancelPaymentIntent
      parameters:
        - name: payment_intent_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Cancelled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentIntentResponse'
        '409':
          description: Not in a cancellable state
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /webhooks:
    post:
      tags: [Webhooks]
      operationId: registerWebhook
      summary: Register a webhook
      description: |
        Register a URL to receive real-time status updates for withdrawals. Fiatsend sends POST requests to your URL with a JSON payload whenever a withdrawal status changes.

        All webhook payloads are signed with HMAC-SHA256. Verify the `X-Fiatsend-Signature` header using your webhook secret.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookRegistration'
            example:
              url: "https://api.example.com/webhooks/fiatsend"
              events:
                - "withdrawal.completed"
                - "withdrawal.failed"
                - "withdrawal.processing"
              secret: "whsec_your_secret_here"
      responses:
        '201':
          description: Webhook registered
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookResponse'
    get:
      tags: [Webhooks]
      operationId: listWebhooks
      summary: List registered webhooks
      responses:
        '200':
          description: List of webhooks
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookListResponse'

  /webhooks/{webhook_id}:
    delete:
      tags: [Webhooks]
      operationId: deleteWebhook
      summary: Delete a webhook
      parameters:
        - name: webhook_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '204':
          description: Webhook deleted

  /health:
    get:
      tags: [Health]
      operationId: getHealth
      summary: Service health check
      description: Returns service status, uptime, and API version.
      security: []
      responses:
        '200':
          description: Service is healthy
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthResponse'
              example:
                status: "healthy"
                version: "1.3.0"
                uptime_seconds: 864000
                environment: "sandbox"
                services:
                  blockchain: "operational"
                  mobile_money: "operational"
                  database: "operational"

components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

  responses:
    Unauthorized:
      description: Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: "error"
            code: "UNAUTHORIZED"
            message: "Invalid or missing API key"
    CheckoutInvalidRequest:
      description: A field is invalid (`invalid_request`). The message names the field.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CheckoutError'
          example:
            error:
              code: "invalid_request"
              message: "amount: amount must be more than 0"
    RateLimited:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: "error"
            code: "RATE_LIMITED"
            message: "Rate limit exceeded. Try again in 60 seconds."

  schemas:
    CreateWithdrawalRequest:
      type: object
      required: [amount, currency, recipient_phone, mobile_network, reference_id]
      properties:
        amount:
          type: string
          description: Amount in source currency (e.g., "50.00")
        currency:
          type: string
          enum: [USDC, USDT]
          description: Source stablecoin currency
        recipient_phone:
          type: string
          description: "Recipient's mobile money phone number (E.164 format, e.g., +233241234567)"
        mobile_network:
          type: string
          enum: [MTN, TELECEL, AIRTELTIGO]
          description: Target mobile money network
        reference_id:
          type: string
          description: Your unique transaction reference (for idempotency)
        metadata:
          type: object
          additionalProperties: true
          description: Optional key-value metadata to attach to the withdrawal

    WithdrawalResponse:
      type: object
      properties:
        status:
          type: string
        data:
          $ref: '#/components/schemas/Withdrawal'

    WithdrawalDetailResponse:
      type: object
      properties:
        status:
          type: string
        data:
          $ref: '#/components/schemas/WithdrawalDetail'

    Withdrawal:
      type: object
      properties:
        withdrawal_id:
          type: string
        status:
          type: string
          enum: [pending, processing, completed, failed]
        amount:
          type: string
        currency:
          type: string
        ghs_amount:
          type: string
        fx_rate:
          type: string
        fee:
          type: string
        recipient_phone:
          type: string
        mobile_network:
          type: string
        reference_id:
          type: string
        estimated_completion:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time

    WithdrawalDetail:
      allOf:
        - $ref: '#/components/schemas/Withdrawal'
        - type: object
          properties:
            on_chain_tx_hash:
              type: string
              description: Blockchain transaction hash
            mobile_money_reference:
              type: string
              description: Mobile money network reference number
            processing_at:
              type: string
              format: date-time
            completed_at:
              type: string
              format: date-time
            failed_at:
              type: string
              format: date-time
            failure_reason:
              type: string

    TransactionListResponse:
      type: object
      properties:
        status:
          type: string
        data:
          type: array
          items:
            $ref: '#/components/schemas/WithdrawalDetail'
        pagination:
          $ref: '#/components/schemas/Pagination'

    RateResponse:
      type: object
      properties:
        status:
          type: string
        data:
          type: object
          properties:
            from_currency:
              type: string
            to_currency:
              type: string
            amount:
              type: string
            rate:
              type: string
            fee:
              type: string
              description: Fee in the source stablecoin (1% of amount).
            total_ghs:
              type: string
              description: Cedis delivered, (amount − fee) × rate.
            valid_until:
              type: string
              format: date-time

    NetworkListResponse:
      type: object
      properties:
        status:
          type: string
        data:
          type: array
          items:
            $ref: '#/components/schemas/Network'

    Network:
      type: object
      properties:
        network_id:
          type: string
        name:
          type: string
        country:
          type: string
        currency:
          type: string
        status:
          type: string
          enum: [operational, degraded, down]
        min_amount:
          type: string
          description: Minimum payout in the network currency (GHS 50.00).
        max_amount:
          type: string
          description: Maximum payout in the network currency (GHS 15,000.00).

    CreatePaymentIntentRequest:
      type: object
      required: [amount, currency, consumer_phone, merchant_reference]
      properties:
        amount:
          type: string
          example: "25.00"
        currency:
          type: string
          enum: [GHS, USDC, USDT]
        consumer_phone:
          type: string
          description: Customer phone in E.164 format
          example: "+233241234567"
        merchant_reference:
          type: string
          description: Your unique reference; also the idempotency key
        terminal_id:
          type: string
        description:
          type: string
        metadata:
          type: object
          additionalProperties: true

    PaymentIntentResponse:
      type: object
      properties:
        status:
          type: string
          example: success
        data:
          $ref: '#/components/schemas/PaymentIntent'

    PaymentIntent:
      type: object
      additionalProperties: true
      properties:
        payment_intent_id:
          type: string
          example: "pi_4f7a3a2d"
        status:
          type: string
          enum: [pending_approval, approved, onchain_pending, paid, completed, rejected, cancelled, expired, failed]
        amount:
          type: string
        currency:
          type: string
        consumer_phone:
          type: string
        merchant_reference:
          type: string
        payment_link:
          type: string
          description: Customer checkout link (USDC intents)
        created_at:
          type: string
          format: date-time
        expires_at:
          type: string
          format: date-time

    LimitsResponse:
      type: object
      properties:
        status:
          type: string
        data:
          type: array
          items:
            type: object
            properties:
              tier:
                type: string
                enum: [basic, standard, enterprise]
              daily_limit:
                type: string
              monthly_limit:
                type: string
              per_transaction_max:
                type: string

    WebhookRegistration:
      type: object
      required: [url, events, secret]
      properties:
        url:
          type: string
          format: uri
        events:
          type: array
          items:
            type: string
            enum: [withdrawal.pending, withdrawal.processing, withdrawal.completed, withdrawal.failed]
        secret:
          type: string
          description: Secret for HMAC-SHA256 signature verification

    WebhookResponse:
      type: object
      properties:
        status:
          type: string
        data:
          type: object
          properties:
            webhook_id:
              type: string
            url:
              type: string
            events:
              type: array
              items:
                type: string
            active:
              type: boolean
            created_at:
              type: string
              format: date-time

    WebhookListResponse:
      type: object
      properties:
        status:
          type: string
        data:
          type: array
          items:
            type: object
            properties:
              webhook_id:
                type: string
              url:
                type: string
              events:
                type: array
                items:
                  type: string
              active:
                type: boolean

    HealthResponse:
      type: object
      properties:
        status:
          type: string
        version:
          type: string
          example: "1.0.0"
        uptime_seconds:
          type: integer
        environment:
          type: string
          description: Deployment environment (e.g. sandbox, production)
        services:
          type: object
          properties:
            blockchain:
              type: string
            mobile_money:
              type: string
            database:
              type: string

    CreateCheckoutSessionRequest:
      type: object
      required: [amount]
      properties:
        amount:
          type: number
          minimum: 0
          exclusiveMinimum: true
          description: Price in major units (for example 50.00)
        currency:
          type: string
          enum: [GHS, USDC]
          default: GHS
        description:
          type: string
          maxLength: 200
          description: What the customer is paying for. Shown on the checkout page and receipt.
        client_reference_id:
          type: string
          maxLength: 100
          description: Your own order ID. Returned on the session and in webhooks.
        customer:
          type: object
          description: Optional customer details. With an email the customer receives a receipt by email.
          properties:
            name:
              type: string
              maxLength: 120
            email:
              type: string
              format: email
            phone:
              type: string
              description: E.164 format, for example +233241234567
        success_url:
          type: string
          maxLength: 500
          description: Where to send the customer after paying. https only (http://localhost allowed for testing). `{SESSION_ID}` is replaced with the session ID; without a placeholder, `session_id` is added as a query parameter.
        cancel_url:
          type: string
          maxLength: 500
          description: Where to send the customer if they go back without paying. Same rules as success_url.
        metadata:
          type: object
          maxProperties: 20
          additionalProperties:
            type: string
            maxLength: 500
          description: String key/value pairs (keys up to 40 characters), returned unchanged.
        accepted_methods:
          type: array
          items:
            type: string
            enum: [fiatsend, mobile_money, bank_transfer]
          description: Payment methods to offer. mobile_money is available for GHS only. Defaults to the methods saved in the business's Payment settings.

    CheckoutSession:
      type: object
      properties:
        id:
          type: string
          example: "cs_5f1c8a2e9d7b4c3a6e0f1b2c3d4e5f60718293a4b5c6d7e8"
        object:
          type: string
          enum: [checkout.session]
        status:
          type: string
          enum: [open, complete, cancelled]
        url:
          type: string
          format: uri
          description: The hosted checkout page. Send the customer here.
        amount:
          type: number
        currency:
          type: string
          enum: [GHS, USDC]
        description:
          type: string
          nullable: true
        client_reference_id:
          type: string
          nullable: true
        metadata:
          type: object
          additionalProperties:
            type: string
        customer:
          type: object
          properties:
            name:
              type: string
              nullable: true
            email:
              type: string
              nullable: true
            phone:
              type: string
              nullable: true
        accepted_methods:
          type: array
          items:
            type: string
            enum: [fiatsend, mobile_money, bank_transfer]
        success_url:
          type: string
          nullable: true
        cancel_url:
          type: string
          nullable: true
        paid_at:
          type: string
          format: date-time
          nullable: true
        paid_via:
          type: string
          enum: [fiatsend, mobile_money, bank_transfer, manual]
          nullable: true
        livemode:
          type: boolean
          description: true for live keys, false for test keys
        created_at:
          type: string
          format: date-time

    CheckoutSessionList:
      type: object
      properties:
        object:
          type: string
          enum: [list]
        data:
          type: array
          items:
            $ref: '#/components/schemas/CheckoutSession'

    CheckoutError:
      type: object
      description: Error shape used by the checkout endpoints.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum: [invalid_request, account_not_active, account_not_ready, not_found, rate_limited, upstream_unavailable]
            message:
              type: string

    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          example: "error"
        code:
          type: string
        message:
          type: string

    Pagination:
      type: object
      properties:
        page:
          type: integer
        per_page:
          type: integer
        total:
          type: integer
        total_pages:
          type: integer

security:
  - BearerAuth: []
