> ## Documentation Index
> Fetch the complete documentation index at: https://api-reference.hyperswitch.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Payment Method - Update

> Update an existing payment method of a customer.
This API is useful for use cases such as updating the card number for expired cards to prevent discontinuity in recurring payments.



## OpenAPI

````yaml post /payment_methods/{method_id}/update
openapi: 3.0.3
info:
  title: Hyperswitch - API Documentation
  description: >

    ## Get started


    Hyperswitch provides a collection of APIs that enable you to process and
    manage payments.

    Our APIs accept and return JSON in the HTTP body, and return standard HTTP
    response codes.


    You can consume the APIs directly using your favorite HTTP/REST library.


    We have a testing environment referred to "sandbox", which you can setup to
    test API calls without

    affecting production data.

    Currently, our sandbox environment is live while our production environment
    is under development

    and will be available soon.

    You can sign up on our Dashboard to get API keys to access Hyperswitch API.


    ### Environment


    Use the following base URLs when making requests to the APIs:


    | Environment   |  Base URL                          |

    |---------------|------------------------------------|

    | Sandbox       | <https://sandbox.hyperswitch.io>   |

    | Production    | <https://api.hyperswitch.io>       |


    ## Authentication


    When you sign up on our [dashboard](https://app.hyperswitch.io) and create a
    merchant

    account, you are given a secret key (also referred as api-key) and a
    publishable key.

    You may authenticate all API requests with Hyperswitch server by providing
    the appropriate key in

    the request Authorization header.


    | Key             | 
    Description                                                                                 
    |

    |-----------------|-----------------------------------------------------------------------------------------------|

    | api-key         | Private key. Used to authenticate all API requests from
    your merchant server                  |

    | publishable key | Unique identifier for your account. Used to authenticate
    API requests from your app's client  |


    Never share your secret api keys. Keep them guarded and secure.
  contact:
    name: Hyperswitch Support
    url: https://hyperswitch.io
    email: support.global@juspay.io
  license:
    name: Apache-2.0
  version: 0.1.0
servers:
  - url: https://sandbox.hyperswitch.io
    description: Sandbox Environment
security: []
tags:
  - name: Merchant Account
    description: Create and manage merchant accounts
  - name: Profile
    description: Create and manage profiles
  - name: Merchant Connector Account
    description: Create and manage merchant connector accounts
  - name: Payments
    description: Create and manage one-time payments, recurring payments and mandates
  - name: Refunds
    description: Create and manage refunds for successful payments
  - name: Mandates
    description: Manage mandates
  - name: Customers
    description: Create and manage customers
  - name: Payment Methods
    description: Create and manage payment methods of customers
  - name: Disputes
    description: Manage disputes
  - name: API Key
    description: Create and manage API Keys
  - name: Payouts
    description: Create and manage payouts
  - name: payment link
    description: Create payment link
  - name: Routing
    description: Create and manage routing configurations
  - name: Event
    description: Manage events
  - name: Authentication
    description: Create and manage authentication
  - name: Subscriptions
    description: Subscription management and billing endpoints
  - name: Card Issuer
    description: Create and manage card issuers
paths:
  /payment_methods/{method_id}/update:
    post:
      tags:
        - Payment Methods
      summary: Payment Method - Update
      description: >-
        Update an existing payment method of a customer.

        This API is useful for use cases such as updating the card number for
        expired cards to prevent discontinuity in recurring payments.
      operationId: Update a Payment method
      parameters:
        - name: method_id
          in: path
          description: The unique identifier for the Payment Method
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentMethodUpdate'
        required: true
      responses:
        '200':
          description: Payment Method updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentMethodResponse'
        '404':
          description: Payment Method does not exist in records
      security:
        - api_key: []
        - publishable_key: []
components:
  schemas:
    PaymentMethodUpdate:
      type: object
      properties:
        card:
          allOf:
            - $ref: '#/components/schemas/CardDetailUpdate'
          nullable: true
        wallet:
          allOf:
            - $ref: '#/components/schemas/PaymentMethodDataWalletInfo'
          nullable: true
        client_secret:
          type: string
          description: >-
            This is a 15 minute expiry token which shall be used from the client
            to authenticate and perform sessions from the SDK
          example: secret_k2uj3he2893eiu2d
          nullable: true
          maxLength: 30
          minLength: 30
      additionalProperties: false
    PaymentMethodResponse:
      type: object
      required:
        - merchant_id
        - payment_method_id
        - payment_method
      properties:
        merchant_id:
          type: string
          description: Unique identifier for a merchant
          example: merchant_1671528864
        customer_id:
          type: string
          description: The unique identifier of the customer.
          example: cus_y3oqhf46pyzuxjbcn2giaqnb44
          nullable: true
          maxLength: 64
          minLength: 1
        payment_method_id:
          type: string
          description: The unique identifier of the Payment method
          example: card_rGK4Vi5iSW70MY7J2mIg
        payment_method:
          $ref: '#/components/schemas/PaymentMethod'
        payment_method_type:
          allOf:
            - $ref: '#/components/schemas/PaymentMethodType'
          nullable: true
        card:
          allOf:
            - $ref: '#/components/schemas/CardDetailFromLocker'
          nullable: true
        recurring_enabled:
          type: boolean
          description: >-
            Indicates whether the payment method supports recurring payments.
            Optional.
          example: true
          nullable: true
        installment_payment_enabled:
          type: boolean
          description: >-
            Indicates whether the payment method is eligible for installment
            payments (e.g., EMI, BNPL). Optional.
          example: true
          nullable: true
        payment_experience:
          type: array
          items:
            $ref: '#/components/schemas/PaymentExperience'
          description: Type of payment experience enabled with the connector
          example:
            - redirect_to_url
          nullable: true
        metadata:
          type: object
          description: >-
            You can specify up to 50 keys, with key names up to 40 characters
            long and values up to 500 characters long. Metadata is useful for
            storing additional, structured information on an object.
          nullable: true
        created:
          type: string
          format: date-time
          description: >-
            A timestamp (ISO 8601 code) that determines when the payment method
            was created
          example: '2023-01-18T11:04:09.922Z'
          nullable: true
        bank_transfer:
          allOf:
            - $ref: '#/components/schemas/Bank'
          nullable: true
        last_used_at:
          type: string
          format: date-time
          example: '2024-02-24T11:04:09.922Z'
          nullable: true
        client_secret:
          type: string
          description: For Client based calls
          nullable: true
    CardDetailUpdate:
      type: object
      required:
        - card_exp_month
        - card_exp_year
        - card_holder_name
      properties:
        card_exp_month:
          type: string
          description: Card Expiry Month
          example: '10'
        card_exp_year:
          type: string
          description: Card Expiry Year
          example: '25'
        card_holder_name:
          type: string
          description: Card Holder Name
          example: John Doe
        nick_name:
          type: string
          description: Card Holder's Nick Name
          example: John Doe
          nullable: true
        last4_digits:
          type: string
          description: Card's Last 4 Digits
          example: '1111'
          nullable: true
        card_issuer:
          type: string
          description: Issuing Bank of the Particular Card
          example: Bank of America
          nullable: true
        issuer_country:
          type: string
          description: The country where that particular card was issued
          example: US
          nullable: true
        issuer_country_code:
          type: string
          description: The country code where that particular card was issued
          example: US
          nullable: true
        card_network:
          type: string
          description: The card network
          example: VISA
          nullable: true
      additionalProperties: false
    PaymentMethodDataWalletInfo:
      type: object
      properties:
        last4:
          type: string
          description: Last 4 digits of the card number
          nullable: true
        card_network:
          type: string
          description: The information of the payment method
          nullable: true
        type:
          type: string
          description: The type of payment method
          nullable: true
        card_exp_month:
          type: string
          description: The card's expiry month
          example: '10'
          nullable: true
        card_exp_year:
          type: string
          description: The card's expiry year
          example: '25'
          nullable: true
        auth_code:
          type: string
          description: Unique authorisation code for the payment
          example: '003225'
          nullable: true
        email:
          type: string
          description: Email address associated with the wallet (e.g. PayPal email)
          example: johntest@test.com
          nullable: true
    PaymentMethod:
      type: string
      description: 'Indicates the type of payment method. Eg: ''card'', ''wallet'', etc.'
      enum:
        - card
        - card_redirect
        - pay_later
        - wallet
        - bank_redirect
        - bank_transfer
        - crypto
        - bank_debit
        - reward
        - real_time_payment
        - upi
        - voucher
        - gift_card
        - open_banking
        - mobile_payment
        - network_token
    PaymentMethodType:
      type: string
      description: >-
        Indicates the sub type of payment method. Eg: 'google_pay' & 'apple_pay'
        for wallets.
      enum:
        - ach
        - affirm
        - afterpay_clearpay
        - alfamart
        - ali_pay
        - ali_pay_hk
        - alma
        - amazon_pay
        - paysera
        - apple_pay
        - atome
        - bacs
        - bancontact_card
        - becs
        - benefit
        - bizum
        - blik
        - bluecode
        - boleto
        - bca_bank_transfer
        - bni_va
        - breadpay
        - bri_va
        - bhn_card_network
        - card_redirect
        - cimb_va
        - classic
        - credit
        - crypto_currency
        - cashapp
        - dana
        - danamon_va
        - debit
        - duit_now
        - efecty
        - eft
        - eft_debit_order
        - eps
        - flexiti
        - fps
        - evoucher
        - giropay
        - givex
        - google_pay
        - go_pay
        - gcash
        - ideal
        - interac
        - indomaret
        - klarna
        - kakao_pay
        - local_bank_redirect
        - mandiri_va
        - knet
        - mb_way
        - mobile_pay
        - momo
        - momo_atm
        - multibanco
        - online_banking_thailand
        - online_banking_czech_republic
        - online_banking_finland
        - online_banking_fpx
        - online_banking_poland
        - online_banking_slovakia
        - oxxo
        - pago_efectivo
        - permata_bank_transfer
        - open_banking_uk
        - pay_bright
        - payjustnow
        - paypal
        - paze
        - pix
        - pix_key
        - pix_emv
        - pix_automatico_qr
        - pix_automatico_push
        - pay_safe_card
        - przelewy24
        - prompt_pay
        - pse
        - qris
        - red_compra
        - red_pagos
        - samsung_pay
        - sepa
        - sepa_bank_transfer
        - sepa_guarenteed_debit
        - skrill
        - sofort
        - swish
        - touch_n_go
        - trustly
        - twint
        - upi_collect
        - upi_intent
        - upi_qr
        - vipps
        - viet_qr
        - venmo
        - walley
        - we_chat_pay
        - seven_eleven
        - lawson
        - mini_stop
        - family_mart
        - seicomart
        - pay_easy
        - local_bank_transfer
        - mifinity
        - open_banking_pis
        - direct_carrier_billing
        - instant_bank_transfer
        - instant_bank_transfer_finland
        - instant_bank_transfer_poland
        - revolut_pay
        - indonesian_bank_transfer
        - open_banking
        - network_token
    CardDetailFromLocker:
      type: object
      required:
        - saved_to_locker
      properties:
        scheme:
          type: string
          nullable: true
        issuer_country:
          type: string
          nullable: true
        issuer_country_code:
          type: string
          nullable: true
        last4_digits:
          type: string
          nullable: true
        expiry_month:
          type: string
          nullable: true
        expiry_year:
          type: string
          nullable: true
        card_token:
          type: string
          nullable: true
        card_holder_name:
          type: string
          nullable: true
        card_fingerprint:
          type: string
          nullable: true
        nick_name:
          type: string
          nullable: true
        card_network:
          allOf:
            - $ref: '#/components/schemas/CardNetwork'
          nullable: true
        card_isin:
          type: string
          nullable: true
        card_issuer:
          type: string
          nullable: true
        card_type:
          type: string
          nullable: true
        saved_to_locker:
          type: boolean
    PaymentExperience:
      type: string
      description: >-
        To indicate the type of payment experience that the customer would go
        through
      enum:
        - redirect_to_url
        - invoke_sdk_client
        - display_qr_code
        - one_click
        - link_wallet
        - invoke_payment_app
        - display_wait_screen
        - collect_otp
    Bank:
      oneOf:
        - $ref: '#/components/schemas/AchBankTransfer'
        - $ref: '#/components/schemas/BacsBankTransfer'
        - $ref: '#/components/schemas/TrustlyBankTransfer'
        - $ref: '#/components/schemas/SepaBankTransfer'
        - $ref: '#/components/schemas/PixBankTransfer'
        - $ref: '#/components/schemas/OpenBanking'
      description: Deprecated - Use `BankTransfer` instead
    CardNetwork:
      type: string
      description: Indicates the card network.
      enum:
        - Visa
        - Mastercard
        - AmericanExpress
        - JCB
        - DinersClub
        - Discover
        - CartesBancaires
        - UnionPay
        - Interac
        - RuPay
        - Maestro
        - Star
        - Pulse
        - Accel
        - Nyce
    AchBankTransfer:
      type: object
      required:
        - bank_account_number
        - bank_routing_number
      properties:
        bank_name:
          type: string
          description: Bank name
          example: Deutsche Bank
          nullable: true
        bank_country_code:
          allOf:
            - $ref: '#/components/schemas/CountryAlpha2'
          nullable: true
        bank_city:
          type: string
          description: Bank city
          example: California
          nullable: true
        bank_account_number:
          type: string
          description: >-
            Bank account number is an unique identifier assigned by a bank to a
            customer.
          example: '000123456'
        bank_routing_number:
          type: string
          description: >-
            [9 digits] Routing number - used in USA for identifying a specific
            bank.
          example: '110000000'
    BacsBankTransfer:
      type: object
      required:
        - bank_account_number
        - bank_sort_code
      properties:
        bank_name:
          type: string
          description: Bank name
          example: Deutsche Bank
          nullable: true
        bank_country_code:
          allOf:
            - $ref: '#/components/schemas/CountryAlpha2'
          nullable: true
        bank_city:
          type: string
          description: Bank city
          example: California
          nullable: true
        bank_account_number:
          type: string
          description: >-
            Bank account number is an unique identifier assigned by a bank to a
            customer.
          example: '000123456'
        bank_sort_code:
          type: string
          description: >-
            [6 digits] Sort Code - used in UK and Ireland for identifying a bank
            and it's branches.
          example: 98-76-54
    TrustlyBankTransfer:
      type: object
      required:
        - iban
        - country_code
        - account_number
        - bank_number
      properties:
        iban:
          type: string
          description: >-
            International Bank Account Number (iban) - used in many countries
            for identifying a bank along with it's customer.
          example: token_12345
        country_code:
          $ref: '#/components/schemas/CountryAlpha2'
        account_number:
          type: string
          description: The account number, identifying the end-user's account in the bank.
          example: '69706212'
        bank_number:
          type: string
          description: >-
            The bank number identifying the end-user's bank in the given
            clearing house.
          example: '6112'
    SepaBankTransfer:
      type: object
      required:
        - iban
        - bic
      properties:
        bank_name:
          type: string
          description: Bank name
          example: Deutsche Bank
          nullable: true
        bank_country_code:
          allOf:
            - $ref: '#/components/schemas/CountryAlpha2'
          nullable: true
        bank_city:
          type: string
          description: Bank city
          example: California
          nullable: true
        iban:
          type: string
          description: >-
            International Bank Account Number (iban) - used in many countries
            for identifying a bank along with it's customer.
          example: DE89370400440532013000
        bic:
          type: string
          description: >-
            [8 / 11 digits] Bank Identifier Code (bic) / Swift Code - used in
            many countries for identifying a bank and it's branches
          example: HSBCGB2LXXX
    PixBankTransfer:
      type: object
      required:
        - bank_account_number
        - pix_key
        - emv
      properties:
        bank_name:
          type: string
          description: Bank name
          example: Deutsche Bank
          nullable: true
        bank_branch:
          type: string
          description: Bank branch
          example: '3707'
          nullable: true
        bank_account_number:
          type: string
          description: >-
            Bank account number is an unique identifier assigned by a bank to a
            customer.
          example: '000123456'
        pix_key:
          type: string
          description: Unique key for pix customer
          example: '000123456'
        tax_id:
          type: string
          description: Individual taxpayer identification number
          example: '000123456'
          nullable: true
        emv:
          type: string
          description: String formatted QR code for pix payout
          example: >-
            00020126580014br.gov.bcb.pix0114000123456785204000053039865802BR5925John
            Doe6009Sao Paulo61080540900062070503***63041D3D
    OpenBanking:
      type: object
      required:
        - account_holder_name
        - iban
      properties:
        account_holder_name:
          type: string
          description: Account holder name
          example: John Doe
        iban:
          type: string
          description: >-
            International Bank Account Number (iban) - used in many countries
            for identifying a bank along with it's customer.
          example: DE89370400440532013000
    CountryAlpha2:
      type: string
      enum:
        - AF
        - AX
        - AL
        - DZ
        - AS
        - AD
        - AO
        - AI
        - AQ
        - AG
        - AR
        - AM
        - AW
        - AU
        - AT
        - AZ
        - BS
        - BH
        - BD
        - BB
        - BY
        - BE
        - BZ
        - BJ
        - BM
        - BT
        - BO
        - BQ
        - BA
        - BW
        - BV
        - BR
        - IO
        - BN
        - BG
        - BF
        - BI
        - KH
        - CM
        - CA
        - CV
        - KY
        - CF
        - TD
        - CL
        - CN
        - CX
        - CC
        - CO
        - KM
        - CG
        - CD
        - CK
        - CR
        - CI
        - HR
        - CU
        - CW
        - CY
        - CZ
        - DK
        - DJ
        - DM
        - DO
        - EC
        - EG
        - SV
        - GQ
        - ER
        - EE
        - ET
        - FK
        - FO
        - FJ
        - FI
        - FR
        - GF
        - PF
        - TF
        - GA
        - GM
        - GE
        - DE
        - GH
        - GI
        - GR
        - GL
        - GD
        - GP
        - GU
        - GT
        - GG
        - GN
        - GW
        - GY
        - HT
        - HM
        - VA
        - HN
        - HK
        - HU
        - IS
        - IN
        - ID
        - IR
        - IQ
        - IE
        - IM
        - IL
        - IT
        - JM
        - JP
        - JE
        - JO
        - KZ
        - KE
        - KI
        - KP
        - KR
        - KW
        - KG
        - LA
        - LV
        - LB
        - LS
        - LR
        - LY
        - LI
        - LT
        - LU
        - MO
        - MK
        - MG
        - MW
        - MY
        - MV
        - ML
        - MT
        - MH
        - MQ
        - MR
        - MU
        - YT
        - MX
        - FM
        - MD
        - MC
        - MN
        - ME
        - MS
        - MA
        - MZ
        - MM
        - NA
        - NR
        - NP
        - NL
        - NC
        - NZ
        - NI
        - NE
        - NG
        - NU
        - NF
        - MP
        - 'NO'
        - OM
        - PK
        - PW
        - PS
        - PA
        - PG
        - PY
        - PE
        - PH
        - PN
        - PL
        - PT
        - PR
        - QA
        - RE
        - RO
        - RU
        - RW
        - BL
        - SH
        - KN
        - LC
        - MF
        - PM
        - VC
        - WS
        - SM
        - ST
        - SA
        - SN
        - RS
        - SC
        - SL
        - SG
        - SX
        - SK
        - SI
        - SB
        - SO
        - ZA
        - GS
        - SS
        - ES
        - LK
        - SD
        - SR
        - SJ
        - SZ
        - SE
        - CH
        - SY
        - TW
        - TJ
        - TZ
        - TH
        - TL
        - TG
        - TK
        - TO
        - TT
        - TN
        - TR
        - TM
        - TC
        - TV
        - UG
        - UA
        - AE
        - GB
        - UM
        - UY
        - UZ
        - VU
        - VE
        - VN
        - VG
        - VI
        - WF
        - EH
        - YE
        - ZM
        - ZW
        - US
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: api-key
      description: >-
        Use the API key created under your merchant account from the HyperSwitch
        dashboard. API key is used to authenticate API requests from your
        merchant server only. Don't expose this key on a website or embed it in
        a mobile application.
    publishable_key:
      type: apiKey
      in: header
      name: api-key
      description: >-
        Publishable keys are a type of keys that can be public and have limited
        scope of usage.

````