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

# Create Payment Session

> Creates a unique payment session for a specified amount that can be shared with a customer.

### How it works
- The customer uses the payment link to make a payment through the selected payment method.
- Once the payment is successfully completed, the partner receives a webhook notification for the session.
- A single session can contain multiple transactions, where each transaction represents a payment attempt.
- Customers can make multiple payment attempts using different payment methods.

### Transaction details
Use the **Get Session API** to retrieve all transactions associated with a session. The status of each transaction can be retrieved using the **Get Transaction API**.



## OpenAPI

````yaml /api-reference/distributions/distribution.json post /billingSession/v1.0/generateBillingSession
openapi: 3.0.3
info:
  title: Mandate API
  description: API's to add and get mandate information.
  version: 1.0.0
servers:
  - url: https://sandbox-api.transactbridge.com
    description: Sandbox Environment
  - url: https://api.transactbridge.com
    description: Production Environment
security:
  - ApiKeyAuth: []
    SignatureAuth: []
paths:
  /billingSession/v1.0/generateBillingSession:
    post:
      tags:
        - Sessions
      summary: Create Payment Session
      description: >-
        Creates a unique payment session for a specified amount that can be
        shared with a customer.


        ### How it works

        - The customer uses the payment link to make a payment through the
        selected payment method.

        - Once the payment is successfully completed, the partner receives a
        webhook notification for the session.

        - A single session can contain multiple transactions, where each
        transaction represents a payment attempt.

        - Customers can make multiple payment attempts using different payment
        methods.


        ### Transaction details

        Use the **Get Session API** to retrieve all transactions associated with
        a session. The status of each transaction can be retrieved using the
        **Get Transaction API**.
      operationId: createPaymentSession
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePaymentSessionRequest'
      responses:
        '200':
          description: Payment session created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingSession'
