Ruby 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

Ruby Example

require 'chilkat'

rest = Chilkat::CkRest.new()

#  URL: https://api.stripe.com/v1/customers/cus_CBbgVLJqv487Oq
bTls = true
port = 443
bAutoReconnect = true
success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect)
if (success != true)
    print "ConnectFailReason: " + rest.get_ConnectFailReason().to_s() + "\n";
    print rest.lastErrorText() + "\n";
    exit
end

rest.SetAuthBasic("STRIPE_SECRET_KEY","")

sbResponseBody = Chilkat::CkStringBuilder.new()
success = rest.FullRequestNoBodySb("DELETE","/v1/customers/cus_CBbgVLJqv487Oq",sbResponseBody)
if (success != true)
    print rest.lastErrorText() + "\n";
    exit
end

jsonResponse = Chilkat::CkJsonObject.new()
jsonResponse.LoadSb(sbResponseBody)

deleted = jsonResponse.BoolOf("deleted")
id = jsonResponse.stringOf("id")

Sample JSON Response Body

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