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

Stripe: Identify the payment for a paid invoice

See more Stripe Examples

List the payments allocated to an invoice and identify a paid charge or PaymentIntent for refund.

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"

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

Local $iReplaced

Local $sInvoiceId = "in_FROM_BILLING_RECORD"

$oPageSuffix = ObjCreate("Chilkat.StringBuilder")
Local $bMore = True
Local $sCursor = ""
While ($bMore = True)
    ;  curl -X GET "https://api.stripe.com/v1/invoice_payments?invoice={invoiceId}&limit=100" \
    ;    -u "$STRIPE_API_KEY:" \
    ;    -H "Stripe-Version: 2026-10-28.endive"
    $oCmd.SetString("curl -X GET ""https://api.stripe.com/v1/invoice_payments?invoice=@ID@&limit=100@CURSOR@""")
    $oCmd.Append(" -u ""@KEY@:""")
    $oCmd.Append(" -H ""Stripe-Version: 2026-10-28.endive""")
    $iReplaced = $oCmd.Replace("@CURSOR@",$oPageSuffix.GetAsString())
    $iReplaced = $oCmd.Replace("@ID@",$sInvoiceId)
    $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

Local $i = 0
Local $iCount = $oJson.SizeOfArray("data")
    While ($i < $iCount)
        $oJson.I = $i
        ConsoleWrite($oJson.StringOf("data[i].id") & " | " & $oJson.StringOf("data[i].status") & " | " & $oJson.StringOf("data[i].amount_paid") & " | " & $oJson.StringOf("data[i].currency") _
             & " | " & $oJson.StringOf("data[i].payment.type") & @CRLF)
        If ($oJson.StringOf("data[i].payment.type") = "payment_intent") Then
            ConsoleWrite("  PaymentIntent: " & $oJson.StringOf("data[i].payment.payment_intent") & @CRLF)
        EndIf

        If ($oJson.StringOf("data[i].payment.type") = "charge") Then
            ConsoleWrite("  Charge: " & $oJson.StringOf("data[i].payment.charge") & @CRLF)
        EndIf

        $i = $i + 1
    Wend
    $bMore = $oJson.BoolOf("has_more")
    If ($bMore = True) Then
Local $sNext = $oJson.StringOf("data[i].id")
        If (($iCount < 1) Or ($sNext = "") Or ($sNext = $sCursor)) Then
            ConsoleWrite("Invalid pagination cursor." & @CRLF)
            Exit
        EndIf

        $sCursor = $sNext
        $oPageSuffix.SetString("&starting_after=")
        $oPageSuffix.Append($sCursor)
    EndIf

Wend

;  Select the paid allocation belonging to the order before issuing its refund.