> ## 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

> Set up 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 /billing.openapi.json post /api/payment-methods
openapi: 3.1.0
info:
  title: Billing
  description: |+

  version: 1.0.0
  summary: ''
servers:
  - url: https://sbx.api.easybilling.cloud/billing
    description: SBX
  - url: https://api.easybilling.cloud/billing
    description: Production-AWS
security:
  - token: []
tags:
  - name: account
  - name: payment method
  - name: contract action
  - name: usage event
  - name: billing document
  - name: invoice pdf
  - name: prepaid credits
  - name: customer portal
paths:
  /api/payment-methods:
    post:
      tags:
        - payment method
      summary: Preset payment method
      description: >-
        Set up 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/StripePaymentMethodPresetRequest'
            examples:
              Stripe:
                value:
                  paymentGatewayType: stripe-connect
                  customerIdentifier: ACC-0000000001
                  redirectUrl: https://example.com/payment/success
                  cancelUrl: https://example.com/payment/cancel
                summary: Stripe Connect request
              PayerMax:
                value:
                  paymentGatewayType: payer-max-isv
                  customerIdentifier: ACC-0000000001
                  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
              example: >-
                https:
                //checkout.stripe.com/c/pay/cs_test_c1h2noxV4xUjSVfLNUkXcW5TlXiQy2TFzA7Hmh2DYHKqe2FSOYtINg9RMw#fidnandhYHdWcXxpYCc%2FJ2FgY2RwaXEnKSdicGRmZGhqaWBTZHdsZGtxJz8nZmprcXdqaScpJ3Zxd2x1YERmZmpwa3EnPydkZmZxWjRWb19vf0NSNUxSR2A1bU4nKSdkdWxOYHwnPyd1blpxYHZxWjA0Vkt0fVQ2U0hHc11DQEdmajRxQG02MERiYkZ0dTM1PEB1RHVMREdkSGZLakE1f05qMlxQNzBVaW5zPWxXc0F1dV1xPUFXT0tkc1xQbDJ1SlY2SE9pYFBXNTV9QmFTdGBBYicpJ2N3amhWYHdzYHcnP3F3cGApJ2dkZm5id2pwa2FGamlqdyc%2FJyZjY2NjY2MnKSdpZHxqcHFRfHVgJz8ndmxrYmlgWmZqaXBoaycpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl
            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:
    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 used to query or create a gateway
            customer. When Billing is used, this is the accountNumber
          examples:
            - ACC-0000000001
        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
    ErrorResponse:
      type: object
      description: Standard billing error envelope.
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
          properties:
            message:
              type: string
              description: Human-readable error message.
            errors:
              type: array
              description: Present only for field-level validation failures.
              items:
                type: object
                properties:
                  field:
                    type: string
                  message:
                    type: string
      examples:
        - error:
            message: Tag does not match pattern [a-z][a-z0-9_.-]{0,63}
  securitySchemes:
    token:
      type: http
      scheme: bearer

````