Sample code for 30+ languages & platforms
Unicode C++ 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 Unicode C++ Downloads

Unicode C++
#include <CkHttpCurlW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    bool success = false;

    //  Requires an unlocked Chilkat bundle. See Global Unlock Sample.
    //  Supply a restricted sandbox key from merchant-controlled configuration.
    const wchar_t *apiKey = L"YOUR_STRIPE_TEST_KEY";
    //  Load the saved UUID for this operation. Reuse it only for a retry with identical inputs.
    const wchar_t *operationId = L"YOUR_SAVED_OPERATION_UUID";

    CkHttpCurlW curl;
    CkStringBuilderW cmd;
    CkJsonObjectW json;

    int replaced;

    const wchar_t *paymentIntent = L"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"
    cmd.SetString(L"curl -X POST \"https://api.stripe.com/v1/refunds\"");
    cmd.Append(L" -u \"@KEY@:\"");
    cmd.Append(L" -H \"Stripe-Version: 2026-10-28.endive\"");
    cmd.Append(L" -H \"Idempotency-Key: @OP@-refund\"");
    cmd.Append(L" -d \"payment_intent=@PAYMENT@\"");
    cmd.Append(L" -d \"amount=500\"");
    replaced = cmd.Replace(L"@PAYMENT@",paymentIntent);
    replaced = cmd.Replace(L"@OP@",operationId);
    replaced = cmd.Replace(L"@KEY@",apiKey);
    success = curl.DoYourThing(cmd.getAsString());
    if (success != true) {
        wprintf(L"No HTTP response. Chilkat failure code: %d\n",curl.get_FailReason());
        return;
    }

    success = curl.GetResponseJson(json);
    if ((curl.get_StatusCode() != 200) || (success != true)) {
        wprintf(L"Stripe HTTP %d  Request-Id: %s\n",curl.get_StatusCode(),curl.getResponseHeaderField(L"Request-Id"));
        if (success == true) {
            wprintf(L"%s\n",json.stringOf(L"error.message"));
        }

        return;
    }

    wprintf(L"id = %s\n",json.stringOf(L"id"));
    wprintf(L"status = %s\n",json.stringOf(L"status"));
    wprintf(L"amount = %s\n",json.stringOf(L"amount"));
    wprintf(L"currency = %s\n",json.stringOf(L"currency"));

    //  Save this refund ID with the refund request for status checks.
    }