Visual FoxPro Stripe: Delete a Card

Back to Index

Deletes a customer credit card.

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

CURL Command

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

Visual FoxPro Example

LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loSbResponseBody
LOCAL loJsonResponse
LOCAL lnDeleted
LOCAL lcId

loRest = CreateObject('Chilkat_9_5_0.Rest')

*  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("api.stripe.com",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

loRest.SetAuthBasic("STRIPE_SECRET_KEY","")

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("DELETE","/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL",loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.LoadSb(loSbResponseBody)

lnDeleted = loJsonResponse.BoolOf("deleted")
lcId = loJsonResponse.StringOf("id")

RELEASE loRest
RELEASE loSbResponseBody
RELEASE loJsonResponse

Sample JSON Response Body

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