components:
  schemas:
    CreatePaymentSessionRequest:
      type: object
      required:
        - quoteCurrCode
        - billTo
        - items
        - returnUrl
      properties:
        email:
          type: string
          description: |-
            Customer's email. Required to send an invoice.
             One of email or clientReferenceId is a mandatory parameter.
        clientReferenceId:
          type: string
          description: >-
            Customer's reference ID that the partner can use to map the customer
            to the TransactBridge panel. If email is not passed in the request
            body, the customer must enter the email on the product checkout
            page.

            One of email or clientReferenceId is a mandatory parameter.
        phoneNo:
          type: string
          description: The customer's Indian phone number in the format of +91-XXXXXXXX
          example: +91-9876543210
        theme:
          type: string
          enum:
            - LIGHT
            - DARK
            - AUTO
          description: Checkout renders accordingly to choosen theme.
        taxIdentity:
          type: string
          description: PAN number of the customer.
        gstIdentity:
          type: string
          description: >-
            If the customer is business type then GST can be used so that the
            business can get input credits.
        customerId:
          type: string
          description: >-
            If the customer is already created, use customerId and then email
            will be optional.
          format: MongoId
        name:
          type: string
          format: AllowedString
          description: Name of the customer.
        quoteCurrCode:
          type: string
          enum:
            - USD
            - EURO
            - INR
          description: Fiat currency for which the request needs to be initiated.
        returnUrl:
          type: string
          description: >-
            This URL is needed to redirect the user after the session is
            completed. The end customer will be redirected to this URL with the
            status of the session.
        pendingUrl:
          type: string
          description: >-
            This URL is needed to redirect the user after the session is in
            CREATED or STARTED status. Mandatory if returnUrl is not passed.
        failedUrl:
          type: string
          description: >-
            URL to redirect the user when the session is in EXPIRED status.
            Manadtory if returnUrl is not passed
        successUrl:
          type: string
          description: >-
            URL to redirect the user when the session is in CLOSED status.
            Manadatory if returnUrl passed
        referenceId:
          type: string
          format: ReferenceId
          description: Reference ID passed by the partner while generating the session.
        userTaxId:
          type: string
          description: >-
            Tax ID created by the partner.This allows us to tax the product
            correctly.
        shipTo:
          type: object
          description: Shipping details of the customer.
          properties:
            name:
              type: string
              description: Name of the customer
            line1:
              type: string
              description: Address Line 1 of the customer
            line2:
              type: string
              description: Address Line 2 of the customer
            city:
              type: string
              description: City of the customer
            state:
              type: string
              description: State of the customer address
            country:
              type: string
              description: Country of the customer.
            postalCode:
              type: string
              description: Pin code of the customer.
        billTo:
          type: object
          description: Billing details of the customer for the invoice.
          required:
            - country
          properties:
            name:
              type: string
              format: AllowedString
              description: Name of the customer.
            line1:
              type: string
              description: Address Line 1 of the customer
            line2:
              type: string
              description: Address Line 2 of the customer
            city:
              type: string
              format: AllowedString
              description: City of the customer.
            state:
              type: string
              description: State of the customer address
            country:
              type: string
              enum:
                - USD
                - EURO
                - INR
              description: Country of the customer.
            postalCode:
              type: string
              description: Pin code of the customer.
        sameAsBilling:
          type: boolean
          description: >-
            Makes the shipping address the same as the billing address. 

            If sameAsBilling the parameter value is set as true then the invoice
            will have the same shipping and billing address.
        payMethod:
          type: array
          items:
            type: string
            enum:
              - UPI
              - NB
              - CC
              - DC
          description: >-
            Payment methods that will be displayed to the customer. If the
            payMethod parameter is sent by the partner then on the payment page
            for the customer only that payment method will be visible to the
            user.
        redirectionType:
          type: string
          enum:
            - SAME_PAGE
            - NEW_PAGE
          default: NEW_PAGE
          description: >-
            Depending on the redirection type value, the user will either be
            redirected to a new page for payment or to the same window of the
            product page.
        items:
          type: array
          description: >-
            Name of the product the customer wants to buy.

            Allowed: alphabets, numerals, spaces, dots, slash, hyphen,
            parentheses, underscore, and colon.
          items:
            type: object
            properties:
              productReferenceId:
                type: string
                format: referenceId
                description: >-
                  If the product is already created, use the referenceId of that
                  product.

                  If productReferenceId is passed then name hsnCode and
                  shippable is not mandatory.
              name:
                type: string
                description: |-
                  Name of the product the customer wants to buy.
                   Allowed: alphabets, numerals, space, dot, slash, hyphen, parenthesis
                format: AllowedString
              quantity:
                type: number
                description: Number of products the customer wants to buy.
              amount:
                type: number
                description: Price of the product.
              description:
                type: string
                description: >-
                  Description of the product.

                  Description in the items object allows HTML syntax for
                  customer view. Use so that the description on the product page
                  is better from a UI perspective. We break and show the
                  description like unlisted items.
                format: MultiLineDescription
              hsnCode:
                type: string
                description: If the product is physical, HSN code is mandatory.
              shippable:
                type: boolean
                default: false
                description: If the product is physical, pass this parameter as true.
              attributes:
                type: array
                description: To send top-up details
                items:
                  type: object
                  required:
                    - orderId
                    - userId
                    - clientId
                  properties:
                    orderId:
                      type: string
                      description: >-
                        The validation API returns the orderId, which needs to
                        be used here.
                    userId:
                      type: string
                      description: >-
                        The customer's ID on the merchant's platform where the
                        top-up needs to be credited.
                    clientId:
                      type: string
                      description: >-
                        The validation API returns the clientId, which needs to
                        be used here.
            required:
              - name
              - quantity
              - amount
              - attributes
        discount:
          type: object
          description: This parameter can be used to reduce the total cart pay amount.
          properties:
            name:
              type: string
              description: >-
                This will be shown on the checkout page as the description of
                the discount being applied.
            quoteAmountOff:
              type: number
              description: Discount value that is being applied on the cart value.
          required:
            - quoteAmountOff
        expiryDate:
          type: string
          format: date-time
          description: >
            The UTC date at which the session link will expire. If this is not
            passed by the partner, then the link will expire after 24 hours.
            This is the expiry of the link if a customer attempts the payment at
            the last minute, then the link will not expire until all the payment
            attempts transactions are not in the terminal state.


            **Note**: Minimum 10 minutes in the future will be accepted as a
            valid expiryDate from the time of session creation.
        invoice:
          type: object
          description: Invoice configuration for the product sold in this billing session.
          properties:
            issueDate:
              type: string
              format: date
              description: Issue date of the invoice.
            dueDate:
              type: string
              format: date
              description: Due date of the invoice.
        serviceStart:
          type: string
          format: date
          description: >-
            If the product is for a specific period, then the invoice created
            for the customer will have this parameter.
        serviceEnd:
          type: string
          format: date
          description: >-
            If the product is for a specific period, then the invoice created
            for the customer will have this parameter.
        meta:
          type: object
          description: >-
            To add meta params in the session. They will be passed in the
            webhook and query API as well.
          properties:
            param1:
              type: string
              maxLength: 256
              description: String with max length of 256 characters.
            param2:
              type: string
              maxLength: 256
              description: String with max length of 256 characters.
            param3:
              type: string
              maxLength: 256
              description: String with max length of 256 characters.
        referrerUrl:
          type: string
          format: uri
          description: >-
            To add the checkout original URL from which customer got redirected
            to Transact Bridge checkout page
        enableMandatoryPopup:
          type: boolean
          description: >-
            If this is set to be true then the customer on the checkout page
            will be first shown to add the remaining mandatory inputs like name,
            etc.
    BillingSession:
      type: object
      properties:
        status:
          type: string
          description: The response from the API
        sub_status:
          type: string
          description: Used for internal purposes only
        data:
          type: object
          description: Contains the session ID and URL
          properties:
            sessionId:
              type: string
              description: The unique ID of the created session
            url:
              type: string
              format: uri
              description: The URL used to access the checkout session.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: Merchant API Key
    SignatureAuth:
      type: apiKey
      in: header
      name: x-signature
      description: Generated request signature

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.