Skip to main content

Documentation

Update Customer

Change one or more fields in a customer profile.

To clear a field, set it to an empty string.

This method triggers the Customer Created Webhook. This webhook contains the same information as the response.

    • addresses

    • Array of 'address' objects associated with this customer. For details of the 'address' object, see Create Address.

    • business_vat_id

    • The tax ID number of the customer.

    • coupon

    • The ID of a coupon that is assigned to this customer.

    • default_payment_method

    • The payment method that is used when the transaction does not specify a payment method. String starting with card_ or other_.

    • description

    • A text description of the customer.

    • email

    • Customer's email address.

    • ewallet

    • ID of the wallet that is linked to the customer. String starting with ewallet_.

    • invoice_prefix

    • A custom string that is prefixed to all invoices for this customer.

      • name

      • The name of the individual customer or the business name.

      • phone_number

      • Customer's primary phone number in E.164 format.

    Code Samples
      • .NET

        • using System;
          using System.Text.Json;
          
          namespace RapydApiRequestSample
          {
              class Program
              {
                  static void Main(string[] args)
                  {
                      try
                      {
                          string customerId = "cus_d3ed65d5091a8398cc3651bcedec1201";
          
                          var requestObj = new
                          {
                              default_payment_method = "card_0ef22c3b9fa5991a4da957d3dcee2e7b"
                          };
          
                          string request = JsonSerializer.Serialize(requestObj);
          
                          string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/customers/{customerId}", 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 = {
                default_payment_method: 'card_0ef22c3b9fa5991a4da957d3dcee2e7b'
              };
              const result = await makeRequest(
                'POST',
                '/v1/customers/cus_d3ed65d5091a8398cc3651bcedec1201',
                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 = [
              "default_payment_method"=> "card_0ef22c3b9fa5991a4da957d3dcee2e7b"
          ];
          
          try {
              $object = make_request('post', "/v1/customers/cus_d3ed65d5091a8398cc3651bcedec1201", $body);
              var_dump($object);
          } catch (Exception $e) {
              echo "Error: $e";
          }
          ?>
      • Python

        • from pprint import pprint
          
          from utilities import make_request
          
          customer_data = {
              "default_payment_method": "card_0ef22c3b9fa5991a4da957d3dcee2e7b",
          }
          result = make_request(method='post', path='/v1/customers/cus_d3ed65d5091a8398cc3651bcedec1201', body=customer_data)
          pprint(result)
          
    • /v1/customers/:customer

    • Add Default Payment Method

    • curl -X post
      https://sandboxapi.rapyd.net/v1/customers/cus_d3ed65d5091a8398cc3651bcedec1201
      -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 '{
          "default_payment_method": "card_0ef22c3b9fa5991a4da957d3dcee2e7b"
      }
      '
      
    • {
          "status": {
              "error_code": "",
              "status": "SUCCESS",
              "message": "",
              "response_code": "",
              "operation_id": "86591aab-d648-4dd2-8e38-8b06c0b6f8c3"
          },
          "data": {
              "id": "cus_d3ed65d5091a8398cc3651bcedec1201",
              "delinquent": false,
              "discount": null,
              "name": "John Doe",
              "default_payment_method": "card_0ef22c3b9fa5991a4da957d3dcee2e7b",
              "description": "",
              "email": "johndoe1@rapyd.net",
              "phone_number": "+14155559983",
              "invoice_prefix": "JD-",
              "addresses": [],
              "payment_methods": {
                  "data": [
                      {
                          "id": "card_0ef22c3b9fa5991a4da957d3dcee2e7b",
                          "type": "us_visa_card",
                          "category": "card",
                          "metadata": {},
                          "image": "https://iconslib.rapyd.net/checkout/us_visa_card.png",
                          "webhook_url": "",
                          "supporting_documentation": "",
                          "next_action": "3d_verification",
                          "name": "John Doe",
                          "last4": "1111",
                          "acs_check": "unchecked",
                          "cvv_check": "unchecked",
                          "bin_details": {
                              "type": null,
                              "brand": null,
                              "country": null,
                              "bin_number": "411111"
                          },
                          "expiration_year": "25",
                          "expiration_month": "12",
                          "fingerprint_token": "ocfp_e599f990674473ce6283b245e9ad2467"
                      },
                      {
                          "id": "other_bc428c38988a5d5aa5a09b79f32b2b15",
                          "type": "us_ach_bank",
                          "category": "bank_transfer",
                          "metadata": {
                              "merchant_defined": true
                          },
                          "image": "https://iconslib.rapyd.net/checkout/us_ach_bank.png",
                          "webhook_url": "",
                          "supporting_documentation": "",
                          "next_action": "not_applicable",
                          "last_name": "Doe",
                          "first_name": "John",
                          "company_name": "Acme",
                          "account_number": "retetert-345345345345-ertretretert-34534534t",
                          "routing_number": "2345345345345345",
                          "payment_purpose": "goods",
                          "proof_of_authorization": false
                      }
                  ],
                  "has_more": false,
                  "total_count": 2,
                  "url": "/v1/customers/cus_d3ed65d5091a8398cc3651bcedec1201/payment_methods"
              },
              "subscriptions": null,
              "created_at": 1634217004,
              "metadata": {
                  "merchant_defined": true
              },
              "business_vat_id": "123456789",
              "ewallet": "ewallet_0430df85c650a9a0a87f677d281b3f59"
          }
      }
    • Add Discount

    • curl -X post
      https://sandboxapi.rapyd.net/v1/customers/cus_c62e8561f1f9217676819dce60accc08
      -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 '{
          "coupon": "coupon_4ab30530e8a7352ffe715deecfab57b9"
      }
      '
      
    • {
          "status": {
              "error_code": "",
              "status": "SUCCESS",
              "message": "",
              "response_code": "",
              "operation_id": "776819ef-0fb4-4e83-aa08-e159569c050b"
          },
          "data": {
              "id": "cus_c62e8561f1f9217676819dce60accc08",
              "delinquent": false,
              "discount": {
                  "id": "dis_d41d8cd98f00b204e9800998ecf8427e",
                  "coupon": {
                      "id": "coupon_4ab30530e8a7352ffe715deecfab57b9",
                      "amount_off": 2,
                      "created": 1646825743,
                      "currency": "USD",
                      "duration": "forever",
                      "duration_in_months": 0,
                      "max_redemptions": 1,
                      "metadata": {
                          "merchant_defined": true
                      },
                      "percent_off": 0,
                      "redeem_by": 0,
                      "times_redeemed": 0,
                      "discount_valid_until": 0,
                      "discount_validity_in_months": 0,
                      "discount_duration_in_uses": 0,
                      "description": "",
                      "valid": true
                  },
                  "end": -1,
                  "start": 1646834885,
                  "subscription": "",
                  "number_of_uses": 0,
                  "valid": true
              },
              "name": "John Doe",
              "default_payment_method": "",
              "description": "",
              "email": "john_doe@rapyd.net",
              "phone_number": "",
              "invoice_prefix": "",
              "addresses": [],
              "payment_methods": {
                  "data": [
                      {
                          "id": "other_83f8ce8cd8cfb19bb61758b224c55cfe",
                          "type": "us_psc_cash",
                          "category": "cash",
                          "metadata": {},
                          "image": "https://iconslib.rapyd.net/checkout/us_psc_cash.png",
                          "webhook_url": "",
                          "supporting_documentation": "",
                          "next_action": "not_applicable"
                      }
                  ],
                  "has_more": false,
                  "total_count": 1,
                  "url": "/v1/customers/cus_c62e8561f1f9217676819dce60accc08/payment_methods"
              },
              "subscriptions": null,
              "created_at": 1616316203,
              "metadata": {},
              "business_vat_id": "",
              "ewallet": ""
          }
      }