openapi: 3.1.0
info:
  title: Bayarcash API
  description: |-
    Bayarcash is a payment gateway in Malaysia. This reference is for **API v3**, the current version.

    Use v3 for all new integrations. API v2 is old, and it gets no new features.

    ## Environments

    | Environment | API base URL | Console |
    |---|---|---|
    | **Production** | `https://api.console.bayar.cash/v3` | [console.bayar.cash](https://console.bayar.cash) |
    | **Sandbox** | `https://api.console.bayarcash-sandbox.com/v3` | [console.bayarcash-sandbox.com](https://console.bayarcash-sandbox.com) |

    ## Authentication

    Send a Personal Access Token as a bearer token in each request. To create a token, go to your account settings in the merchant dashboard.

    ```
    Authorization: Bearer <Personal_Access_Token>
    ```

    The sandbox and production have different tokens. A production token does not work in the sandbox.
  version: 3.0.0
servers:
  - url: https://api.console.bayar.cash
  - url: https://api.console.bayarcash-sandbox.com
security:
  - bearerAuth: []
paths:
  /v3/up:
    get:
      tags:
        - Health Check
      summary: Get the API server status
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              example: OK
      description: Check that the API server is available.
      operationId: get-api-status
  /v3/payment-intents:
    post:
      tags:
        - Payment Intent
      summary: Initialize Payment
      description: |-
        Create a payment intent to start a payment.

        - For FPX and FPX B2B, you can verify the identity of the payer. See [Payer Identity Verification](#tag/payer-identity-verification).
        - To send the request again safely, add the `Idempotency-Key` header. See [Idempotency](#tag/idempotency).
        - For a DuitNow QR channel, set `generate_qr` to `true`. The response then also has the QR, in the `duitnow_qr` object. You show this QR on your own page.
      security:
        - bearerAuth: []
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            maxLength: 255
          description: Optional. A unique key to ensure idempotent request processing. If provided, the API will return the cached response for duplicate requests with the same key and parameters. Keys are scoped per merchant and portal, and expire after 24 hours. We recommend using a UUID v4.
          example: 8f14e45f-ceea-367f-a27f-c790e02b3045
      requestBody:
        description: Create Payment Intent
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - payment_channel
                - portal_key
                - order_number
                - amount
                - payer_name
                - payer_email
              properties:
                payment_channel:
                  type: integer
                  enum:
                    - 1
                    - 23
                    - 4
                    - 5
                    - 12
                    - 6
                    - 9
                    - 10
                    - 11
                    - 13
                    - 14
                    - 15
                    - 16
                    - 17
                    - 18
                    - 21
                    - 7
                    - 8
                    - 19
                  description: The ID of the payment channel. See [Payment Channels](#tag/payment-channels) for each channel.
                  examples:
                    - 1
                  x-enumDescriptions:
                    "1": FPX Personal Banking (B2C)
                    "4": FPX Line of Credit (CCA)
                    "5": DuitNow Online Banking/Wallets (DOBW)
                    "6": DuitNow QR
                    "7": SPayLater
                    "8": Boost PayFlex
                    "9": QRIS Indonesia (online banking)
                    "10": QRIS Indonesia (e-wallet)
                    "11": NETS
                    "12": Cards (Visa, Mastercard, MyDebit)
                    "13": Alipay
                    "14": WeChat Pay
                    "15": PromptPay
                    "16": Touch 'n Go eWallet
                    "17": Boost Wallet
                    "18": GrabPay
                    "19": PayLater by Grab
                    "21": ShopeePay
                    "23": FPX Business Banking (B2B)
                portal_key:
                  type: string
                order_number:
                  type: string
                  examples:
                    - ORD001
                amount:
                  type: number
                  format: double
                  examples:
                    - 100
                payer_name:
                  type: string
                  examples:
                    - MOHD ALI
                payer_email:
                  type: string
                  examples:
                    - payer@example.com
                payer_telephone_number:
                  type: string
                  examples:
                    - number
                payer_bank_code:
                  type: string
                  examples:
                    - string
                payer_bank_name:
                  type: string
                  examples:
                    - string
                metadata:
                  type: string
                  examples:
                    - "{product_sku: SKU001, product_name: TSHIRT, PRICE: RM100}"
                return_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/return
                callback_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/callback
                autosubmit_form:
                  type: boolean
                  description: Optional. Set to `true` to send the payment to the selected bank automatically. FPX only. You must also send `payer_bank_code`.
                  examples:
                    - false
                link_expired_at:
                  type: string
                  format: yyyy-MM-dd HH:mm:ss
                  description: Optional. The date and time when the payment link expires. The default is 1 hour after you create the payment intent.
                  examples:
                    - 2024-08-01 23:59:59
                platform_id:
                  type: string
                  examples:
                    - string
                checksum:
                  type: string
                  examples:
                    - string
                verify_identity:
                  type: boolean
                  description: Optional. Set to `true` to verify the identity of the payer. Only for FPX (`1`) and FPX B2B (`23`). See [Payer Identity Verification](#tag/payer-identity-verification).
                  examples:
                    - true
                fpx_eaccount_number:
                  type: string
                  maxLength: 40
                  description: Required when `verify_identity` is `true`. The bank account number of the payer.
                  examples:
                    - "1234567890"
                fpx_ebuyer_id:
                  type: string
                  maxLength: 40
                  description: Required when `verify_identity` is `true`. The NRIC, passport number or business registration number of the payer.
                  examples:
                    - "9060123456789"
                generate_qr:
                  type: boolean
                  description: |-
                    Optional. Set to `true` to get the DuitNow QR in the same response. You then do not need a second request.

                    The response then has a `duitnow_qr` object:

                    - `qr_image`: a PNG data URI. Put it in an `img` tag.
                    - `qr_string`: the QR data, if you make the QR image yourself.
                    - `qr_expires_at`, `poll_url`, `next_poll_after_ms` and `transaction_id`.

                    Rules:

                    - `payment_channel` must be one DuitNow QR channel: 6 to 11, or 13 to 15.
                    - `link_expired_at` must be at least 5 minutes after the request. The QR is valid for approximately 5 minutes.

                    If Bayarcash cannot make the QR, the API returns 403 or 502, with the `payment_intent_id`. The payment intent stays as a cancelled record. Send the same request again. If you used an `Idempotency-Key`, you can send the same key again.
                  examples:
                    - true
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - payment_channel
                - portal_key
                - order_number
                - amount
                - payer_name
                - payer_email
              properties:
                payment_channel:
                  type: integer
                  enum:
                    - 1
                    - 23
                    - 4
                    - 5
                    - 12
                    - 6
                    - 9
                    - 10
                    - 11
                    - 13
                    - 14
                    - 15
                    - 16
                    - 17
                    - 18
                    - 21
                    - 7
                    - 8
                    - 19
                  description: The ID of the payment channel. See [Payment Channels](#tag/payment-channels) for each channel.
                  examples:
                    - 1
                  x-enumDescriptions:
                    "1": FPX Personal Banking (B2C)
                    "4": FPX Line of Credit (CCA)
                    "5": DuitNow Online Banking/Wallets (DOBW)
                    "6": DuitNow QR
                    "7": SPayLater
                    "8": Boost PayFlex
                    "9": QRIS Indonesia (online banking)
                    "10": QRIS Indonesia (e-wallet)
                    "11": NETS
                    "12": Cards (Visa, Mastercard, MyDebit)
                    "13": Alipay
                    "14": WeChat Pay
                    "15": PromptPay
                    "16": Touch 'n Go eWallet
                    "17": Boost Wallet
                    "18": GrabPay
                    "19": PayLater by Grab
                    "21": ShopeePay
                    "23": FPX Business Banking (B2B)
                portal_key:
                  type: string
                order_number:
                  type: string
                  examples:
                    - ORD001
                amount:
                  type: number
                  format: double
                  examples:
                    - 100
                payer_name:
                  type: string
                  examples:
                    - MOHD ALI
                payer_email:
                  type: string
                  examples:
                    - payer@example.com
                payer_telephone_number:
                  type: string
                  examples:
                    - number
                payer_bank_code:
                  type: string
                  examples:
                    - string
                payer_bank_name:
                  type: string
                  examples:
                    - string
                metadata:
                  type: string
                  examples:
                    - "{product_sku: SKU001, product_name: TSHIRT, PRICE: RM100}"
                return_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/return
                callback_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/callback
                autosubmit_form:
                  type: boolean
                  description: Optional. Set to `true` to send the payment to the selected bank automatically. FPX only. You must also send `payer_bank_code`.
                  examples:
                    - false
                link_expired_at:
                  type: string
                  format: yyyy-MM-dd HH:mm:ss
                  description: Optional. The date and time when the payment link expires. The default is 1 hour after you create the payment intent.
                  examples:
                    - 2024-08-01 23:59:59
                platform_id:
                  type: string
                  examples:
                    - string
                checksum:
                  type: string
                  examples:
                    - string
                verify_identity:
                  type: boolean
                  description: Optional. Set to `true` to verify the identity of the payer. Only for FPX (`1`) and FPX B2B (`23`). See [Payer Identity Verification](#tag/payer-identity-verification).
                  examples:
                    - true
                fpx_eaccount_number:
                  type: string
                  maxLength: 40
                  description: Required when `verify_identity` is `true`. The bank account number of the payer.
                  examples:
                    - "1234567890"
                fpx_ebuyer_id:
                  type: string
                  maxLength: 40
                  description: Required when `verify_identity` is `true`. The NRIC, passport number or business registration number of the payer.
                  examples:
                    - "9060123456789"
                generate_qr:
                  type: boolean
                  description: |-
                    Optional. Set to `true` to get the DuitNow QR in the same response. You then do not need a second request.

                    The response then has a `duitnow_qr` object:

                    - `qr_image`: a PNG data URI. Put it in an `img` tag.
                    - `qr_string`: the QR data, if you make the QR image yourself.
                    - `qr_expires_at`, `poll_url`, `next_poll_after_ms` and `transaction_id`.

                    Rules:

                    - `payment_channel` must be one DuitNow QR channel: 6 to 11, or 13 to 15.
                    - `link_expired_at` must be at least 5 minutes after the request. The QR is valid for approximately 5 minutes.

                    If Bayarcash cannot make the QR, the API returns 403 or 502, with the `payment_intent_id`. The payment intent stays as a cancelled record. Send the same request again. If you used an `Idempotency-Key`, you can send the same key again.
                  examples:
                    - true
      responses:
        "201":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentIntentResponse"
              example: |-
                {
                    "type": "payment_intent",
                    "id": "pi_PGPP2G",
                    "payer_name": "MOHD ALI",
                    "payer_email": "payer@example.com",
                    "payer_telephone_number": "60123456789",
                    "order_number": "ORD001",
                    "amount": "10.50",
                    "url": "https://console.bayar.cash/payment-intent/pi_KYdojq"
                }
        "403":
          description: "`generate_qr` was `true`, but this payment intent cannot have a DuitNow QR. The `payment_channel` is not a DuitNow QR channel, or `link_expired_at` is less than 5 minutes after the request."
          content:
            application/json:
              schema:
                type: object
              examples:
                - success: false
                  message: Payment intent is not a DuitNow QR payment.
                  payment_intent_id: pi_PGPP2G
        "502":
          description: "`generate_qr` was `true`, but Bayarcash could not make the QR because of a failure at the QR provider. Send the same request again."
          content:
            application/json:
              schema:
                type: object
              examples:
                - success: false
                  message: Unable to generate QR code. Please retry.
                  payment_intent_id: pi_PGPP2G
      callbacks:
        Pre-Transaction:
          "{$request.body#/callback}":
            post:
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: "#/components/schemas/PreTransactionCallback"
              responses:
                "200":
                  description: Your server returns this code if it accepts the callback
        Transaction:
          "{$request.body#/callback}":
            post:
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: "#/components/schemas/TransactionCallback"
              responses:
                "200":
                  description: Your server returns this code if it accepts the callback
        Transaction Receipt:
          "{$request.body#/return_url}":
            get:
              parameters:
                - name: transaction_id
                  in: query
                  required: true
                  schema:
                    type: string
                - name: exchange_reference_number
                  in: query
                  required: true
                  schema:
                    type: string
                - name: exchange_transaction_id
                  in: query
                  required: true
                  schema:
                    type: string
                - name: order_number
                  in: query
                  required: true
                  schema:
                    type: string
                - name: currency
                  in: query
                  required: true
                  schema:
                    type: string
                - name: amount
                  in: query
                  required: true
                  schema:
                    type: string
                - name: payer_bank_name
                  in: query
                  required: true
                  schema:
                    type: string
                - name: status
                  in: query
                  required: true
                  schema:
                    type: string
                  description: |
                    status:
                      * 0 - New
                      * 1 - Pending
                      * 2 - Unsuccessful
                      * 3 - Successful
                      * 4 - Cancelled
                      * 5 - Abandoned
                      * 6 - Authorized
                      * 7 - Void
                      * 8 - Refund
                - name: status_description
                  in: query
                  required: true
                  schema:
                    type: string
                - name: checksum
                  in: query
                  required: true
                  schema:
                    type: string
      operationId: create-payment-intent
  /v3/payment-intents/{payment_intent_id}:
    delete:
      tags:
        - Payment Intent
      summary: Cancel a Payment Intent
      description: |-
        Cancel a payment intent. After you cancel it, nobody can pay it.

        You can cancel a payment intent only when nobody paid it and its status allows a cancellation. If a payment has the status pending, wait for its final status: successful, unsuccessful or expired. Then cancel the payment intent.
      security:
        - bearerAuth: []
      parameters:
        - name: payment_intent_id
          description: Payment Intent ID
          in: path
          required: true
          schema:
            type: string
      responses:
        "201":
          description: Payment intent successfully cancelled. The cancelled payment intent object is returned.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetPaymentIntentResponse"
                examples:
                  - type: payment_intent
                    id: pi_PGPP2G
                    status: cancelled
                    last_attempt: null
                    paid_at: ""
                    order_number: ORD001
                    amount: "10.50"
                    currency: MYR
                    payer_name: MOHD ALI
                    payer_email: payer@example.com
                    payer_telephone_number: ""
                    payment_gateway:
                      id: 1
                      name: FPX
                      code: FPX
                    attempts: []
        "403":
          description: The payment intent cannot be cancelled (for example, it has already been paid or a payment attempt is still pending).
          content:
            application/json:
              schema:
                type: object
              example:
                success: false
                message: Payment intent cannot be cancelled.
      operationId: cancel-payment-intent
    get:
      tags:
        - Payment Intent
      summary: Get a Payment Intent
      description: Get a payment intent to check the payment status. The response is the payment intent object.
      security:
        - bearerAuth: []
      parameters:
        - name: payment_intent_id
          description: Payment Intent ID
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetPaymentIntentResponse"
                examples:
                  - type: payment_intent
                    id: pi_PGPP2G
                    status: paid
                    last_attempt: 2024-12-30 12:07:57
                    paid_at: 2024-12-30 12:07:57
                    order_number: ORD001
                    amount: "10.50"
                    currency: MYR
                    payer_name: MOHD ALI
                    payer_email: payer@example.com
                    payer_telephone_number: ""
                    attempts:
                      - transaction_id: trx_YdoXvn
                        created_at: 2024-12-30 12:07:57
                        payer_name: MOHD ALI
                        payer_email: payer@example.com
                        payer_telephone_number: null
                        order_number: ORD001
                        currency: MYR
                        amount: "10.50"
                        exchange_reference_number: 1-735-272-902-315691
                        exchange_transaction_id: "2412271215020084"
                        payer_bank_name: SBI Bank A
                        status: 3
                        status_description: Approved
                        payment_gateway:
                          id: 1
                          name: FPX
                          code: FPX
                      - transaction_id: trx_GWlpvW
                        created_at: 2024-12-27 12:15:02
                        payer_name: MOHD ALI
                        payer_email: payer@example.com
                        payer_telephone_number: null
                        order_number: ORD001
                        currency: MYR
                        amount: "10.50"
                        exchange_reference_number: 1-735-272-902-315691
                        exchange_transaction_id: "2412271215020084"
                        payer_bank_name: SBI Bank A
                        status: 2
                        status_description: Unsuccessful
                        payment_gateway:
                          id: 1
                          name: FPX
                          code: FPX
      operationId: get-payment-intent
  /v3/payment-intents/{payment_intent_id}/duitnow-qr:
    post:
      tags:
        - DuitNow QR
      summary: Generate a DuitNow QR for a Payment Intent
      description: |-
        Make a DuitNow QR code for a payment intent, and show it on your own page. The payer then does not go to the Bayarcash payment page.

        The response has 2 fields for the QR:

        - `qr_image`: a PNG data URI. Put it in an `img` tag.
        - `qr_string`: the QR data, if you make the QR image yourself.

        The payment intent must use a DuitNow QR payment channel, and nobody must have paid it.

        > [!TIP]
        > You can do this in 1 step. Send `generate_qr: true` when you create the payment intent. The response then has the same `duitnow_qr` object. Use this endpoint to make a new QR after a QR expires.

        The callback to your `callback_url` is the main payment notification. Use the `poll_url` in this response only to update your page. Wait `next_poll_after_ms` between 2 polls. Stop when the QR expires (`qr_expires_at`) or when the status is final.

        When a QR is active (not expired and not paid), each call gives the same QR with HTTP 200. After the QR expires, a new call makes a new QR for the same payment intent.
      security:
        - bearerAuth: []
      parameters:
        - name: payment_intent_id
          description: Payment Intent ID
          in: path
          required: true
          schema:
            type: string
      responses:
        "201":
          description: QR code generated (200 is returned instead when an active QR already exists and is being re-served).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DuitNowQrResponse"
              examples:
                - type: duitnow_qr
                  transaction_id: trx_9V2LxK
                  payment_intent_id: pi_PGPP2G
                  qr_string: 0002026012345678914A0000006150060123456789...
                  qr_image: data:image/png;base64,iVBORw0KGgo...
                  qr_expires_at: 2026-08-13T15:30:00+08:00
                  poll_url: https://api.console.bayar.cash/v3/transactions/trx_9V2LxK/duitnow-qr/status
                  next_poll_after_ms: 2000
                  amount: 100
                  currency: MYR
                  order_number: ORD-000123
        "403":
          description: The payment intent is not a DuitNow QR payment, is no longer payable, or the merchant is not allowed to accept this payment.
          content:
            application/json:
              schema:
                type: object
              examples:
                - success: false
                  message: Payment intent is no longer payable.
        "404":
          description: Payment intent not found.
        "409":
          description: A QR generation attempt is already in progress for this payment intent (concurrent request). Retry.
          content:
            application/json:
              schema:
                type: object
              examples:
                - success: false
                  message: A QR code is already being generated for this payment intent. Please retry.
        "502":
          description: The QR code could not be generated due to an upstream failure. Retry the request.
          content:
            application/json:
              schema:
                type: object
              examples:
                - success: false
                  message: Unable to generate QR code. Please retry.
      operationId: create-duitnow-qr
  /v3/transactions:
    get:
      tags:
        - Transaction
      summary: Get a list of all transactions
      description: Get a list of all transactions. The response is an array of transaction objects.
      security:
        - bearerAuth: []
      parameters:
        - name: order_number
          in: query
          description: Filter transactions by their order number.
          required: false
          schema:
            type: string
        - name: recurring_type
          in: query
          description: "Show only one type of card recurring charge: `on_demand` (from `POST /v3/payments`), `subscription` or `installment`. To find an on-demand charge with its `reference`, use it with `order_number`: `?order_number={reference}&recurring_type=on_demand`."
          required: false
          schema:
            type: string
            enum:
              - on_demand
              - subscription
              - installment
        - name: status
          in: query
          required: false
          schema:
            type: integer
            format: int32
            enum:
              - 0
              - 1
              - 2
              - 3
              - 4
              - 5
              - 6
              - 7
              - 8
            description: |
              Filter transactions by their status:
                * 0 - New
                * 1 - Pending
                * 2 - Unsuccessful
                * 3 - Successful
                * 4 - Cancelled
                * 5 - Abandoned
                * 6 - Authorized
                * 7 - Void
                * 8 - Refund
        - name: payment_channel
          in: query
          required: false
          schema:
            type: integer
            format: int32
            enum:
              - 1
              - 23
              - 4
              - 5
              - 3
              - 12
              - 6
              - 9
              - 10
              - 11
              - 13
              - 14
              - 15
              - 16
              - 17
              - 18
              - 21
              - 7
              - 8
              - 19
            description: Filter transactions by payment channel. See [Payment Channels](#tag/payment-channels) for each channel.
            x-enumDescriptions:
              "1": FPX Personal Banking (B2C)
              "3": Direct Debit
              "4": FPX Line of Credit (CCA)
              "5": DuitNow Online Banking/Wallets (DOBW)
              "6": DuitNow QR
              "7": SPayLater
              "8": Boost PayFlex
              "9": QRIS Indonesia (online banking)
              "10": QRIS Indonesia (e-wallet)
              "11": NETS
              "12": Cards (Visa, Mastercard, MyDebit)
              "13": Alipay
              "14": WeChat Pay
              "15": PromptPay
              "16": Touch 'n Go eWallet
              "17": Boost Wallet
              "18": GrabPay
              "19": PayLater by Grab
              "21": ShopeePay
              "23": FPX Business Banking (B2B)
        - name: exchange_reference_number
          in: query
          required: false
          schema:
            type: string
            description: Filter transactions by exchange reference number
        - name: payer_email
          in: query
          required: false
          schema:
            type: string
            description: Filter transactions by payer email
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetTransactionResponse"
                examples:
                  - data:
                      - id: trx_zD3ELD
                        created_at: 2025-01-05 12:41:47
                        payer_name: john2
                        payer_email: payer@example.com
                        payer_telephone_number: null
                        order_number: ORD00122
                        currency: MYR
                        amount: 100
                        exchange_reference_number: 20250105M0042494861OBW00000002
                        exchange_transaction_id: 20250105M004249486100000002
                        payer_bank_name: PYN Bank A
                        status: 0
                        status_description: null
                        return_url: ""
                        metadata:
                          currency: MYR
                          total_discount: "0.00"
                          total_tax: "0.00"
                          total: "75.00"
                          items:
                            - description: Kebarung Deeja in Hot Pink (K624KKD-1) - L
                              quantity: "1"
                              total: "69.00"
                        payout:
                          reference_number: null
                        payment_gateway:
                          id: 5
                          name: DuitNow DOBW
                          code: DuitNowDobw
                        portal: Default-monster
                        merchant:
                          name: ABC Ind Sdn. Bhd.
                          email: payer@example.com
                      - id: trx_Yk8r7O
                        created_at: 2025-01-05 12:40:23
                        payer_name: john2
                        payer_email: payer@example.com
                        payer_telephone_number: null
                        order_number: ORD00122
                        currency: MYR
                        amount: 100
                        exchange_reference_number: 20250105M0042494861OBW00000001
                        exchange_transaction_id: 20250105M004249486100000001
                        payer_bank_name: PYN Bank A
                        status: 0
                        status_description: null
                        return_url: ""
                        metadata:
                          currency: MYR
                          total_discount: "0.00"
                          total_tax: "0.00"
                          total: "75.00"
                          items:
                            - description: Kebarung Deeja in Hot Pink (K624KKD-1) - L
                              quantity: "1"
                              total: "69.00"
                        payout:
                          reference_number: null
                        payment_gateway:
                          id: 5
                          name: DuitNow DOBW
                          code: DuitNowDobw
                        portal: Default-monster
                        merchant:
                          name: ABC Ind Sdn. Bhd.
                          email: payer@example.com
                      - id: trx_YdoXvn
                        created_at: 2024-12-30 12:07:57
                        payer_name: john2
                        payer_email: payer@example.com
                        payer_telephone_number: null
                        order_number: ORD00122
                        currency: MYR
                        amount: 100
                        exchange_reference_number: 1-735-272-902-315691
                        exchange_transaction_id: "2412271215020084"
                        payer_bank_name: SBI Bank A
                        status: 3
                        status_description: Approved
                        return_url: ""
                        metadata:
                          currency: MYR
                          total_discount: "0.00"
                          total_tax: "0.00"
                          total: "75.00"
                          items:
                            - description: Kebarung Deeja in Hot Pink (K624KKD-1) - L
                              quantity: "1"
                              total: "69.00"
                        payout:
                          reference_number: P1735272680872263
                        payment_gateway:
                          id: 1
                          name: FPX
                          code: FPX
                        portal: Default-monster
                        merchant:
                          name: ABC Ind Sdn. Bhd.
                          email: payer@example.com
                    links:
                      first: https://api.console.bayar.cash/v3/transactions?page=1
                      last: https://api.console.bayar.cash/v3/transactions?page=1
                      prev: null
                      next: null
                    meta:
                      current_page: 1
                      from: 1
                      last_page: 1
                      links:
                        - url: null
                          label: "&laquo; Previous"
                          active: false
                        - url: https://api.console.bayar.cash/v3/transactions?page=1
                          label: "1"
                          active: true
                        - url: null
                          label: Next &raquo;
                          active: false
                      path: https://api.console.bayar.cash/v3/transactions
                      per_page: 15
                      to: 6
                      total: 6
      operationId: list-transactions
  /v3/transactions/{transaction_id}:
    get:
      tags:
        - Transaction
      summary: Get a transaction
      description: Get a transaction to check its status. The response is the transaction object.
      security:
        - bearerAuth: []
      parameters:
        - name: transaction_id
          description: Transaction ID
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetTransactionResponse"
                examples:
                  - id: trx_q6LJdl
                    updated_at: 2023-05-26 13:35:01
                    datetime: 2023-05-26 13:29:06
                    order_number: D-24354620275
                    payer_name: MOHD ALI
                    payer_email: payer@example.com
                    payer_telephone_number: "60123456789"
                    currency: MYR
                    amount: 50
                    exchange_reference_number: 1-685-0718-946-53336
                    exchange_transaction_id: "23052613290110936"
                    payer_bank_name: Bank Islam
                    status: 3
                    status_description: Approved
                    return_url: https://example.com/return_url
                    metadata: null
                    payout:
                      reference_number: P168560123456789
                    payment_gateway:
                      name: FPX
                      code: FPX
                    portal: Donation
                    merchant:
                      name: Donation for You
                      email: payer@example.com
      operationId: get-transaction
  /v3/transactions/{transaction_id}/duitnow-qr/status:
    get:
      tags:
        - DuitNow QR
      summary: Poll DuitNow QR payment status
      description: |-
        Get the status of a DuitNow QR transaction that you made with the Generate DuitNow QR endpoint. Use it only to update your page. The callback to your `callback_url` is the main payment notification.

        Bayarcash gets the status from its records. If nobody checked the status recently, Bayarcash checks with the provider before it answers.

        - Wait `next_poll_after_ms` between 2 polls. When it is `null`, stop. It is `null` when the status is final or when `qr_expired` is `true`.
        - The limit is 30 requests each minute for each transaction. There is also a limit for each merchant. A 429 response has a `Retry-After` header.
        - Status codes: 0 new, 1 pending, 2 unsuccessful, 3 successful, 4 cancelled, 5 abandoned.
        - After `qr_expires_at`, `qr_expired` is `true` and `next_poll_after_ms` is `null`. The transaction can stay pending for some time after this. Treat an expired QR as failed. If the payer still wants to pay, make a new QR.
      security:
        - bearerAuth: []
      parameters:
        - name: transaction_id
          description: Transaction ID (returned as transaction_id when generating the QR)
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Current status of the QR transaction.
          content:
            application/json:
              schema:
                type: object
              examples:
                - transaction_id: trx_9V2LxK
                  status: 1
                  status_description: Pending
                  is_terminal: false
                  qr_expired: false
                  qr_expires_at: 2026-08-13T15:30:00+08:00
                  next_poll_after_ms: 2000
        "404":
          description: Transaction not found, or the transaction has no DuitNow QR code.
        "429":
          description: Rate limit exceeded. Honour the Retry-After header before polling again.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
          content:
            application/json:
              schema:
                type: object
              examples:
                - code: 429
                  message: Too many requests.
      operationId: get-duitnow-qr-status
  /v3/mandates:
    get:
      tags:
        - Direct Debit
      summary: Get a list of all Direct Debit mandates
      description: Get a list of all Direct Debit mandates. The response is an array of Direct Debit objects.
      security:
        - bearerAuth: []
      parameters:
        - name: order_number
          in: query
          description: Filter transactions by their order number.
          required: false
          schema:
            type: string
        - name: status
          in: query
          required: false
          schema:
            type: integer
            format: int32
            enum:
              - 0
              - 1
              - 2
              - 3
              - 4
              - 6
              - 7
            description: |
              status:
                * 0 - New
                * 1 - Waiting Approval
                * 2 - Failed Bank Authorization
                * 3 - Active
                * 4 - Terminated
                * 6 - Rejected
                * 7 - Cancelled
        - name: payer_email
          in: query
          required: false
          schema:
            type: string
            description: Filter transactions by payer email
      responses:
        "200":
          description: Successful response
          headers:
            Content-Type:
              schema:
                type: string
                examples:
                  - application/json
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetListOfAllFpxDirectDebitResponse"
      operationId: list-mandates
    post:
      tags:
        - Direct Debit
      summary: Direct Debit Enrollment
      security:
        - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - portal_key
                - order_number
                - amount
                - payer_id_type
                - payer_id
                - payer_name
                - payer_email
                - payer_telephone_number
                - frequency_mode
                - max_frequency
                - application_reason
                - effective_date
              properties:
                portal_key:
                  type: string
                  examples:
                    - string
                order_number:
                  type: string
                  examples:
                    - DD001
                amount:
                  type: string
                  description: Required <br/><br/> Between 5.00 and 30000.00
                  examples:
                    - 100
                payer_id_type:
                  type: integer
                  enum:
                    - 1
                    - 2
                    - 3
                    - 4
                    - 5
                  description: Required <br/><br/>1 - New IC Number <br/> 2 - Old IC Number <br/> 3 - Passport Number <br/> 4 - Business Registration <br/> 5 - Others
                  examples:
                    - 1
                payer_id:
                  type: string
                  examples:
                    - "123456121234"
                payer_name:
                  type: string
                  examples:
                    - MOHD ALI
                payer_email:
                  type: string
                  examples:
                    - payer@example.com
                payer_telephone_number:
                  type: string
                  examples:
                    - "60123456789"
                payer_bank_code:
                  type: string
                  description: Optional
                  examples:
                    - string
                payer_bank_code_hashed:
                  type: string
                  description: Optional
                  examples:
                    - string
                frequency_mode:
                  type: string
                  enum:
                    - WK
                    - MT
                    - YR
                  description: Required. WK - weekly, MT - monthly, YR - yearly. Bayarcash does not offer daily Direct Debit.
                  examples:
                    - MT
                max_frequency:
                  type: integer
                  description: Required. Maximum number of charges within a collection cycle. Defaults to 9.
                  examples:
                    - 9
                application_reason:
                  type: string
                  description: Required
                  examples:
                    - Enrolment for DD001
                effective_date:
                  type: string
                  format: yyyy-MM-dd
                  description: Required. Defaults to the next day.
                  examples:
                    - 2024-08-01
                expiry_date:
                  type: string
                  format: yyyy-MM-dd
                  description: Optional
                  examples:
                    - 2025-07-01
                metadata:
                  type: string
                  examples:
                    - string
                return_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/callback
                success_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/success
                failed_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/failed
                maintenance_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/maintenance
                termination_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/termination
                link_expired_at:
                  type: string
                  format: yyyy-MM-dd HH:mm:ss
                  description: Optional. Payment link expiry datetime. Defaults to 1 hour from creation.
                  examples:
                    - 2024-08-01 23:59:59
                platform_id:
                  type: string
                  examples:
                    - string
                checksum:
                  type: string
                  examples:
                    - string
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - portal_key
                - order_number
                - amount
                - payer_id_type
                - payer_id
                - payer_name
                - payer_email
                - payer_telephone_number
                - frequency_mode
                - max_frequency
                - application_reason
                - effective_date
              properties:
                portal_key:
                  type: string
                  examples:
                    - string
                order_number:
                  type: string
                  examples:
                    - DD001
                amount:
                  type: string
                  description: Required <br/><br/> Between 5.00 and 30000.00
                  examples:
                    - 100
                payer_id_type:
                  type: integer
                  enum:
                    - 1
                    - 2
                    - 3
                    - 4
                    - 5
                  description: Required <br/><br/>1 - New IC Number <br/> 2 - Old IC Number <br/> 3 - Passport Number <br/> 4 - Business Registration <br/> 5 - Others
                  examples:
                    - 1
                payer_id:
                  type: string
                  examples:
                    - "123456121234"
                payer_name:
                  type: string
                  examples:
                    - MOHD ALI
                payer_email:
                  type: string
                  examples:
                    - payer@example.com
                payer_telephone_number:
                  type: string
                  examples:
                    - "60123456789"
                payer_bank_code:
                  type: string
                  description: Optional
                  examples:
                    - string
                payer_bank_code_hashed:
                  type: string
                  description: Optional
                  examples:
                    - string
                frequency_mode:
                  type: string
                  enum:
                    - WK
                    - MT
                    - YR
                  description: Required. WK - weekly, MT - monthly, YR - yearly. Bayarcash does not offer daily Direct Debit.
                  examples:
                    - MT
                max_frequency:
                  type: integer
                  description: Required. Maximum number of charges within a collection cycle. Defaults to 9.
                  examples:
                    - 9
                application_reason:
                  type: string
                  description: Required
                  examples:
                    - Enrolment for DD001
                effective_date:
                  type: string
                  format: yyyy-MM-dd
                  description: Required. Defaults to the next day.
                  examples:
                    - 2024-08-01
                expiry_date:
                  type: string
                  format: yyyy-MM-dd
                  description: Optional
                  examples:
                    - 2025-07-01
                metadata:
                  type: string
                  examples:
                    - string
                return_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/callback
                success_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/success
                failed_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/failed
                maintenance_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/maintenance
                termination_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/termination
                link_expired_at:
                  type: string
                  format: yyyy-MM-dd HH:mm:ss
                  description: Optional. Payment link expiry datetime. Defaults to 1 hour from creation.
                  examples:
                    - 2024-08-01 23:59:59
                platform_id:
                  type: string
                  examples:
                    - string
                checksum:
                  type: string
                  examples:
                    - string
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FpxDirectDebitApplicationResponse"
              example: |-
                {
                  "payer_name": "MOHD ALI",
                  "payer_id_type": 1,
                  "payer_id": "123456121234",
                  "payer_email": "payer@example.com",
                  "payer_telephone_number": "60123456789",
                  "order_number": "DD001",
                  "amount": 30.00,
                  "application_type": "Enrolment",
                  "application_reason": "Enrolment of DD001",
                  "frequency_mode": "MT",
                  "effective_date": "2024-06-15",
                  "expiry_date": "2024-08-15",
                  "url": "https://console.bayar.cash/payment-intent/pi_pGwZaY"
                }
      callbacks:
        Bank Authorization (Success/Failed Redirect):
          "{$request.body#/success_url}|{$request.body#/failed_url}":
            get:
              parameters:
                - name: transaction_id
                  in: query
                  required: true
                  schema:
                    type: string
                - name: exchange_reference_number
                  in: query
                  required: true
                  schema:
                    type: string
                - name: exchange_transaction_id
                  in: query
                  required: true
                  schema:
                    type: string
                - name: order_number
                  in: query
                  required: true
                  schema:
                    type: string
                - name: currency
                  in: query
                  required: true
                  schema:
                    type: string
                - name: amount
                  in: query
                  required: true
                  schema:
                    type: string
                - name: payer_bank_name
                  in: query
                  required: true
                  schema:
                    type: string
                - name: status
                  in: query
                  required: true
                  schema:
                    type: string
                - name: status_description
                  in: query
                  required: true
                  schema:
                    type: string
                - name: checksum
                  in: query
                  required: true
                  schema:
                    type: string
        Bank Approval:
          "{$request.body#/return_url}":
            post:
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: "#/components/schemas/FpxDirectDebitBankApprovalCallback"
              responses:
                "200":
                  description: Your server returns this code if it accepts the callback
        Transaction:
          "{$request.body#/return_url}":
            post:
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: "#/components/schemas/FpxDirectDebitTransactionCallback"
              responses:
                "200":
                  description: Your server returns this code if it accepts the callback
      description: |-
        Start a Direct Debit enrolment. The payer approves the e-mandate through FPX online banking.

        When the payer approves the e-mandate, their bank takes RM1.00 from the account. Bayarcash does not refund it. The bank statement of the payer can show it as "e-Mandate Enrolment".

        FPX is only for the enrolment, the maintenance and the termination of a mandate. The deductions are a separate process. They do not use FPX.
      operationId: enrol-mandate
  /v3/mandates/{mandate_id}:
    put:
      tags:
        - Direct Debit
      summary: Direct Debit Maintenance
      description: |-
        Change a Direct Debit mandate, for example the amount. The payer approves the change through FPX online banking.

        - To change the bank account, the payer selects a different account in their online banking.
        - A change cannot move the mandate to a different bank. The change always goes to the bank of the enrolment. To use a different bank, end the mandate and start a new enrolment.

        FPX is only for the enrolment, the maintenance and the termination of a mandate. The deductions are a separate process. They do not use FPX.
      security:
        - bearerAuth: []
      parameters:
        - name: mandate_id
          description: Mandate ID
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - amount
                - payer_email
                - payer_telephone_number
                - frequency_mode
                - max_frequency
                - application_reason
              properties:
                amount:
                  type: string
                  description: Required <br/><br/> Between 5.00 and 30000.00
                  examples:
                    - 100
                payer_email:
                  type: string
                  examples:
                    - payer@example.com
                payer_telephone_number:
                  type: string
                  examples:
                    - "60123456789"
                frequency_mode:
                  type: string
                  enum:
                    - WK
                    - MT
                    - YR
                  description: Required. WK - weekly, MT - monthly, YR - yearly. Bayarcash does not offer daily Direct Debit.
                  examples:
                    - MT
                max_frequency:
                  type: integer
                  description: Required. Maximum number of charges within a collection cycle. Defaults to 9.
                  examples:
                    - 9
                application_reason:
                  type: string
                  description: Required
                  examples:
                    - Maintenance for DD001
                metadata:
                  type: string
                  description: Optional
                link_expired_at:
                  type: string
                  format: yyyy-MM-dd HH:mm:ss
                  description: Optional. Payment link expiry datetime. Defaults to 1 hour from creation.
                  examples:
                    - 2024-08-01 23:59:59
                platform_id:
                  type: string
                  description: Optional
                checksum:
                  type: string
                  description: Optional
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - amount
                - payer_email
                - payer_telephone_number
                - frequency_mode
                - max_frequency
                - application_reason
              properties:
                amount:
                  type: string
                  description: Required <br/><br/> Between 5.00 and 30000.00
                  examples:
                    - 100
                payer_email:
                  type: string
                  examples:
                    - payer@example.com
                payer_telephone_number:
                  type: string
                  examples:
                    - "60123456789"
                frequency_mode:
                  type: string
                  enum:
                    - WK
                    - MT
                    - YR
                  description: Required. WK - weekly, MT - monthly, YR - yearly. Bayarcash does not offer daily Direct Debit.
                  examples:
                    - MT
                max_frequency:
                  type: integer
                  description: Required. Maximum number of charges within a collection cycle. Defaults to 9.
                  examples:
                    - 9
                application_reason:
                  type: string
                  description: Required
                  examples:
                    - Maintenance for DD001
                metadata:
                  type: string
                  description: Optional
                link_expired_at:
                  type: string
                  format: yyyy-MM-dd HH:mm:ss
                  description: Optional. Payment link expiry datetime. Defaults to 1 hour from creation.
                  examples:
                    - 2024-08-01 23:59:59
                platform_id:
                  type: string
                  description: Optional
                checksum:
                  type: string
                  description: Optional
      responses:
        "200":
          description: Successful response
          headers:
            Content-Type:
              schema:
                type: string
                examples:
                  - application/json
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetFpxDirectDebitResponse"
              example: |-
                {
                  "payer_name": "MOHD ALI",
                  "payer_id_type": 1,
                  "payer_id": "123456121234",
                  "payer_email": "payer@example.com",
                  "payer_telephone_number": "60123456789",
                  "order_number": "DD001",
                  "amount": 30.00,
                  "application_type": "Maintenance",
                  "application_reason": "Maintenance of DD001",
                  "frequency_mode": "YR",
                  "effective_date": "2024-06-15",
                  "expiry_date": "2024-08-15",
                  "url": "https://console.bayar.cash/payment-intent/pi_pGwZaY"
                }
      callbacks:
        Bank Authorization (Success/Failed Redirect):
          "{$request.body#/success_url}|{$request.body#/failed_url}":
            get:
              parameters:
                - name: transaction_id
                  in: query
                  required: true
                  schema:
                    type: string
                - name: exchange_reference_number
                  in: query
                  required: true
                  schema:
                    type: string
                - name: exchange_transaction_id
                  in: query
                  required: true
                  schema:
                    type: string
                - name: order_number
                  in: query
                  required: true
                  schema:
                    type: string
                - name: currency
                  in: query
                  required: true
                  schema:
                    type: string
                - name: amount
                  in: query
                  required: true
                  schema:
                    type: string
                - name: payer_bank_name
                  in: query
                  required: true
                  schema:
                    type: string
                - name: status
                  in: query
                  required: true
                  schema:
                    type: string
                - name: status_description
                  in: query
                  required: true
                  schema:
                    type: string
                - name: checksum
                  in: query
                  required: true
                  schema:
                    type: string
        Authorization:
          "{$request.body#/return_url}":
            post:
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: "#/components/schemas/FpxDirectDebitAuthorizationCallback"
              responses:
                "200":
                  description: Your server returns this code if it accepts the callback
        Bank Approval:
          "{$request.body#/return_url}":
            post:
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: "#/components/schemas/FpxDirectDebitBankApprovalCallback"
              responses:
                "200":
                  description: Your server returns this code if it accepts the callback
      operationId: change-mandate
    delete:
      tags:
        - Direct Debit
      summary: Direct Debit Termination
      description: |-
        End a Direct Debit mandate. The payer approves the termination through FPX online banking. After the termination, Bayarcash makes no more deductions.

        FPX is only for the enrolment, the maintenance and the termination of a mandate. The deductions are a separate process. They do not use FPX.
      security:
        - bearerAuth: []
      parameters:
        - name: mandate_id
          description: Mandate ID
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - application_reason
              properties:
                application_reason:
                  type: string
                  description: Required
                  examples:
                    - Termination for DD001
                link_expired_at:
                  type: string
                  format: yyyy-MM-dd HH:mm:ss
                  description: Optional. Payment link expiry datetime. Defaults to 1 hour from creation.
                  examples:
                    - 2024-08-01 23:59:59
                platform_id:
                  type: string
                  examples:
                    - string
                checksum:
                  type: string
                  description: Optional
                  examples:
                    - string
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - application_reason
              properties:
                application_reason:
                  type: string
                  description: Required
                  examples:
                    - Termination for DD001
                link_expired_at:
                  type: string
                  format: yyyy-MM-dd HH:mm:ss
                  description: Optional. Payment link expiry datetime. Defaults to 1 hour from creation.
                  examples:
                    - 2024-08-01 23:59:59
                platform_id:
                  type: string
                  examples:
                    - WOOCOMMERCE
                checksum:
                  type: string
                  description: Optional
                  examples:
                    - string
      responses:
        "200":
          description: Successful response
          headers:
            Content-Type:
              schema:
                type: string
                examples:
                  - application/json
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FpxDirectDebitApplicationResponse"
              example: |-
                {
                  "payer_name": "MOHD ALI",
                  "payer_id_type": 1,
                  "payer_id": "123456121234",
                  "payer_email": "payer@example.com",
                  "payer_telephone_number": "60123456789",
                  "order_number": "DD001",
                  "amount": 30.00,
                  "application_type": "Termination",
                  "application_reason": "Termination of DD001",
                  "frequency_mode": "YR",
                  "effective_date": "2024-06-15",
                  "expiry_date": "2024-08-15",
                  "url": "https://console.bayar.cash/payment-intent/pi_pGwZaY"
                }
      callbacks:
        Bank Authorization (Success/Failed Redirect):
          "{$request.body#/success_url}|{$request.body#/failed_url}":
            get:
              parameters:
                - name: transaction_id
                  in: query
                  required: true
                  schema:
                    type: string
                - name: exchange_reference_number
                  in: query
                  required: true
                  schema:
                    type: string
                - name: exchange_transaction_id
                  in: query
                  required: true
                  schema:
                    type: string
                - name: order_number
                  in: query
                  required: true
                  schema:
                    type: string
                - name: currency
                  in: query
                  required: true
                  schema:
                    type: string
                - name: amount
                  in: query
                  required: true
                  schema:
                    type: string
                - name: payer_bank_name
                  in: query
                  required: true
                  schema:
                    type: string
                - name: status
                  in: query
                  required: true
                  schema:
                    type: string
                - name: status_description
                  in: query
                  required: true
                  schema:
                    type: string
                - name: checksum
                  in: query
                  required: true
                  schema:
                    type: string
        Authorization:
          "{$request.body#/return_url}":
            post:
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: "#/components/schemas/FpxDirectDebitAuthorizationCallback"
              responses:
                "200":
                  description: Your server returns this code if it accepts the callback
        Bank Approval:
          "{$request.body#/return_url}":
            post:
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: "#/components/schemas/FpxDirectDebitBankApprovalCallback"
              responses:
                "200":
                  description: Your server returns this code if it accepts the callback
      operationId: end-mandate
    get:
      tags:
        - Direct Debit
      summary: Get a Direct Debit mandate
      description: Get a Direct Debit mandate to check its status. The response is the Direct Debit object.
      security:
        - bearerAuth: []
      parameters:
        - name: mandate_id
          description: Mandate ID
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Successful response
          headers:
            Content-Type:
              schema:
                type: string
                examples:
                  - application/json
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetFpxDirectDebitResponse"
              example:
                id: md_MGWpzp
                updated_at: 2024-07-21T15:07:09.000000Z
                mandate_reference_number: E-20230408F00230289
                order_number: 1-680-631-498-908819
                application_reason: Enrollment for 1-680-631-498-908819
                frequency_mode: MT
                frequency_mode_label: Monthly
                effective_date: 2023-04-05
                expiry_date: null
                currency: MYR
                amount: 10
                payer_name: MOHD ALI
                payer_id: "123456121234"
                payer_id_type: "1"
                payer_bank_account_number: "000000000000"
                payer_email: payer@example.com
                payer_telephone_number: "60123456789"
                status: 3
                status_description: Active
                return_url: https://example.com/donations/mandates/callback
                metadata: null
                portal: Donation Portal
                merchant:
                  name: Sekolah Agama.
                  email: payer@example.com
      operationId: get-mandate
  /v3/mandates/{mandate_id}/activate:
    patch:
      tags:
        - Direct Debit
      summary: Activate a Direct Debit mandate
      description: Activate an inactive mandate again. It is then part of the next deduction cycle. You can activate only a mandate with the status `Inactive`.
      security:
        - bearerAuth: []
      parameters:
        - name: mandate_id
          description: Mandate ID
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Mandate successfully activated. The mandate object is returned.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetFpxDirectDebitResponse"
        "422":
          description: The mandate is not in a state that can be activated.
          content:
            application/json:
              schema:
                type: object
              example:
                message: Only `Inactive` mandate can be activate.
                errors:
                  status:
                    - Only `Inactive` mandate can be activate.
        "500":
          description: Error processing request.
          content:
            application/json:
              schema:
                type: object
              example:
                success: false
                message: Error processing request.
      operationId: activate-mandate
  /v3/mandates/{mandate_id}/deactivate:
    patch:
      tags:
        - Direct Debit
      summary: Deactivate a Direct Debit mandate
      description: Remove an active mandate from the deductions. This does not end the mandate. Only the payer can end it. You can deactivate only a mandate with the status `Active`.
      security:
        - bearerAuth: []
      parameters:
        - name: mandate_id
          description: Mandate ID
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Mandate successfully deactivated. The mandate object is returned.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetFpxDirectDebitResponse"
        "422":
          description: The mandate is not in a state that can be deactivated.
          content:
            application/json:
              schema:
                type: object
              example:
                message: Only `Active` mandate can be deactivate.
                errors:
                  status:
                    - Only `Active` mandate can be deactivate.
        "500":
          description: Error processing request.
          content:
            application/json:
              schema:
                type: object
              example:
                success: false
                message: Error processing request.
      operationId: deactivate-mandate
  /v3/mandates/transactions:
    get:
      tags:
        - Direct Debit
      summary: Get a list of all Direct Debit transactions
      description: Get a list of all Direct Debit transactions. The list has the mandate applications and the deductions. The response is an array of transaction objects.
      security:
        - bearerAuth: []
      parameters:
        - name: order_number
          in: query
          description: Filter transactions by their order number.
          required: false
          schema:
            type: string
        - name: status
          in: query
          required: false
          schema:
            type: integer
            format: int32
            enum:
              - 0
              - 1
              - 2
              - 3
              - 4
              - 5
              - 6
              - 7
              - 8
            description: |
              Filter transactions by their status:
                * 0 - New
                * 1 - Pending
                * 2 - Unsuccessful
                * 3 - Successful
                * 4 - Cancelled
                * 5 - Abandoned
                * 6 - Authorized
                * 7 - Void
                * 8 - Refund
        - name: exchange_reference_number
          in: query
          required: false
          schema:
            type: string
            description: Filter transactions by exchange reference number
        - name: payer_email
          in: query
          required: false
          schema:
            type: string
            description: Filter transactions by payer email
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetFpxDirectDebitTransactionResponse"
                examples:
                  - data:
                      - id: trx_GPk868
                        transaction_type: Deduction
                        created_at: 2024-06-27 17:56:42
                        payer_name: MOHD ALI
                        payer_email: payer@example.com
                        payer_telephone_number: "60123456789"
                        order_number: DDD-24060323
                        currency: MYR
                        amount: 10
                        exchange_reference_number: 1-719-482-202-565809
                        exchange_transaction_id: "2406271756420574"
                        payer_bank_name: SBI Bank A
                        status: 3
                        status_description: Approved
                        return_url: https://example.com/donations/mandates/callback
                        metadata: null
                        payout:
                          reference_number: null
                        payment_gateway:
                          id: 3
                          name: Direct Debit
                          code: FpxDirectDebit
                        portal: Donations Portal
                        merchant:
                          name: Sekolah Agama.
                          email: payer@example.com
                    links:
                      first: https://api.console.bayar.cash/v3/mandates/transactions?page=1
                      last: https://api.console.bayar.cash/v3/mandates/transactions?page=1
                      prev: null
                      next: null
                    meta:
                      current_page: 1
                      from: 1
                      last_page: 1
                      path: https://api.console.bayar.cash/v3/mandates/transactions
                      per_page: 25
                      to: 1
                      total: 1
      operationId: list-mandate-transactions
  /v3/mandates/transactions/{transaction_id}:
    get:
      tags:
        - Direct Debit
      summary: Get a Direct Debit transaction
      description: Get a Direct Debit transaction to check its status. The response is the transaction object.
      security:
        - bearerAuth: []
      parameters:
        - name: transaction_id
          description: Transaction ID
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetFpxDirectDebitTransactionResponse"
              example:
                id: trx_GPk868
                updated_at: 2024-06-27 17:57:01
                datetime: 2024-06-27 17:56:42
                order_number: DDD-24060323
                payer_name: MOHD ALI
                payer_email: payer@example.com
                payer_telephone_number: "60123456789"
                currency: MYR
                amount: 10
                exchange_reference_number: 1-719-482-202-565809
                exchange_transaction_id: "2406271756420574"
                payer_bank_name: SBI Bank A
                status: 3
                status_description: Approved
                return_url: https://example.com/donations/mandates/callback
                metadata: null
                payout:
                  reference_number: null
                payment_gateway:
                  name: Direct Debit
                  code: FpxDirectDebit
                portal: Donations Portal
                merchant:
                  name: Sekolah Agama.
                  email: payer@example.com
                mandate:
                  id: md_nq5oAG
                  updated_at: 2024-06-27T09:57:27.000000Z
                  mandate_reference_number: E-20241719482236
                  order_number: DDD-24060323
                  application_reason: Enrollment of DDD-24060323
                  frequency_mode: MT
                  frequency_mode_label: Monthly
                  effective_date: 2024-06-30
                  expiry_date: 2025-06-30
                  currency: MYR
                  amount: 200
                  payer_name: MOHD ALI
                  payer_id: "123456121234"
                  payer_id_type: "1"
                  payer_bank_account_number: "000000000000"
                  payer_email: payer@example.com
                  payer_telephone_number: "60123456789"
                  status: 4
                  status_description: Terminated
                  return_url: https://example.com/donations/mandates/callback
                  metadata:
                    Dana Untuk Asrama Sekolah:
                      - id: 332
                        key: N2wSHl
                        name: Pakej 001
                        code: P-001
                        amount: 10
                        custom_amount_enabled: 0
                        min_custom_amount: 0
                        count: 0
                        campaign: Dana Untuk Asrama Sekolah
                        campaign_id: 95
                  portal: Donations Portal
                  merchant:
                    name: Sekolah Agama.
                    email: payer@example.com
      operationId: get-mandate-transaction
  /v3/payouts:
    get:
      tags:
        - Merchant Settlement
      summary: Get a list of merchant settlements
      description: |-
        Get all the settlements of the merchant. Bayarcash settles and pays most of them. Boost settles and pays its own settlements.

        - `settled_by` tells you who settled each settlement.
        - The ID starts with `pay_` for Bayarcash and `bpay_` for Boost. The prefix is part of the ID, because the numbers of the two parties can be the same.
      security:
        - bearerAuth: []
      parameters:
        - name: X-API-KEY
          description: Enterprise partner API key
          in: header
          required: true
          schema:
            type: string
        - name: settled_by
          description: Show only the settlements of `Bayarcash` or `Boost`. To get both, send a comma-separated list or do not send the filter. An unknown value gives an empty list.
          in: query
          required: false
          schema:
            type: string
            enum:
              - Bayarcash
              - Boost
        - name: per_page
          description: The number of rows on each page. The default is 15. The maximum is 100.
          in: query
          required: false
          schema:
            type: integer
            default: 15
            maximum: 100
        - name: page
          description: The page number. The first page is 1.
          in: query
          required: false
          schema:
            type: integer
            default: 1
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetListOfAllPayoutResponse"
                examples:
                  - data:
                      - id: pay_qK7gOq
                        created_at: 2025-01-14 10:57:33
                        settled_by: Bayarcash
                        merchant:
                          id: usr_Zz29gG
                          name: ABC Ind Sdn. Bhd.
                          email: payer@example.com
                        status: Processing
                        reference_number: P1736823453599915
                        split_payout: "-"
                        bank_transaction_reference_number: null
                        amount: "1.50"
                      - id: bpay_9Kq3Xm
                        created_at: 2025-01-13 18:02:11
                        settled_by: Boost
                        merchant:
                          id: usr_Zz29gG
                          name: ABC Ind Sdn. Bhd.
                          email: payer@example.com
                        status: Paid
                        reference_number: DSR-2026-0812
                        split_payout: "-"
                        bank_transaction_reference_number: DSR-2026-0812
                        amount: "1222.22"
                    links:
                      first: https://api.console.bayar.cash/v3/payouts?page=1
                      last: https://api.console.bayar.cash/v3/payouts?page=2
                      prev: null
                      next: https://api.console.bayar.cash/v3/payouts?page=2
                    meta:
                      current_page: 1
                      from: 1
                      last_page: 2
                      links:
                        - url: null
                          label: "&laquo; Previous"
                          active: false
                        - url: https://api.console.bayar.cash/v3/payouts?page=1
                          label: "1"
                          active: true
                        - url: https://api.console.bayar.cash/v3/payouts?page=2
                          label: "2"
                          active: false
                        - url: https://api.console.bayar.cash/v3/payouts?page=2
                          label: Next &raquo;
                          active: false
                      path: https://api.console.bayar.cash/v3/payouts
                      per_page: 15
                      to: 15
                      total: 27
      operationId: list-settlements
  /v3/payouts/{payout_id}:
    get:
      tags:
        - Merchant Settlement
      summary: Get a merchant settlement
      security:
        - bearerAuth: []
      parameters:
        - name: X-API-KEY
          description: Enterprise partner API key
          in: header
          required: true
          schema:
            type: string
        - name: payout_id
          description: The settlement ID from the list, with its prefix. For example, `pay_qK7gOq` for Bayarcash or `bpay_9Kq3Xm` for Boost. An ID with no known prefix gives "not found".
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PayoutResponse"
                examples:
                  - id: pay_qK7gOq
                    created_at: 2025-01-14 10:57:33
                    settled_by: Bayarcash
                    merchant:
                      id: usr_Zz29gG
                      name: ABC Ind Sdn. Bhd.
                      email: payer@example.com
                    status: Processing
                    reference_number: P1736823453599915
                    split_payout: "-"
                    bank_transaction_reference_number: null
                    amount: "1.50"
      operationId: get-settlement
  /v3/portals:
    get:
      tags:
        - Merchant Portal
      summary: Get a list of merchant portals
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetListOfAllPortalResponse"
                example: |-
                  {
                    "data": [
                      {
                        "id": "prt_PGMo1q",
                        "created_at": "2025-01-15 20:52:45",
                        "portal_key": "eae86b17b8138e3e7b573418dc7bf125",
                        "portal_name": "Portal Default",
                        "url": "https://example.com",
                        "transaction_notification_email": "payer@example.com",
                        "custom_payment_button_text": null,
                        "enabled_sms_on_successful_transaction": 0,
                        "split_payment_enabled": true,
                        "split_payment_merchants": [
                          {
                            "merchant": "Web Impian Sdn. Bhd.",
                            "merchant_email": "merchant@example.com",
                            "type": "fix_amount",
                            "value": 10
                          }
                        ],
                        "payment_channels": [
                          {
                            "id": 1,
                            "code": "FPX",
                            "name": "FPX"
                          },
                          {
                            "id": 5,
                            "code": "DuitNowDobw",
                            "name": "DuitNow DOBW"
                          }
                        ],
                        "merchant": {
                          "id": "usr_Zz29gG"
                          "name": "ABC Ind Sdn. Bhd.",
                          "email": "payer@example.com"
                        }
                      }
                    ],
                    "links": {
                      "first": "https://api.console.bayar.cash/v3/portals?page=1",
                      "last": "https://api.console.bayar.cash/v3/portals?page=2",
                      "prev": null,
                      "next": "https://api.console.bayar.cash/v3/portals?page=2"
                    },
                    "meta": {
                      "current_page": 1,
                      "from": 1,
                      "last_page": 2,
                      "links": [
                        {
                          "url": null,
                          "label": "&laquo; Previous",
                          "active": false
                        },
                        {
                          "url": "https://api.console.bayar.cash/v3/portals?page=1",
                          "label": "1",
                          "active": true
                        },
                        {
                          "url": "https://api.console.bayar.cash/v3/portals?page=2",
                          "label": "2",
                          "active": false
                        },
                        {
                          "url": "https://api.console.bayar.cash/v3/portals?page=2",
                          "label": "Next &raquo;",
                          "active": false
                        }
                      ],
                      "path": "https://api.console.bayar.cash/v3/portals",
                      "per_page": 15,
                      "to": 15,
                      "total": 27,
                    }
                  }
      operationId: list-portals
    post:
      tags:
        - Merchant Portal
      summary: Create a merchant portal
      security:
        - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              required:
                - name
                - merchant_transaction_notification_email
                - payment_channels
              type: object
              properties:
                merchant_id:
                  type: string
                  examples:
                    - string
                name:
                  type: string
                  examples:
                    - Portal Default
                website_url:
                  type: string
                  examples:
                    - https://example.com
                merchant_transaction_notification_email:
                  type: string
                  examples:
                    - payer@example.com
                secondary_merchant_transaction_notification_email:
                  type: string
                  examples:
                    - payer@example.com
                fpx_landing_page_payment_button_text_label:
                  type: string
                  examples:
                    - payer@example.com
                payment_channels:
                  type: string
                  enums:
                    - 1
                    - 23
                    - 4
                    - 3
                    - 5
                    - 12
                    - 6
                    - 7
                    - 8
                    - 9
                    - 10
                    - 11
                    - 13
                    - 14
                    - 15
                    - 16
                    - 17
                    - 18
                    - 19
                    - 20
                    - 21
                    - 22
                  description: The IDs of the payment channels to switch on for the portal. See [Payment Channels](#tag/payment-channels) for each channel.
                  examples:
                    - - 1
                      - 4
                      - 5
                enabled_sms_on_successful_transaction:
                  type: boolean
                  description: Default false
                split_payment_enabled:
                  type: boolean
                  description: Default false
                split_payment_merchants:
                  type: string
                  description: |
                    Split payment setting. Format as below: |-
                      [
                        {
                          "merchant_email": "merchant@example.com",
                          "type": "fix_amount", // fix_amount or percentage
                          "value": 10
                        }.
                        { ... }
                      ]
                  items:
                    type: object
                    properties:
                      merchant_email:
                        type: string
                        description: Must be valid Bayarcash merchant's email
                      type:
                        type: string
                        enums:
                          - fix_amount
                          - percentage
                      value:
                        type: number
                        format: int32|float
                  examples:
                    - - merchant_email: merchant@example.com
                        type: fix_amount
                        value: 10
                bank_accounts:
                  type: array
                  description: Optional. Required when the Manual Bank Transfer channel (id 2) is enabled. Each item describes a bank account.
                  items:
                    type: object
                    properties:
                      account_no:
                        type: string
                      bank_id:
                        type: integer
                      payment_gateway_id:
                        type: integer
                  examples:
                    - - account_no: "1234567890"
                        bank_id: 1
                        payment_gateway_id: 2
                cashier_id:
                  type: integer
                  description: Optional. Required when the DuitNow QR channel (id 6) is enabled.
                  examples:
                    - 1
          application/x-www-form-urlencoded:
            schema:
              required:
                - name
                - merchant_transaction_notification_email
                - payment_channels
              type: object
              properties:
                merchant_id:
                  type: string
                  examples:
                    - string
                name:
                  type: string
                  examples:
                    - Portal Default
                website_url:
                  type: string
                  examples:
                    - https://example.com
                merchant_transaction_notification_email:
                  type: string
                  examples:
                    - payer@example.com
                secondary_merchant_transaction_notification_email:
                  type: string
                  examples:
                    - payer@example.com
                fpx_landing_page_payment_button_text_label:
                  type: string
                  examples:
                    - payer@example.com
                payment_channels:
                  type: string
                  enums:
                    - 1
                    - 23
                    - 4
                    - 3
                    - 5
                    - 12
                    - 6
                    - 7
                    - 8
                    - 9
                    - 10
                    - 11
                    - 13
                    - 14
                    - 15
                    - 16
                    - 17
                    - 18
                    - 19
                    - 20
                    - 21
                    - 22
                  description: The IDs of the payment channels to switch on for the portal. See [Payment Channels](#tag/payment-channels) for each channel.
                  examples:
                    - - 1
                      - 4
                      - 5
                enabled_sms_on_successful_transaction:
                  type: boolean
                  description: Default false
                split_payment_enabled:
                  type: boolean
                  description: Default false
                split_payment_merchants:
                  type: string
                  description: |
                    Split payment setting. Format as below: |-
                      [
                        {
                          "merchant_email": "merchant@example.com",
                          "type": "fix_amount", // fix_amount or percentage
                          "value": 10
                        }.
                        { ... }
                      ]
                  items:
                    type: object
                    properties:
                      merchant_email:
                        type: string
                        description: Must be valid Bayarcash merchant's email
                      type:
                        type: string
                        enums:
                          - fix_amount
                          - percentage
                      value:
                        type: number
                        format: int32|float
                  examples:
                    - - merchant_email: merchant@example.com
                        type: fix_amount
                        value: 10
                bank_accounts:
                  type: array
                  description: Optional. Required when the Manual Bank Transfer channel (id 2) is enabled. Each item describes a bank account.
                  items:
                    type: object
                    properties:
                      account_no:
                        type: string
                      bank_id:
                        type: integer
                      payment_gateway_id:
                        type: integer
                  examples:
                    - - account_no: "1234567890"
                        bank_id: 1
                        payment_gateway_id: 2
                cashier_id:
                  type: integer
                  description: Optional. Required when the DuitNow QR channel (id 6) is enabled.
                  examples:
                    - 1
      responses:
        "201":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PortalResponse"
              example: |
                {
                  "id": "prt_mqXlBq",
                  "created_at": "2025-01-15 21:01:56",
                  "portal_key": "0572cc9c83ac33d6104edf19b36ec4e8",
                  "portal_name": "Portal Default",
                  "website_url": "https://example.com",
                  "transaction_notification_email": "payer@example.com",
                  "secondary_transaction_notification_email": "payer@example.com",
                  "custom_payment_button_text": null,
                  "enabled_sms_on_successful_transaction": 0,
                  "split_payment_enabled": false,
                  "split_payment_merchants": [],
                  "payment_channels": [
                      {
                          "id": 1,
                          "code": "FPX",
                          "name": "FPX"
                      },
                      {
                          "id": 5,
                          "code": "DuitNowDobw",
                          "name": "DuitNow DOBW"
                      }
                  ],
                  "merchant": {
                    "id": "usr_Zz29gG"
                    "name": "ABC Ind Sdn. Bhd.",
                    "email": "payer@example.com"
                  }
                }
      operationId: create-portal
  /v3/portals/{portal_id}:
    get:
      tags:
        - Merchant Portal
      summary: Get a merchant portal
      security:
        - bearerAuth: []
      parameters:
        - name: portal_id
          description: Portal ID
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PortalResponse"
                example:
                  id: prt_PGMo1q
                  created_at: 2025-01-15 20:52:45
                  portal_key: eae86b17b8138e3e7b573418dc7bf125
                  portal_name: Portal Default
                  url: https://example.com
                  transaction_notification_email: payer@example.com
                  custom_payment_button_text: null
                  enabled_sms_on_successful_transaction: 0
                  split_payment_enabled: true
                  split_payment_merchants:
                    - merchant: Web Impian Sdn. Bhd.
                      merchant_email: merchant@example.com
                      type: fix_amount
                      value: 10
                  payment_channels:
                    - id: 1
                      code: FPX
                      name: FPX
                    - id: 5
                      code: DuitNowDobw
                      name: DuitNow DOBW
                  merchant:
                    id: usr_DzoB1G
                    name: EXAMPLE SDN BHD
                    email: merchant@example.com
      operationId: get-portal
    put:
      tags:
        - Merchant Portal
      summary: Update a merchant portal
      security:
        - bearerAuth: []
      parameters:
        - name: portal_id
          description: Portal ID
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              required:
                - name
                - merchant_transaction_notification_email
              type: object
              properties:
                name:
                  type: string
                  examples:
                    - Portal Default
                website_url:
                  type: string
                  examples:
                    - https://example.com
                merchant_transaction_notification_email:
                  type: string
                  examples:
                    - payer@example.com
                secondary_merchant_transaction_notification_email:
                  type: string
                  examples:
                    - payer@example.com
                fpx_landing_page_payment_button_text_label:
                  type: string
                  examples:
                    - Pay Now
                payment_channels:
                  type: array
                  description: The IDs of the payment channels to switch on for the portal. See [Payment Channels](#tag/payment-channels) for each channel.
                  examples:
                    - - 1
                      - 4
                      - 5
                enabled_sms_on_successful_transaction:
                  type: boolean
                  description: Default false
                split_payment_enabled:
                  type: boolean
                  description: Default false
                split_payment_merchants:
                  type: array
                  description: "Split payment setting. Each item: { merchant_email, type (fix_amount|percentage), value }."
                  examples:
                    - - merchant_email: merchant@example.com
                        type: fix_amount
                        value: 10
                bank_accounts:
                  type: array
                  description: Optional. Required when the Manual Bank Transfer channel (id 2) is enabled. Each item describes a bank account.
                  examples:
                    - - account_no: "1234567890"
                        bank_id: 1
                        payment_gateway_id: 2
                cashier_id:
                  type: integer
                  description: Optional. Required when the DuitNow QR channel (id 6) is enabled.
                  examples:
                    - 1
      responses:
        "200":
          description: Successful response. The updated portal object is returned.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PortalResponse"
      operationId: update-portal
    delete:
      tags:
        - Merchant Portal
      summary: Delete a merchant portal
      description: Delete a portal. After you delete it, you cannot use it to create payment intents.
      security:
        - bearerAuth: []
      parameters:
        - name: portal_id
          description: Portal ID
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Portal successfully deleted
          content:
            application/json:
              schema:
                type: object
              example:
                success: true
      operationId: delete-portal
  /v3/banks:
    get:
      tags:
        - Banks List
      summary: Get the FPX bank list
      description: |-
        Get the bank codes for **buyer_bank_code** and **buyer_bank_name** in an FPX payment request.

        The list has the banks for **FPX** and **Direct Debit** online banking.
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetFpxBanksListResponse"
              example:
                - bank_display_name: Affin B2C - Test ID
                  bank_name: Affin Bank Berhad B2C - Test ID
                  bank_code: ABB0234
                  bank_code_hashed: a1ff1c836eb71209cf64935041f8e993
                  bank_availability: true
                - bank_display_name: Affin Bank
                  bank_name: Affin Bank Berhad
                  bank_code: ABB0233
                  bank_code_hashed: 472e729c398dbc372d96f5d852393b76
                  bank_availability: true
                - bank_display_name: AGRONet
                  bank_name: Bank Pertanian Malaysia Berhad (AgroBank)
                  bank_code: AGRO01
                  bank_code_hashed: 6f692c003561e3c52f0d993805b6be01
                  bank_availability: true
      operationId: list-fpx-banks
  /v3/duitnow/dobw/banks:
    get:
      tags:
        - Banks List
      summary: Get the DuitNow Online Banking/Wallets (DOBW) bank list
      description: Get the list of banks and e-wallets for DuitNow Online Banking/Wallets (DOBW).
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetDuitNowDobwBanksListResponse"
              example:
                - bank_name: ACF Bank
                  bank_code: ACFBMYK1
                  bank_availability: true
                - bank_name: AFFIN BANK BERHAD
                  bank_code: PHBMMYKL
                  bank_availability: true
                - bank_name: Agro Bank
                  bank_code: AGRO01
                  bank_availability: true
      operationId: list-dobw-banks
  /v3/customers:
    post:
      tags:
        - Customers
      summary: Create a customer
      description: |-
        Create the customer for a subscription, an installment or an on-demand charge. Only the merchant can create a customer. An agent, admin or staff user gets `401`.

        Each customer has a unique email address. The comparison ignores the case. If you already have a customer with the email, the API returns `422` `customer_email_exists`, and it creates nothing. Use the ID of that customer. A new customer returns `201`.

        There is no `Idempotency-Key`. The email stops a second create. If a create gets no response or a `5xx` (for example a `504` from a proxy), send it again:

        - A `422` `customer_email_exists` tells you that Bayarcash recorded the first create. Find it with `GET /v3/customers?search={email}`.
        - If the search finds nothing, the provider has the email outside your records. Contact Bayarcash support.

        A new customer has no card. To save a card, the payer completes the card page of an enrolment, or you use [Save a card](#tag/customers/save-card).
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - full_name
                - email
                - phone
              properties:
                full_name:
                  type: string
                  maxLength: 255
                  examples:
                    - Ahmad Tan
                email:
                  type: string
                  format: email
                  maxLength: 255
                  examples:
                    - ahmad@example.com
                phone:
                  type: string
                  maxLength: 20
                  description: The provider requires it.
                  examples:
                    - "60123456789"
      responses:
        "201":
          description: Bayarcash created the customer.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringCustomer"
        "401":
          $ref: "#/components/responses/RecurringMerchantOnly"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "422":
          description: "`customer_email_exists`: you have a customer with this email, or the payment exchange has one. Nothing was created. Or a different validation error."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringError"
              examples:
                customer_email_exists:
                  value:
                    error:
                      code: customer_email_exists
                      message: A customer with this email already exists for this merchant.
        "502":
          $ref: "#/components/responses/RecurringUpstreamError"
      operationId: create-customer
    get:
      tags:
        - Customers
      summary: Get a list of customers
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringPerPage"
        - $ref: "#/components/parameters/RecurringPage"
        - name: search
          in: query
          required: false
          schema:
            type: string
          description: Find customers by full name or email.
      responses:
        "200":
          description: A list of customers, in pages.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/RecurringPagination"
                  - type: object
                    properties:
                      data:
                        type: array
                        items:
                          $ref: "#/components/schemas/RecurringCustomer"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
      operationId: list-customers
  /v3/customers/{customerId}:
    get:
      tags:
        - Customers
      summary: Get a customer
      description: Get a customer. Bayarcash reads the card status from the provider, so `card_on_file` changes to `true` after the customer saves a card. If Bayarcash cannot connect to the provider, it gives the last record that it has.
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringCustomerId"
      responses:
        "200":
          description: The customer
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringCustomer"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
      operationId: get-customer
  /v3/customers/{customerId}/save-card:
    post:
      tags:
        - Customers
      summary: Save a card
      description: |-
        Save the card of a customer for on-demand charges. This creates a Cards payment intent.

        Send the payer to the `url` in the response. This is the card page of the provider, not the Bayarcash checkout. The page:

        - Is available for 30 minutes after the create.
        - Works only 1 time.
        - Has no other link. The Bayarcash checkout does not open a save-card payment intent.

        After 30 minutes, or after the payer used the page, create a new one.

        ## Request

        Send the fields of `POST /v3/payment-intents`, but not the payer fields. Add `tokenize`. Bayarcash takes `payer_name`, `payer_email` and `payer_telephone_number` from the customer record, and ignores the values that you send. If the customer has no phone number, the API returns `422` on `payer_telephone_number`.

        - `tokenize` `capture`: charge the amount and save the card. The minimum amount is 2.00.
        - `tokenize` `validate_only`: authorize the amount and save the card. No money moves. The minimum amount is 1.00.

        The payment channel is always Cards (`12`). You can leave out `payment_channel`. Bayarcash refuses all other channels. Only a merchant with a card provider that can save cards can use this endpoint. Other merchants get `422` on `tokenize`.

        `GET /v3/payment-intents/{payment_intent_id}` gives the payment intent, with `tokenize`. A `validate_only` payment intent has the status `authorized` after the provider authorizes the card.

        ## No Idempotency-Key

        **Each call creates a new payment intent**, with its own link. The API ignores an `Idempotency-Key`. A link does not charge money, but a payer can pay each link. With `capture`, each paid link is a sale, so 2 paid links are 2 sales.

        After a timeout or a `5xx`, get the payment intent if you have its ID. Or create a new one. Send the payer **only the newest link**.
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringCustomerId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - portal_key
                - order_number
                - amount
                - tokenize
              properties:
                tokenize:
                  type: string
                  enum:
                    - capture
                    - validate_only
                  description: |-
                    - `capture`: charge the amount and save the card. The minimum amount is 2.00.
                    - `validate_only`: authorize the amount and save the card. No money moves. The minimum amount is 1.00.
                  examples:
                    - validate_only
                payment_channel:
                  type: integer
                  enum:
                    - 12
                  description: Optional. Cards (`12`). Bayarcash saves a card only on this channel.
                  examples:
                    - 12
                portal_key:
                  type: string
                  description: One of your portals, with the Cards channel switched on.
                order_number:
                  type: string
                  examples:
                    - ORD001
                amount:
                  type: number
                  format: double
                  description: The minimum is 2.00 for `capture` and 1.00 for `validate_only`.
                  examples:
                    - 1
                metadata:
                  type: string
                  examples:
                    - "{product_sku: SKU001}"
                return_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/return
                callback_url:
                  type: string
                  format: url
                  examples:
                    - https://example.com/callback
                terminal_mode:
                  type: boolean
                  description: Optional. Set to `true` for terminal (POS) mode.
                  examples:
                    - false
                link_expired_at:
                  type: string
                  format: yyyy-MM-dd HH:mm:ss
                  description: Not used. A save-card payment intent always expires 30 minutes after the create, the same as the card page. The API ignores this value.
                  examples:
                    - 2024-08-01 23:59:59
                platform_id:
                  type: string
                  examples:
                    - string
                checksum:
                  type: string
                  description: Optional. To send it, make it the same as for `POST /v3/payment-intents`. Use `payment_channel` `12`, also when you do not send `payment_channel`. Use the `full_name` and `email` of the customer record, exactly, as `payer_name` and `payer_email`. A different name, email or channel gives `422` `Data checksum mismatch.`
                  examples:
                    - string
      responses:
        "201":
          description: Bayarcash created the payment intent. The payer is the customer.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentIntentResponse"
              example: |-
                {
                    "type": "payment_intent",
                    "id": "pi_PGPP2G",
                    "payer_name": "MOHD ALI",
                    "payer_email": "payer@example.com",
                    "payer_telephone_number": "60123456789",
                    "order_number": "ORD001",
                    "amount": 1,
                    "payment_channel": 12,
                    "url": "https://pay.provider.example/card?t=abc123",
                    "tokenize": "validate_only"
                }
        "401":
          $ref: "#/components/responses/RecurringOwnerOnly"
        "403":
          description: |-
            - `recurring_not_enabled`: card recurring is not switched on for this merchant.
            - `save_card_refused`: the provider refused the card page, and a retry will not help. For example, the account is suspended or not approved yet. `message` gives the cause. `payment_intent_id` is the payment intent, which is closed. Correct the cause before you send a new request.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringError"
              example:
                error:
                  code: save_card_refused
                  message: Account is suspended, please contact Admin.
                  payment_intent_id: pi_PGPP2G
        "404":
          $ref: "#/components/responses/RecurringNotFound"
        "422":
          description: A field is not correct. This error body is the same as for `POST /v3/payment-intents`, not the card recurring error body.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    examples:
                      - 422
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
              example:
                code: 422
                message: The tokenize field is required.
                errors:
                  tokenize:
                    - The tokenize field is required.
        "502":
          description: |-
            `save_card_failed`: Bayarcash could not start the card page. The provider did not start the payment, or did not answer in time.

            Nobody can pay this payment intent. It has the status `cancelled`, or `processing` if the provider started it. `payment_intent_id` is the reference for support. Send a new request, and send the payer only the newest link.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringError"
              example:
                error:
                  code: save_card_failed
                  message: Unable to start saving the card. Please retry the request.
                  payment_intent_id: pi_PGPP2G
      operationId: save-card
  /v3/customers/{customerId}/payments:
    get:
      tags:
        - Charges
      summary: Get a list of the charges of a customer
      description: |-
        Get all the charges of a customer, newest first. The list has the charges of all the agreements of the customer **and** the on-demand charges. This is the only endpoint that lists on-demand charges.

        Each row is a transaction record, the same as `GET /v3/transactions/{transaction_id}`. Each row has `recurring_customer_id`. A charge from an agreement also has `subscription` or `installment`. `exchange_transaction_id` is the charge ID for `GET /v3/payments/{paymentId}`.
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringCustomerId"
        - $ref: "#/components/parameters/RecurringPerPage"
        - $ref: "#/components/parameters/RecurringPage"
      responses:
        "200":
          description: A list of charges, in pages. Each charge is a transaction record.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetListOfAllTransactionResponse"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
      operationId: list-customer-charges
  /v3/plans:
    post:
      tags:
        - Plans
      summary: Create a plan
      description: |-
        Create a plan. A plan gives the price and the interval of a subscription. Only the merchant can create a plan. An agent, admin or staff user gets `401`.

        Each plan has your own `code`. The code is unique among your plans for all time. A deleted plan keeps its code. The comparison ignores the case, so `PLAN-1` and `plan-1` are the same code.

        There is no `Idempotency-Key`. If you already have a plan with the code, the API returns `422` `plan_code_already_used` before all other checks, and it records nothing. Bayarcash records the plan only after the payment exchange answers. Thus, after a `502`, no plan has the code, and you can send the request again.

        If the create gets no response or a `5xx` (for example a `504` from a proxy), send it again. A `422` `plan_code_already_used` tells you that Bayarcash recorded the first create. Find it with `GET /v3/plans?code={code}`.
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - code
                - name
                - price
                - interval
              properties:
                code:
                  type: string
                  maxLength: 36
                  pattern: ^[A-Za-z0-9_-]+$
                  description: "**Required.** Your own code for this plan. Use letters, digits, `_` and `-`, a maximum of 36 characters. It is unique among your plans for all time. The comparison ignores the case. Bayarcash does not send it to the provider."
                  examples:
                    - PREMIUM-MONTHLY
                name:
                  type: string
                  maxLength: 255
                  examples:
                    - Premium Monthly
                description:
                  type: string
                  maxLength: 1000
                  description: Optional. If you do not send it, Bayarcash uses `name`. The provider must have a description.
                price:
                  type: number
                  format: double
                  minimum: 0.01
                  maximum: 999999.99
                  examples:
                    - 49
                currency:
                  type: string
                  minLength: 3
                  maxLength: 3
                  default: MYR
                interval:
                  $ref: "#/components/schemas/RecurringInterval"
      responses:
        "201":
          description: Bayarcash created the plan.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringPlan"
        "401":
          $ref: "#/components/responses/RecurringMerchantOnly"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "422":
          description: "`plan_code_already_used`: you have a plan with this `code`. Nothing was recorded. Or a different validation error."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringError"
              examples:
                plan_code_already_used:
                  value:
                    error:
                      code: plan_code_already_used
                      message: The plan code PREMIUM-MONTHLY already exists.
        "502":
          $ref: "#/components/responses/RecurringUpstreamError"
      operationId: create-plan
    get:
      tags:
        - Plans
      summary: Get a list of plans
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringPerPage"
        - $ref: "#/components/parameters/RecurringPage"
        - name: search
          in: query
          required: false
          schema:
            type: string
          description: Find plans by name.
        - name: code
          in: query
          required: false
          schema:
            type: string
            example: PREMIUM-MONTHLY
          description: Your own plan `code`, an exact match. The case is ignored. Use it to find a create that got no response.
      responses:
        "200":
          description: A list of plans, in pages.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/RecurringPagination"
                  - type: object
                    properties:
                      data:
                        type: array
                        items:
                          $ref: "#/components/schemas/RecurringPlan"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
      operationId: list-plans
  /v3/plans/{planId}:
    get:
      tags:
        - Plans
      summary: Get a plan
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringPlanId"
      responses:
        "200":
          description: The plan
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringPlan"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
      operationId: get-plan
    patch:
      tags:
        - Plans
      summary: Update a plan
      description: Send 1 field or more. You cannot change `name`. A change to a plan also changes the subscriptions of the plan.
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringPlanId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                description:
                  type: string
                  maxLength: 1000
                price:
                  type: number
                  format: double
                  minimum: 0.01
                  maximum: 999999.99
                currency:
                  type: string
                  minLength: 3
                  maxLength: 3
                interval:
                  $ref: "#/components/schemas/RecurringInterval"
      responses:
        "200":
          description: The updated plan
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringPlan"
        "401":
          $ref: "#/components/responses/RecurringOwnerOnly"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
        "422":
          $ref: "#/components/responses/RecurringValidationError"
        "502":
          $ref: "#/components/responses/RecurringUpstreamError"
      operationId: update-plan
  /v3/subscriptions:
    post:
      tags:
        - Subscriptions
      summary: Create a subscription
      description: |-
        Create a subscription at the provider. The response has the status `pending` and a `redirect_url`, the card page of the provider. **Send the customer to `redirect_url`.**

        - The subscription becomes `active` when the customer completes the card page. The provider takes the first charge at that time.
        - The card page is available for 20 minutes after the create.
        - If nobody completes the card page, the provider cancels the subscription approximately 30 minutes after the create. It then has the status `expired`.

        Each enrolment uses the card page, also for a customer with a saved card.

        ## The customer

        Send `customer_id` **or** a `customer` object, not both. If you already have a customer with the email of the `customer` object, Bayarcash uses that customer. If that customer is in a card account that you do not use now, the API returns `422` `customer_email_exists`, and it records and sends nothing.

        ## Your reference

        Each create has your own `reference`. There is no `Idempotency-Key`. The reference stops a second agreement.

        - **A reference that you used before** gets `422` `reference_already_used` before all other checks. This occurs in all conditions: a different status, the same body or a different body, a different case, and a request that is not complete. Bayarcash sends and records nothing. **Do not send a create again. Read it.**
        - **A customer with a subscription to the plan** gets `422` `customer_already_subscribed`. This occurs when you have a subscription for the same customer and plan with the status `pending`, `active` or `paused`. Bayarcash sends and records nothing. First cancel the old subscription (`PATCH` with `status` `canceled`). A subscription that has the status `canceled`, `terminated`, `expired` or `failed` does not count. The provider can also have a subscription for the customer and plan that you do not have. Then the API also returns `customer_already_subscribed`, and Bayarcash keeps the new subscription as `failed`.

        ## When you do not get a clear response

        - **`202`**: the payment exchange did not answer. Bayarcash recorded the subscription as `pending`. The status usually changes in 6 minutes, a maximum of approximately 10 minutes. Get it with `GET /v3/subscriptions/{id}`. The `id` is in the `202`.
        - **No response, or a `5xx`** (for example a `504` from a proxy): get `GET /v3/subscriptions?reference={reference}`. If no subscription has the reference, send the request again. If one has it, read it. Do not send the create again.
        - **The exchange refused the create:** usually `422` `upstream_rejected`, with `fields` when the exchange gave them. Or `409` `upstream_conflict`, `404` `not_found`, `429` `rate_limited` or `502` `upstream_auth`. Nothing was created. Bayarcash keeps the subscription as `failed`, and you cannot use the reference again. Correct the request, or wait for `Retry-After`. Then send it with a new reference.

        ## The card page

        `redirect_url` is in each response while the subscription is `pending` and Bayarcash knows the card page. After a `202`, it is in `GET /v3/subscriptions/{id}` when the create is complete. Use `created_at` to calculate the time that remains.

        After 20 minutes the link does not work, also when the status is still `pending`. The `pending` subscription also stops a new create for the same customer and plan. Cancel it, or wait for `expired`. Then send a new create with a new `reference`.

        The charges come to `callback_url` as the [Recurring Charge Callback](#tag/charges/webhook/POST/recurringchargecallback). The first callback tells you that the enrolment is complete. The customer then goes to `return_url`. There is no webhook for a status change. Get the subscription to see its status.
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - portal_key
                - reference
                - plan_id
                - start_date
              properties:
                portal_key:
                  $ref: "#/components/schemas/RecurringPortalKey"
                reference:
                  $ref: "#/components/schemas/RecurringReference"
                customer_id:
                  type: string
                  description: Required if you do not send `customer`. Do not send it with `customer`.
                  examples:
                    - rcus_a1b2c3
                customer:
                  $ref: "#/components/schemas/RecurringInlineCustomer"
                plan_id:
                  type: string
                  description: One of your plans. An unknown plan, or the plan of a different merchant, gets `422` `validation_error` on `plan_id` ("Invalid plan id."). Bayarcash creates nothing.
                  examples:
                    - rpln_a1b2c3
                start_date:
                  type: string
                  format: date-time
                  description: A full ISO 8601 timestamp, a minimum of 1 hour in the future. The first charge occurs when the customer completes the card page. The schedule then starts from this date.
                  examples:
                    - 2027-01-01T10:00:00+08:00
                callback_url:
                  type: string
                  format: uri
                  maxLength: 500
                  description: Bayarcash sends the Recurring Charge Callback here for each charge of this subscription, at each status change. Bayarcash does not send it to the provider. Use a public http or https URL, a maximum of 500 characters. A private, loopback or internal host gets `422`.
                return_url:
                  type: string
                  format: uri
                  maxLength: 500
                  description: The customer goes here after the card page. The query string has the status of the agreement and a checksum. See Recurring Return URL in the Card Recurring Overview. Bayarcash does not send it to the provider. Use a public http or https URL, a maximum of 500 characters. A private, loopback or internal host gets `422`.
      responses:
        "201":
          description: Bayarcash created the subscription at the provider, with the status `pending`. Send the customer to `redirect_url`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringSubscription"
        "202":
          description: |-
            The payment exchange did not answer. Bayarcash recorded the subscription as `pending`, with no `redirect_url` yet. The status usually changes in 6 minutes, a maximum of approximately 10 minutes.

            Get it with `GET /v3/subscriptions/{id}`. While it is `pending`, the response has `redirect_url`.

            The card page is available for 20 minutes after the create. After that, cancel the subscription or wait for `expired`. Then send a new create with a new `reference`. Do not send the same create again.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringSubscription"
        "401":
          $ref: "#/components/responses/RecurringMerchantOnly"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
        "409":
          description: "`upstream_conflict`: the exchange refused the create because of the current condition at the provider. Bayarcash keeps the subscription as `failed`."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringError"
        "422":
          description: |-
            `customer_already_subscribed`: you have a subscription for this customer and plan with the status `pending`, `active` or `paused`. Bayarcash sent and recorded nothing. Cancel the old one first.

            The provider can also have such a subscription that you do not have. Then Bayarcash keeps the new subscription as `failed`. Or a different validation error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringError"
              examples:
                customer_already_subscribed:
                  value:
                    error:
                      code: customer_already_subscribed
                      message: The customer is already subscribed to this plan.
        "429":
          description: "`rate_limited`: the exchange got too many requests. Nothing was created. Bayarcash keeps the subscription as `failed`, and you cannot use the reference again. Wait for the time in `Retry-After`. Then send the request with a new reference."
          headers:
            Retry-After:
              schema:
                type: string
              description: The number of seconds to wait, if the exchange gave it.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringError"
        "502":
          $ref: "#/components/responses/RecurringUpstreamError"
      operationId: create-subscription
    get:
      tags:
        - Subscriptions
      summary: Get a list of subscriptions
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringPerPage"
        - $ref: "#/components/parameters/RecurringPage"
        - name: customer_id
          in: query
          required: false
          schema:
            type: string
            example: rcus_a1b2c3
        - name: status
          in: query
          required: false
          schema:
            $ref: "#/components/schemas/RecurringSubscriptionStatus"
        - name: reference
          in: query
          required: false
          schema:
            type: string
            example: INV-1042
          description: Your own `reference`, an exact match. The case is ignored. Use it to find a create that got no response.
      responses:
        "200":
          description: A list of subscriptions, in pages.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/RecurringPagination"
                  - type: object
                    properties:
                      data:
                        type: array
                        items:
                          $ref: "#/components/schemas/RecurringSubscription"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
      operationId: list-subscriptions
  /v3/subscriptions/{subscriptionId}:
    get:
      tags:
        - Subscriptions
      summary: Get a subscription
      description: |-
        Get a subscription. Bayarcash reads the status from the provider. If it cannot connect to the provider, it gives the last record that it has. The response does not have the charges. To get them, use `GET /v3/subscriptions/{id}/payments`.

        While the subscription is `pending` and Bayarcash knows the card page, the response has `redirect_url`. The card page is available for 20 minutes after `created_at`. After that, cancel the subscription or wait for `expired` (approximately 30 minutes after the create). Then send a new create with a new `reference`. Until then, a new create for the same customer and plan gets `422` `customer_already_subscribed`.
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringSubscriptionId"
      responses:
        "200":
          description: The subscription
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringSubscription"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
      operationId: get-subscription
    patch:
      tags:
        - Subscriptions
      summary: Change the status of a subscription
      description: |-
        Pause, continue, cancel or terminate a subscription. Use the American spelling `canceled`. The API refuses `cancelled`.

        Bayarcash first reads the current status from the provider. These changes are permitted:

        - `pending` to `canceled`.
        - `active` to `paused`, `terminated` or `canceled`.
        - `paused` to `active`, `terminated` or `canceled`.

        You cannot change a subscription that ended, also not to the same status. All other changes get `422` `invalid_transition`, and Bayarcash sends nothing to the provider.

        You cannot change the card of a subscription. Terminate it, and enrol the customer again.
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringSubscriptionId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - status
              properties:
                status:
                  type: string
                  enum:
                    - active
                    - canceled
                    - terminated
                    - paused
                next_payment_date:
                  type: string
                  format: date-time
                  description: Optional. It must be in the future.
      responses:
        "200":
          description: The updated subscription
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringSubscription"
        "401":
          $ref: "#/components/responses/RecurringOwnerOnly"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
        "422":
          $ref: "#/components/responses/RecurringValidationError"
        "502":
          $ref: "#/components/responses/RecurringUpstreamError"
      operationId: change-subscription-status
  /v3/subscriptions/{subscriptionId}/payments:
    get:
      tags:
        - Charges
      summary: Get a list of the charges of a subscription
      description: Get all the charges of this subscription, newest first. Each row is a transaction record, the same as `GET /v3/transactions/{transaction_id}`, with the subscription in `subscription`. `exchange_transaction_id` is the charge ID for `GET /v3/payments/{paymentId}`.
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringSubscriptionId"
        - $ref: "#/components/parameters/RecurringPerPage"
        - $ref: "#/components/parameters/RecurringPage"
      responses:
        "200":
          description: A list of charges, in pages. Each charge is a transaction record.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetListOfAllTransactionResponse"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
      operationId: list-subscription-charges
  /v3/installments:
    post:
      tags:
        - Installments
      summary: Create an installment
      description: |-
        Create an installment at the provider. It works the same as [Create a subscription](#tag/subscriptions/create-subscription). The response has the status `pending` and a `redirect_url`, the card page of the provider. **Send the customer to `redirect_url`.**

        An installment has its own amount, interval and number of charges. It has no plan.

        - **Your reference:** each create has your own `reference`, unique among your installments. There is no `Idempotency-Key`. A reference that you used before gets `422` `reference_already_used` before all other checks. Bayarcash sends and records nothing.
        - **`202`:** the payment exchange did not answer. Bayarcash recorded the installment as `pending`. Get it with `GET /v3/installments/{id}`. The status usually changes in 6 minutes, a maximum of approximately 10 minutes.
        - **No response, or a `5xx`:** get `GET /v3/installments?reference={reference}`. If the list is empty, send the request again. If not, read the installment.
        - **The exchange refused the create:** usually `422` `upstream_rejected`, or `429` `rate_limited` or `502` `upstream_auth`. Nothing was created. Bayarcash keeps the installment as `failed`. Correct the request, and send it with a new reference.

        Do not send a create again. Read it.

        `redirect_url` is in each response while the installment is `pending` and Bayarcash knows the card page. The card page is available for 20 minutes after the create. Use `created_at` to calculate the time that remains.

        After 20 minutes the link does not work, also when the status is `pending`. Then send a new create with a new `reference`. The provider cancels a `pending` installment approximately 30 minutes after the create. It then has the status `expired`.

        The charges come to `callback_url`. The customer goes to `return_url`. Get the installment to see its status.
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - portal_key
                - reference
                - total_amount
                - interval
                - installment_count
                - description
                - start_date
              properties:
                portal_key:
                  $ref: "#/components/schemas/RecurringPortalKey"
                reference:
                  $ref: "#/components/schemas/RecurringReference"
                customer_id:
                  type: string
                  description: Required if you do not send `customer`. Do not send it with `customer`.
                  examples:
                    - rcus_a1b2c3
                customer:
                  $ref: "#/components/schemas/RecurringInlineCustomer"
                total_amount:
                  type: number
                  format: double
                  minimum: 5
                  maximum: 999999.99
                  description: The total amount to collect. The minimum is MYR 5.00.
                  examples:
                    - 600
                currency:
                  type: string
                  minLength: 3
                  maxLength: 3
                  default: MYR
                interval:
                  $ref: "#/components/schemas/RecurringInterval"
                installment_count:
                  type: integer
                  minimum: 2
                  maximum: 60
                  examples:
                    - 6
                description:
                  type: string
                  maxLength: 500
                  description: The item that the customer pays for. An installment has no plan to give a name.
                  examples:
                    - Laptop, 6 payments
                start_date:
                  type: string
                  format: date-time
                  description: A full ISO 8601 timestamp, a minimum of 1 hour in the future. The first charge occurs when the customer completes the card page. The schedule then starts from this date.
                  examples:
                    - 2027-01-01T10:00:00+08:00
                callback_url:
                  type: string
                  format: uri
                  maxLength: 500
                  description: Bayarcash sends the Recurring Charge Callback here for each charge of this installment, at each status change. Use a public http or https URL, a maximum of 500 characters. A private, loopback or internal host gets `422`.
                return_url:
                  type: string
                  format: uri
                  maxLength: 500
                  description: The customer goes here after the card page. The query string has the status of the agreement and a checksum. See Recurring Return URL in the Card Recurring Overview. Use a public http or https URL, a maximum of 500 characters. A private, loopback or internal host gets `422`.
      responses:
        "201":
          description: Bayarcash created the installment at the provider, with the status `pending`. Send the customer to `redirect_url`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringInstallment"
        "202":
          description: |-
            The payment exchange did not answer. Bayarcash recorded the installment as `pending`, with no `redirect_url` yet. The status usually changes in 6 minutes, a maximum of approximately 10 minutes.

            Get it with `GET /v3/installments/{id}`. While it is `pending`, the response has `redirect_url`.

            The card page is available for 20 minutes after the create. After that, send a new create with a new `reference`. Do not send the same create again.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringInstallment"
        "401":
          $ref: "#/components/responses/RecurringMerchantOnly"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
        "409":
          description: "`upstream_conflict`: the exchange refused the create because of the current condition at the provider. Bayarcash keeps the installment as `failed`."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringError"
        "422":
          $ref: "#/components/responses/RecurringValidationError"
        "429":
          description: "`rate_limited`: the exchange got too many requests. Nothing was created. Bayarcash keeps the installment as `failed`, and you cannot use the reference again. Wait for the time in `Retry-After`. Then send the request with a new reference."
          headers:
            Retry-After:
              schema:
                type: string
              description: The number of seconds to wait, if the exchange gave it.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringError"
        "502":
          $ref: "#/components/responses/RecurringUpstreamError"
      operationId: create-installment
    get:
      tags:
        - Installments
      summary: Get a list of installments
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringPerPage"
        - $ref: "#/components/parameters/RecurringPage"
        - name: customer_id
          in: query
          required: false
          schema:
            type: string
        - name: status
          in: query
          required: false
          schema:
            $ref: "#/components/schemas/RecurringInstallmentStatus"
        - name: reference
          in: query
          required: false
          schema:
            type: string
            example: INV-1042
          description: Your own `reference`, an exact match. The case is ignored. Use it to find a create that got no response.
      responses:
        "200":
          description: A list of installments, in pages.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/RecurringPagination"
                  - type: object
                    properties:
                      data:
                        type: array
                        items:
                          $ref: "#/components/schemas/RecurringInstallment"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
      operationId: list-installments
  /v3/installments/{installmentId}:
    get:
      tags:
        - Installments
      summary: Get an installment
      description: |-
        Get an installment. Bayarcash reads the status and the remaining amount from the provider. The response does not have the charges. To get them, use `GET /v3/installments/{id}/payments`.

        While the installment is `pending` and Bayarcash knows the card page, the response has `redirect_url`. The card page is available for 20 minutes after `created_at`. After that, send a new create with a new `reference`.
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringInstallmentId"
      responses:
        "200":
          description: The installment
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringInstallment"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
      operationId: get-installment
    patch:
      tags:
        - Installments
      summary: Change the status of an installment
      description: |-
        Pause, continue, cancel or terminate an installment. Use the American spelling `canceled`.

        Bayarcash first reads the current status from the provider. These changes are permitted:

        - `pending` to `canceled`.
        - `active` to `paused`, `terminated` or `canceled`.
        - `paused` to `active`, `terminated` or `canceled`.

        You cannot change an installment that ended (`canceled`, `terminated`, `completed` or `failed`), also not to the same status. All other changes get `422` `invalid_transition`, and Bayarcash sends nothing to the provider.

        You cannot change the card of an installment. Terminate it, and enrol the customer again.
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringInstallmentId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - status
              properties:
                status:
                  type: string
                  enum:
                    - active
                    - canceled
                    - terminated
                    - paused
                next_payment_date:
                  type: string
                  format: date-time
      responses:
        "200":
          description: The updated installment
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringInstallment"
        "401":
          $ref: "#/components/responses/RecurringOwnerOnly"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
        "422":
          $ref: "#/components/responses/RecurringValidationError"
        "502":
          $ref: "#/components/responses/RecurringUpstreamError"
      operationId: change-installment-status
  /v3/installments/{installmentId}/payments:
    get:
      tags:
        - Charges
      summary: Get a list of the charges of an installment
      description: Get all the charges of this installment, newest first. Each row is a transaction record, the same as `GET /v3/transactions/{transaction_id}`, with the installment in `installment`. `exchange_transaction_id` is the charge ID for `GET /v3/payments/{paymentId}`.
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/RecurringInstallmentId"
        - $ref: "#/components/parameters/RecurringPerPage"
        - $ref: "#/components/parameters/RecurringPage"
      responses:
        "200":
          description: A list of charges, in pages. Each charge is a transaction record.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetListOfAllTransactionResponse"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
      operationId: list-installment-charges
  /v3/payments:
    post:
      tags:
        - Charges
      summary: Charge a saved card
      description: |-
        **Charge the saved card now.** The response is the charge, as a transaction record. `GET /v3/transactions/{id}` and `GET /v3/payments/{id}` give the same record. There is no customer page and no `return_url`. The response is the result.

        - `status` `3`: the charge is successful.
        - `status` `2`: the card declined the charge. This is a failed charge, not an error.
        - `status` `1`: the provider did not complete the charge yet. The final status comes to `callback_url` as the Recurring Charge Callback.

        The customer must have a saved card. `422` `customer_no_saved_card` tells you to save a card first with [Save a card](#tag/customers/save-card). Then send the charge with a new reference. `422` `charge_rejected` tells you that the provider refused the request.

        ## Your reference

        Your own `reference` stops a second charge. You do not need an `Idempotency-Key`. The API ignores it.

        - **A reference that you used before** gets `422` `reference_already_used` before all other checks. This occurs in all conditions: a different status, the same body or a different body, a different case, and a request that is not complete. Bayarcash sends, charges and records nothing. **Do not send a charge again. Read it.**
        - **`202` `{"reference", "status": "pending"}`**: the payment exchange did not answer, or did not complete the charge yet. **The card can have a charge.** Wait for the callback on `callback_url`. Or get `GET /v3/transactions?order_number={reference}&recurring_type=on_demand` after Bayarcash records the charge.
        - **No response, or a `5xx`** (for example a `504` from a proxy): do the same steps as for a `202`. The reference cannot charge 2 times. If Bayarcash recorded the first request, the same reference gets `422` `reference_already_used`.

        After a `202`, an empty search result is not proof that there is no charge. Bayarcash first checks the charge 15 minutes after it records it, then each 5 minutes. This usually takes approximately 20 minutes.

        It can take longer when Bayarcash cannot connect to the exchange, or when the exchange did not complete the charge. Use the callback. Charge again with a new reference only after a failed charge callback. Or charge again when the search is still empty a long time after that.

        If the provider refuses a charge after the exchange recorded it, Bayarcash records a failed transaction with your reference.

        A `429` `rate_limited` or a `502` `upstream_auth` means that there is no charge. Bayarcash can keep a failed record with your reference. After a `429`, wait for the time in `Retry-After`. Then send the charge with a new reference.

        Bayarcash sends `description` to the provider. The provider accepts only letters, digits, spaces, full stops and hyphens. Thus, the API refuses `Invoice #1042`.
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - portal_key
                - reference
                - amount
                - description
              properties:
                portal_key:
                  $ref: "#/components/schemas/RecurringPortalKey"
                reference:
                  $ref: "#/components/schemas/RecurringReference"
                customer_id:
                  type: string
                  description: Required if you do not send `customer`. Do not send it with `customer`.
                  examples:
                    - rcus_a1b2c3
                customer:
                  $ref: "#/components/schemas/RecurringInlineCustomer"
                amount:
                  type: number
                  format: double
                  minimum: 0.01
                  maximum: 999999.99
                  examples:
                    - 25
                currency:
                  type: string
                  minLength: 3
                  maxLength: 3
                  default: MYR
                description:
                  type: string
                  maxLength: 500
                  pattern: ^[a-zA-Z0-9\s.\-]+$
                  examples:
                    - Overage charge for June
                callback_url:
                  type: string
                  format: uri
                  maxLength: 500
                  description: Bayarcash sends the Recurring Charge Callback here for this charge, at each status change. Use a public http or https URL, a maximum of 500 characters. A private, loopback or internal host gets `422`. There is no `return_url`, because the response gives the result.
      responses:
        "201":
          description: The charge, as a transaction record. `status` `3` is successful, `2` is declined, `1` is not complete yet. `order_number` is your `reference`. `exchange_reference_number` is the `BPGR-` reference of the exchange.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetTransactionResponse"
        "202":
          description: |-
            The charge is pending, and Bayarcash did not record it yet. The payment exchange did not answer, or did not complete it. The card can have a charge.

            Wait for the callback, or get `GET /v3/transactions?order_number={reference}&recurring_type=on_demand`. Do not send the charge again.

            An empty result soon after the `202` is not proof. Bayarcash checks the charge 15 minutes after it records it, then each 5 minutes. This usually takes approximately 20 minutes. Charge again with a new reference only after a failed charge callback. Or charge again when the search is still empty a long time after that.
          content:
            application/json:
              schema:
                type: object
                properties:
                  reference:
                    type: string
                    examples:
                      - INV-1042
                  status:
                    type: string
                    enum:
                      - pending
        "401":
          $ref: "#/components/responses/RecurringOwnerOnly"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
        "422":
          description: |-
            - `validation_error`: a field is not correct.
            - `reference_already_used`: you used the reference before. There is no charge.
            - `customer_no_saved_card`: the customer has no saved card. Save a card with `POST /v3/customers/{id}/save-card`. Then send the charge with a new reference.
            - `charge_rejected`: the provider refused the charge request.
            - `customer_email_exists`: the payment exchange has the email of the `customer` object outside your records. Or one of your customers in a card account that you do not use now has it. There is no charge.
            - `upstream_rejected`: the payment exchange refused the request. `fields` gives the details. You cannot use the reference again.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringError"
        "429":
          description: "`rate_limited`: the exchange got too many requests. There is no charge. Bayarcash can keep a failed record with the reference, and then you cannot use the reference again. Wait for the time in `Retry-After`. Then send the charge with a new reference."
          headers:
            Retry-After:
              schema:
                type: string
              description: The number of seconds to wait, if the exchange gave it.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecurringError"
        "502":
          $ref: "#/components/responses/RecurringUpstreamError"
      operationId: charge-saved-card
  /v3/payments/{paymentId}:
    get:
      tags:
        - Charges
      summary: Get a charge
      description: |-
        Get a charge as a transaction record, the same as `GET /v3/transactions/{id}`. The record has `recurring_customer_id`. A scheduled charge also has the `subscription` or `installment`.

        Send the charge ID of the provider (`exchange_transaction_id` in the charge lists and the callback), **or** the `trx_` transaction ID.

        On each card recurring charge, `order_number` is your `reference`, and `exchange_reference_number` is the `BPGR-` reference of the exchange. The callback sends the same values.
      security:
        - bearerAuth: []
      parameters:
        - name: paymentId
          in: path
          required: true
          schema:
            type: string
            example: 9f2c1a7e-0d44-4f2a-9d1e-0c9b8a7f6e5d
      responses:
        "200":
          description: The charge, as a transaction record.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetTransactionResponse"
        "403":
          $ref: "#/components/responses/RecurringNotEnabled"
        "404":
          $ref: "#/components/responses/RecurringNotFound"
      operationId: get-charge
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  parameters:
    RecurringPerPage:
      name: per_page
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 15
      description: The number of rows on each page. The maximum is 100.
    RecurringPage:
      name: page
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        default: 1
    RecurringCustomerId:
      name: customerId
      in: path
      required: true
      schema:
        type: string
        example: rcus_a1b2c3
    RecurringPlanId:
      name: planId
      in: path
      required: true
      schema:
        type: string
        example: rpln_a1b2c3
    RecurringSubscriptionId:
      name: subscriptionId
      in: path
      required: true
      schema:
        type: string
        example: rsub_a1b2c3
    RecurringInstallmentId:
      name: installmentId
      in: path
      required: true
      schema:
        type: string
        example: rins_a1b2c3
  responses:
    RecurringOwnerOnly:
      description: Only the merchant that owns the record can change it. This applies to a plan update, a status change, a charge and a saved card. An enterprise or agent user can read the record of a child merchant, but gets `401` for a change.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: integer
                examples:
                  - 401
              message:
                type: string
                examples:
                  - This action is unauthorized.
    RecurringMerchantOnly:
      description: Only a merchant can create a customer, a plan, a subscription or an installment. An enterprise merchant creates its own. An agent, admin or staff user gets `401`.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: integer
                examples:
                  - 401
              message:
                type: string
                examples:
                  - This action is unauthorized.
    RecurringNotFound:
      description: "`not_found`: the record does not exist, or it is not a record of your account. The API does not tell you which."
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/RecurringError"
    RecurringValidationError:
      description: |-
        - `validation_error`: a field in the body is not correct. This includes a `portal_key` that is not yours, that has no card channel, or that is of a merchant with no card recurring. `fields.portal_key` tells you.
        - `recurring_not_configured`: card recurring is not set up for the card gateway of the merchant. This is not the same as `recurring_not_enabled` (`403`).
        - `upstream_rejected`: the payment exchange refused the request. `fields` gives the details.
        - `invalid_transition`: on a status change, the current status does not permit the new status.
        - `reference_already_used`: on a create of a subscription, an installment or a charge, you used the `reference` before. Bayarcash sends and records nothing.
        - `customer_email_exists`: the payment exchange has the email of the `customer` object outside your records. Or one of your customers in a card account that you do not use now has it. Bayarcash sends and records nothing.
        - `customer_already_subscribed`: on a create of a subscription, you have a subscription for the same customer and plan with the status `pending`, `active` or `paused`. Cancel it first.
        - `plan_code_already_used`: on a create of a plan, you have a plan with the `code`.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/RecurringError"
    RecurringNotEnabled:
      description: "`recurring_not_enabled`: card recurring is not switched on for this merchant. All card recurring endpoints give this error, also the reads. A retry does not help. Ask Bayarcash to switch it on."
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/RecurringError"
    RecurringUpstreamError:
      description: |-
        Your request did not cause this error.

        - `upstream_error`: Bayarcash cannot connect to the payment exchange, or the exchange has a fault.
        - `upstream_auth`: the exchange refused the credentials of Bayarcash.
        - `upstream_integrity`: Bayarcash cannot verify the answer of the exchange. It recorded nothing from it.

        On a create of a subscription, an installment or a charge, a timeout or a `5xx` of the exchange gives `202`, not `502`. A fault when Bayarcash gets or creates the `customer` object still gives `502`.

        An `upstream_auth` or a `429` `rate_limited` on the create or the charge means that nothing was created. Bayarcash can keep a failed record with the `reference`. Send the request again with a new reference.

        Do not send these 3 creates again with the same `reference`. A record from before the fault can have it, and the API then returns `422` `reference_already_used`. Read the result:

        - For a subscription or an installment, get the list with `?reference=`. If the list is empty, send the request again.
        - For a charge, wait for the callback, or get `GET /v3/transactions?order_number={reference}&recurring_type=on_demand`. This usually takes approximately 20 minutes. Charge again only when the callback says that the charge failed, or when the search is still empty a long time after that.

        `409` `upstream_conflict`: the provider refused the change because of the current condition of the record. This is not a repeated customer. That is `422` `customer_email_exists`. Get the record again before you try again.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/RecurringError"
  schemas:
    PaymentIntentResponse:
      type: object
      properties:
        type:
          type: string
          examples:
            - string
        id:
          type: string
          examples:
            - string
        payer_name:
          type: string
          examples:
            - string
        payer_email:
          type: string
          examples:
            - string
        payer_telephone_number:
          type: string
          examples:
            - string
        order_number:
          type: string
          examples:
            - string
        amount:
          type: number
          format: double
          examples:
            - 100
        url:
          type: string
          format: url
          description: The page for the payer. Usually this is the checkout page of the payment intent, for example https://console.bayar.cash/payment-intent/pi_KYdojq. When `generate_qr` is `true`, it is the page of the QR from this request, for example https://console.bayar.cash/duitnow-qr/dnqr_Xk9P2q. The payer then pays that QR, and does not make a new QR from the checkout.
          examples:
            - string
        tokenize:
          type: string
          enum:
            - capture
            - validate_only
          description: Only on a payment intent from `POST /v3/customers/{customerId}/save-card`.
        duitnow_qr:
          allOf:
            - $ref: "#/components/schemas/DuitNowQrResponse"
          description: Only when `generate_qr` is `true`.
    DuitNowQrResponse:
      type: object
      properties:
        type:
          type: string
          examples:
            - duitnow_qr
        transaction_id:
          type: string
          examples:
            - trx_9V2LxK
        payment_intent_id:
          type: string
          examples:
            - pi_PGPP2G
        qr_string:
          type: string
          examples:
            - 0002026012345678914A0000006150060123456789...
        qr_image:
          type: string
          nullable: true
          description: Ready-to-display PNG data URI. Render it directly in an img tag.
          examples:
            - data:image/png;base64,iVBORw0KGgo...
        qr_expires_at:
          type: string
          format: date-time
          examples:
            - 2026-08-13T15:30:00+08:00
        poll_url:
          type: string
          format: url
          examples:
            - https://api.console.bayar.cash/v3/transactions/trx_9V2LxK/duitnow-qr/status
        next_poll_after_ms:
          type: integer
          nullable: true
          examples:
            - 2000
        amount:
          type: number
          format: double
          examples:
            - 100
        currency:
          type: string
          examples:
            - MYR
        order_number:
          type: string
          examples:
            - ORD-000123
    FpxDirectDebitApplicationResponse:
      type: object
      properties:
        payer_name:
          type: string
          examples:
            - string
        payer_id_type:
          type: integer
          format: int32
          description: 1 - New IC Number <br/> 2 - Old IC Number <br/> 3 - Passport Number <br/> 4 - Business Registration <br/> 5 - Others
          examples:
            - 1
        payer_id:
          type: number
          examples:
            - string
        payer_email:
          type: string
          examples:
            - string
        payer_telephone_number:
          type: string
          examples:
            - string
        order_number:
          type: string
          examples:
            - string
        amount:
          type: number
          format: double
          examples:
            - 100
        application_type:
          type: string
          examples:
            - string
        application_reason:
          type: string
          examples:
            - string
        frequency_mode:
          type: string
          examples:
            - string
        effective_date:
          type: string
          examples:
            - string
        expiry_date:
          type: string
          examples:
            - string
        url:
          type: string
          format: url
          examples:
            - string
    PreTransactionCallback:
      type: object
      properties:
        record_type:
          type: string
          examples:
            - pre_transaction
        transaction_id:
          type: string
          examples:
            - string
        exchange_reference_number:
          type: string
          examples:
            - string
        order_number:
          type: string
          examples:
            - string
        checksum:
          type: string
          dscription: null
          examples:
            - string
    TransactionCallback:
      type: object
      properties:
        record_type:
          type: string
          examples:
            - transaction
        transaction_id:
          type: string
          examples:
            - string
        exchange_reference_number:
          type: string
          examples:
            - string
        exchange_transaction_id:
          type: string
          examples:
            - string
        order_number:
          type: string
          examples:
            - string
        currency:
          type: string
          examples:
            - string
        amount:
          type: number
          format: double
          examples:
            - string
        payer_name:
          type: string
          examples:
            - string
        payer_email:
          type: string
          examples:
            - string
        payer_bank_name:
          type: string
          examples:
            - string
        status:
          type: integer
          format: int32
          examples:
            - 3
          description: |
            status:
              * 0 - New
              * 1 - Pending
              * 2 - Unsuccessful
              * 3 - Successful
              * 4 - Cancelled
              * 5 - Abandoned
              * 6 - Authorized
              * 7 - Void
              * 8 - Refund
        status_description:
          type: string
          examples:
            - string
        datetime:
          type: string
          examples:
            - string
        checksum:
          type: string
          examples:
            - string
        payer_identity_verified:
          type: boolean
          nullable: true
          description: null for normal transactions. true if payer identity verified, false otherwise.
          examples:
            - true
        fpx_extra_info:
          $ref: "#/components/schemas/FpxExtraInfo"
    TransactionReceiptCallback:
      type: object
      properties:
        transaction_id:
          type: string
          examples:
            - string
        exchange_reference_number:
          type: string
          examples:
            - string
        exchange_transaction_id:
          type: string
          examples:
            - string
        order_number:
          type: string
          examples:
            - string
        currency:
          type: string
          examples:
            - string
        amount:
          type: number
          format: double
          examples:
            - string
        payer_bank_name:
          type: string
          examples:
            - string
        status:
          type: integer
          format: int32
          examples:
            - 3
          description: |
            status:
              * 0 - New
              * 1 - Pending
              * 2 - Unsuccessful
              * 3 - Successful
              * 4 - Cancelled
              * 5 - Abandoned
              * 6 - Authorized
              * 7 - Void
              * 8 - Refund
        status_description:
          type: string
          examples:
            - string
        checksum:
          type: string
          examples:
            - string
    FpxDirectDebitAuthorizationCallback:
      type: object
      properties:
        record_type:
          type: string
          examples:
            - authorization
        transaction_id:
          type: string
          examples:
            - string
        mandate_id:
          type: string
          examples:
            - string
        application_type:
          type: string
          examples:
            - "01"
        exchange_reference_number:
          type: string
          examples:
            - string
        exchange_transaction_id:
          type: string
          examples:
            - string
        order_number:
          type: number
          format: double
          examples:
            - 100
        currency:
          type: string
          examples:
            - string
        amount:
          type: number
          format: double
          examples:
            - string
        payer_name:
          type: string
          examples:
            - string
        payer_email:
          type: string
          examples:
            - string
        payer_bank_name:
          type: string
          examples:
            - string
        status:
          type: integer
          format: int32
          examples:
            - string
        status_description:
          type: string
          examples:
            - string
        datetime:
          type: string
          examples:
            - string
        checksum:
          type: string
          examples:
            - string
    FpxDirectDebitBankApprovalCallback:
      type: object
      properties:
        record_type:
          type: string
          examples:
            - bank_approval
        approval_date:
          type: string
          examples:
            - string
        approval_status:
          type: string
          examples:
            - string
        mandate_id:
          type: string
          examples:
            - string
        mandate_reference_number:
          type: string
          examples:
            - string
        order_number:
          type: string
          examples:
            - string
        payer_bank_code_hashed:
          type: string
          examples:
            - string
        payer_bank_code:
          type: string
          examples:
            - string
        payer_bank_account_no:
          type: string
          examples:
            - string
        application_type:
          type: string
          description: 01 - Enrolment <br/> 02 - Maintenance <br/> 03 - Termination
          examples:
            - "01"
        checksum:
          type: string
          examples:
            - string
    FpxDirectDebitTransactionCallback:
      type: object
      properties:
        record_type:
          type: string
          examples:
            - transaction
        batch_number:
          type: string
          examples:
            - string
        mandate_id:
          type: string
          examples:
            - string
        mandate_reference_number:
          type: string
          examples:
            - string
        transaction_id:
          type: string
          examples:
            - string
        datetime:
          type: string
          examples:
            - string
        reference_number:
          type: string
          examples:
            - string
        amount:
          type: number
          format: double
          examples:
            - 100
        status:
          type: integer
          format: int32
          examples:
            - string
        status_description:
          type: string
          examples:
            - string
        cycle:
          type: integer
          format: int32
          examples:
            - 1
        checksum:
          type: string
          examples:
            - string
    GetPaymentIntentResponse:
      type: object
      properties:
        type:
          type: string
          examples:
            - string
        id:
          type: string
          examples:
            - string
        status:
          type: string
          enum:
            - paid
            - unpaid
            - authorized
          description: |-
            - `paid`: the payment is complete.
            - `unpaid`: the payment is pending, or it failed.
            - `authorized`: the provider authorized the card. The payment is not final yet.
        last_attempt:
          type: string
          examples:
            - string
        paid_at:
          type: string
          examples:
            - string
        order_number:
          type: string
          examples:
            - string
        amount:
          type: number
          format: double
          examples:
            - 100
        currency:
          type: string
          examples:
            - string
        payer_name:
          type: string
          examples:
            - string
        payer_email:
          type: string
          examples:
            - string
        payer_telephone_number:
          type: string
          examples:
            - string
        tokenize:
          type: string
          enum:
            - capture
            - validate_only
          description: Only on a payment intent from `POST /v3/customers/{customerId}/save-card`.
        attempts:
          type: object
          properties:
            transaction_id:
              type: string
              examples:
                - string
            created_at:
              type: string
              examples:
                - string
            payer_name:
              type: string
              examples:
                - string
            payer_email:
              type: string
              examples:
                - string
            payer_telephone_number:
              type: string
              examples:
                - string
            order_number:
              type: string
              examples:
                - string
            currency:
              type: string
              examples:
                - string
            amount:
              type: number
              format: double
              examples:
                - 100
            exchange_reference_number:
              type: string
              examples:
                - string
            exchange_transaction_id:
              type: string
              examples:
                - string
            payer_bank_name:
              type: string
              examples:
                - string
            status:
              type: number
              format: int32
              enum:
                - 0
                - 1
                - 2
                - 3
                - 4
                - 5
                - 6
                - 7
                - 8
              description: |
                status:
                  * 0 - New
                  * 1 - Pending
                  * 2 - Unsuccessful
                  * 3 - Successful
                  * 4 - Cancelled
                  * 5 - Abandoned
                  * 6 - Authorized
                  * 7 - Void
                  * 8 - Refund
            status_description:
              type: string
              examples:
                - string
            payment_gateway:
              type: object
              properties:
                id:
                  type: string
                  examples:
                    - string
                code:
                  type: string
                  examples:
                    - string
                name:
                  type: string
                  examples:
                    - string
    GetListOfAllTransactionResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/GetTransactionResponse"
        links:
          type: object
          properties:
            first:
              type: string
              format: url
              examples:
                - url
            last:
              type: string
              format: url
              examples:
                - url
            prev:
              type: string
              format: url
              examples:
                - url
            next:
              type: string
              format: url
              examples:
                - url
        meta:
          type: object
          properties:
            current_page:
              type: integer
              examples:
                - url
            from:
              type: integer
              examples:
                - url
            last_page:
              type: integer
              examples:
                - url
            links:
              type: array
              items:
                type: object
                properties:
                  url:
                    type: string
                    format: url
                    examples:
                      - url
            path:
              type: string
              format: url
              examples:
                - url
            per_page:
              type: integer
              examples:
                - url
            to:
              type: integer
              examples:
                - url
            total:
              type: integer
              examples:
                - url
    GetTransactionResponse:
      type: object
      description: A transaction record. `GET /v3/transactions/{transaction_id}` gives it. Each row of the charge lists and `GET /v3/payments/{paymentId}` give the same object. This object does not have the result of payer identity verification. That result is only in the transaction callback.
      properties:
        id:
          type: string
          examples:
            - trx_a1b2c3
        transaction_type:
          type: string
          description: Only on a Direct Debit transaction. For an application, the type of the mandate application and the word "Application". For a debit, `Deduction`.
          examples:
            - Deduction
        application_reason:
          type: string
          description: Only on a Direct Debit mandate application.
        created_at:
          type: string
          description: The time of the transaction. For a card recurring charge, the time of the charge. Kuala Lumpur time as `Y-m-d H:i:s`, with **no** offset. The card recurring records use ISO 8601 with an offset.
          examples:
            - 2026-10-06 14:30:00
        payer_name:
          type: string
          nullable: true
          examples:
            - MOHD ALI
        payer_email:
          type: string
          nullable: true
          examples:
            - payer@example.com
        payer_telephone_number:
          type: string
          nullable: true
          examples:
            - "60123456789"
        order_number:
          type: string
          nullable: true
          description: Your order number. On a card recurring charge, your `reference`.
          examples:
            - ORD001
        currency:
          type: string
          examples:
            - MYR
        amount:
          type: number
          format: double
          examples:
            - 100
        platform_fees:
          type: number
          format: double
          examples:
            - 1
        nett_amount:
          type: number
          format: double
          description: The amount that Bayarcash pays you after the fees.
          examples:
            - 99
        exchange_reference_number:
          type: string
          nullable: true
          description: The reference of the payment exchange. On a card recurring charge, the callback sends the same value.
          examples:
            - 1-726-210-822-807492
        exchange_transaction_id:
          type: string
          nullable: true
          description: The transaction ID of the provider. On a card recurring charge, the charge ID for `GET /v3/payments/{paymentId}`.
          examples:
            - string
        payer_bank_name:
          type: string
          nullable: true
          examples:
            - Maybank2u
        status:
          type: integer
          format: int32
          enum:
            - 0
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
            - 7
            - 8
          description: |
            status:
              * 0 - New
              * 1 - Pending
              * 2 - Unsuccessful
              * 3 - Successful
              * 4 - Cancelled
              * 5 - Abandoned
              * 6 - Authorized
              * 7 - Void
              * 8 - Refund
        status_description:
          type: string
          nullable: true
          examples:
            - Approved
        return_url:
          type: string
          nullable: true
          examples:
            - https://example.com/return
        metadata:
          type: object
          nullable: true
          description: The response of the provider for this transaction, as an object.
        payout:
          type: object
          properties:
            reference_number:
              type: string
              nullable: true
        payment_gateway:
          type: object
          properties:
            id:
              type: integer
              nullable: true
              examples:
                - 1
            name:
              type: string
              nullable: true
              examples:
                - FPX
            code:
              type: string
              nullable: true
              examples:
                - fpx
        portal:
          type: string
          nullable: true
          description: The portal name.
        merchant:
          type: object
          properties:
            id:
              type: string
              nullable: true
            name:
              type: string
              nullable: true
            email:
              type: string
              format: email
              nullable: true
        payment_intent_id:
          type: string
          description: Only when the transaction is part of a payment intent.
          examples:
            - pi_a1b2c3
        mandate:
          description: Only on a Direct Debit transaction.
          allOf:
            - $ref: "#/components/schemas/GetFpxDirectDebitResponse"
        recurring_customer_id:
          type: string
          nullable: true
          description: Only on a card recurring charge. The customer of the charge, for an agreement charge and an on-demand charge.
          examples:
            - rcus_a1b2c3
        subscription:
          description: Only on a charge from a subscription. It is the same as `GET /v3/subscriptions/{subscriptionId}`.
          nullable: true
          allOf:
            - $ref: "#/components/schemas/RecurringSubscription"
        installment:
          description: Only on a charge from an installment. It is the same as `GET /v3/installments/{installmentId}`.
          nullable: true
          allOf:
            - $ref: "#/components/schemas/RecurringInstallment"
    FpxExtraInfo:
      type: object
      description: Payer identity verification result. Only present for verification transactions.
      properties:
        account_type:
          type: string
          enum:
            - Undetermined
            - CASA
            - LCA
          description: Account type - CASA (Current Account/Savings Account) or LCA (Loan/Credit Account)
          examples:
            - CASA
        account_number_verified:
          type: boolean
          nullable: true
          description: Whether the payer's bank account number matches. null if undetermined.
          examples:
            - true
        buyer_id_verified:
          type: boolean
          nullable: true
          description: Whether the payer's ID (NRIC/Passport/BRN) matches. null if undetermined.
          examples:
            - true
    GetListOfAllFpxDirectDebitResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/GetFpxDirectDebitResponse"
        links:
          type: object
          properties:
            first:
              type: string
              format: url
              examples:
                - url
            last:
              type: string
              format: url
              examples:
                - url
            prev:
              type: string
              format: url
              examples:
                - url
            next:
              type: string
              format: url
              examples:
                - url
        meta:
          type: object
          properties:
            current_page:
              type: integer
              examples:
                - url
            from:
              type: integer
              examples:
                - url
            last_page:
              type: integer
              examples:
                - url
            links:
              type: array
              items:
                type: object
                properties:
                  url:
                    type: string
                    format: url
                    examples:
                      - url
            path:
              type: string
              format: url
              examples:
                - url
            per_page:
              type: integer
              examples:
                - url
            to:
              type: integer
              examples:
                - url
            total:
              type: integer
              examples:
                - url
    GetFpxDirectDebitResponse:
      type: object
      properties:
        id:
          type: string
          examples:
            - string
        updated_at:
          type: string
          examples:
            - string
        mandate_reference_number:
          type: string
          examples:
            - string
        order_number:
          type: string
          examples:
            - string
        application_reason:
          type: string
          examples:
            - string
        frequency_mode:
          type: string
          examples:
            - string
        frequency_mode_label:
          type: string
          examples:
            - string
        effective_date:
          type: string
          examples:
            - string
        expiry_date:
          type: string
          examples:
            - string
        currency:
          type: string
          examples:
            - string
        amount:
          type: number
          format: double
          examples:
            - string
        payer_name:
          type: string
          examples:
            - string
        payer_id:
          type: string
          examples:
            - string
        payer_id_type:
          type: integer
          format: int32
          examples:
            - string
        payer_bank_account_number:
          type: string
          examples:
            - string
        payer_email:
          type: string
          examples:
            - string
        payer_telephone_number:
          type: string
          examples:
            - string
        status:
          type: integer
          format: int32
          enum:
            - 0
            - 1
            - 2
            - 3
            - 4
            - 6
            - 7
          description: |
            status:
              * 0 - New
              * 1 - Waiting Approval
              * 2 - Failed Bank Authorization
              * 3 - Active
              * 4 - Terminated
              * 6 - Rejected
              * 7 - Cancelled
        status_description:
          type: string
          examples:
            - string
        merchant:
          type: object
          properties:
            name:
              type: string
              description: null
              examples:
                - string
            email:
              type: string
              description: null
              examples:
                - string
        metadata:
          type: string
          examples:
            - string
        return_url:
          type: string
          format: url
          examples:
            - string
    GetFpxDirectDebitTransactionResponse:
      type: object
      properties:
        id:
          type: string
          examples:
            - string
        updated_at:
          type: string
          examples:
            - string
        datetime:
          type: string
          examples:
            - string
        order_number:
          type: string
          examples:
            - string
        payer_name:
          type: string
          examples:
            - string
        payer_email:
          type: string
          examples:
            - string
        payer_telephone_number:
          type: string
          examples:
            - string
        payer_bank_name:
          type: string
          examples:
            - string
        currency:
          type: string
          examples:
            - string
        amount:
          type: number
          format: double
          examples:
            - string
        exchange_reference_number:
          type: string
          examples:
            - string
        exchange_transaction_id:
          type: string
          examples:
            - string
        status:
          type: integer
          format: int32
          enum:
            - 0
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
            - 7
            - 8
          description: |
            status:
              * 0 - New
              * 1 - Pending
              * 2 - Unsuccessful
              * 3 - Successful
              * 4 - Cancelled
              * 5 - Abandoned
              * 6 - Authorized
              * 7 - Void
              * 8 - Refund
        status_description:
          type: string
          examples:
            - string
        metadata:
          type: string
          examples:
            - string
        payout:
          type: object
          properties:
            reference_number:
              type: string
              examples:
                - string
        payment_gateway:
          type: object
          properties:
            code:
              type: string
              examples:
                - string
            name:
              type: string
              examples:
                - string
        portal:
          type: string
          examples:
            - string
        merchant:
          type: object
          properties:
            name:
              type: string
              examples:
                - string
            email:
              type: string
              examples:
                - string
        mandate:
          type: object
          description: Mandate details
          $ref: "#/components/schemas/GetFpxDirectDebitResponse"
        checksum:
          type: string
          examples:
            - string
    GetListOfAllPortalResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PortalResponse"
        links:
          type: object
          properties:
            first:
              type: string
              format: url
              examples:
                - url
            last:
              type: string
              format: url
              examples:
                - url
            prev:
              type: string
              format: url
              examples:
                - url
            next:
              type: string
              format: url
              examples:
                - url
        meta:
          type: object
          properties:
            current_page:
              type: integer
              examples:
                - url
            from:
              type: integer
              examples:
                - url
            last_page:
              type: integer
              examples:
                - url
            links:
              type: array
              items:
                type: object
                properties:
                  url:
                    type: string
                    format: url
                    examples:
                      - url
            path:
              type: string
              format: url
              examples:
                - url
            per_page:
              type: integer
              examples:
                - url
            to:
              type: integer
              examples:
                - url
            total:
              type: integer
              examples:
                - url
    PortalResponse:
      type: object
      properties:
        id:
          type: string
          examples:
            - string
        created_at:
          type: string
          format: datetime
        portal_key:
          type: string
        portal_name:
          type: string
        website_url:
          type: string
          format: url
        transaction_notification_email:
          type: number
          format: email
          examples:
            - payer@example.com
        secondary_transaction_notification_email:
          type: string
          format: email
          examples:
            - payer@example.com
        custom_payment_button_text:
          type: string
        enabled_sms_on_successful_transaction:
          type: boolean
        split_payment_enabled:
          type: boolean
        split_payment_merchants:
          type: array
          properties:
            merchant_email:
              type: string
              format: email
            type:
              type: string
              enum:
                - fix_amount
                - percentage
            value:
              type: number
              format: integer|float
          examples:
            - merchant_email: merchant@example.com
              type: fix_amount
              value: 10
        payment_channels:
          type: array
          properties:
            id:
              type: string
              examples:
                - 1
            code:
              type: string
              examples:
                - FPX
            name:
              type: number
              examples:
                - FPX
          examples:
            - merchant_email: merchant@example.com
              type: fix_amount
              value: 10
        merchant:
          type: object
          properties:
            id:
              type: string
            name:
              type: string
            email:
              type: string
              format: email
    GetListOfAllPayoutResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PayoutResponse"
        links:
          type: object
          properties:
            first:
              type: string
              format: url
              examples:
                - url
            last:
              type: string
              format: url
              examples:
                - url
            prev:
              type: string
              format: url
              examples:
                - url
            next:
              type: string
              format: url
              examples:
                - url
        meta:
          type: object
          properties:
            current_page:
              type: integer
              examples:
                - url
            from:
              type: integer
              examples:
                - url
            last_page:
              type: integer
              examples:
                - url
            links:
              type: array
              items:
                type: object
                properties:
                  url:
                    type: string
                    format: url
                    examples:
                      - url
            path:
              type: string
              format: url
              examples:
                - url
            per_page:
              type: integer
              examples:
                - url
            to:
              type: integer
              examples:
                - url
            total:
              type: integer
              examples:
                - url
    PayoutResponse:
      type: object
      properties:
        id:
          type: string
          description: The prefix shows the party. `pay_` is Bayarcash and `bpay_` is Boost. The numbers of the two parties can be the same, so the prefix is necessary.
        created_at:
          type: string
          format: datetime
        settled_by:
          type: string
          description: The party that settled and paid this settlement. This is not the payment channel. Boost Wallet is also a payment channel, so a Bayarcash settlement can have Boost Wallet transactions.
          enum:
            - Bayarcash
            - Boost
        merchant:
          type: object
          properties:
            id:
              type: string
            name:
              type: string
            email:
              type: string
              format: email
        status:
          type: string
        reference_number:
          type: string
        split_payout:
          type: string
        bank_transaction_reference_number:
          type: string
        amount:
          type: string
    GetFpxBanksListResponse:
      type: object
      properties:
        bank_display_name:
          type: string
          examples:
            - string
        bank_name:
          type: string
          examples:
            - string
        bank_code:
          type: string
          examples:
            - string
        bank_code_hashed:
          type: string
          examples:
            - string
        bank_availability:
          type: boolean
          examples:
            - string
    GetDuitNowDobwBanksListResponse:
      type: object
      properties:
        bank_name:
          type: string
          examples:
            - string
        bank_code:
          type: string
          examples:
            - string
        bank_availability:
          type: boolean
          examples:
            - string
    RecurringError:
      type: object
      description: The error body of each card recurring endpoint. `code` does not change, so use it in your code. `message` is for persons. `fields` is only in a validation error.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - validation_error
                - reference_already_used
                - plan_code_already_used
                - invalid_transition
                - not_found
                - recurring_not_enabled
                - recurring_not_configured
                - customer_email_exists
                - customer_already_subscribed
                - upstream_conflict
                - upstream_rejected
                - upstream_auth
                - upstream_integrity
                - upstream_error
                - rate_limited
                - customer_no_saved_card
                - charge_rejected
                - save_card_refused
                - save_card_failed
              examples:
                - validation_error
            message:
              type: string
              examples:
                - The email field is required.
            payment_intent_id:
              type: string
              description: Only on `save_card_refused` and `save_card_failed`. The save-card payment intent, as a reference for support.
              examples:
                - pi_PGPP2G
            fields:
              type: object
              additionalProperties:
                type: array
                items:
                  type: string
              examples:
                - email:
                    - The email field is required.
    RecurringPortalKey:
      type: string
      description: The portal of this sale. It is required on the 3 requests that move money, `POST /v3/subscriptions`, `POST /v3/installments` and `POST /v3/payments`. It must be one of your own portals, not the portal of a child merchant. It must have the Cards channel, because a recurring charge is a card payment. A customer and a plan belong to your account, not to a portal. Save a card uses `portal_key` the same as `POST /v3/payment-intents`.
      example: your-portal-key
    RecurringReference:
      type: string
      maxLength: 36
      pattern: ^[A-Za-z0-9_-]+$
      description: "**Required.** Your own reference for this subscription, installment or on-demand charge. Use letters, digits, `_` and `-`, a maximum of 36 characters. It is unique for each merchant and each type, for all time. You cannot use it again, also after the record failed or ended. The comparison ignores the case. A reference that you used before gets `422` `reference_already_used` before all other checks. After a `202`, a timeout or a `5xx`, read the result. Do not send the create again. Each charge gives the reference back as `order_number`."
      examples:
        - INV-1042
    RecurringInlineCustomer:
      type: object
      description: Create a customer, or use a customer, in the same request. Do not send it with `customer_id`. If you have a customer with the email, Bayarcash uses that customer. If that customer is in a card account that you do not use now, the API returns `422` `customer_email_exists`, and Bayarcash records and sends nothing.
      required:
        - full_name
        - email
        - phone
      properties:
        full_name:
          type: string
          maxLength: 255
        email:
          type: string
          format: email
          maxLength: 255
        phone:
          type: string
          maxLength: 20
    RecurringSubscriptionStatus:
      type: string
      description: |-
        The status of a subscription. The API uses the American spelling `canceled`.

        - `pending`: the customer did not complete the card page yet, or the create got a `202`.
        - `active`: the charges occur on the schedule.
        - `paused`: the charges stopped for a time. See `paused_reason`.
        - `canceled`: you or the provider stopped it.
        - `expired`: nobody completed the card page. The provider canceled it approximately 30 minutes after the create. There was no charge.
        - `terminated`: you or the provider ended it.
        - `failed`: the card page declined the card, or the exchange refused the create. Create a new subscription with a new `reference`.

        A subscription with the status `pending`, `active` or `paused` stops a new create for the same customer and plan. A subscription never has the status `completed`. To filter the list, use `?status=`.
      enum:
        - pending
        - active
        - paused
        - canceled
        - expired
        - terminated
        - failed
    RecurringInstallmentStatus:
      type: string
      description: The status of an installment. It has the same values as a subscription, and also `completed`. `completed` means that Bayarcash collected all the charges. The provider calls this `terminated`, but the API gives `completed`.
      enum:
        - pending
        - active
        - paused
        - canceled
        - expired
        - terminated
        - failed
        - completed
    RecurringPagination:
      type: object
      properties:
        links:
          type: object
          properties:
            first:
              type: string
            last:
              type: string
            prev:
              type: string
              nullable: true
            next:
              type: string
              nullable: true
        meta:
          type: object
          properties:
            current_page:
              type: integer
              examples:
                - 1
            per_page:
              type: integer
              description: The maximum is 100.
              examples:
                - 15
            total:
              type: integer
              examples:
                - 42
    RecurringCustomer:
      type: object
      properties:
        type:
          type: string
          examples:
            - customer
        id:
          type: string
          examples:
            - rcus_a1b2c3
        full_name:
          type: string
          examples:
            - Ahmad Tan
        email:
          type: string
          examples:
            - ahmad@example.com
        phone:
          type: string
          nullable: true
          examples:
            - "60123456789"
        card_on_file:
          type: boolean
          examples:
            - true
        card_last4:
          type: string
          nullable: true
          examples:
            - "4242"
        card_brand:
          type: string
          nullable: true
          examples:
            - visa
        created_at:
          type: string
          format: date-time
    RecurringInterval:
      type: string
      enum:
        - day
        - week
        - month
        - year
      description: The interval of the charges of a plan or an installment.
      examples:
        - month
    RecurringPlan:
      type: object
      properties:
        type:
          type: string
          examples:
            - plan
        id:
          type: string
          examples:
            - rpln_a1b2c3
        code:
          type:
            - string
            - "null"
          description: Your own code for the plan, from the create. It is null on a plan from before Bayarcash required a code.
          examples:
            - PREMIUM-MONTHLY
        name:
          type: string
          examples:
            - Premium Monthly
        description:
          type: string
          nullable: true
        price:
          type: string
          description: The amount, as a string with 2 decimals.
          examples:
            - "49.00"
        currency:
          type: string
          examples:
            - MYR
        interval:
          $ref: "#/components/schemas/RecurringInterval"
        created_at:
          type: string
          format: date-time
    RecurringSubscription:
      type: object
      properties:
        type:
          type: string
          examples:
            - subscription
        id:
          type: string
          examples:
            - rsub_a1b2c3
        reference:
          type: string
          description: Your own reference, from the create.
          examples:
            - INV-1042
        customer_id:
          type: string
          nullable: true
          examples:
            - rcus_a1b2c3
        plan_id:
          type: string
          nullable: true
          examples:
            - rpln_a1b2c3
        plan:
          nullable: true
          description: The plan of this subscription, with its name, price and interval. It is the same as `GET /v3/plans/{planId}`. It is null when Bayarcash has no plan on record.
          allOf:
            - $ref: "#/components/schemas/RecurringPlan"
        status:
          $ref: "#/components/schemas/RecurringSubscriptionStatus"
        paused_reason:
          type: string
          nullable: true
          enum:
            - payment_failed
            - merchant
            - provider
          description: |-
            The cause of a pause. Each pause has one. It is null when the agreement is not paused.

            - `payment_failed`: the provider paused it after a scheduled charge failed. The charges stopped. Correct the card problem before you continue.
            - `merchant`: you paused it.
            - `provider`: the provider paused it, and Bayarcash did not see the failed charge yet. It changes to `payment_failed` when Bayarcash sees it.
        card:
          nullable: true
          description: The card of the agreement, from the enrolment. It does not change. It is null until Bayarcash sees the first charge. Bayarcash never gives a token.
          allOf:
            - $ref: "#/components/schemas/RecurringAgreementCard"
        start_date:
          type: string
          format: date-time
          nullable: true
        next_payment_date:
          type: string
          format: date-time
          nullable: true
        portal_key:
          type: string
          nullable: true
          description: The portal of the sale. It is null on a record from before Bayarcash required a portal.
          example: your-portal-key
        redirect_url:
          type: string
          format: uri
          description: The card page of the provider. The customer completes it to enrol. It is in each response while the subscription is `pending` and Bayarcash knows the page. After a `202`, it comes when the create is complete. The page is available for 20 minutes after the create. After that, cancel the subscription or wait for `expired`. Then send a new create with a new `reference`.
          examples:
            - https://provider.example/card/abc123
        created_at:
          type: string
          format: date-time
    RecurringInstallment:
      type: object
      properties:
        type:
          type: string
          examples:
            - installment
        id:
          type: string
          examples:
            - rins_a1b2c3
        reference:
          type: string
          description: Your own reference, from the create.
          examples:
            - INV-1042
        customer_id:
          type: string
          nullable: true
          examples:
            - rcus_a1b2c3
        total_amount:
          type: string
          examples:
            - "600.00"
        remaining_amount:
          type: string
          examples:
            - "500.00"
        paid_amount:
          type: string
          examples:
            - "100.00"
        progress_percent:
          type: number
          examples:
            - 16.67
        currency:
          type: string
          examples:
            - MYR
        interval:
          $ref: "#/components/schemas/RecurringInterval"
        installment_count:
          type: integer
          examples:
            - 6
        description:
          type: string
          nullable: true
          description: The item that the customer pays for. It is null on an installment from before Bayarcash required it.
          examples:
            - Laptop, 6 payments
        status:
          $ref: "#/components/schemas/RecurringInstallmentStatus"
        paused_reason:
          type: string
          nullable: true
          enum:
            - payment_failed
            - merchant
            - provider
          description: |-
            The cause of a pause. Each pause has one. It is null when the agreement is not paused.

            - `payment_failed`: the provider paused it after a scheduled charge failed. The charges stopped. Correct the card problem before you continue.
            - `merchant`: you paused it.
            - `provider`: the provider paused it, and Bayarcash did not see the failed charge yet. It changes to `payment_failed` when Bayarcash sees it.
        card:
          nullable: true
          description: The card of the agreement, from the enrolment. It does not change. It is null until Bayarcash sees the first charge. Bayarcash never gives a token.
          allOf:
            - $ref: "#/components/schemas/RecurringAgreementCard"
        next_payment_date:
          type: string
          format: date-time
          nullable: true
        portal_key:
          type: string
          nullable: true
          description: The portal of the sale. It is null on a record from before Bayarcash required a portal.
          example: your-portal-key
        redirect_url:
          type: string
          format: uri
          description: The card page of the provider. The customer completes it to enrol. It is in each response while the installment is `pending` and Bayarcash knows the page. After a `202`, it comes when the create is complete. The page is available for 20 minutes after the create. After that, send a new create with a new `reference`.
          examples:
            - https://provider.example/card/abc123
        created_at:
          type: string
          format: date-time
    RecurringAgreementCard:
      type: object
      properties:
        last4:
          type: string
          examples:
            - "1118"
        brand:
          type: string
          nullable: true
          description: The card scheme from the provider, for example `visa` or `mastercard`. It is null when the provider does not give it.
          examples:
            - visa
        country:
          type: string
          nullable: true
          description: The country of the card issuer from the provider (ISO 3166-1 alpha-2). It is null when the provider does not give it.
          examples:
            - MY
        exp_month:
          type: integer
          nullable: true
          minimum: 1
          maximum: 12
          examples:
            - 12
        exp_year:
          type: integer
          nullable: true
          examples:
            - 2030
tags:
  - name: Getting Started
    description: |-
      Each v3 request needs 3 items: a **Personal Access Token**, a **portal key** and a **payment channel**.

      ## 1. Personal Access Token

      Create a token in your account settings in the merchant dashboard. Send it as a bearer token in each request. The sandbox and production have different tokens.

      ## 2. Portal key

      A portal is a shop or a place where you collect payments. Create a portal in the merchant dashboard or with [Merchant Portal](#tag/merchant-portal). Then use its `portal_key`.

      ## 3. Payment channel

      Each channel has a number. You can use only the channels that are switched on for your account. FPX is on by default. Before you show banks to a payer, use [Banks List](#tag/banks-list) to get the banks for the channel.

      ## Next steps

      1. Create a [Payment Intent](#tag/payment-intent).
      2. Send the payer to the `url` in the response.
      3. When the payment is complete, Bayarcash sends the [Transaction Callback](#tag/transaction/webhook/POST/transactioncallback) to your server.

      Sign your requests with a [checksum](#tag/checksum). The checksum is optional. It shows that the request came from you and that nobody changed it.
  - name: Payment Channels
    description: |-
      Send the ID of the channel as `payment_channel`. You can use only the channels that are switched on for your portal. FPX Personal Banking (B2C) is on by default. To switch on a channel, ask the Bayarcash team.

      | ID | Channel | Use it for |
      |---|---|---|
      | | **Online banking** | |
      | 1 | FPX Personal Banking (B2C) | Online banking from Malaysian banks. On by default. |
      | 23 | FPX Business Banking (B2B) | Company (business) online banking. |
      | 4 | FPX Line of Credit (CCA) | Paying with a bank credit facility. See [FPX Line of Credit](https://docs.bayarcash.com/fpx-line-of-credit/). |
      | 5 | DuitNow Online Banking/Wallets (DOBW) | Real-time payment from a bank app or e-wallet. |
      | | **Recurring** | |
      | 3 | Direct Debit | Recurring collection after an e-mandate. Use the [Direct Debit](#tag/direct-debit) endpoints. |
      | | **Cards** | |
      | 12 | Cards (Visa, Mastercard, MyDebit) | Card payments. Card recurring also uses this channel. See [Card Recurring Overview](#tag/card-recurring-overview). |
      | | **DuitNow QR** | |
      | 6 | DuitNow QR | Customers scan a QR code with their banking app or e-wallet. |
      | | **Cross-border QR** | |
      | 9 | QRIS Indonesia (online banking) | Customers from Indonesia who pay with a bank app. See [Cross-border channels](https://docs.bayarcash.com/cross-border-channels/). |
      | 10 | QRIS Indonesia (e-wallet) | Customers from Indonesia who pay with an e-wallet. |
      | 11 | NETS | Customers from Singapore. |
      | 13 | Alipay | Customers from China who pay with Alipay. |
      | 14 | WeChat Pay | Customers from China who pay with WeChat Pay. |
      | 15 | PromptPay | Customers from Thailand. |
      | | **E-wallets** | |
      | 16 | Touch 'n Go eWallet | Touch 'n Go eWallet. |
      | 17 | Boost Wallet | Boost e-wallet. |
      | 18 | GrabPay | Grab e-wallet. |
      | 21 | ShopeePay | ShopeePay e-wallet. |
      | | **Buy now, pay later** | |
      | 7 | SPayLater | Buy now pay later with SPayLater. |
      | 8 | Boost PayFlex | Buy now pay later with Boost PayFlex. |
      | 19 | PayLater by Grab | Buy now pay later with Grab. |

      Direct Debit (3) uses the [Direct Debit](#tag/direct-debit) endpoints, not a payment intent. The payer uses FPX online banking only to enrol, change or end a mandate. The deductions are a separate process.

      For each channel in more detail, see [Payment channels](https://docs.bayarcash.com/payment-channels/) in the help centre.
  - name: Checksum
    description: |-
      ## Make a request checksum

      For secure requests, make a checksum with your API Secret Key and add it to the request. Bayarcash uses the checksum to make sure that nobody changed the request and that it came from you. Your API Secret Key is in the merchant dashboard.

      > [!NOTE]
      > The checksum is optional. We recommend it, because it makes your integration more secure.

      ## Request Checksum
      **1. Payment Intent Request**
      ```
        <?php
        $secretKey = 'xxxxx';  // Your API secret key

        $payloadData = [
            "payment_channel" => "1",
            "order_number" => "ORD-0060",
            "amount" => "60.00",
            "payer_name" => "MOHD ALI",
            "payer_email" => "m.ali@gmail.com"
        ];

        ksort($payloadData);  // Sort the payload data by key
        $payloadString = implode('|', $payloadData);  // Concatenate values with '|'

        $checksum = hash_hmac('sha256', $payloadString, $secretKey); // Generate HMAC SHA256 checksum
      ```
      **2. Direct Debit Enrolment**
      ```
        <?php
        $secretKey = 'xxxxx';  // Your API secret key

        $payloadData = [
          "order_number" => "ORD-0027",
          "amount" => "10",
          "payer_name" => "MOHD ALI",
          "payer_email" => "m.ali@gmail.com",
          "payer_telephone_number" => "0199009001",
          "payer_id_type" => "1",
          "payer_id" => "880101010123",
          "frequency_mode" => "MT",
          "application_reason" => "Enrollment of ORD-0027",
        ];

        ksort($payloadData);  // Sort the payload data by key
        $payloadString = implode('|', $payloadData);  // Concatenate values with '|'

        $checksum = hash_hmac('sha256', $payloadString, $secretKey); // Generate HMAC SHA256 checksum
      ```
      **3. Direct Debit Maintenance**
      ```
        <?php
        $secretKey = 'xxxxx';  // Your API secret key

        $payloadData = [
          "order_number" => "ORD-0027",
          "amount" => "10",
          "payer_email" => "m.ali@gmail.com",
          "payer_telephone_number" => "0199009001",
          "frequency_mode" => "MT",
          "application_reason" => "Enrollment of ORD-0027",
        ];

        ksort($payloadData);  // Sort the payload data by key
        $payloadString = implode('|', $payloadData);  // Concatenate values with '|'

        $checksum = hash_hmac('sha256', $payloadString, $secretKey); // Generate HMAC SHA256 checksum
      ```
      ## Check the callback data
      **1. Pre-Transaction Callback**
      ```
        <?php
        $secretKey = 'xxxxx';  // Your API secret key

        $callbackChecksum = $callbackData['checksum'];

        $payloadData = [
          "record_type" => $callbackData['record_type'],
          "exchange_reference_number" => $callbackData['exchange_reference_number'],
          "order_number" => $callbackData['order_number'],
        ];

        ksort($payloadData);  // Sort the payload data by key
        $payloadString = implode('|', $payloadData);  // Concatenate values with '|'

        $validResponse= hash_hmac('sha256', $payloadString, $secretKey) === $callbackChecksum;  // Validate checksum
      ```
      **2. Transaction Callback**
      ```
        <?php
        $secretKey = 'xxxxx';  // Your API secret key

        $callbackChecksum = $callbackData['checksum'];

        $payloadData = [
          "record_type" => $callbackData['record_type'],
          "transaction_id" => $callbackData['transaction_id'],
          "exchange_reference_number" => $callbackData['exchange_reference_number'],
          "exchange_transaction_id" => $callbackData['exchange_transaction_id'],
          "order_number" => $callbackData['order_number'],
          "currency" => $callbackData['currency'],
          "amount" => $callbackData['amount'],
          "payer_name" => $callbackData['payer_name'],
          "payer_email" => $callbackData['payer_email'],
          "payer_bank_name" => $callbackData['payer_bank_name'],
          "status" => $callbackData['status'],
          "status_description" => $callbackData['status_description'],
          "datetime" => $callbackData['datetime'],
        ];

        ksort($payloadData);  // Sort the payload data by key
        $payloadString = implode('|', $payloadData);  // Concatenate values with '|'

        $validResponse= hash_hmac('sha256', $payloadString, $secretKey) === $callbackChecksum;  // Validate checksum
      ```
      **3. Direct Debit Authorization Callback**
      ```
        <?php
        $secretKey = 'xxxxx';  // Your API secret key

        $callbackChecksum = $callbackData['checksum'];

        $payloadData = [
            "record_type" => $callbackData['record_type'],
            "exchange_reference_number" => $callbackData['exchange_reference_number'],
            "order_number" => $callbackData['order_number'],
        ];

        ksort($payloadData);  // Sort the payload data by key
        $payloadString = implode('|', $payloadData);  // Concatenate values with '|'

        $validResponse= hash_hmac('sha256', $payloadString, $secretKey) === $callbackChecksum;  // Validate checksum
      ```
      **4. Direct Debit Bank Approval Callback**
      ```
        <?php
        $secretKey = 'xxxxx';  // Your API secret key

        $callbackChecksum = $callbackData['checksum'];

        $payloadData = [
          "record_type" => $callbackData['record_type'],
          "approval_date" => $callbackData['approval_date'],
          "approval_status" => $callbackData['approval_status'],
          "mandate_id" => $callbackData['mandate_id'],
          "mandate_reference_number" => $callbackData['mandate_reference_number'],
          "order_number" => $callbackData['order_number'],
          "payer_bank_code_hashed" => $callbackData['payer_bank_code_hashed'],
          "payer_bank_code" => $callbackData['payer_bank_code'],
          "payer_bank_account_no" => $callbackData['payer_bank_account_no'],
          "application_type" => $callbackData['application_type'],
        ];

        ksort($payloadData);  // Sort the payload data by key
        $payloadString = implode('|', $payloadData);  // Concatenate values with '|'

        $validResponse= hash_hmac('sha256', $payloadString, $secretKey) === $callbackChecksum;  // Validate checksum
      ```
      **5. Direct Debit Transaction Callback**
      ```
        <?php
        $secretKey = 'xxxxx';  // Your API secret key

        $callbackChecksum = $callbackData['checksum'];

        $payloadData = [
          "record_type" => $callbackData['record_type'],
          "batch_number" => $callbackData['batch_number'],
          "mandate_id" => $callbackData['mandate_id'],
          "mandate_reference_number" => $callbackData['mandate_reference_number'],
          "transaction_id" => $callbackData['transaction_id'],
          "datetime" => $callbackData['datetime'],
          "reference_number" => $callbackData['reference_number'],
          "amount" => $callbackData['amount'],
          "status" => $callbackData['status'],
          "status_description" => $callbackData['status_description'],
          "cycle" => $callbackData['cycle'],
        ];

        ksort($payloadData);  // Sort the payload data by key
        $payloadString = implode('|', $payloadData);  // Concatenate values with '|'

        $validResponse= hash_hmac('sha256', $payloadString, $secretKey) === $callbackChecksum;  // Validate checksum
      ```
      ## Notes
      - Keep the API Secret Key in a safe place. Do not put it in code that runs in the browser.
      - Always check the checksum in the callback data. This shows that the data came from Bayarcash and that nobody changed it.
      - `ksort` sorts the payload data by key. The checksum is correct only when the order is the same.
      - `implode` joins the sorted values with `|`. The result is the string for the checksum.
      - `hash_hmac` makes the checksum with SHA256 and your API Secret Key.
      - **Trim each value** before you make the checksum, so that the string has no extra spaces.
  - name: Payer Identity Verification
    description: |-
      ## Payer Identity Verification

      FPX can verify the identity of the payer. It checks that the buyer and the payer are the same person or company, and it checks the source of the money. It uses the bank account number of the payer, the NRIC, passport number or business registration number of the payer, or both.

      ### Requirements

      - `payment_channel` **must be 1 channel only**: FPX (`1`) or FPX B2B (`23`). A payment intent with more than 1 channel cannot use identity verification.
      - `payment_channel` is **required** when `verify_identity` is `true`.
      - Set `verify_identity` to `true`.
      - `fpx_eaccount_number` (string, maximum 40 characters): **required**. The bank account number of the payer.
      - `fpx_ebuyer_id` (string, maximum 40 characters): **required**. The NRIC, passport number or business registration number of the payer.

      ### Example request
      ```json
      {
        "payment_channel": 1,
        "portal_key": "your-portal-key",
        "order_number": "ORD001",
        "amount": 100.00,
        "payer_name": "MOHD ALI",
        "payer_email": "m.ali@gmail.com",
        "verify_identity": true,
        "fpx_eaccount_number": "1234567890",
        "fpx_ebuyer_id": "900101145678"
      }
      ```

      ### Verification result

      After the payment, the transaction callback includes these fields. The response of `GET /v3/transactions/{id}` does not include them.

      - `payer_identity_verified` (boolean | null): `true` if the identity is correct, `false` if it is not correct, `null` if the transaction has no verification.
      - `fpx_extra_info` (object | null): the details of the verification. Only a transaction with verification has it. It contains:
      - `fpx_extra_info.account_type` (string): `"CASA"` (current or savings account), `"LCA"` (loan or credit account), or `"Undetermined"`.
      - `fpx_extra_info.account_number_verified` (boolean | null): `true` if the account number is correct, `false` if it is not correct, `null` if FPX cannot tell.
      - `fpx_extra_info.buyer_id_verified` (boolean | null): `true` if the buyer ID is correct, `false` if it is not correct, `null` if FPX cannot tell.

      ### Example callback
      ```json
      {
        "record_type": "transaction",
        "transaction_id": "trx_abc123",
        "exchange_reference_number": "1-726-210-822-807492",
        "order_number": "ORD001",
        "currency": "MYR",
        "amount": 100.00,
        "payer_name": "MOHD ALI",
        "payer_email": "m.ali@gmail.com",
        "status": 3,
        "status_description": "Approved",
        "payer_identity_verified": true,
        "fpx_extra_info": {
          "account_type": "CASA",
          "account_number_verified": true,
          "buyer_id_verified": true
        },
        "checksum": "..."
      }
      ```
  - name: Idempotency
    description: |-
      ## Idempotent requests

      With an idempotency key, you can safely send a request again. Bayarcash does not do the same operation 2 times. Use it when a request stops before you get a response.

      To send an idempotent request, add an `Idempotency-Key` header with a unique key. We recommend a UUID v4. The key applies to your merchant account and portal, so different portals can use the same key.

      Bayarcash keeps the body of the first successful (2xx) response for each key. If you send the same key with the same parameters again, you get the same body and the same status code (for example `201` for a create). The status code does not show that the response is a copy. To find a copy, compare the `id`. Bayarcash does not keep a response that is not successful, so you can send the request again with the same key. Keys expire after **24 hours**.

      The [Card Recurring](#tag/card-recurring-overview) endpoints do not use an `Idempotency-Key`. They ignore the header. Each create has your own `reference`, plan `code` or customer email instead. Bayarcash refuses a second create with the same value (`422`).

      > [!IMPORTANT]
      > If you send the same key with different parameters, the API returns an error. This prevents mistakes.

      **Example request with an idempotency key:**

      ```bash
      curl https://api.console.bayar.cash/v3/payment-intents \
        -H "Authorization: Bearer <Personal_Access_Token>" \
        -H "Idempotency-Key: 8f14e45f-ceea-367f-a27f-c790e02b3045" \
        -H "Content-Type: application/json" \
        -d '{"portal_key":"xxx","payment_channel":[1],"order_number":"ORD001","amount":100.00,"payer_name":"MOHD ALI","payer_email":"m.ali@gmail.com"}'

      ```

      **Error responses:**

      | When | Status | Error message |
      |----------|--------|-------------|
      | The same key with different parameters | 422 | Idempotency key already used with different request parameters |
      | A request with the same key is not complete yet | 409 | A request with this idempotency key is currently being processed |
      | The key is longer than 255 characters | 422 | Idempotency key must not exceed 255 characters |

      This error body is not the `{"error": {"code", "message"}}` body of the Card Recurring endpoints:

      ```json
      {
        "error": {
          "idempotency_key": "A request with this idempotency key is currently being processed."
        }
      }
      ```

      ## Methods that a path does not accept

      If you send a method that a path does not accept, the API returns `405 Method Not Allowed`. An example is `PATCH /v3/plans` or `GET /v3/payments`. The API does this check before the authentication. Thus a request with no token also gets `405`, not `401`.

      ```json
      {
        "code": 405,
        "message": "Method PATCH not allowed."
      }
      ```
  - name: SDKs & Plugins
    description: |-
      Official libraries, and integrations that need no code. Each SDK supports API v2 and v3.

      ## SDKs

      | Language | Package | Install |
      |---|---|---|
      | PHP | [`bayarcash/php-sdk`](https://packagist.org/packages/bayarcash/php-sdk) | `composer require bayarcash/php-sdk` |
      | Node.js / TypeScript | [`bayarcash`](https://www.npmjs.com/package/bayarcash) | `npm install bayarcash` |
      | Python | [`bayarcash`](https://pypi.org/project/bayarcash/) | `pip install bayarcash` |
      | Go | [`go-sdk`](https://pkg.go.dev/github.com/bayarcash/go-sdk) | `go get github.com/bayarcash/go-sdk` |
      | Ruby | [`bayarcash`](https://rubygems.org/gems/bayarcash) | `gem install bayarcash` |
      | Rust | [`bayarcash`](https://crates.io/crates/bayarcash) | `cargo add bayarcash` |
      | Dart / Flutter | [`bayarcash`](https://pub.dev/packages/bayarcash) | `dart pub add bayarcash` |
      | C# / .NET | [`Bayarcash`](https://www.nuget.org/packages/Bayarcash) | `dotnet add package Bayarcash` |

      The PHP SDK uses v2 by default. To use this API, call `setApiVersion('v3')`.

      ## Demos

      - [bayarcash-demo.com](https://bayarcash-demo.com/): try the payment flow of Bayarcash.
      - [bayarcash/php-demo](https://github.com/bayarcash/php-demo): a demo page in plain PHP that uses the API.

      ## Framework integrations

      | Framework | Package | Install |
      |---|---|---|
      | Laravel | [`bayarcash/laravel`](https://packagist.org/packages/bayarcash/laravel) | `composer require bayarcash/laravel` |
      | Django | [`django-bayarcash`](https://pypi.org/project/django-bayarcash/) | `pip install django-bayarcash` |

      ## Plugins

      Plugins are available for WooCommerce, GiveWP, Gravity Forms, Fluent Forms, FluentCart, Easy Digital Downloads, Paymattic, OpenCart, PrestaShop, WHMCS and HostBill. To get them, go to [plugin.bayarcash.com](https://plugin.bayarcash.com). The WordPress plugins are also on [WordPress.org](https://profiles.wordpress.org/bayarcash/).

      ## Workflow automation

      Bayarcash nodes and BCL nodes for [n8n](https://github.com/bayarcash/n8n-nodes-bayarcash).
  - name: Card Recurring Overview
    description: |-
      With card recurring, Bayarcash charges the card of a customer more than 1 time. There are 3 types:

      - **Subscription:** a fixed price at a fixed interval, from a plan. The charges continue until you or the customer stops them.
      - **Installment:** a total amount in a fixed number of charges (2 to 60). An installment has no plan.
      - **On-demand charge:** you charge a saved card at the time that you select.

      ## Before you start

      - Bayarcash must switch on card recurring for your account. Until then, each card recurring endpoint returns `403` `recurring_not_enabled`. To switch it on, ask the Bayarcash team.
      - The card processor examines each merchant before the switch-on. Prepare the items in the checklist for your checkout, below.
      - The portal must have the Cards channel (`12`). A recurring charge is a card payment.
      - Only the merchant can create a customer, a plan, a subscription or an installment. An agent, admin or staff user gets `401`. An enterprise or agent user can read the records of a child merchant, but cannot change them.

      ## Enrol a customer in a subscription

      1. Create a [plan](#tag/plans/create-plan) with your own `code`, the price and the interval.
      2. [Create a subscription](#tag/subscriptions/create-subscription) for the plan. Send your own `reference`, a `start_date`, a `callback_url` and a `return_url`.
      3. Send the customer to the `redirect_url` in the response. This is the card page of the provider. It is available for 20 minutes.
      4. The customer completes the card page. The provider takes the first charge at that time.
      5. Bayarcash sends the [Recurring Charge Callback](#tag/charges/webhook/POST/recurringchargecallback) to your `callback_url`. A successful first charge means that the subscription is `active`.
      6. The customer goes to your `return_url`. Verify the checksum. Then get the subscription, and use its status.

      An installment uses the same steps with [Create an installment](#tag/installments/create-installment). It has no plan.

      Each enrolment uses the card page, also for a customer with a saved card. A saved card is only for on-demand charges.

      ## Charge a saved card

      1. [Save a card](#tag/customers/save-card) for the customer. The customer completes the card page of the provider.
      2. [Charge the saved card](#tag/charges/charge-saved-card) when you must collect money. The response is the result of the charge. There is no customer page and no `return_url`.

      ## Your reference

      A create of a subscription, an installment or an on-demand charge has your own `reference`. There is no `Idempotency-Key`.

      - Use letters, digits, `_` and `-`, a maximum of 36 characters.
      - A reference is unique for each merchant and each type, for all time. You cannot use it again, also after the record failed or ended.
      - The comparison ignores the case. `INV-1` and `inv-1` are the same reference.
      - If you send a reference again, the API returns `422` `reference_already_used`. It does not return the first record.

      Each charge gives the reference back as `order_number`. An on-demand charge gives its own reference. A scheduled charge gives the reference of its subscription or installment.

      ## When you do not get a clear response

      Do not send the same create again. Read the record.

      | Response | What occurred | What to do |
      |---|---|---|
      | `202` on a subscription or an installment | The payment exchange did not answer. Bayarcash recorded the create as `pending`. | Get the record with its `id`. It usually changes in 6 minutes, a maximum of approximately 10 minutes. |
      | No response, or a `5xx` | You do not know. | Get the list with `?reference=`. If the list is empty, send the request again. If the list has the record, read it. |
      | `422` `upstream_rejected`, `409`, `429` or `502` `upstream_auth` | The exchange refused the create. Nothing was created. | Correct the request. Send it with a new reference. After a `429`, wait for the time in `Retry-After`. |
      | `202` on an on-demand charge | **The card can have a charge.** | Wait for the callback. Or get `GET /v3/transactions?order_number={reference}&recurring_type=on_demand`. |

      After a `202` on an on-demand charge, an empty search result is not proof that there is no charge. Bayarcash first checks the charge 15 minutes after it records it, then each 5 minutes. This usually takes approximately 20 minutes, and it can take longer. Charge again with a new reference only after a failed charge callback. Or charge again when the search is still empty a long time after that.

      ## Status of a subscription or an installment

      | Status | Meaning |
      |---|---|
      | `pending` | The customer did not complete the card page yet. Or the create got a `202`. |
      | `active` | The charges occur on the schedule. |
      | `paused` | The charges stopped for a time. `paused_reason` gives the cause. |
      | `canceled` | You or the provider stopped it, before or after the first charge. |
      | `expired` | Nobody completed the card page. The provider canceled it approximately 30 minutes after the create. There was no charge. |
      | `terminated` | You or the provider ended it. |
      | `failed` | The card page declined the card, or the exchange refused the create. Create a new one with a new reference. |
      | `completed` | Installments only. Bayarcash collected all the charges. |

      The API uses the American spelling `canceled`. It refuses `cancelled`.

      `paused_reason` has 3 values:

      - `payment_failed`: the provider paused it after a scheduled charge failed. Correct the card problem before you continue the charges.
      - `merchant`: you paused it.
      - `provider`: the provider paused it, and Bayarcash did not see the failed charge yet. The value changes to `payment_failed` when Bayarcash sees it.

      ## Change the status

      Send `PATCH` with the new `status`. Bayarcash first reads the current status from the provider. These changes are permitted:

      | From | To |
      |---|---|
      | `pending` | `canceled` |
      | `active` | `paused`, `terminated` or `canceled` |
      | `paused` | `active`, `terminated` or `canceled` |

      You cannot change a subscription or an installment that ended. All other changes get `422` `invalid_transition`.

      You cannot change the card of an agreement. Terminate the agreement, and enrol the customer again.

      ## Notifications

      The [Recurring Charge Callback](#tag/charges/webhook/POST/recurringchargecallback) is the only card recurring webhook. There is no webhook for a change of the subscription or installment status. Obey these rules:

      - **The first charge callback tells you that the enrolment is complete.** A successful first charge means that the agreement is `active`.
      - **The order is not fixed.** The first charge callback can come before or after the customer goes to your `return_url`. Use `subscription_id` or `installment_id` to connect them.
      - **A declined first charge comes as a failed charge callback.** The agreement then has the status `failed`. To try again, create a new agreement.
      - **A change with no charge does not send a callback.** Get the record to see it. Examples: `expired`, a pause or a cancellation that you made, and a pause that the provider made. The failed scheduled charge before the pause of the provider sends a failed charge callback.

      ## Recurring Return URL

      After the card page of an enrolment, the customer goes to the `return_url` of the agreement. The query string has the status of the agreement and a checksum. An on-demand charge has no return.

      The query string has these fields. Each field is always there. A field with no value is an empty string.

      - `recurring_type`: `subscription` or `installment`.
      - `status`: the status of the agreement, as a word, for example `active`. This is not the number in `status` of the charge callback.
      - `customer_id`, `subscription_id`, `installment_id`.
      - `transaction_id`, `exchange_reference_number`, `exchange_transaction_id`, `currency`, `amount`, `transaction_status`, `transaction_status_description`: the first charge. These fields are empty until Bayarcash records the charge. Then `currency` is the currency of the agreement.
      - `datetime`: ISO 8601, with an offset.
      - `checksum`.

      **Verify the checksum. Then get the agreement. Then do the next step.** The return only tells you that the customer came back. The status of the agreement and the charge callback are the record. If the customer closes the card page, the customer does not come to the `return_url`.

      The checksum signs the 12 fields before `datetime`:

      ```php
      <?php
      $secretKey = 'xxxxx';  // Your API secret key

      $checksum = $_GET['checksum'];

      $payloadData = [
        "recurring_type" => $_GET['recurring_type'] ?? '',
        "status" => $_GET['status'] ?? '',
        "customer_id" => $_GET['customer_id'] ?? '',
        "subscription_id" => $_GET['subscription_id'] ?? '',
        "installment_id" => $_GET['installment_id'] ?? '',
        "transaction_id" => $_GET['transaction_id'] ?? '',
        "exchange_reference_number" => $_GET['exchange_reference_number'] ?? '',
        "exchange_transaction_id" => $_GET['exchange_transaction_id'] ?? '',
        "currency" => $_GET['currency'] ?? '',
        "amount" => $_GET['amount'] ?? '',
        "transaction_status" => $_GET['transaction_status'] ?? '',
        "transaction_status_description" => $_GET['transaction_status_description'] ?? '',
      ];

      ksort($payloadData);  // Sort the payload data by key
      $payloadString = implode('|', $payloadData);  // Join the values with '|'

      $validResponse = hash_equals(hash_hmac('sha256', $payloadString, $secretKey), $checksum);
      ```

      ## Checklist for your checkout

      Bayarcash does not show its own page for an enrolment. Your checkout shows the consent. Then the customer goes directly to the card page of the provider (`redirect_url`). The card processor asks for these items before the switch-on:

      - Your recurring terms and conditions, and your policies.
      - Your checkout page with the recurring consent. For example, a required checkbox next to the amount and the interval: *"I authorise {merchant} to charge my card {amount} {every month} starting {date} until I cancel"*.
      - A sample authorization form, or a description of how the customer gives consent.
      - A clear cancellation process for the customer. For example: *"Cancel at any time from your account page, or send an email to {support e-mail}. We stop the charges from the next cycle."* To cancel, send `PATCH` with the `status` `canceled`.

      ## Dates and times

      - Transaction records (`GET /v3/transactions`, the charge lists and `GET /v3/payments/{paymentId}`) and the `datetime` of the callback use Kuala Lumpur time as `Y-m-d H:i:s`, **with no offset**.
      - Customers, plans, subscriptions, installments and `next_payment_date` use ISO 8601 **with an offset**, for example `2027-01-01T10:00:00+08:00`.

      ## Errors

      The card recurring endpoints use this error body. `code` does not change, so use it in your code. `message` is for persons. `fields` is only in a validation error.

      ```json
      {
        "error": {
          "code": "validation_error",
          "message": "The email field is required.",
          "fields": { "email": ["The email field is required."] }
        }
      }
      ```

      A `401` uses the body `{"code": 401, "message": "This action is unauthorized."}`. A validation error of [Save a card](#tag/customers/save-card) uses the body of `POST /v3/payment-intents`.

      Bayarcash keeps a log of each call to the payment exchange for your requests, with the request and the answer. The exchange keeps a log of each call to the provider. These logs are the audit record of card recurring.
  - name: Customers
    description: |-
      A customer is the person that a subscription, an installment or an on-demand charge bills. A customer belongs to your account, not to a portal. Each customer has a unique email address.

      You can also create a customer in the same request as a subscription, an installment or an on-demand charge. Use the `customer` object for this.
  - name: Plans
    description: A plan gives the price and the interval of a subscription. A plan belongs to your account, not to a portal. Each plan has your own `code`.
  - name: Subscriptions
    description: A subscription charges the card of a customer at the price and the interval of a plan. It continues until you, the customer or the provider stops it. See [Card Recurring Overview](#tag/card-recurring-overview).
  - name: Installments
    description: An installment divides a total amount into 2 to 60 charges at a fixed interval. It has no plan. See [Card Recurring Overview](#tag/card-recurring-overview).
  - name: Charges
    description: Charge a saved card, and read the charges of a customer, a subscription or an installment. Each charge is a transaction record, the same as `GET /v3/transactions/{transaction_id}`.
  - name: Changelog
    description: |-
      Changes to the Bayarcash API v3, and corrections to this reference. The newest changes are first.

      ## 10 Nov 2026

      ### New: card recurring

      Charge the card of a customer more than 1 time: subscriptions, installments and on-demand charges. Bayarcash must switch on card recurring for your account. See [Card Recurring Overview](#tag/card-recurring-overview).

      - **Customers:** `POST /v3/customers`, `GET /v3/customers`, `GET /v3/customers/{customerId}`, `POST /v3/customers/{customerId}/save-card`.
      - **Plans:** `POST /v3/plans`, `GET /v3/plans`, `GET /v3/plans/{planId}`, `PATCH /v3/plans/{planId}`.
      - **Subscriptions:** `POST /v3/subscriptions`, `GET /v3/subscriptions`, `GET /v3/subscriptions/{subscriptionId}`, `PATCH /v3/subscriptions/{subscriptionId}`.
      - **Installments:** `POST /v3/installments`, `GET /v3/installments`, `GET /v3/installments/{installmentId}`, `PATCH /v3/installments/{installmentId}`.
      - **Charges:** `POST /v3/payments`, `GET /v3/payments/{paymentId}`, and the charge lists of a customer, a subscription and an installment.
      - **Recurring Charge Callback**, and the signed **Recurring Return URL**.

      ### New: other changes

      - **Payment intent:** the new status `authorized`. A card saved with `validate_only` has this status. The new field `tokenize` is only on a payment intent from Save a card.
      - **List transactions:** the new filter `recurring_type` (`on_demand`, `subscription` or `installment`).
      - **Transaction object:** for card recurring, the fields `recurring_customer_id`, `subscription` and `installment`.
      - **Settlements:** Boost settles and pays its own settlements. Each settlement has the new field `settled_by` (`Bayarcash` or `Boost`). The ID starts with `pay_` for Bayarcash and `bpay_` for Boost. The list has the new filters `settled_by`, `per_page` and `page`.

      ### Now in this reference

      This reference did not show these items before.

      - **Transaction status:** the codes `6` Authorized, `7` Void and `8` Refund. Make sure that your code accepts them.
      - **Transaction object:** the fields `platform_fees`, `nett_amount` and `payment_intent_id`. For Direct Debit: `transaction_type`, `application_reason` and `mandate`.
      - **Payment intent:** when `generate_qr` is `true`, `url` is the page of the QR, not the checkout page.

      ### Corrections

      - **Idempotency:** Bayarcash keeps only a successful (2xx) first response. If the first request fails, you can send it again with the same key. See [Idempotency](#tag/idempotency).
      - **Methods:** a method that a path does not accept returns `405`, also with no token.
      - **Payer identity verification:** `payer_identity_verified` and `fpx_extra_info` are only in the transaction callback. `GET /v3/transactions/{id}` does not have them.
      - **Get a settlement:** `payout_id` is in the path, not in the query.

      ## 29 Oct 2026

      - **Short links:** each endpoint has a short link, for example `#tag/duitnow-qr/create-duitnow-qr`. The old links go to the new links.

      ## 28 Oct 2026

      - **Direct Debit:** `frequency_mode` accepts only `WK` (weekly), `MT` (monthly) and `YR` (yearly). Bayarcash does not offer daily Direct Debit.
      - **API version:** the reference shows version 3.0.0.

      ## 27 Oct 2026

      - **Direct Debit:** Bayarcash does not refund the RM1.00 enrolment debit. A mandate change cannot move to a different bank. The mandate callbacks have `application_type`.
      - **Callbacks:** the retries and the status codes of each callback.
      - **Merchant Registration:** removed from this reference. Bayarcash selects the merchants that can use it.

      ## 21 Aug 2026

      - The first release of this reference for API v3.
webhooks:
  transactionCallback:
    post:
      summary: Transaction callback
      description: |-
        Bayarcash sends this request from its server to your server when a payment has its final status. Set the address with `callback_url` on the payment intent.

        Always check the `checksum` before you use the data. Use the callback as the final result. Do not use the browser redirect for this, because the payer can stop it.

        Your server must return HTTP 200. If it returns a different status, Bayarcash sends the callback again. It tries up to 5 times, 300 seconds (5 minutes) after the last try.

        | `status` | Meaning |
        |---|---|
        | 0 | New |
        | 1 | Pending |
        | 2 | Failed |
        | 3 | Successful |
        | 4 | Cancelled |
        | 5 | Abandoned |
        | 6 | Authorized |
        | 7 | Void |
        | 8 | Refund |
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                record_type:
                  type: string
                  description: Always `transaction`.
                  examples:
                    - transaction
                transaction_id:
                  type: string
                  description: The Bayarcash transaction ID.
                  examples:
                    - trx_9V2LxK
                exchange_reference_number:
                  type: string
                  description: The reference number from the payment network.
                exchange_transaction_id:
                  type: string
                  description: The transaction ID from the payment network.
                order_number:
                  type: string
                  description: The `order_number` that you sent in the request.
                  examples:
                    - ORD-0060
                currency:
                  type: string
                  description: The ISO 4217 currency code.
                  examples:
                    - MYR
                amount:
                  type: string
                  description: The amount, as a decimal string.
                  examples:
                    - "60.00"
                payer_name:
                  type: string
                  description: The name of the payer.
                  examples:
                    - MOHD ALI
                payer_email:
                  type: string
                  description: The email address of the payer.
                  examples:
                    - payer@example.com
                payer_bank_name:
                  type: string
                  description: The bank that the payer used.
                status:
                  type: integer
                  description: "The transaction status code: 0 new, 1 pending, 2 failed, 3 successful, 4 cancelled, 5 abandoned, 6 authorized, 7 void, 8 refund."
                  examples:
                    - 3
                status_description:
                  type: string
                  description: The status as text.
                  examples:
                    - Successful
                datetime:
                  type: string
                  description: The date and time of the event.
                  examples:
                    - 2026-08-21 09:15:00
                checksum:
                  type: string
                  description: The HMAC-SHA256 of the data, made with your API Secret Key. Check it before you use the callback.
              required:
                - record_type
                - transaction_id
                - order_number
                - amount
                - status
                - checksum
      responses:
        "200":
          description: Return 200 to confirm. If Bayarcash gets a different status, it sends the callback again. It tries up to 5 times, 300 seconds (5 minutes) after the last try.
      tags:
        - Transaction
  mandateAuthorizationCallback:
    post:
      summary: Direct Debit - authorization callback
      description: Bayarcash sends this when a payer completes or stops an enrolment, a change or a termination in their online banking. `application_type` tells which one.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                record_type:
                  type: string
                  description: Always `authorization`.
                  examples:
                    - authorization
                mandate_id:
                  type: string
                  description: The mandate ID.
                  examples:
                    - mdt_9V2LxK
                transaction_id:
                  type: string
                  description: The Bayarcash transaction ID.
                  examples:
                    - trx_9V2LxK
                exchange_reference_number:
                  type: string
                  description: The reference number from the payment network.
                exchange_transaction_id:
                  type: string
                  description: The transaction ID from the payment network.
                order_number:
                  type: string
                  description: The `order_number` that you sent in the request.
                  examples:
                    - ORD-0060
                currency:
                  type: string
                  description: The ISO 4217 currency code.
                  examples:
                    - MYR
                amount:
                  type: string
                  description: The amount, as a decimal string.
                  examples:
                    - "60.00"
                payer_name:
                  type: string
                  description: The name of the payer.
                  examples:
                    - MOHD ALI
                payer_email:
                  type: string
                  description: The email address of the payer.
                  examples:
                    - payer@example.com
                payer_bank_name:
                  type: string
                  description: The bank that the payer used.
                status:
                  type: integer
                  description: "The transaction status code: 0 new, 1 pending, 2 failed, 3 successful, 4 cancelled, 5 abandoned, 6 authorized, 7 void, 8 refund."
                  examples:
                    - 3
                status_description:
                  type: string
                  description: The status as text.
                  examples:
                    - Successful
                datetime:
                  type: string
                  description: The date and time of the event.
                  examples:
                    - 2026-08-21 09:15:00
                application_type:
                  type: string
                  description: "The type of mandate application: `01` enrolment, `02` maintenance (a change), `03` termination."
                  examples:
                    - "01"
                checksum:
                  type: string
                  description: The HMAC-SHA256 of the data, made with your API Secret Key. Check it before you use the callback.
              required:
                - record_type
                - mandate_id
                - order_number
                - status
                - checksum
      responses:
        "200":
          description: Return 200 to confirm. If Bayarcash gets a different status, it sends the callback again. It tries up to 5 times, 300 seconds (5 minutes) after the last try.
      tags:
        - Direct Debit
  mandateBankApprovalCallback:
    post:
      summary: Direct Debit - bank approval callback
      description: Bayarcash sends this when the bank of the payer approves or rejects a mandate. This can come some days after the enrolment.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                record_type:
                  type: string
                  description: Always `bank_approval`.
                  examples:
                    - bank_approval
                approval_date:
                  type: string
                  description: The date of the decision of the bank.
                  examples:
                    - 2026-08-21
                approval_status:
                  type: string
                  description: The decision of the bank.
                  examples:
                    - approved
                mandate_id:
                  type: string
                  description: The mandate ID.
                  examples:
                    - mdt_9V2LxK
                mandate_reference_number:
                  type: string
                  description: The reference number of the mandate.
                order_number:
                  type: string
                  description: The `order_number` that you sent in the request.
                  examples:
                    - ORD-0060
                payer_bank_code:
                  type: string
                  description: The bank code of the account of the payer.
                payer_bank_code_hashed:
                  type: string
                  description: The bank code, hashed.
                payer_bank_account_no:
                  type: string
                  description: The bank account number of the payer, partly hidden.
                application_type:
                  type: string
                  description: "The type of mandate application: `01` enrolment, `02` maintenance (a change), `03` termination."
                  examples:
                    - "01"
                checksum:
                  type: string
                  description: The HMAC-SHA256 of the data, made with your API Secret Key. Check it before you use the callback.
              required:
                - record_type
                - mandate_id
                - approval_status
                - checksum
      responses:
        "200":
          description: Return 200 to confirm. If Bayarcash gets a different status, it sends the callback again. It tries up to 5 times, 300 seconds (5 minutes) after the last try.
      tags:
        - Direct Debit
  mandateTransactionCallback:
    post:
      summary: Direct Debit - transaction callback
      description: Bayarcash sends this for each deduction from an active mandate.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                record_type:
                  type: string
                  description: Always `transaction`.
                  examples:
                    - transaction
                batch_number:
                  type: string
                  description: The deduction batch of the transaction.
                mandate_id:
                  type: string
                  description: The mandate ID.
                  examples:
                    - mdt_9V2LxK
                mandate_reference_number:
                  type: string
                  description: The reference number of the mandate.
                transaction_id:
                  type: string
                  description: The Bayarcash transaction ID.
                  examples:
                    - trx_9V2LxK
                exchange_reference_number:
                  type: string
                  description: The reference number from the payment network.
                exchange_transaction_id:
                  type: string
                  description: The transaction ID from the payment network.
                order_number:
                  type: string
                  description: The `order_number` that you sent in the request.
                  examples:
                    - ORD-0060
                currency:
                  type: string
                  description: The ISO 4217 currency code.
                  examples:
                    - MYR
                amount:
                  type: string
                  description: The amount, as a decimal string.
                  examples:
                    - "60.00"
                payer_name:
                  type: string
                  description: The name of the payer.
                  examples:
                    - MOHD ALI
                payer_email:
                  type: string
                  description: The email address of the payer.
                  examples:
                    - payer@example.com
                payer_bank_name:
                  type: string
                  description: The bank that the payer used.
                status:
                  type: integer
                  description: "The transaction status code: 0 new, 1 pending, 2 failed, 3 successful, 4 cancelled, 5 abandoned, 6 authorized, 7 void, 8 refund."
                  examples:
                    - 3
                status_description:
                  type: string
                  description: The status as text.
                  examples:
                    - Successful
                datetime:
                  type: string
                  description: The date and time of the event.
                  examples:
                    - 2026-08-21 09:15:00
                checksum:
                  type: string
                  description: The HMAC-SHA256 of the data, made with your API Secret Key. Check it before you use the callback.
              required:
                - record_type
                - mandate_id
                - amount
                - status
                - checksum
      responses:
        "200":
          description: Return 200 to confirm. If Bayarcash gets a different status, it sends the callback again. It tries up to 5 times, 300 seconds (5 minutes) after the last try.
      tags:
        - Direct Debit
  recurringChargeCallback:
    post:
      summary: Recurring Charge Callback
      description: |-
        The only card recurring webhook. Bayarcash sends it for **each** charge of a subscription, an installment or an on-demand charge, also the first charge of an enrolment. It sends it at **each change** of the charge status.

        - Bayarcash sends it to the `callback_url` of the agreement. For an on-demand charge, it uses the `callback_url` of `POST /v3/payments`.
        - A pending charge comes with `status` `1`. Then it comes again with `3` (successful) or `2` (failed).
        - Bayarcash does not send the same status 2 times.
        - If your server returns a status that is not 2xx, Bayarcash sends the callback again, up to 5 times.

        There is no webhook for a change of the subscription or installment status. See [Notifications](#tag/card-recurring-overview) in the Card Recurring Overview.

        ## Check the checksum

        The body is form-encoded. Form encoding removes each field that has a null value. The checksum signs these fields as empty strings.

        Thus, make the fixed list of fields below, and use `''` for each field that is not in the body. Do not use only the fields that came in the body. Do not change a value that you received. For example, use `amount` exactly as Bayarcash sent it. On a recurring charge, `payer_bank_name` is always null, so it is never in the body.

        ```php
        <?php
        $secretKey = 'xxxxx';  // Your API secret key

        $callbackChecksum = $callbackData['checksum'];

        $payloadData = [
          "record_type" => $callbackData['record_type'] ?? '',
          "transaction_id" => $callbackData['transaction_id'] ?? '',
          "exchange_reference_number" => $callbackData['exchange_reference_number'] ?? '',
          "exchange_transaction_id" => $callbackData['exchange_transaction_id'] ?? '',
          "order_number" => $callbackData['order_number'] ?? '',
          "currency" => $callbackData['currency'] ?? '',
          "amount" => $callbackData['amount'] ?? '',
          "payer_name" => $callbackData['payer_name'] ?? '',
          "payer_email" => $callbackData['payer_email'] ?? '',
          "payer_bank_name" => $callbackData['payer_bank_name'] ?? '',
          "status" => $callbackData['status'] ?? '',
          "status_description" => $callbackData['status_description'] ?? '',
          "datetime" => $callbackData['datetime'] ?? '',
          "charge_source" => $callbackData['charge_source'] ?? '',
          "subscription_id" => $callbackData['subscription_id'] ?? '',
          "installment_id" => $callbackData['installment_id'] ?? '',
          "customer_id" => $callbackData['customer_id'] ?? '',
          "card_brand" => $callbackData['card_brand'] ?? '',
          "card_country" => $callbackData['card_country'] ?? '',
          "card_last4" => $callbackData['card_last4'] ?? '',
          "card_exp_month" => $callbackData['card_exp_month'] ?? '',
          "card_exp_year" => $callbackData['card_exp_year'] ?? '',
        ];

        ksort($payloadData);  // Sort the payload data by key
        $payloadString = implode('|', $payloadData);  // Join the values with '|'

        $validResponse = hash_equals(hash_hmac('sha256', $payloadString, $secretKey), $callbackChecksum);
        ```

        The checksum does not sign `payment_gateway_id` and `payer_telephone_number`. It signs the fields that identify the charge and the card. Thus, nobody can connect a charge to a different subscription or a different card with a valid checksum.
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                record_type:
                  type: string
                  description: Always `recurring_charge`.
                  examples:
                    - recurring_charge
                transaction_id:
                  type: string
                  description: The Bayarcash transaction ID. `GET /v3/transactions/{transaction_id}` accepts it.
                  examples:
                    - trx_9V2LxK
                exchange_reference_number:
                  type: string
                  description: The `BPGR-` reference of the payment exchange for the charge.
                exchange_transaction_id:
                  type: string
                  description: The charge ID of the provider. `GET /v3/payments/{paymentId}` accepts it.
                order_number:
                  type: string
                  description: Your `reference`. For an on-demand charge, the reference of `POST /v3/payments`. For a scheduled charge, the reference of the agreement.
                  examples:
                    - INV-1042
                charge_source:
                  type: string
                  description: "`subscription`, `installment` or `on_demand`."
                  enum:
                    - subscription
                    - installment
                    - on_demand
                subscription_id:
                  type: string
                  description: Only when `charge_source` is `subscription`.
                  examples:
                    - rsub_a1b2c3
                installment_id:
                  type: string
                  description: Only when `charge_source` is `installment`.
                  examples:
                    - rins_a1b2c3
                customer_id:
                  type: string
                  description: The recurring customer. An on-demand charge has a customer, but no agreement.
                  examples:
                    - rcus_a1b2c3
                currency:
                  type: string
                  description: The ISO 4217 currency code.
                  examples:
                    - MYR
                amount:
                  type: string
                  description: The amount, as a decimal string.
                  examples:
                    - "60.00"
                payer_name:
                  type: string
                  description: The name of the payer.
                  examples:
                    - MOHD ALI
                payer_email:
                  type: string
                  description: The email address of the payer.
                  examples:
                    - payer@example.com
                payer_telephone_number:
                  type: string
                  description: The phone number of the payer. The checksum does not sign it.
                payer_bank_name:
                  type: string
                  description: Always null on a recurring charge, so it is not in the body.
                status:
                  type: integer
                  description: "`1` pending, `2` failed, `3` successful."
                  enum:
                    - 1
                    - 2
                    - 3
                  examples:
                    - 3
                status_description:
                  type: string
                  description: The status as text.
                  examples:
                    - Successful
                datetime:
                  type: string
                  description: Kuala Lumpur time as `Y-m-d H:i:s`, with no offset.
                  examples:
                    - 2026-11-09 14:30:00
                payment_gateway_id:
                  type: string
                  description: The checksum does not sign it.
                card_brand:
                  type: string
                  description: The card scheme, as the provider gives it. Not in the body when the provider did not give it.
                  examples:
                    - visa
                card_country:
                  type: string
                  description: The country of the card issuer (ISO 3166-1 alpha-2).
                  examples:
                    - MY
                card_last4:
                  type: string
                  description: The last 4 digits of the card. Bayarcash never sends a token.
                  examples:
                    - "1118"
                card_exp_month:
                  type: string
                  description: The expiry month of the card.
                  examples:
                    - "12"
                card_exp_year:
                  type: string
                  description: The expiry year of the card.
                  examples:
                    - "2030"
                checksum:
                  type: string
                  description: The HMAC-SHA256 of the data, made with your API Secret Key. Check it before you use the callback.
              required:
                - record_type
                - transaction_id
                - order_number
                - charge_source
                - amount
                - status
                - checksum
      responses:
        "200":
          description: Return a 2xx status to confirm. If Bayarcash gets a different status, it sends the callback again, up to 5 times.
      tags:
        - Charges
x-tagGroups:
  - name: Guides
    tags:
      - Getting Started
      - Payment Channels
      - Checksum
      - Idempotency
      - Payer Identity Verification
      - Card Recurring Overview
      - SDKs & Plugins
      - Changelog
  - name: Payments
    tags:
      - Payment Intent
      - DuitNow QR
      - Transaction
      - Banks List
  - name: Recurring
    tags:
      - Direct Debit
  - name: Card Recurring
    tags:
      - Customers
      - Plans
      - Subscriptions
      - Installments
      - Charges
  - name: Merchant
    tags:
      - Merchant Portal
      - Merchant Settlement
  - name: Service
    tags:
      - Health Check
