Perl Stripe: Delete a Customer

Back to Index

Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.

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

CURL Command

curl https://api.stripe.com/v1/customers/cus_CBbgVLJqv487Oq \
   -u STRIPE_SECRET_KEY: \
   -X DELETE

Perl Example

use chilkat();

$rest = chilkat::CkRest->new();

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

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

$sbResponseBody = chilkat::CkStringBuilder->new();
$success = $rest->FullRequestNoBodySb("DELETE","/v1/customers/cus_CBbgVLJqv487Oq",$sbResponseBody);
if ($success != 1) {
    print $rest->lastErrorText() . "\r\n";
    exit;
}

$jsonResponse = chilkat::CkJsonObject->new();
$jsonResponse->LoadSb($sbResponseBody);

$deleted = $jsonResponse->BoolOf("deleted");
$id = $jsonResponse->stringOf("id");

Sample JSON Response Body

{
  "deleted": true,
  "id": "cus_CBbgVLJqv487Oq"
}