> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bnplx.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Payments - Cancel

> A Payment could can be cancelled when it is in one of these statuses: `requires_payment_method`, `requires_capture`, `requires_confirmation`, `requires_customer_action`.



## OpenAPI

````yaml openapi_spec post /payments/{payment_id}/cancel
openapi: 3.0.3
info:
  title: GreenBanana - API Documentation
  description: >

    ## Get started


    GreenBanana provides a collection of APIs that enable you to process and
    manage payments.

    Our APIs accept and return JSON in the HTTP body, and return standard HTTP
    response codes.


    You can consume the APIs directly using your favorite HTTP/REST library.


    We have a testing environment referred to "sandbox", which you can setup to
    test API calls without

    affecting production data.

    Currently, our sandbox environment is live while our production environment
    is under development

    and will be available soon.

    You can sign up on our Dashboard to get API keys to access GreenBanana API.


    ### Environment


    Use the following base URLs when making requests to the APIs:


    | Environment   |  Base URL                          |

    |---------------|------------------------------------|

    | Sandbox       | <https://api.staging.bnplx.io>   |

    | Production    | <https://api.bnplx.io>       |


    ## Authentication


    When you sign up on our [dashboard](https://app.bnplx.io) and create a
    merchant

    account, you are given a secret key (also referred as api-key) and a
    publishable key.

    You may authenticate all API requests with GreenBanana server by providing
    the appropriate key in

    the request Authorization header.


    | Key             | 
    Description                                                                                 
    |

    |-----------------|-----------------------------------------------------------------------------------------------|

    | api-key         | Private key. Used to authenticate all API requests from
    your merchant server                  |

    | publishable key | Unique identifier for your account. Used to authenticate
    API requests from your app's client  |


    Never share your secret api keys. Keep them guarded and secure.
  contact:
    name: GreenBanana Support
    url: https://api.staging.bnplx.io
    email: support@greenbanana.group
  license:
    name: Apache-2.0
  version: 0.1.0
servers:
  - url: https://api.staging.bnplx.io
    description: Sandbox Environment
security: []
tags:
  - name: Guide
    description: Follow this guide to do your first BNPL payment with GreenBanana
  - name: Merchant Account
    description: Create and manage merchant accounts
  - name: Profile
    description: Create and manage profiles
  - name: Merchant Connector Account
    description: Create and manage merchant connector accounts
  - name: Payments
    description: Create and manage one-time payments, recurring payments and mandates
  - name: Refunds
    description: Create and manage refunds for successful payments
  - name: Mandates
    description: Manage mandates
  - name: Customers
    description: Create and manage customers
  - name: Payment Methods
    description: Create and manage payment methods of customers
  - name: Products
    description: Create and manage products in the merchant catalog
  - name: Disputes
    description: Manage disputes
  - name: API Key
    description: Create and manage API Keys
  - name: payment link
    description: Create payment link
  - name: Routing
    description: Create and manage routing configurations
  - name: Event
    description: Manage events
paths:
  /payments/{payment_id}/cancel:
    post:
      tags:
        - Guide
      summary: Payments - Cancel
      description: >-
        A Payment could can be cancelled when it is in one of these statuses:
        `requires_payment_method`, `requires_capture`, `requires_confirmation`,
        `requires_customer_action`.
      operationId: Cancel a Payment
      parameters:
        - name: payment_id
          in: path
          description: The identifier for payment
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentsCancelRequest'
            examples:
              Cancel partial amount:
                value:
                  amount_to_cancel: 5125
                  cancellation_reason: requested_by_customer
                  order_details:
                    - amount: 5000
                      product_id: i124
                      product_name: Apple airpods
                      quantity: 1
                      tax_amount: 125
                      tax_percentage: 10
              Cancel the full amount:
                value:
                  amount_to_cancel: 10250
                  cancellation_reason: consumer_request
                  order_details:
                    - amount: 5000
                      product_id: i124
                      product_name: Apple airpods
                      quantity: 1
                      tax_amount: 125
                      tax_percentage: 10
                    - amount: 5000
                      product_id: i124
                      product_name: Apple airpods
                      quantity: 1
                      tax_amount: 125
                      tax_percentage: 10
              Cancel the payment with cancellation reason:
                value:
                  cancellation_reason: requested_by_customer
        required: true
      responses:
        '200':
          description: Payment canceled
        '400':
          description: Missing mandatory fields
      security:
        - api_key: []
components:
  schemas:
    PaymentsCancelRequest:
      type: object
      properties:
        amount_to_cancel:
          allOf:
            - $ref: '#/components/schemas/MinorUnit'
          nullable: true
        cancellation_reason:
          type: string
          description: The reason for the payment cancel
          nullable: true
        merchant_connector_details:
          allOf:
            - $ref: '#/components/schemas/MerchantConnectorDetailsWrap'
          nullable: true
        order_details:
          type: array
          items:
            $ref: '#/components/schemas/OrderDetailsWithAmount'
          description: >-
            Use this object to capture the details about the different products
            for which the payment is being made. The sum of amount across
            different products here should be equal to the overall payment
            amount
          example: |-
            [{
                    "product_name": "Apple iPhone 16",
                    "quantity": 1,
                    "amount" : 69000
                    "product_img_link" : "https://dummy-img-link.com"
                }]
          nullable: true
    MinorUnit:
      type: integer
      format: int64
      description: This Unit struct represents MinorUnit in which core amount works
    MerchantConnectorDetailsWrap:
      type: object
      description: Merchant connector details used to make payments.
      required:
        - creds_identifier
      properties:
        creds_identifier:
          type: string
          description: >-
            Creds Identifier is to uniquely identify the credentials. Do not
            send any sensitive info, like encoded_data in this field. And do not
            send the string "null".
        encoded_data:
          allOf:
            - $ref: '#/components/schemas/MerchantConnectorDetails'
          nullable: true
    OrderDetailsWithAmount:
      type: object
      required:
        - product_name
        - quantity
        - amount
      properties:
        product_name:
          type: string
          description: Name of the product that is being purchased
          example: shirt
          maxLength: 255
        quantity:
          type: integer
          format: int32
          description: The quantity of the product to be purchased
          example: 1
          minimum: 0
        amount:
          type: integer
          format: int64
          description: >-
            the amount per quantity of product, this is the amount before tax is
            added to it
        requires_shipping:
          type: boolean
          nullable: true
        product_img_link:
          type: string
          description: The image URL of the product
          nullable: true
        product_link:
          type: string
          description: The URL of the product
          nullable: true
        product_id:
          type: string
          description: ID of the product that is being purchased
          nullable: true
        category:
          allOf:
            - $ref: '#/components/schemas/ProductCategory'
          nullable: true
        sub_category:
          type: string
          description: Sub category of the product that is being purchased
          nullable: true
        brand:
          type: string
          description: Brand of the product that is being purchased
          nullable: true
        product_type:
          allOf:
            - $ref: '#/components/schemas/ProductType'
          nullable: true
        tax_percentage:
          type: integer
          format: int32
          description: Tax of the product in percentage
          nullable: true
        product_tax_code:
          type: string
          description: The tax code for the product
          nullable: true
        tax_amount:
          allOf:
            - $ref: '#/components/schemas/MinorUnit'
          nullable: true
    MerchantConnectorDetails:
      type: object
      properties:
        connector_account_details:
          type: object
          description: >-
            Account details of the Connector. You can specify up to 50 keys,
            with key names up to 40 characters long and values up to 500
            characters long. Useful for storing additional, structured
            information on an object.
          nullable: true
        metadata:
          type: object
          description: >-
            Metadata is useful for storing additional, unstructured information
            on an object.
          nullable: true
    ProductCategory:
      type: string
      enum:
        - regular
        - shipping_costs
        - gift_card
        - discount
        - voucher
        - return_costs
    ProductType:
      type: string
      enum:
        - physical
        - digital
        - travel
        - ride
        - event
        - accommodation
        - variable
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: api-key
      description: >-
        Use the API key created under your merchant account from the GreenBanana
        dashboard. API key is used to authenticate API requests from your
        merchant server only. Don't expose this key on a website or embed it in
        a mobile application.

````