> ## Documentation Index
> Fetch the complete documentation index at: https://telnesstech-a0a16404.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create payment session

> Create a new payment session to collect payment information for an order. For orders with a positive total, this initiates payment collection. For zero-total orders, consider creating a payment profile session instead.



## OpenAPI

````yaml /api-reference/bundled_openapi.json post /payment-sessions
openapi: 3.1.0
info:
  title: Telness Tech Connect
  version: 2.0.0-alpha
  description: >
    Telness Tech Connect API provides all you need to own your user's
    connectivity experience.


    Go back to [Telnesstech.com](https://telnesstech.com)
servers:
  - url: https://apiv2.example.com
    description: Connect API URL for your domain
security:
  - apiKey: []
  - bearerAuth: []
    apiKey: []
tags:
  - name: Auth
    description: Authenticate users and obtain access tokens.
  - name: Users
    description: Manage users.
  - name: Customers
    description: Manage customers.
  - name: Subscriptions
    description: Manage subscriptions and subscription.
  - name: Subscription Addons
    description: Manage subscription addons.
  - name: Subscription Usage
    description: Get subscription usage.
  - name: Subscribers
    description: Manage subscribers.
  - name: Licenses
    description: Manage licenses.
  - name: Product Offerings
    description: Browse product offerings.
  - name: Product Catalogs
    description: Browse product catalogs.
  - name: Product Discounts
    description: Discounts and promotions.
  - name: Orders
    description: Manage orders and line items.
  - name: Payment Intents
    description: >-
      Inspect payment intents, the money collected over card rails for orders
      and renewals.
  - name: Payment Links
    description: Create and manage payment links for orders and invoices.
  - name: Payment Sessions
    description: Create and manage payment sessions for orders.
  - name: Payment Profiles
    description: Manage customer payment profiles and methods.
  - name: Payment Profile Sessions
    description: Create sessions for setting up payment profiles.
  - name: Signing sessions
    description: Handle contract signing sessions for postpaid orders.
  - name: Porting
    description: Manage number porting for subscriptions.
  - name: Taxes
    description: Calculate taxes for products and line items.
  - name: Invoices
    description: Manage invoices and invoice items.
  - name: Tools
    description: >-
      Tools for address validation, number porting, device info, and network
      coverage.
  - name: Inventory
    description: Manage phone number inventory, SIM cards, and reservations.
  - name: Workflows
    description: Dynamic processing of customer journeys and events.
paths:
  /payment-sessions:
    post:
      tags:
        - Payment Sessions
      summary: Create payment session
      description: >-
        Create a new payment session to collect payment information for an
        order. For orders with a positive total, this initiates payment
        collection. For zero-total orders, consider creating a payment profile
        session instead.
      operationId: createPaymentSession
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePaymentSessionRequest'
      responses:
        '201':
          description: Payment session created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentSession'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '412':
          $ref: '#/components/responses/PreconditionFailed'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    IdempotencyKey:
      in: header
      name: X-Idempotency-Key
      required: false
      description: >
        A unique key to ensure idempotency of requests. If a request with the
        same key has already been processed, the same result will be returned.

        The key must be unique for each distinct operation. Keys are expired
        after 24 hours, but we recommend using a new key for each request.


        Modified requests with the same idempotency keys are rejected with a
        `409 Conflict` status code.
      schema:
        type: string
        maxLength: 256
  schemas:
    CreatePaymentSessionRequest:
      type: object
      description: >-
        Request to create a new payment session for processing payment for an
        order.
      required:
        - orderId
        - paymentProvider
      additionalProperties: false
      properties:
        orderId:
          type: string
          description: The unique identifier of the order to create a payment session for.
          example: d4e5f6a7-b8c9-0123-4567-89abcdef0123
        paymentProvider:
          $ref: '#/components/schemas/PaymentProvider'
        paymentProfileId:
          type: string
          description: >-
            You can add the previously saved payment method to prefill in the
            payment details.
          example: e5f6a7b8-c9d0-1234-5678-9abcdef01234
        savePaymentProfile:
          type: boolean
          description: >-
            Whether to save the payment profile for future use. Only applicable
            if the customer is authenticated or for the initial order. Defaults
            to false.
          example: true
        setAsDefaultPaymentProfile:
          type: boolean
          description: >
            Whether to set the payment method as the default for future
            payments. Only applicable if savePaymentProfile is true and the
            customer is authenticated or for the initial order. Defaults to
            false.
        hosted:
          type: boolean
          description: >-
            Whether to create a hosted checkout session. When true, a hosted
            payment page URL is returned for redirecting the customer. When
            false (default), a payment intent is created for rendering an
            embedded payment widget.
          example: false
        returnUrl:
          type: string
          description: >-
            The URL to redirect the customer to after payment is completed.
            Required when hosted is true.
          example: https://example.com/order/confirmation
        cancelUrl:
          type: string
          description: >-
            The URL to redirect the customer to if they cancel the payment. Only
            used when hosted is true.
          example: https://example.com/order/checkout
        metadata:
          $ref: '#/components/schemas/Metadata'
    PaymentSession:
      type: object
      description: >-
        A payment session that wraps the payment process and collects payment
        information from the user for a specific order.
      required:
        - paymentSessionId
        - orderId
        - paymentProvider
        - savePaymentProfile
        - hostedUrl
        - status
        - metadata
        - createdAt
        - updatedAt
      additionalProperties: false
      properties:
        paymentSessionId:
          type: string
          description: The unique identifier for this payment session.
          example: d2e3f4a5-b6c7-8901-2345-012345678901
        orderId:
          type: string
          description: The unique identifier of the order this payment session is for.
          example: e3f4a5b6-c7d8-9012-3456-123456789012
        paymentProvider:
          $ref: '#/components/schemas/PaymentProvider'
        paymentProfileId:
          type: string
          description: >-
            The saved payment method to use for this payment (for returning
            customers).
          example: f4a5b6c7-d8e9-0123-4567-234567890123
        savePaymentProfile:
          type: boolean
          description: >-
            Whether to save the payment profile for future use. Only applicable
            if the customer is authenticated or for the initial order. Defaults
            to false.
          example: true
        hostedUrl:
          type: string
          format: uri
          description: >-
            The hosted checkout page to redirect the customer to in order to
            complete payment.
          example: >-
            https://payments.example.com/checkout/d2e3f4a5-b6c7-8901-2345-012345678901
        returnUrl:
          type: string
          description: The URL the customer is redirected to after payment completion.
          example: https://example.com/order/confirmation
        cancelUrl:
          type: string
          description: The URL the customer is redirected to if they cancel the payment.
          example: https://example.com/order/checkout
        status:
          $ref: '#/components/schemas/PaymentSessionStatus'
        metadata:
          type: object
          additionalProperties:
            type: string
          description: Custom key-value pairs for additional payment session information.
          example:
            source: mobile_app
            campaign: summer_2024
        createdAt:
          type: string
          format: date-time
          description: When this payment session was created.
          example: '2024-09-29T10:00:00Z'
        updatedAt:
          type: string
          format: date-time
          description: When this payment session was last updated.
          example: '2024-09-29T10:30:00Z'
    PaymentProvider:
      type: string
      description: Payment service provider that processes the transaction.
      enum:
        - STRIPE
        - BILLOGRAM
      example: STRIPE
    Metadata:
      type: object
      additionalProperties:
        type: string
      description: >
        A set of key-value pairs that can be attached to an object for storing
        additional information in a semi-structured format.
    PaymentSessionStatus:
      type: string
      description: Current status of a payment session lifecycle.
      enum:
        - PENDING
        - REQUIRES_ACTION
        - COMPLETED
        - FAILED
        - CANCELED
        - EXPIRED
      example: PENDING
    Error:
      type: object
      required:
        - message
        - code
      properties:
        message:
          type: string
          description: A human-readable message providing more details about the error.
        code:
          type: string
          description: A machine-readable code for the error.
        details:
          type: array
          description: Additional details about the error.
          items:
            type: object
            required:
              - message
              - code
            properties:
              message:
                type: string
                description: >-
                  A human-readable message providing more details about the
                  error.
              code:
                type: string
                description: A machine-readable code for the specific detail.
              property:
                type: string
                description: The property or field related to the error.
              suggestion:
                $ref: '#/components/schemas/Any'
                description: >
                  A suggested value for the particular property.


                  For example, this may be set when validating an address with
                  an alias, suggesting the expected value by the operator.
        hint:
          type: string
          description: A hint to help resolve the error.
    Any:
      oneOf:
        - type: string
        - type: number
        - type: boolean
        - type: object
          additionalProperties: true
        - type: array
  responses:
    BadRequest:
      description: The request was malformed or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Authentication is required to access this resource.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Access to this resource is forbidden.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The requested resource was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Conflict:
      description: Conflict
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PreconditionFailed:
      description: Precondition Failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: An unexpected error occurred on the server.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-Api-Key
      description: >
        An API key that grants access to the Connect API. You can create and
        manage API keys in the portal.
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Bearer authentication with JWT tokens is used to authenticate users.


        Do note that a valid API keys is also required to access the Connect API
        to prove that requests are made by a trusted party.


        Requests with a JWT token is scoped to the permissions of the user the
        token belongs to, regardless of the API key used.

````

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