PowerShell 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

PowerShell Example

[Reflection.Assembly]::LoadFile("C:\myAssemblies\ChilkatDotNet2.dll")

$rest = New-Object Chilkat.Rest

#  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL
$bTls = $true
$port = 443
$bAutoReconnect = $true
$success = $rest.Connect("api.stripe.com",$port,$bTls,$bAutoReconnect)
if ($success -ne $true) {
    $("ConnectFailReason: " + $rest.ConnectFailReason)
    $($rest.LastErrorText)
    exit
}

$rest.SetAuthBasic("STRIPE_SECRET_KEY","")

$sbResponseBody = New-Object Chilkat.StringBuilder
$success = $rest.FullRequestNoBodySb("DELETE","/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL",$sbResponseBody)
if ($success -ne $true) {
    $($rest.LastErrorText)
    exit
}

$jsonResponse = New-Object Chilkat.JsonObject
$jsonResponse.LoadSb($sbResponseBody)

$deleted = $jsonResponse.BoolOf("deleted")
$id = $jsonResponse.StringOf("id")

Sample JSON Response Body

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