Skip to main content

Documentation

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.

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

    • customer

    • ID of the customer. String starting with cus_.

    • payment_method

    • ID of the payment method to update. String starting with card_ or other_.

    • address

    • Object containing the following fields:

Code Samples
    • .NET

      • 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

      • 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
        $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

      • 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 -X post
    https://sandboxapi.rapyd.net/v1/customers/cus_e467136cc0d5ab97ff2c3cbcda43a658/payment_methods/other_5297656fe59c03a699037d194441a0e3
    -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'
    -d '{
        "metadata": {
        	"merchant_defined": "Prime customer"
        }
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "c11d212d-daa9-461b-957e-da2f3db2f4ef"
        },
        "data": {
            "id": "other_5297656fe59c03a699037d194441a0e3",
            "type": "it_sofort_bank",
            "category": "bank_redirect",
            "metadata": {
                "merchant_defined": "Prime customer"
            },
            "image": "",
            "webhook_url": "",
            "supporting_documentation": "",
            "next_action": "not_applicable"
        }
    }
  • Update Card Fields

  • 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'
    -d '{
        "fields": {
        	"expiration_month": "02",
        	"expiration_year": "25",
        	"name": "John H Doe"
        },
        "metadata": {
            "merchant_defined": "Prime customer"
        }
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "4009e60d-2d07-40a2-8e1b-f0464f6f2f00"
        },
        "data": {
            "id": "card_01d8003336238b9896a26b86d86b7ad8",
            "type": "us_mastercard_card",
            "category": "card",
            "metadata": {
                "merchant_defined": "Prime customer"
            },
            "image": "",
            "webhook_url": "",
            "supporting_documentation": "",
            "next_action": "not_applicable",
            "name": "John H Doe",
            "last4": "1111",
            "acs_check": "unchecked",
            "cvv_check": "unchecked",
            "bin_details": {
                "type": "UNKNOWN",
                "brand": "VISA",
                "country": "US",
                "bin_number": "411111"
            },
            "expiration_year": "25",
            "expiration_month": "02",
            "fingerprint_token": "ocfp_b93d769fc9a57b34c28615aee6ca2162"
        }
    }