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

# Set default payment method

> Set the default payment method for a customer

<sup>Required permissions: `payment-method:write`, `customer:payment-method:change`</sup>



## OpenAPI

````yaml put /customers/{customerId}/payment-method
openapi: 3.1.0
info:
  title: Fynn API
  description: ''
  termsOfService: https://www.fynn.eu/tos
  contact:
    name: Fynn UG (haftungsbeschränkt)
    url: https://www.fynn.eu
    email: hi@fynn.eu
  license:
    name: Proprietary
    url: https://www.fynn.eu/license
  version: 0.0.0
servers:
  - url: https://coreapi.io
    description: Production
  - url: https://preview.coreapi.io
    description: Sandbox
security:
  - JWT: []
tags: []
paths:
  /customers/{customerId}/payment-method:
    parameters: []
    put:
      tags:
        - PaymentMethod
      summary: Set default payment method
      description: >-
        Set the default payment method for a customer


        <sup>Required permissions: `payment-method:write`,
        `customer:payment-method:change`</sup>
      operationId: setDefaultPaymentMethod
      parameters:
        - name: customerId
          in: path
          description: PaymentMethod identifier
          required: true
          deprecated: false
          schema:
            type: string
          style: simple
          explode: false
      requestBody:
        description: The updated PaymentMethod resource
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/PaymentMethod.SetDefaultPaymentMethod-SetDefaultPaymentMethod
            example:
              paymentMethodId: c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b
          text/html:
            schema:
              $ref: >-
                #/components/schemas/PaymentMethod.SetDefaultPaymentMethod-SetDefaultPaymentMethod
            example:
              paymentMethodId: c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b
        required: true
      responses:
        '200':
          description: PaymentMethod resource updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentMethod-PaymentMethodRead'
              example:
                id: c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b
                customer: ad8f3b9e-1b1a-4b9a-9b9a-9b9a9b9a9b9a
                gatewayName: stripe
                type: card
                referenceId: pm_1J5J2n2eZvKYlo2C
                default: true
                status: active
                source: api
                enabled: true
                name: Visa (4242)
                data: []
                creationDate: '2024-01-15T10:30:00+00:00'
                expirationDate: '2026-12-31T23:59:59+00:00'
                expirationInDays: 1082
                sepaMandate: null
                card:
                  brand: Visa
                  last4: '4242'
                  expMonth: 12
                  expYear: 2026
                  cardHolder: Max Mustermann
                sepaDebit: null
                paypal: null
            text/html:
              schema:
                $ref: '#/components/schemas/PaymentMethod-PaymentMethodRead'
              example:
                id: c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b
                customer: ad8f3b9e-1b1a-4b9a-9b9a-9b9a9b9a9b9a
                gatewayName: stripe
                type: card
                referenceId: pm_1J5J2n2eZvKYlo2C
                default: true
                status: active
                source: api
                enabled: true
                name: Visa (4242)
                data: []
                creationDate: '2024-01-15T10:30:00+00:00'
                expirationDate: '2026-12-31T23:59:59+00:00'
                expirationInDays: 1082
                sepaMandate: null
                card:
                  brand: Visa
                  last4: '4242'
                  expMonth: 12
                  expYear: 2026
                  cardHolder: Max Mustermann
                sepaDebit: null
                paypal: null
          links: {}
        '400':
          description: Invalid input
        '404':
          description: Resource not found
        '422':
          description: Unprocessable entity
      deprecated: false
      security:
        - JWT:
            - payment-method:write
            - customer:payment-method:change
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X PUT \
             /customers/{customerId}/payment-method \
             --header "Content-Type: application/json" \
             --header "Authorization: Bearer <token>" \
             --data '{
                "paymentMethodId": ""
            }'
