AutoIt Requires Chilkat v11.7.0+
AutoIt
Stripe: Issue a full or partial refund
See more Stripe Examples
Issue a partial refund against a selected payment, or refund the remaining amount by omitting the amount field.
Stripe documentation and cURL example
Chilkat AutoIt Downloads
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
Local $sPaymentIntent = "pi_FROM_SELECTED_PAYMENT"
; The operator selected a partial refund of 500 minor units. Omit the amount field to refund the remaining balance. For a charge ID use charge= instead of payment_intent=.
; curl -X POST "https://api.stripe.com/v1/refunds" \
; -u "$STRIPE_API_KEY:" \
; -H "Stripe-Version: 2026-10-28.endive" \
; -H "Idempotency-Key: {operationId}-refund" \
; -d "payment_intent={paymentIntent}" \
; -d "amount=500"
$oCmd.SetString("curl -X POST ""https://api.stripe.com/v1/refunds""")
$oCmd.Append(" -u ""@KEY@:""")
$oCmd.Append(" -H ""Stripe-Version: 2026-10-28.endive""")
$oCmd.Append(" -H ""Idempotency-Key: @OP@-refund""")
$oCmd.Append(" -d ""payment_intent=@PAYMENT@""")
$oCmd.Append(" -d ""amount=500""")
$iReplaced = $oCmd.Replace("@PAYMENT@",$sPaymentIntent)
$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
ConsoleWrite("id = " & $oJson.StringOf("id") & @CRLF)
ConsoleWrite("status = " & $oJson.StringOf("status") & @CRLF)
ConsoleWrite("amount = " & $oJson.StringOf("amount") & @CRLF)
ConsoleWrite("currency = " & $oJson.StringOf("currency") & @CRLF)
; Save this refund ID with the refund request for status checks.