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 <CkRest.h>
#include <CkStringBuilder.h>
#include <CkJsonObject.h>

void ChilkatSample(void)
    {
    CkRest rest;
    bool success;

    //  URL: https://api.stripe.com/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0
    bool bTls = true;
    int port = 443;
    bool bAutoReconnect = true;
    success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect);
    if (success != true) {
        std::cout << "ConnectFailReason: " << rest.get_ConnectFailReason() << "\r\n";
        std::cout << rest.lastErrorText() << "\r\n";
        return;
    }

    rest.SetAuthBasic("STRIPE_SECRET_KEY","");

    CkStringBuilder sbResponseBody;
    success = rest.FullRequestNoBodySb("POST","/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0",sbResponseBody);
    if (success != true) {
        std::cout << rest.lastErrorText() << "\r\n";
        return;
    }

    CkJsonObject jsonResponse;
    jsonResponse.LoadSb(sbResponseBody);

    const char *id = 0;
    const char *object = 0;
    int amount;
    const char *balance_transaction = 0;
    const char *charge = 0;
    int created;
    const char *currency = 0;
    const char *metadataKey = 0;
    bool reason;
    bool receipt_number;
    const char *status = 0;

    id = jsonResponse.stringOf("id");
    object = jsonResponse.stringOf("object");
    amount = jsonResponse.IntOf("amount");
    balance_transaction = jsonResponse.stringOf("balance_transaction");
    charge = jsonResponse.stringOf("charge");
    created = jsonResponse.IntOf("created");
    currency = jsonResponse.stringOf("currency");
    metadataKey = jsonResponse.stringOf("metadata.key");
    reason = jsonResponse.IsNullOf("reason");
    receipt_number = jsonResponse.IsNullOf("receipt_number");
    status = jsonResponse.stringOf("status");
    }

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"
}