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

> 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 /billing.openapi.json post /api/payment-methods/account
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/account:
    post:
      tags:
        - customer portal
      summary: Preset payment method by account
      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
                  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
                  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:
      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}
    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
    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 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
        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

````