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

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

Visual FoxPro
LOCAL lnSuccess
LOCAL lcApiKey
LOCAL lcOperationId
LOCAL loCurl
LOCAL loCmd
LOCAL loJson
LOCAL lnReplaced
LOCAL lcPaymentIntent

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"
*  Load the saved UUID for this operation. Reuse it only for a retry with identical inputs.
lcOperationId = "YOUR_SAVED_OPERATION_UUID"

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

lcPaymentIntent = "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"
loCmd.SetString('curl -X POST "https://api.stripe.com/v1/refunds"')
loCmd.Append(' -u "@KEY@:"')
loCmd.Append(' -H "Stripe-Version: 2026-10-28.endive"')
loCmd.Append(' -H "Idempotency-Key: @OP@-refund"')
loCmd.Append(' -d "payment_intent=@PAYMENT@"')
loCmd.Append(' -d "amount=500"')
lnReplaced = loCmd.Replace("@PAYMENT@",lcPaymentIntent)
lnReplaced = loCmd.Replace("@OP@",lcOperationId)
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
    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
    CANCEL
ENDIF

? "id = " + loJson.StringOf("id")
? "status = " + loJson.StringOf("status")
? "amount = " + loJson.StringOf("amount")
? "currency = " + loJson.StringOf("currency")

*  Save this refund ID with the refund request for status checks.

RELEASE loCurl
RELEASE loCmd
RELEASE loJson