Visual FoxPro Requires Chilkat v11.7.0+
Visual FoxPro
Stripe: Create a Stripe Customer for an Existing Billing Account
See more Stripe Examples
Create a Stripe Customer for a local billing account. Send its internal reference in metadata and read the customer ID to save with that account.
Stripe documentation and cURL example
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL lcApiKey
LOCAL lcOperationId
LOCAL loCurl
LOCAL loCmd
LOCAL loJson
LOCAL lnReplaced
LOCAL loBusinessName
LOCAL loEmail
LOCAL lcAccountRef
LOCAL lcCustomerId
lnSuccess = 0
* Requires an unlocked Chilkat bundle. See Global Unlock Sample.
* Supply a restricted sandbox key from merchant-controlled configuration.
lcApiKey = "YOUR_STRIPE_TEST_KEY"
* Load the saved UUID for this operation. Reuse it only for a retry with identical inputs.
lcOperationId = "YOUR_SAVED_OPERATION_UUID"
loCurl = CreateObject('Chilkat.HttpCurl')
loCmd = CreateObject('Chilkat.StringBuilder')
loJson = CreateObject('Chilkat.JsonObject')
* For an account already linked to Stripe, reuse its saved customer ID.
loBusinessName = CreateObject('Chilkat.StringBuilder')
loBusinessName.SetString("Acme & Sons")
loEmail = CreateObject('Chilkat.StringBuilder')
loEmail.SetString("billing+east@example.com")
lcAccountRef = "ACME-1042"
* curl -X POST "https://api.stripe.com/v1/customers" \
* -u "$STRIPE_API_KEY:" \
* -H "Stripe-Version: 2026-10-28.endive" \
* -H "Idempotency-Key: {operationId}-customer" \
* -d "name={businessName}" \
* -d "email={email}" \
* -d "metadata[account_ref]={accountRef}"
loCmd.SetString('curl -X POST "https://api.stripe.com/v1/customers"')
loCmd.Append(' -u "@KEY@:"')
loCmd.Append(' -H "Stripe-Version: 2026-10-28.endive"')
loCmd.Append(' -H "Idempotency-Key: @OP@-customer"')
loCmd.Append(' -d "name=@NAME@"')
loCmd.Append(' -d "email=@EMAIL@"')
loCmd.Append(' -d "metadata[account_ref]=@REF@"')
lnReplaced = loCmd.Replace("@NAME@",loBusinessName.GetEncoded("url_rfc3986","utf-8"))
lnReplaced = loCmd.Replace("@EMAIL@",loEmail.GetEncoded("url_rfc3986","utf-8"))
lnReplaced = loCmd.Replace("@REF@",lcAccountRef)
lnReplaced = loCmd.Replace("@OP@",lcOperationId)
lnReplaced = loCmd.Replace("@KEY@",lcApiKey)
lnSuccess = loCurl.DoYourThing(loCmd.GetAsString())
IF (lnSuccess <> 1) THEN
? "No HTTP response. Chilkat failure code: " + STR(loCurl.FailReason)
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loBusinessName
RELEASE loEmail
CANCEL
ENDIF
lnSuccess = loCurl.GetResponseJson(loJson)
IF ((loCurl.StatusCode <> 200) OR (lnSuccess <> 1)) THEN
? "Stripe HTTP " + STR(loCurl.StatusCode) + " Request-Id: " + loCurl.GetResponseHeaderField("Request-Id")
IF (lnSuccess = 1) THEN
? loJson.StringOf("error.message")
ENDIF
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loBusinessName
RELEASE loEmail
CANCEL
ENDIF
* Save this string on the existing billing account after a successful create.
lcCustomerId = loJson.StringOf("id")
? "Stripe customer: " + lcCustomerId
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loBusinessName
RELEASE loEmail