PureBasic Requires Chilkat v11.7.0+
PureBasic
Stripe: Retire a payment link
See more Stripe Examples
Deactivate a saved Payment Link. Existing subscriptions created through that link keep their own lifecycle.
Stripe documentation and cURL example
Chilkat PureBasic Downloads
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttpCurl.pb"
Procedure ChilkatExample()
success.i = 0
; Requires an unlocked Chilkat bundle. See Global Unlock Sample.
; Supply a restricted sandbox key from merchant-controlled configuration.
apiKey.s = "YOUR_STRIPE_TEST_KEY"
; Load the saved UUID for this operation. Reuse it only for a retry with identical inputs.
operationId.s = "YOUR_SAVED_OPERATION_UUID"
curl.i = CkHttpCurl::ckCreate()
If curl.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
cmd.i = CkStringBuilder::ckCreate()
If cmd.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
replaced.i
linkId.s = "plink_FROM_SAVED_LINK"
; curl -X POST "https://api.stripe.com/v1/payment_links/{linkId}" \
; -u "$STRIPE_API_KEY:" \
; -H "Stripe-Version: 2026-10-28.endive" \
; -H "Idempotency-Key: {operationId}-deactivate" \
; -d "active=false"
CkStringBuilder::ckSetString(cmd,"curl -X POST " + Chr(34) + "https://api.stripe.com/v1/payment_links/@ID@" + Chr(34))
CkStringBuilder::ckAppend(cmd," -u " + Chr(34) + "@KEY@:" + Chr(34))
CkStringBuilder::ckAppend(cmd," -H " + Chr(34) + "Stripe-Version: 2026-10-28.endive" + Chr(34))
CkStringBuilder::ckAppend(cmd," -H " + Chr(34) + "Idempotency-Key: @OP@-deactivate" + Chr(34))
CkStringBuilder::ckAppend(cmd," -d " + Chr(34) + "active=false" + Chr(34))
replaced = CkStringBuilder::ckReplace(cmd,"@ID@",linkId)
replaced = CkStringBuilder::ckReplace(cmd,"@OP@",operationId)
replaced = CkStringBuilder::ckReplace(cmd,"@KEY@",apiKey)
success = CkHttpCurl::ckDoYourThing(curl,CkStringBuilder::ckGetAsString(cmd))
If success <> 1
Debug "No HTTP response. Chilkat failure code: " + Str(CkHttpCurl::ckFailReason(curl))
CkHttpCurl::ckDispose(curl)
CkStringBuilder::ckDispose(cmd)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndIf
success = CkHttpCurl::ckGetResponseJson(curl,json)
If (CkHttpCurl::ckStatusCode(curl) <> 200) OR (success <> 1)
Debug "Stripe HTTP " + Str(CkHttpCurl::ckStatusCode(curl)) + " Request-Id: " + CkHttpCurl::ckGetResponseHeaderField(curl,"Request-Id")
If success = 1
Debug CkJsonObject::ckStringOf(json,"error.message")
EndIf
CkHttpCurl::ckDispose(curl)
CkStringBuilder::ckDispose(cmd)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndIf
Debug "id = " + CkJsonObject::ckStringOf(json,"id")
Debug "url = " + CkJsonObject::ckStringOf(json,"url")
Debug "Link active: " + Str(CkJsonObject::ckBoolOf(json,"active"))
; Existing subscriptions continue until managed separately.
CkHttpCurl::ckDispose(curl)
CkStringBuilder::ckDispose(cmd)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure