Unicode C Stripe: Update a Refund

Back to Index

Updates the specified refund by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Documentation: https://stripe.com/docs/api/curl#update_refund

CURL Command

curl https://api.stripe.com/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0 \
   -u STRIPE_SECRET_KEY:
   -X POST

Unicode C Example

#include <C_CkRestW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    HCkRestW rest;
    BOOL success;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jsonResponse;
    const wchar_t *id;
    const wchar_t *object;
    int amount;
    const wchar_t *balance_transaction;
    const wchar_t *charge;
    int created;
    const wchar_t *currency;
    const wchar_t *metadataKey;
    BOOL reason;
    BOOL receipt_number;
    const wchar_t *status;

    rest = CkRestW_Create();

    //  URL: https://api.stripe.com/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0
    bTls = TRUE;
    port = 443;
    bAutoReconnect = TRUE;
    success = CkRestW_Connect(rest,L"api.stripe.com",port,bTls,bAutoReconnect);
    if (success != TRUE) {
        wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        return;
    }

    CkRestW_SetAuthBasic(rest,L"STRIPE_SECRET_KEY",L"");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkRestW_FullRequestNoBodySb(rest,L"POST",L"/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0",sbResponseBody);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    jsonResponse = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);

    id = CkJsonObjectW_stringOf(jsonResponse,L"id");
    object = CkJsonObjectW_stringOf(jsonResponse,L"object");
    amount = CkJsonObjectW_IntOf(jsonResponse,L"amount");
    balance_transaction = CkJsonObjectW_stringOf(jsonResponse,L"balance_transaction");
    charge = CkJsonObjectW_stringOf(jsonResponse,L"charge");
    created = CkJsonObjectW_IntOf(jsonResponse,L"created");
    currency = CkJsonObjectW_stringOf(jsonResponse,L"currency");
    metadataKey = CkJsonObjectW_stringOf(jsonResponse,L"metadata.key");
    reason = CkJsonObjectW_IsNullOf(jsonResponse,L"reason");
    receipt_number = CkJsonObjectW_IsNullOf(jsonResponse,L"receipt_number");
    status = CkJsonObjectW_stringOf(jsonResponse,L"status");


    CkRestW_Dispose(rest);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jsonResponse);

    }

Sample JSON Response Body

{
  "id": "re_1BnETKGswQrCoh0XT2qLx7S0",
  "object": "refund",
  "amount": 100,
  "balance_transaction": "txn_1BnETKGswQrCoh0X762wrMpF",
  "charge": "ch_1BnETKGswQrCoh0XE7kJI2wj",
  "created": 1516662782,
  "currency": "usd",
  "metadata": {
    "key": "value"
  },
  "reason": null,
  "receipt_number": null,
  "status": "succeeded"
}