components:
  schemas:
    PaymentMethod.SetDefaultPaymentMethod-SetDefaultPaymentMethod:
      type: object
      description: Request body for setting the default payment method of a customer.
      deprecated: false
      required:
        - paymentMethodId
      properties:
        paymentMethodId:
          description: >-
            The new default payment method which should be used for new
            invoices, subscriptions and other offers.
          type: string
    PaymentMethod-PaymentMethodRead:
      type: object
      description: Payment method details returned when reading a payment method.
      deprecated: false
      properties:
        id:
          readOnly: true
          type: string
          description: Unique identifier of the payment method
          example: c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b
        customer:
          type: string
          format: uuid
          example: ad8f3b9e-1b1a-4b9a-9b9a-9b9a9b9a9b9a
          description: The ID of the customer that owns this payment method
        gatewayName:
          type: string
          enum:
            - wallet
            - sepa_debit
            - stripe
            - fake_provider
            - paypal
            - bank_transfer
            - go_cardless
            - testing
          description: The payment gateway used to process the payment method
        type:
          type:
            - string
            - 'null'
          enum:
            - sepa_debit
            - card
            - paypal
            - bank_transfer
            - wallet
            - fake_provider
            - null
          description: The type of the payment method
        referenceId:
          type:
            - string
            - 'null'
          description: The reference ID of the payment method at the payment gateway
        default:
          type: boolean
          description: Whether this is the default payment method for the customer
          example: true
        status:
          default: active
          example: active
          type: string
          enum:
            - active
            - action_required
            - expired
            - revoked
            - gateway_unconfigured
          description: The current status of the payment method
        source:
          default: api
          example: api
          type: string
          enum:
            - checkout
            - customerfront
            - api
            - add_link
          description: The source where the payment method was created
        enabled:
          type: boolean
          description: Whether the payment method is enabled for use
          example: true
        name:
          type:
            - string
            - 'null'
          description: Display name of the payment method
          example: Visa (4242)
        data:
          type: array
          items:
            type: string
          description: Additional data associated with the payment method
        creationDate:
          readOnly: true
          type: string
          format: date-time
          description: The date when the payment method was created
          example: '2024-01-15T10:30:00+00:00'
        expirationDate:
          type:
            - string
            - 'null'
          format: date-time
          description: The expiration date of the payment method, if applicable
          example: '2026-12-31T23:59:59+00:00'
        sepaMandate:
          readOnly: true
          description: >-
            The sepa mandate of the payment method, if the gatewayName is
            "payment_sepa"
          anyOf:
            - $ref: '#/components/schemas/SepaMandate-PaymentMethodRead'
            - type: 'null'
        card:
          readOnly: true
          description: The card data of the payment method, if the type is "card"
          type: object
          properties:
            brand:
              type: string
              example: Visa
              description: The brand of the card
            last4:
              type: string
              example: '4242'
              description: The last 4 digits of the card
            expMonth:
              type: integer
              example: 12
              description: The expiration month of the card
            expYear:
              type: integer
              example: 2022
              description: The expiration year of the card
            cardHolder:
              type: string
              example: Max Mustermann
              description: The card holder name
        sepaDebit:
          readOnly: true
          description: >-
            The sepa mandate data of the payment method, if the type is
            "sepa_debit"
          type: object
          properties:
            iban:
              type: string
              example: DE8937*********3232
              description: The iban of the sepa mandate
            bic:
              type: string
              example: COBADEFFXXX
              description: The bic of the sepa mandate
            mandateReference:
              type: string
              example: MNDT-2021-123456
              description: The mandate reference of the sepa mandate
            signingDate:
              type: string
              example: '2021-01-01T00:00:00+00:00'
              description: The signing date of the sepa mandate
        paypal:
          readOnly: true
          description: The paypal data of the payment method, if the type is "paypal"
          type: object
          properties:
            email:
              type: string
              example: max@mustermann.de
              description: The email of the paypal account
            billingAgreementId:
              type: string
              example: I-1J5gqz2eZvKYlo2C2X2X2X2X
              description: The billing agreement id of the paypal account
        expirationInDays:
          readOnly: true
          type:
            - integer
            - 'null'
          description: >-
            Number of days until the payment method expires. Null if no
            expiration.
          example: 365
    SepaMandate-PaymentMethodRead:
      type: object
      description: ''
      deprecated: false
      properties:
        id:
          readOnly: true
          example: ad8f0b9c-0b1a-4e1a-8b0a-0b1a4e1a8b0a
          type: string
        status:
          description: |-
            The status of the mandate

            Possible values:
             * `active`: The mandate is active and can be used for payments
             * `revoked`: The customer has revoked the mandate or a payment was rejected by the bank. The mandate can not be used for payments anymore
          example: active
          enum:
            - active
            - revoked
        creditorIdentifier:
          readOnly: true
          type: string
        mandateReference:
          description: The reference of the mandate
          example: MNDT-2021-0001
          type: string
        bankAccount:
          $ref: '#/components/schemas/BankAccount-PaymentMethodRead'
          description: The bank account of the mandate
        sequenceType:
          description: |-
            The sequence type of the mandate

            Possible values:
             * `FRST`: The sepa mandate is used for the first time for a recurring payment
             * `RCUR`: The sepa mandate was already used the first time and is now used for recurring payments
             * `FNAL`: The sepa mandate is used for the last time for a recurring payment
             * `OOFF`: The sepa mandate is only allowed to be used for one payment
          example: FRST
          enum:
            - FRST
            - RCUR
            - FNAL
            - OOFF
        sepaType:
          description: |-
            The type of the mandate

            Possible values:
             * `CORE`: The core scheme is used for payments between consumers and companies
             * `B2B`: The B2B scheme is used for payments between companies. No refund is possible
             * `COR1`: The COR1 scheme is used for payments between consumers and companies. The payment is processed faster than with the core scheme
          example: core
          enum:
            - CORE
            - B2B
            - COR1
    BankAccount-PaymentMethodRead:
      type: object
      description: ''
      deprecated: false
      properties:
        id:
          readOnly: true
          example: ad8f0b9c-4b1e-4e0e-8b9c-4b1e4e0e8b9c
          type: string
          description: Unique identifier of the bank account
        iban:
          example: DE12500105170648489890
          type: string
          description: The IBAN of the bank account
        bic:
          example: PBNKDEFFXXX
          type: string
          description: The BIC/SWIFT code of the bank
        accountHolder:
          example: Max Mustermann
          type: string
          description: The name of the account holder
        bankName:
          example: Commerzbank
          type: string
          description: The name of the bank
  securitySchemes:
    JWT:
      type: http
      scheme: bearer

````