Lua Requires Chilkat v11.7.0+
Lua
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 Lua Downloads
local chilkat = require("chilkat")
local success = false
-- Requires an unlocked Chilkat bundle. See Global Unlock Sample.
-- Supply a restricted sandbox key from merchant-controlled configuration.
local apiKey = "YOUR_STRIPE_TEST_KEY"
local curl = chilkat.HttpCurl.new()
local cmd = chilkat.StringBuilder.new()
local json = chilkat.JsonObject.new()
local replaced = 0
local email = chilkat.StringBuilder.new()
email:set_string("billing+east@example.com")
-- Show every match so the operator can check the internal account reference.
local pageSuffix = chilkat.StringBuilder.new()
local more = true
local cursor = ""
while more do
-- curl -X GET "https://api.stripe.com/v1/customers?email={email}&limit=100" \
-- -u "$STRIPE_API_KEY:" \
-- -H "Stripe-Version: 2026-10-28.endive"
cmd:set_string("curl -X GET \"https://api.stripe.com/v1/customers?email=@EMAIL@&limit=100@CURSOR@\"")
cmd:append(" -u \"@KEY@:\"")
cmd:append(" -H \"Stripe-Version: 2026-10-28.endive\"")
replaced = cmd:replace("@CURSOR@", pageSuffix:get_as_string())
replaced = cmd:replace("@EMAIL@", email:get_encoded("url_rfc3986", "utf-8"))
replaced = cmd:replace("@KEY@", apiKey)
success = curl:do_your_thing(cmd:get_as_string())
if not success then
print("No HTTP response. Chilkat failure code: " .. curl.fail_reason)
return
end
success = curl:get_response_json(json)
if (curl.status_code ~= 200) or (not success) then
print("Stripe HTTP " .. curl.status_code .. " Request-Id: " .. curl:get_response_header_field("Request-Id"))
if success then
print(json:string_of("error.message"))
end
return
end
local i = 0
local count = json:size_of_array("data")
while i < count do
json.i = i
print(json:string_of("data[i].id") .. " | " .. json:string_of("data[i].name") .. " | " .. json:string_of("data[i].email") .. " | " .. json:string_of("data[i].metadata.account_ref"))
i = i + 1
end
more = json:bool_of("has_more")
if more then
local next_ = json:string_of("data[i].id")
if (count < 1) or ((next_ == "") or (next_ == cursor)) then
print("Invalid pagination cursor.")
return
end
cursor = next_
pageSuffix:set_string("&starting_after=")
pageSuffix:append(cursor)
end
end