Xbase++ Requires Chilkat v11.7.0+
Xbase++
Stripe: Find customer records by billing email
See more Stripe Examples
Find all customers with a given billing email, including addresses with a plus sign. Display the internal account reference so the operator can select the right record.
Stripe documentation and cURL example
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL cApiKey
LOCAL oCurl
LOCAL oCmd
LOCAL oJson
LOCAL nReplaced
LOCAL oEmail
LOCAL oPageSuffix
LOCAL nMore
LOCAL cCursor
LOCAL i
LOCAL nCount
LOCAL cNext
nSuccess := 0
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
cApiKey := "YOUR_STRIPE_TEST_KEY"
oCurl := CreateObject("Chilkat.HttpCurl")
oCmd := CreateObject("Chilkat.StringBuilder")
oJson := CreateObject("Chilkat.JsonObject")
oEmail := CreateObject("Chilkat.StringBuilder")
oEmail:SetString("billing+east@example.com")
// Show every match so the operator can check the internal account reference.
oPageSuffix := CreateObject("Chilkat.StringBuilder")
nMore := 1
cCursor := ""
DO WHILE (nMore == 1)
// curl -X GET "https://api.stripe.com/v1/customers?email={email}&limit=100" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
oCmd:SetString('curl -X GET "https://api.stripe.com/v1/customers?email=@EMAIL@&limit=100@CURSOR@"')
oCmd:Append(' -u "@KEY@:"')
oCmd:Append(' -H "Stripe-Version: 2026-10-28.endive"')
nReplaced := oCmd:Replace("@CURSOR@", oPageSuffix:GetAsString())
nReplaced := oCmd:Replace("@EMAIL@", oEmail:GetEncoded("url_rfc3986", "utf-8"))
nReplaced := oCmd:Replace("@KEY@", cApiKey)
nSuccess := oCurl:DoYourThing(oCmd:GetAsString())
IF (nSuccess != 1)
? "No HTTP response. Chilkat failure code: " + Str(oCurl:FailReason)
oCurl:destroy()
oCmd:destroy()
oJson:destroy()
oEmail:destroy()
oPageSuffix:destroy()
RETURN
ENDIF
nSuccess := oCurl:GetResponseJson(oJson)
IF ((oCurl:StatusCode != 200) .OR. (nSuccess != 1))
? "Stripe HTTP " + Str(oCurl:StatusCode) + " Request-Id: " + oCurl:GetResponseHeaderField("Request-Id")
IF (nSuccess == 1)
? oJson:StringOf("error.message")
ENDIF
oCurl:destroy()
oCmd:destroy()
oJson:destroy()
oEmail:destroy()
oPageSuffix:destroy()
RETURN
ENDIF
i := 0
nCount := oJson:SizeOfArray("data")
DO WHILE (i < nCount)
oJson:I := i
? oJson:StringOf("data[i].id") + " | " + oJson:StringOf("data[i].name") + " | " + oJson:StringOf("data[i].email") + " | " + oJson:StringOf("data[i].metadata.account_ref")
i := i + 1
ENDDO
nMore := oJson:BoolOf("has_more")
IF (nMore == 1)
cNext := oJson:StringOf("data[i].id")
IF ((nCount < 1) .OR. (cNext == "") .OR. (cNext == cCursor))
? "Invalid pagination cursor."
oCurl:destroy()
oCmd:destroy()
oJson:destroy()
oEmail:destroy()
oPageSuffix:destroy()
RETURN
ENDIF
cCursor := cNext
oPageSuffix:SetString("&starting_after=")
oPageSuffix:Append(cCursor)
ENDIF
ENDDO
oCurl:destroy()
oCmd:destroy()
oJson:destroy()
oEmail:destroy()
oPageSuffix:destroy()