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

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 AutoIt Downloads

AutoIt
Local $bSuccess = False

;  Requires an unlocked Chilkat bundle. See Global Unlock Sample.
;  Supply a restricted sandbox key from merchant-controlled configuration.
Local $sApiKey = "YOUR_STRIPE_TEST_KEY"
;  Load the saved UUID for this operation. Reuse it only for a retry with identical inputs.
Local $sOperationId = "YOUR_SAVED_OPERATION_UUID"

$oCurl = ObjCreate("Chilkat.HttpCurl")
$oCmd = ObjCreate("Chilkat.StringBuilder")
$oJson = ObjCreate("Chilkat.JsonObject")

Local $iReplaced

;  For an account already linked to Stripe, reuse its saved customer ID.

$oBusinessName = ObjCreate("Chilkat.StringBuilder")
$oBusinessName.SetString("Acme & Sons")

$oEmail = ObjCreate("Chilkat.StringBuilder")
$oEmail.SetString("billing+east@example.com")

Local $sAccountRef = "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}"
$oCmd.SetString("curl -X POST ""https://api.stripe.com/v1/customers""")
$oCmd.Append(" -u ""@KEY@:""")
$oCmd.Append(" -H ""Stripe-Version: 2026-10-28.endive""")
$oCmd.Append(" -H ""Idempotency-Key: @OP@-customer""")
$oCmd.Append(" -d ""name=@NAME@""")
$oCmd.Append(" -d ""email=@EMAIL@""")
$oCmd.Append(" -d ""metadata[account_ref]=@REF@""")
$iReplaced = $oCmd.Replace("@NAME@",$oBusinessName.GetEncoded("url_rfc3986","utf-8"))
$iReplaced = $oCmd.Replace("@EMAIL@",$oEmail.GetEncoded("url_rfc3986","utf-8"))
$iReplaced = $oCmd.Replace("@REF@",$sAccountRef)
$iReplaced = $oCmd.Replace("@OP@",$sOperationId)
$iReplaced = $oCmd.Replace("@KEY@",$sApiKey)
$bSuccess = $oCurl.DoYourThing($oCmd.GetAsString())
If ($bSuccess <> True) Then
    ConsoleWrite("No HTTP response. Chilkat failure code: " & $oCurl.FailReason & @CRLF)
    Exit
EndIf

$bSuccess = $oCurl.GetResponseJson($oJson)
If (($oCurl.StatusCode <> 200) Or ($bSuccess <> True)) Then
    ConsoleWrite("Stripe HTTP " & $oCurl.StatusCode & "  Request-Id: " & $oCurl.GetResponseHeaderField("Request-Id") & @CRLF)
    If ($bSuccess = True) Then
        ConsoleWrite($oJson.StringOf("error.message") & @CRLF)
    EndIf

    Exit
EndIf

;  Save this string on the existing billing account after a successful create.
Local $sCustomerId = $oJson.StringOf("id")
ConsoleWrite("Stripe customer: " & $sCustomerId & @CRLF)