PHP Extension Stripe: Update a Bank Account

Back to Index

Updates the metadata, account_holder_name, and account_holder_type of a bank account belonging to a Customer. Other bank account details are not editable by design.

Documentation: https://stripe.com/docs/api/curl#customer_update_bank_account

CURL Command

curl https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/ba_1BnETKGswQrCoh0XzgjB3t99 \
   -u STRIPE_SECRET_KEY: \
   -d metadata[key]=value \
   -X POST

PHP Extension Example

<?php

// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");

$rest = new CkRest();

//  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/ba_1BnETKGswQrCoh0XzgjB3t99
$bTls = true;
$port = 443;
$bAutoReconnect = true;
$success = $rest->Connect('api.stripe.com',$port,$bTls,$bAutoReconnect);
if ($success != true) {
    print 'ConnectFailReason: ' . $rest->get_ConnectFailReason() . "\n";
    print $rest->lastErrorText() . "\n";
    exit;
}

$rest->SetAuthBasic('STRIPE_SECRET_KEY','');

$rest->AddQueryParam('metadata[key]','value');

$strResponseBody = $rest->fullRequestFormUrlEncoded('POST','/v1/customers/cus_CBbg3iRMzWBjoe/sources/ba_1BnETKGswQrCoh0XzgjB3t99');
if ($rest->get_LastMethodSuccess() != true) {
    print $rest->lastErrorText() . "\n";
    exit;
}

$jsonResponse = new CkJsonObject();
$jsonResponse->Load($strResponseBody);

$id = $jsonResponse->stringOf('id');
$object = $jsonResponse->stringOf('object');
$account = $jsonResponse->stringOf('account');
$account_holder_name = $jsonResponse->stringOf('account_holder_name');
$account_holder_type = $jsonResponse->stringOf('account_holder_type');
$bank_name = $jsonResponse->stringOf('bank_name');
$country = $jsonResponse->stringOf('country');
$currency = $jsonResponse->stringOf('currency');
$default_for_currency = $jsonResponse->BoolOf('default_for_currency');
$fingerprint = $jsonResponse->stringOf('fingerprint');
$last4 = $jsonResponse->stringOf('last4');
$routing_number = $jsonResponse->stringOf('routing_number');
$status = $jsonResponse->stringOf('status');
$customer = $jsonResponse->stringOf('customer');
$name = $jsonResponse->stringOf('name');

?>

Sample JSON Response Body

{
  "id": "ba_1BnETKGswQrCoh0XzgjB3t99",
  "object": "bank_account",
  "account": "acct_18qpKxGswQrCoh0X",
  "account_holder_name": "Jane Austen",
  "account_holder_type": "individual",
  "bank_name": "STRIPE TEST BANK",
  "country": "US",
  "currency": "usd",
  "default_for_currency": false,
  "fingerprint": "L2j4aSuWk1MZMDZ5",
  "last4": "6789",
  "metadata": {},
  "routing_number": "110000000",
  "status": "new",
  "customer": "cus_CBbg3iRMzWBjoe",
  "name": "Liam Thomas"
}