Python 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

Python Example

import sys
import chilkat

rest = chilkat.CkRest()

#  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: " + str(rest.get_ConnectFailReason()))
    print(rest.lastErrorText())
    sys.exit()

rest.SetAuthBasic("STRIPE_SECRET_KEY","")

sbResponseBody = chilkat.CkStringBuilder()
success = rest.FullRequestNoBodySb("DELETE","/v1/customers/cus_CBbgVLJqv487Oq",sbResponseBody)
if (success != True):
    print(rest.lastErrorText())
    sys.exit()

jsonResponse = chilkat.CkJsonObject()
jsonResponse.LoadSb(sbResponseBody)

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

Sample JSON Response Body

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