Sample code for 30+ languages & platforms
Visual FoxPro Requires Chilkat v11.7.0+

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL lcApiKey
LOCAL loCurl
LOCAL loCmd
LOCAL loJson
LOCAL lnReplaced
LOCAL loEmail
LOCAL loPageSuffix
LOCAL lnMore
LOCAL lcCursor
LOCAL i
LOCAL lnCount
LOCAL lcNext

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"

loCurl = CreateObject('Chilkat.HttpCurl')
loCmd = CreateObject('Chilkat.StringBuilder')
loJson = CreateObject('Chilkat.JsonObject')

loEmail = CreateObject('Chilkat.StringBuilder')
loEmail.SetString("billing+east@example.com")

*  Show every match so the operator can check the internal account reference.

loPageSuffix = CreateObject('Chilkat.StringBuilder')
lnMore = 1
lcCursor = ""
DO WHILE (lnMore = 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"
    loCmd.SetString('curl -X GET "https://api.stripe.com/v1/customers?email=@EMAIL@&limit=100@CURSOR@"')
    loCmd.Append(' -u "@KEY@:"')
    loCmd.Append(' -H "Stripe-Version: 2026-10-28.endive"')
    lnReplaced = loCmd.Replace("@CURSOR@",loPageSuffix.GetAsString())
    lnReplaced = loCmd.Replace("@EMAIL@",loEmail.GetEncoded("url_rfc3986","utf-8"))
    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 loEmail
        RELEASE loPageSuffix
        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 loEmail
        RELEASE loPageSuffix
        CANCEL
    ENDIF

    i = 0
    lnCount = loJson.SizeOfArray("data")
    DO WHILE (i < lnCount)
        loJson.I = i
        ? loJson.StringOf("data[i].id") + " | " + loJson.StringOf("data[i].name") + " | " + loJson.StringOf("data[i].email") + " | " + loJson.StringOf("data[i].metadata.account_ref")
        i = i + 1
    ENDDO
    lnMore = loJson.BoolOf("has_more")
    IF (lnMore = 1) THEN
        lcNext = loJson.StringOf("data[i].id")
        IF ((lnCount < 1) OR (lcNext = "") OR (lcNext = lcCursor)) THEN
            ? "Invalid pagination cursor."
            RELEASE loCurl
            RELEASE loCmd
            RELEASE loJson
            RELEASE loEmail
            RELEASE loPageSuffix
            CANCEL
        ENDIF

        lcCursor = lcNext
        loPageSuffix.SetString("&starting_after=")
        loPageSuffix.Append(lcCursor)
    ENDIF

ENDDO

RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loEmail
RELEASE loPageSuffix