---
title: "Update Payment Method"
source_url: https://docs.rapyd.net/en/update-payment-method.html
lang: en
---

# Update Payment Method

Change or modify a payment method that was stored in a customer profile.

Use this method when the customer updates their address with the bank or financial institution.

> **Note:**
>
> - If this method is used to update one of the fields of the `fields` object in a card, the payment method ID is replaced with a new value.
> - You must provide all required fields of the `address` object. If you change the expiration date, you must update both the month and year. If you try to change the card number or CVV, the update request fails.
> - Other fields might be required, as shown by [Get Payment Method Required Fields](https://docs.rapyd.net/en/get-payment-method-required-fields.md "Get Payment Method Required Fields").
> - The code samples include successful requests (200) and bad requests (400).
>
>   - For error messages that appear due to bad requests (400), see:
>
>     - [General Errors](https://docs.rapyd.net/en/general-errors.md "General Errors")
>     - [Payment Method Errors](https://docs.rapyd.net/en/payment-method-errors.md "Payment Method Errors")
>   - For information about unauthorized request (401) and other authentication errors, see [Troubleshooting Authentication and Authorization Errors](https://docs.rapyd.net/en/troubleshooting-authentication-and-authorization-errors.md "Troubleshooting Authentication and Authorization Errors").

This method triggers the **Customer Payment Method Updated** webhook. This webhook contains the same information as the response.

### Parameters

### Request Path Parameters

- - customer
  - ID of the customer. String starting with **cus_**.
- - payment_method
  - ID of the payment method to update. String starting with **card_** or **other_**.

### Request Header Parameters

- - access_key
  - Unique access key provided by Rapyd for each authorized user.

    See [Developers](https://docs.rapyd.net/en/developers.md "Developers").
- - Content-Type
  - Indicates that the data appears in JSON format. Set to **application/json**.
- - idempotency
  - A unique key that prevents the platform from creating the same object twice.

    See [Idempotency](https://docs.rapyd.net/en/idempotency.md "Idempotency").
- - salt
  - Random string. Recommended length: 8-16 characters.
- - signature
  - Signature calculated for each request individually.

    See [Request Signatures](https://docs.rapyd.net/en/request-signatures.md "Request Signatures").
- - timestamp
  - Timestamp for the request, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time") (seconds).

### Request Body Parameters

- - address
  - Object containing the following fields:

    - - canton
      - Name of the canton administrative subdivision, as used in banking.
    - - city
      - City portion of the address.

        Required for issuance of a card to the wallet contact. Required for creating a Visa card payment that requires 3DS.
    - - country
      - The two-letter ISO 3166-1 ALPHA-2 code for the country.

        Required for creating a Visa card payment that requires 3DS.
    - - district
      - Name of the district administrative subdivision, as used in banking.
    - - line_1
      - Line 1 of the address, such as a building number and street name.

        Required for creating a Visa card payment that requires 3DS.
    - - line_2
      - Line 2 of the address, such as a suite or apartment number, or the name of a named building.
    - - line_3
      - Line 3 of the address.
    - - metadata
      - A JSON object defined by the client. See [Metadata](https://docs.rapyd.net/en/metadata.md "Metadata").
    - - name
      - The name of a contact person or an "in care of" person at this address. For a **personal** wallet contact type, alphabetic characters and spaces.

        Required for creating a Visa card payment that requires 3DS.
    - - phone_number
      - Phone number associated with this specific address in E.164 format. Must be unique.

        Required for creating a Visa card payment that requires 3DS.
    - - state
      - State or province portion of the address.

        Required for creating a Visa card payment that requires 3DS.
    - - zip
      - Postal code portion of the address.

        Required for creating a Visa card payment that requires 3DS.
- - fields
  - Contains the fields that are required for the specific payment method. See [Get Payment Method Required Fields](https://docs.rapyd.net/en/get-payment-method-required-fields.md "Get Payment Method Required Fields"). To determine what fields can be updated, see the `payment_options` field in the response to [List Payment Methods by Country](https://docs.rapyd.net/en/list-payment-methods-by-country.md "List Payment Methods by Country").
- - metadata
  - A JSON object defined by the client. See [Metadata](https://docs.rapyd.net/en/metadata.md "Metadata").

### Response Parameters

- - account_last4
  - Last four digits of the bank account number or [IBAN (International Bank Account Number)](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_iban "International Bank Account Number").

- - account_name_inquiry
  - Data about the account name inquiry (ANI).

    - - account_name_inquiry_result
      - Result of the account name inquiry. One of the following values:

        - **match** - Indicates that the name provided in the request fully matched the issuing bank's records.
        - **partial match** - Indicates that the name provided in the request partially matched the issuing bank's records.
        - **no match** - Indicates that the name provided in the request did not match the issuing bank's records.
        - **not performed** - Indicates that the account name inquiry was not performed.
        - **not supported** - Indicates that the payment method does not support account name inquiries.
    - - account_name_inquiry_details
      - Indicates the degree that the name provided in the request matched the issuing bank's records.

        - - first_name
          - Indicates the result of matching the cardholder's given name. One of the following values:

            - **match** - Indicates that the first name provided in the request fully matched the first name in the issuing bank's records.
            - **partial match** - Indicates that the first name provided in the request partially matched the first name in the issuing bank's records.
            - **no match** - Indicates that first the name provided in the request did not match the first name in the issuing bank's records.
        - - middle_name
          - indicates the result of matching the cardholder's middle name. One of the following values:

            - **match** - Indicates that the middle name provided in the request fully matched the middle name in the issuing bank's records.
            - **partial match** - Indicates that the middle name provided in the request partially middle the first name in the issuing bank's records.
            - **no match** - Indicates that the middle name provided in the request did not match the middle name in the issuing bank's records.
        - - last_name
          - indicates the result of matching the cardholder's family name. One of the following values:

            - **match** - Indicates that the last name provided in the request fully matched the family name in the issuing bank's records.
            - **partial match** - Indicates that the last name provided in the request partially matched the family name in the issuing bank's records.
            - **no match** - Indicates that the last name provided in the request did not match the family name in the issuing bank's records.
- - account_number
  - Bank account number.
- - acs_check
  - Results of the [Access Control Server (ACS)](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_acs "Access Control Server") check. Possible values:

    - **pass**
    - **fail**
    - **unavailable**
    - **unchecked**

    Relevant to cards.
- - address
  - Describes a physical address. For details about the fields of the 'address' object, see [Create Address](https://docs.rapyd.net/en/create-address.md "Create Address").
- - bic_swift
  - BIC or SWIFT code.
- - bin_details
  - Bank identification details. Includes the following fields:

    - - bin_number
      - BIN number of the bank.
    - - brand
      - The brand of the card. For example, **Visa**.
    - - country
      - Country of the bank that issued the card.
    - - issuer
      - Business name of the bank that issued the card.
    - - level
      - Type of card as categorized by the issuer.
    - - type
      - The type of the card:

        - **credit**
        - **debit**
        - **prepaid**
- - category
  - Category of payment method. One of the following:

    - **bank_redirect**
    - **bank_transfer**
    - **card**
    - **card_redirect**
    - **cash**
    - **ewallet**
    - **ewallet_redirect**
- - company_name
  - Name of the customer's company.
- - complete_payment_url
  - URL where the customer is redirected when payment is successful, after returning from an external page such as a 3DS page. Does not support localhost URLs.
- - cvv_check
  - Verification of the card’s CVV. Valid values:

    - **pass**
    - **fail**
    - **unavailable**
    - **unchecked**
- - error_payment_url
  - URL where the customer is redirected when payment is not successful, after returning from an external page, such as a 3DS page. Does not support localhost URLs.
- - expiration_month
  - Month of expiration.

    Relevant to cards.
- - expiration_year
  - Year of expiration.

    Relevant to cards.
- - fingerprint_token
  - Hash of the card number, expiration date and CVV.

    Relevant to cards.
- - first_name
  - Customer's first name.
- - full_name
  - Full name of the cardholder, as submitted for account name inquiry (ANI).

    - - first_name
      - The cardholder's given name.
    - - middle_name
      - The cardholder's middle name.
    - - last_name
      - The cardholder's family name.
- - id
  - ID of the payment method. String starting with **card_** or **other_**.
- - image
  - A URL to the image of the icon for the type of payment method.
- - is_default
  - Indicates that the added payment method will become the customer's default payment method. If it is the only payment method of the customer then it will automatically become the default payment method even if this parameter is set to **false**.
- - language
  - Determines the default language of the hosted page. For a list of values, see [List Supported Languages](https://docs.rapyd.net/en/list-supported-languages.md "List Supported Languages").

    - When this parameter is null, the language of the user's browser is used.
    - If the language of the user's browser cannot be determined, the default language is English.
- - last4
  - Last four digits of the card or IBAN (International Bank Account Number).
- - metadata
  - A JSON object defined by the client. See [Metadata](https://docs.rapyd.net/en/metadata.md "Metadata").
- - name
  - Full name of the customer.
- - network_reference_id
  - Identifier for use in a recurring card payment.
- - next_action
  - Indicates the next action for completing the payment. One of the following values:

    - **3d_verification** - The next action is 3DS authentication. Relevant only to card payments.
    - **pending_capture** - The next action is pending the capture of the amount. Relevant only to card payments when the amount is not zero.
    - **pending_confirmation** - The next action is pending the confirmation for the payment. Relevant to all payment methods excluding card payment.
    - **pending_offline_capture** - The next action is pending an offline capture, where the payment settles to a **closed** (**CLO**) status via the clearing process. A payment in this state can be successfully refunded, **but cannot be canceled**. Currently, relevant only to Shva Arena card payments.
    - **not_applicable** - The payment has completed or the next action is not relevant.
- - payment_purpose
  - Purpose of the transfer, as reported by the payer's bank.
- - proof_of_authorization
  - Proof of authorization for the bank transfer.
- - redirect_url
  - URL of the hosted page that is shown to the customer.
- - routing_number
  - Routing number for the bank transfer.
- - supporting_documentation
  - Reserved.
- - type
  - Name of the payment method type. For example, **us_mastercard_card**.

    To get a list of payment methods for a country, use [List Payment Methods by Country](https://docs.rapyd.net/en/list-payment-methods-by-country.md "List Payment Methods by Country").
- - webhook_url
  - Reserved.

### Code Samples

- - .NET

    - ```csharp
      using System;
      using System.Text.Json;

      namespace RapydApiRequestSample
      {
          class Program
          {
              static void Main(string[] args)
              {
                  try
                  {
                      string[] payment_method_type_categories = new string[] { "cash", "bank_redirect", "bank_transfer" };
                      string customerId = "cus_7200986c0d1a044b5f6cfa42379bf8c1";
                      string paymentMethod = "other_d2b9b58a7d31eeb8fb7212c165189783";

                      var metadata = new { merchant_defined = true };

                      var requestObj = new
                      {
                          metadata
                      };

                      string request = JsonSerializer.Serialize(requestObj);

                      string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/customers/{customerId}/payment_methods/{paymentMethod}", request);

                      Console.WriteLine(result);
                  }
                  catch (Exception e)
                  {
                      Console.WriteLine("Error completing request: " + e.Message);
                  }
              }
          }
      }
      ```
- - JavaScript

    - ```javascript
      const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest;

      async function main() {
        try {
          const body = {
            metadata: {
              merchant_defined: 'Prime customer'
            }
          };
          const result = await makeRequest(
            'POST',
            '/v1/customers/cus_f3923ec56a56578b6a18df24d4f32d54/payment_methods/card_8d6f3c733165d63023a8449e18977cf8',
            body
          );

          console.log(result);
        } catch (error) {
          console.error('Error completing request', error);
        }
      }
      ```
- - PHP

    - ```php
      <?php
      $path = $_SERVER['DOCUMENT_ROOT'];
      $path .= "/<path-to-your-utility-file>/utilities.php";
      include($path);

      $body = [
          "address" => 'Moon, Falcon 9',
      ];

      try {
          $object = make_request('post', "/v1/customers/cus_5861b2ec3e7441bfd43756bb491ddf10/payment_methods/other_d2b9b58a7d31eeb8fb7212c165189783", $body);
          var_dump($object);
      } catch (Exception $e) {
          echo "Error => $e";
      }
      ?>
      ```
- - Python

    - ```python
      from pprint import pprint

      from utilities import make_request

      payment_method_data = {
          "metadata": {
              "merchant_defined": "Prime customer"
          }
      }
      result = make_request(method='post',
                            path=f'/v1/customers/cus_a97e4e29c079d5bea3e5856ebf1810ad/payment_methods/card_ed89925f45399dd503f5f3bdc14f4e08',
                            body=payment_method_data)
      pprint(result)
      ```

- /v1/customers/:customer/payment_methods/:payment_method

- Update Payment Method - Metadata
- ```curl
  curl -X post 'https://sandboxapi.rapyd.net/v1/customers/cus_4e25112ac20e144ad073a614dc46934b/payment_methods/card_b9548d9b53a565b2315fecdc6c87f158' \
  -H 'access_key: your-access-key-here' \
  -H 'Content-Type: application/json' \
  -H 'idempotency: your-idempotency-parameter-here' \
  -H 'salt: your-random-string-here' \
  -H 'signature: your-calculated-signature-here' \
  -H 'timestamp: your-unix-timestamp-here' \
  --data-raw '{
      "metadata": {
      	"merchant_defined": "Prime customer"
      }
  }'
  ```
- ```json
  {
      "status": {
          "error_code": "",
          "status": "SUCCESS",
          "message": "",
          "response_code": "",
          "operation_id": "292272b1-27c1-4008-8d26-2ff9a3951de2"
      },
      "data": {
          "id": "card_b9548d9b53a565b2315fecdc6c87f158",
          "type": "gb_visa_card",
          "category": "card",
          "metadata": {
              "merchant_defined": "Prime customer"
          },
          "image": "",
          "webhook_url": "",
          "supporting_documentation": "",
          "next_action": "not_applicable",
          "name": "John Doe",
          "last4": "1111",
          "acs_check": "unchecked",
          "cvv_check": "unchecked",
          "bin_details": {
              "type": "DEBIT",
              "brand": "VISA",
              "level": "CLASSIC",
              "issuer": "CONOTOXIA SP. Z O.O",
              "country": "PL",
              "bin_number": "411111"
          },
          "expiration_year": "35",
          "expiration_month": "02",
          "fingerprint_token": "ocfp_e599f990674473ce6283b245e9ad2467",
          "network_reference_id": "272205",
          "payment_account_reference": "V001KNQF3SKKUSGTKZ7VB07649XBJ"
      }
  }
  ```

- Update Card Fields
- ```curl
  curl -X post 'https://sandboxapi.rapyd.net/v1/customers/cus_4e25112ac20e144ad073a614dc46934b/payment_methods/card_b9548d9b53a565b2315fecdc6c87f158' \
  -H 'access_key: your-access-key-here' \
  -H 'Content-Type: application/json' \
  -H 'idempotency: your-idempotency-parameter-here' \
  -H 'salt: your-random-string-here' \
  -H 'signature: your-calculated-signature-here' \
  -H 'timestamp: your-unix-timestamp-here' \
  --data-raw '{
      "fields": {
          "expiration_month": "12",
          "expiration_year": "36",
          "name": "John Doe"
      }
  }'
  ```
- ```json
  {
      "status": {
          "error_code": "",
          "status": "SUCCESS",
          "message": "",
          "response_code": "",
          "operation_id": "feca114c-0c8e-4b78-956b-086c8f70c893"
      },
      "data": {
          "id": "card_b9548d9b53a565b2315fecdc6c87f158",
          "type": "gb_visa_card",
          "category": "card",
          "metadata": {
              "merchant_defined": "Prime customer"
          },
          "image": "",
          "webhook_url": "",
          "supporting_documentation": "",
          "next_action": "not_applicable",
          "name": "John Doe",
          "last4": "1111",
          "acs_check": "unchecked",
          "cvv_check": "unchecked",
          "bin_details": {
              "type": "DEBIT",
              "brand": "VISA",
              "level": "CLASSIC",
              "issuer": "CONOTOXIA SP. Z O.O",
              "country": "PL",
              "bin_number": "411111"
          },
          "expiration_year": "36",
          "expiration_month": "12",
          "fingerprint_token": "ocfp_e599f990674473ce6283b245e9ad2467",
          "network_reference_id": "272205",
          "payment_account_reference": "V001KNQF3SKKUSGTKZ7VB07649XBJ"
      }
  }
  ```

- Bad Request - Payment Method Not Found
- ```curl
  curl -X post 'https://sandboxapi.rapyd.net/v1/customers/cus_d3ed65d5091a8398cc3651bcedec1201/payment_methods/card_291ba88b24be649b3672b2a90b0a6a2f' \
  -H 'access_key: your-access-key-here' \
  -H 'Content-Type: application/json' \
  -H 'idempotency: your-idempotency-parameter-here' \
  -H 'salt: your-random-string-here' \
  -H 'signature: your-calculated-signature-here' \
  -H 'timestamp: your-unix-timestamp-here' \
  --data-raw '{
      "fields": {
      	"expiration_month": "02",
      	"expiration_year": "35",
      	"name": "John Doe"
      },
      "metadata": {
          "merchant_defined": "Prime customer"
      }
  }'
  ```
- ```json
  {
      "status": {
          "error_code": "INVALID_PAYMENT_METHOD",
          "status": "ERROR",
          "message": "The request tried to perform an operation that requires a payment method, but the payment method was not found. The request was rejected. Corrective action: Use the correct payment method ID or payment method object.",
          "response_code": "INVALID_PAYMENT_METHOD",
          "operation_id": "7c3cf4b4-55b9-414f-bac7-4a060b578cc7"
      }
  }
  ```

- Bad Request - Incorrect Expiration Year
- ```curl
  curl -X post 'https://sandboxapi.rapyd.net/v1/customers/cus_e467136cc0d5ab97ff2c3cbcda43a658/payment_methods/card_cd430a8ec629d43cd3ebae11617bd45f' \
  -H 'access_key: your-access-key-here' \
  -H 'Content-Type: application/json' \
  -H 'idempotency: your-idempotency-parameter-here' \
  -H 'salt: your-random-string-here' \
  -H 'signature: your-calculated-signature-here' \
  -H 'timestamp: your-unix-timestamp-here' \
  --data-raw '{
      "fields": {
      	"expiration_month": "02",
      	"expiration_year": "25",
      	"name": "John H Doe"
      }
  }'
  ```
- ```json
  {
      "status": {
          "error_code": "ERROR_UPDATE_PAYMENT_METHOD",
          "status": "ERROR",
          "message": "The request tried to update a payment method, but one or more fields were missing or contained incorrect values. The request was rejected. Corrective action: Check all input fields. For details, see the API Reference.",
          "response_code": "ERROR_UPDATE_PAYMENT_METHOD",
          "operation_id": "b1f5b1d9-af7a-4b26-9531-b4c1916a9725"
      }
  }
  ```
