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

# Hosted Session Checkout

> Payment gateway hosted session checkout.

The following input parameters are expected to be provided by the merchant to initiate a hosted checkout session. Unlike [Direct Integration](/api-reference/direct-integration-api-request-payment), this endpoint does not take a `channelId` — the customer selects their own payment method on CommercePay's hosted payment page.



## OpenAPI

````yaml /openapi.json post /api/services/app/PaymentGateway/InitialSession
openapi: 3.0.1
info:
  title: CommercePay API
  version: v1
  description: >
    ---

    **Credentials Accounts**


    Every account is provided with separate keys for testing and for running
    live transactions. Once the merchant application has been approved,
    developers can begin the process of integrating the CommercePay API. The
    following details will be provided to get started with the integration. 


    <a href="https://docs.commercepay.asia/docs/api/d19b0f3289ae0-get-started"
    target="_blank">Get Started</a>
  contact: {}
servers:
  - description: Staging
    url: https://staging-payments.commerce.asia
  - url: https://payments.commerce.asia
    description: Production
security: []
paths:
  /api/services/app/PaymentGateway/InitialSession:
    post:
      tags:
        - PaymentGateway
      summary: Hosted Session Checkout
      description: "Payment gateway hosted session checkout.\r\n\r\nThe following input parameters are expected to be provided by the merchant to initiate a hosted checkout session. Unlike [Direct Integration](/api-reference/direct-integration-api-request-payment), this endpoint does not take a `channelId` — the customer selects their own payment method on CommercePay's hosted payment page."
      operationId: post-api-services-app-PaymentGateway-InitialSession
      parameters:
        - $ref: '#/components/parameters/AbpTenantId'
        - $ref: '#/components/parameters/Authorization'
        - $ref: '#/components/parameters/CapSignature'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentSessionInputDto'
            examples: {}
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentSessionOutputDto'
              examples:
                Example 1:
                  value:
                    redirectionType: 1
                    redirectUrl: string
                    sessionNumber: string
        '400':
          description: "Bad Request: \r\nInvalid Timestamp.\r\nInvalid Signature."
