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

C Example

#include <C_CkRest.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkRest rest;
    BOOL success;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jsonResponse;
    const char *id;
    const char *object;
    int amount;
    const char *balance_transaction;
    const char *charge;
    int created;
    const char *currency;
    const char *metadataKey;
    BOOL reason;
    BOOL receipt_number;
    const char *status;

    rest = CkRest_Create();

    //  URL: https://api.stripe.com/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0
    bTls = TRUE;
    port = 443;
    bAutoReconnect = TRUE;
    success = CkRest_Connect(rest,"api.stripe.com",port,bTls,bAutoReconnect);
    if (success != TRUE) {
        printf("ConnectFailReason: %d\n",CkRest_getConnectFailReason(rest));
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        return;
    }

    CkRest_SetAuthBasic(rest,"STRIPE_SECRET_KEY","");

    sbResponseBody = CkStringBuilder_Create();
    success = CkRest_FullRequestNoBodySb(rest,"POST","/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0",sbResponseBody);
    if (success != TRUE) {
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        CkStringBuilder_Dispose(sbResponseBody);
        return;
    }

    jsonResponse = CkJsonObject_Create();
    CkJsonObject_LoadSb(jsonResponse,sbResponseBody);

    id = CkJsonObject_stringOf(jsonResponse,"id");
    object = CkJsonObject_stringOf(jsonResponse,"object");
    amount = CkJsonObject_IntOf(jsonResponse,"amount");
    balance_transaction = CkJsonObject_stringOf(jsonResponse,"balance_transaction");
    charge = CkJsonObject_stringOf(jsonResponse,"charge");
    created = CkJsonObject_IntOf(jsonResponse,"created");
    currency = CkJsonObject_stringOf(jsonResponse,"currency");
    metadataKey = CkJsonObject_stringOf(jsonResponse,"metadata.key");
    reason = CkJsonObject_IsNullOf(jsonResponse,"reason");
    receipt_number = CkJsonObject_IsNullOf(jsonResponse,"receipt_number");
    status = CkJsonObject_stringOf(jsonResponse,"status");


    CkRest_Dispose(rest);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_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"
}