PHP ActiveX 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

PHP ActiveX Example

<?php

$rest = new COM("Chilkat_9_5_0.Rest");

//  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->ConnectFailReason . "\n";
    print $rest->LastErrorText . "\n";
    exit;
}

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

$sbResponseBody = new COM("Chilkat_9_5_0.StringBuilder");
$success = $rest->FullRequestNoBodySb('DELETE','/v1/customers/cus_CBbgVLJqv487Oq',$sbResponseBody);
if ($success != 1) {
    print $rest->LastErrorText . "\n";
    exit;
}

$jsonResponse = new COM("Chilkat_9_5_0.JsonObject");
$jsonResponse->LoadSb($sbResponseBody);

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

?>

Sample JSON Response Body

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