openapi: 3.0.0
info:
  title: Payment Method Session
  description: A payment method session is a temporary, secure session created to collect and store a customer's payment method. It doesn't initiate a charge but ensures the payment method is tokenized and safely linked to the customer's profile.
  contact: {}
  version: 1.0.0
servers:
  - url: https://payments.zoho.com/api/v1
    description: API Endpoint
tags:
  - name: payment-method-session
    description: Payment Method Sessions Module
paths:
  /paymentmethodsessions:
    post:
      tags:
        - payment-method-session
      summary: Create Payment Method Session
      description: ' This API endpoint allows you to create a payment method session for a customer to collect their payment method details securely.'
      parameters:
        - $ref: '#/components/parameters/account_id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/payment-method-session-create-request'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/payment-method-session-create-response'
      deprecated: false
      security:
        - Zoho_Auth:
            - ZohoPay.paymentmethods.CREATE
  /paymentmethodsessions/{payment_method_session_id}:
    get:
      tags:
        - payment-method-session
      summary: Retrieve Payment Method Session
      description: This API endpoint allows you to retrieve the details of a specific payment method session.
      parameters:
        - name: payment_method_session_id
          description: A unique identifier for the payment method session.
          in: path
          required: true
          schema:
            type: number
            format: long
          example: 731000001449003
        - $ref: '#/components/parameters/account_id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/payment-method-session-retrieve-response'
      deprecated: false
      security:
        - Zoho_Auth:
            - ZohoPay.paymentmethods.READ
components:
  parameters:
    account_id:
      name: account_id
      description: The Zoho Payments account ID.
      in: query
      required: true
      schema:
        type: number
        format: long
      example: 23137556
  schemas:
    gendoc-attributes-schema:
      $ref: '#/components/schemas/payment-method-session-response'
    payment-method-session-response:
      type: object
      properties:
        payment_method_session_id:
          $ref: '#/components/schemas/payment_method_session_id'
        customer_id:
          $ref: '#/components/schemas/customer_id'
        description:
          $ref: '#/components/schemas/description'
        created_time:
          $ref: '#/components/schemas/created_time'
    payment_method_session_id:
      description: A unique identifier for the payment method session.
      type: string
      example: '1987000000724209'
    customer_id:
      description: A unique identifier for the customer.
      type: string
      example: '1987000000724207'
    description:
      description: Description of the payment method session.
      type: string
      example: Payment method session for customer 1987000000724207
    created_time:
      description: The timestamp (milliseconds) indicating when the payment method session was created.
      type: integer
      format: int64
      example: 1708950672
    status:
      description: Payment Method Session status is either <code>failed</code>, <code>created</code>, <code>in_progress</code>, and <code>succeeded</code>.
      type: string
      example: succeeded
    payment_method:
      description: Payment method is either <code>card</code> or <code>ach_debit</code>.
      type: object
      properties:
        payment_method_id:
          description: A unique identifier for the payment method.
          type: string
          example: '1987000000724215'
        type:
          description: The type of payment method. This can be <code>card</code> or <code>ach_debit</code>.
          type: string
          example: card
        status:
          description: The status of the payment method.
          type: string
          example: active
        created_time:
          $ref: '#/components/schemas/created_time'
    payment-method-session-create-request:
      required:
        - customer_id
      type: object
      properties:
        customer_id:
          $ref: '#/components/schemas/customer_id'
        description:
          $ref: '#/components/schemas/description'
    payment-method-session-create-response:
      type: object
      properties:
        code:
          type: integer
          example: 0
          readOnly: true
        message:
          type: string
          example: success
          readOnly: true
        payment_method_session:
          $ref: '#/components/schemas/payment-method-session-response'
    payment-method-session-retrieve-response:
      type: object
      properties:
        code:
          type: integer
          example: 0
          readOnly: true
        message:
          type: string
          example: success
          readOnly: true
        payment_method_session:
          type: object
          properties:
            payment_method_session_id:
              $ref: '#/components/schemas/payment_method_session_id'
            customer_id:
              $ref: '#/components/schemas/customer_id'
            status:
              $ref: '#/components/schemas/status'
            payment_method:
              $ref: '#/components/schemas/payment_method'
  securitySchemes:
    Zoho_Auth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://accounts.zoho.com/oauth/v2/auth
          scopes:
            ZohoPay.paymentmethods.READ: Fetch Payment Method Session
            ZohoPay.paymentmethods.CREATE: Update Payment Method Session
