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

# Preset payment method

> Presets a payment method for a customer on the selected payment gateway and returns
the gateway-hosted setup page URL.

The request body is polymorphic and is selected by paymentGatewayType.




## OpenAPI

````yaml /payment.openapi.json post /api/payment-methods
openapi: 3.1.0
info:
  title: payment hub
  description: |
    Focused OpenAPI 3.1 contract for the **launch-payment** endpoint
    (`POST /api/transactions`). The request body is polymorphic on
    `paymentGatewayType`; each gateway sub-schema documents the gateway-specific
    fields. Highlights:

      * `onlineScenario=true` → customer-initiated, Hosted-Checkout / redirect flow
      * `onlineScenario=false` → merchant-initiated debit using a previously
        stored payment method (only valid on gateways that support offline)
      * `supportOfflineScenario` (Stripe / PayerMax only) — when `true` and
        `onlineScenario=true`, the gateway is instructed to remember the card
        so a future off-session (merchant-initiated) charge can succeed.
  version: 1.0.0
  summary: ''
servers:
  - url: https://sbx.api.easybilling.cloud/payment-hub
    description: SBX
  - url: https://api.easybilling.cloud/payment-hub
    description: Production-AWS
security:
  - token: []
tags:
  - name: Payment Hub
paths:
  /api/payment-methods:
    post:
      tags:
        - Payment Hub
      summary: Preset payment method
      description: >
        Presets a payment method for a customer on the selected payment gateway
        and returns

        the gateway-hosted setup page URL.


        The request body is polymorphic and is selected by paymentGatewayType.
      operationId: presetPaymentMethod
      parameters:
        - name: trace-id
          in: header
          description: ''
          required: true
          example: '{{$string.uuid}}'
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentMethodPresetRequest'
            examples:
              stripe-connect-example:
                value:
                  paymentGatewayType: stripe-connect
                  customerIdentifier: user-12345
                  redirectUrl: https://example.com/payment/success
                  cancelUrl: https://example.com/payment/cancel
                summary: Stripe Connect request
              payer-max-isv-example:
                value:
                  paymentGatewayType: payer-max-isv
                  customerIdentifier: user-12345
                  redirectUrl: https://example.com/payment/success
                summary: PayerMax ISV request
        required: true
      responses:
        '200':
          description: Success; returns the payment method setup page URL
          content:
            application/json:
              schema:
                type: string
                description: Gateway-provided redirect URL to the setup page
            text/plain:
              schema:
                type: string
                description: Gateway-provided redirect URL to the setup page
              examples:
                stripe:
                  summary: Stripe setup URL
                  value: https://checkout.stripe.com/c/pay/cs_test_xxxxxxxxxxxxxx
                payermax:
                  summary: PayerMax setup URL
                  value: https://checkout.payermax.com/setup?token=xxxxxxxxxxxxxx
          headers: {}
        '400':
          description: Request validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missing-customerIdentifier:
                  summary: Missing customer identifier
                  value:
                    message: Customer identifier is required for setup action!
                missing-redirectUrl:
                  summary: Missing redirect URL
                  value:
                    message: Redirect URL is required for setup action!
                stripe-missing-cancelUrl:
                  summary: Missing cancel URL for Stripe
                  value:
                    message: Cancel URL is required for setup action!
                payermax-missing-currency:
                  summary: Missing currency for PayerMax
                  value:
                    message: Currency is required for PayerMax setup action!
          headers: {}
        '500':
          description: Internal server error (for example gateway service not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                gateway-service-not-found:
                  summary: No trade service for gateway type
                  value:
                    message: >-
                      No trade service found in preset payment method process
                      for type: UNKNOWN
          headers: {}
      deprecated: false
      security:
        - token: []
components:
  schemas:
    PaymentMethodPresetRequest:
      description: |
        Polymorphic request payload for presetting a payment method.

        The concrete schema is selected by paymentGatewayType:
        - stripe-connect -> StripePaymentMethodPresetRequest
        - payer-max-isv -> PayerMaxPaymentMethodPresetRequest
      oneOf:
        - $ref: '#/components/schemas/StripePaymentMethodPresetRequest'
        - $ref: '#/components/schemas/PayerMaxPaymentMethodPresetRequest'
      discriminator:
        propertyName: paymentGatewayType
        mapping:
          stripe-connect:
            $ref: '#/components/schemas/StripePaymentMethodPresetRequest'
          payer-max-isv:
            $ref: '#/components/schemas/PayerMaxPaymentMethodPresetRequest'
    ErrorResponse:
      description: Error response returned by global exception handling
      type: object
      properties:
        message:
          type: string
          description: Error message
          examples:
            - Customer identifier is required for setup action!
    StripePaymentMethodPresetRequest:
      description: Preset payment method request for Stripe Connect
      type: object
      required:
        - paymentGatewayType
        - customerIdentifier
        - redirectUrl
        - cancelUrl
      properties:
        paymentGatewayType:
          type: string
          enum:
            - stripe-connect
          description: Gateway type discriminator. Fixed value `stripe-connect`
          examples:
            - stripe-connect
        customerIdentifier:
          type: string
          description: >-
            Unique customer identifier (for example user ID) used to query or
            create a gateway customer
          examples:
            - user-12345
        redirectUrl:
          type: string
          format: uri
          description: Redirect URL after setup is completed
          examples:
            - https://example.com/payment/success
        cancelUrl:
          type: string
          format: uri
          description: |
            Stripe-only required field.
            Redirect URL when the user cancels setup on Stripe.
          examples:
            - https://example.com/payment/cancel
    PayerMaxPaymentMethodPresetRequest:
      description: Preset payment method request for PayerMax ISV
      type: object
      required:
        - paymentGatewayType
        - customerIdentifier
        - redirectUrl
        - currency
      properties:
        paymentGatewayType:
          type: string
          enum:
            - payer-max-isv
          description: Gateway type discriminator. Fixed value `payer-max-isv`
          examples:
            - payer-max-isv
        customerIdentifier:
          type: string
          description: >-
            Unique customer identifier (for example user ID) used to query or
            create a gateway customer
          examples:
            - user-12345
        redirectUrl:
          type: string
          format: uri
          description: Redirect URL after setup is completed
          examples:
            - https://example.com/payment/success
        currency:
          type: string
          description: |
            PayerMax-only required field.
            Currency code (ISO 4217), for example USD, EUR, SGD.
          examples:
            - USD
  securitySchemes:
    token:
      type: http
      scheme: bearer

````