components:
  parameters:
    AbpTenantId:
      schema:
        type: string
      in: header
      name: Abp-TenantId
      required: true
      description: Your unique Merchant ID assigned by CommercePay.
    Authorization:
      schema:
        type: string
      in: header
      name: Authorization
      required: true
      description: Your API credentials used for authentication (typically a Bearer token).
    CapSignature:
      schema:
        type: string
      in: header
      name: cap-signature
      required: true
      description: >-
        A unique security hash used to verify the integrity of the request body.
        See [Generate Signature](/docs/generate-signature) for how to generate
        this.
  schemas:
    PaymentSessionInputDto:
      title: PaymentSessionInputDto
      type: object
      x-examples:
        Example 1:
          currencyCode: MYR
          amount: 100
          referenceCode: string
          description: Order details
          ipAddress: string
          userAgent: string
          returnUrl: https://returnurl.com/
          callbackUrl: https://callback.com/
          Customer:
            email: email@gmail.com
            mobileNo: '0123456789'
            name: name
            username: username
            identificationNumber: string
            identificationType: 1
          SubMerchant:
            uniqueId: string
            name: string
          PlatformCharge:
            partnerId: string
            amount: 0
          virtualAccountCode: string
          RequestPaymentExtraInfo:
            channelGroupId: 0
            hiddenChannel:
              - 0
          expiredInMinutes: 15
          tenantId: 0
          timestamp: 1621851652617
      required:
        - currencyCode
        - amount
        - referenceCode
        - ipAddress
        - returnUrl
        - timestamp
      properties:
        currencyCode:
          type: string
          description: Currency code with a 3-letter ISO 4217 standard code
          maxLength: 3
          example: MYR
        amount:
          type: integer
          format: int64
          description: "Please take note: The Amount parameter only accepts integer units. For example, 1000 is equivalent to 10.00 for the backend.\r\n\r\nInvalid Format: 1,000.00"
          example: 100
        referenceCode:
          type: string
          description: Merchant Reference Code
          maxLength: 50
        description:
          type: string
          description: Transaction Description
          example: Order details
          maxLength: 100
          nullable: true
        ipAddress:
          type: string
          description: Customer’s IP address captured by the merchant system
          maxLength: 50
        userAgent:
          type: string
          description: >-
            **[Conditional]** Customer’s user agent. It is recommended to input
            for a better user experience for specific channels due to different
            platforms such as desktop, mobile, or app view. Example channels
            impact: ShopeePay
          maxLength: 200
          nullable: true
        returnUrl:
          type: string
          description: >-
            Return URL supplied by the merchant server for the payment response
            and used by CommercePay to redirect the customer's browser back to
            the desired page on the Merchant’s site
          example: https://returnurl.com/
          maxLength: 500
        callbackUrl:
          type: string
          example: https://callback.com/
          maxLength: 500
          description: >-
            Callback URL is host-to-host communication. CommercePay sends the
            transaction response to the merchant callback server based on the
            callback URL given. If the URL is provided, the callback will be
            triggered; otherwise, it would not trigger. Refer to the Merchant
            Callback URL to know more
          nullable: true
        Customer:
          $ref: '#/components/schemas/UserInfoDto'
        SubMerchant:
          $ref: '#/components/schemas/SubMerchant'
        PlatformCharge:
          $ref: '#/components/schemas/PlatformChargeDto'
        virtualAccountCode:
          type: string
          maxLength: 30
          description: Code to identify virtual account to make payment.
          nullable: true
        RequestPaymentExtraInfo:
          $ref: '#/components/schemas/RequestPaymentExtraInfo'
        expiredInMinutes:
          type: integer
          description: Set the session expired in minutes
          example: 30
          nullable: true
        tenantId:
          type: integer
          description: Fill in tenant id
          nullable: true
        timestamp:
          type: integer
          format: int64
          description: new Date().getTime()
          example: 1621851652617
    PaymentSessionOutputDto:
      title: PaymentSessionOutputDto
      type: object
      properties:
        redirectionType:
          $ref: '#/components/schemas/RedirectionType'
        redirectUrl:
          type: string
          description: URL used for the customer to redirect to the payment page
          nullable: true
        sessionNumber:
          type: string
          description: Unique CAP Session Number
          nullable: true
    UserInfoDto:
      type: object
      additionalProperties: false
      properties:
        email:
          type: string
          description: Customer’s Email Address
          example: email@gmail.com
          maxLength: 150
          nullable: true
        mobileNo:
          type: string
          description: Customer’s Mobile Number
          example: '0123456789'
          maxLength: 16
          nullable: true
        name:
          type: string
          description: Customer’s Name
          example: name
          maxLength: 36
          nullable: true
        username:
          type: string
          description: Customer’s unique ID for recurring payments or next saved payments
          example: username
          maxLength: 36
          nullable: true
        identificationNumber:
          type: string
          description: '**[Conditional for FPX Recurring]**'
          nullable: true
        identificationType:
          $ref: '#/components/schemas/IdentificationType'
    SubMerchant:
      type: object
      properties:
        uniqueId:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
      additionalProperties: false
    PlatformChargeDto:
      type: object
      additionalProperties: false
      description: >-
        Optional: Only Authorized Partners by CommercePay are allowed to charge
        platform fees to the merchant
      properties:
        partnerId:
          type: string
          description: Unique Id to identify authorized partner.
          nullable: true
        amount:
          type: integer
          format: int64
          description: Platform charge amount.
          nullable: true
    RequestPaymentExtraInfo:
      type: object
      description: '[Optional]'
      properties:
        ChannelGroupId:
          type: integer
          description: >-
            Optional: Used for displaying selected channel groups on CommercePay
            hosted payment web
          format: int32
          nullable: true
        HiddenChannel:
          type: array
          description: 'Optional: To hide channels on CommercePay hosted payment web'
          deprecated: true
          nullable: true
          items:
            type: integer
            format: int32
            default: 0
        WhitelistChannelGroup:
          type: array
          description: >-
            Optional: Specific channel group channel display on the CommercePay
            hosted payment page.
          nullable: true
          items:
            type: integer
            format: int32
        WhitelistChannel:
          type: array
          description: >-
            Optional: Specific channel display on the CommercePay hosted payment
            page.
          nullable: true
          items:
            type: integer
            format: int32
    RedirectionType:
      enum:
        - 1
        - 2
      type: integer
      format: int32
      x-enumNames:
        - UrlRedirection
        - RenderScriptRedirection
      description: |
        Notes: 1 = UrlRedirection
    IdentificationType:
      enum:
        - 1
        - 2
        - 3
        - 4
        - 5
      type: integer
      x-enumNames:
        - NewIdentityNumber
        - OldIdentityNumber
        - PassportNumber
        - BusinessRegistration
        - Others
      x-examples: {}
      description: >-
        **[Conditional for FPX Recurring]**


        New Identity Number = 1, Old Identity Number = 2, Passport Number = 3,
        Business Registration = 4, Others = 5

````