C Stripe: Cancel a Payout

Back to Index

A previously created payout can be canceled if it has not yet been paid out.

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

CURL Command

curl https://api.stripe.com/v1/payouts/po_1BnETKGswQrCoh0XeUopRyDR/cancel \
   -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;
    int arrival_date;
    BOOL automatic;
    const char *balance_transaction;
    int created;
    const char *currency;
    const char *description;
    const char *destination;
    BOOL failure_balance_transaction;
    BOOL failure_code;
    BOOL failure_message;
    BOOL livemode;
    const char *method;
    const char *source_type;
    BOOL statement_descriptor;
    const char *status;
    const char *type;

    rest = CkRest_Create();

    //  URL: https://api.stripe.com/v1/payouts/po_1BnETKGswQrCoh0XeUopRyDR/cancel
    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/payouts/po_1BnETKGswQrCoh0XeUopRyDR/cancel",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");
    arrival_date = CkJsonObject_IntOf(jsonResponse,"arrival_date");
    automatic = CkJsonObject_BoolOf(jsonResponse,"automatic");
    balance_transaction = CkJsonObject_stringOf(jsonResponse,"balance_transaction");
    created = CkJsonObject_IntOf(jsonResponse,"created");
    currency = CkJsonObject_stringOf(jsonResponse,"currency");
    description = CkJsonObject_stringOf(jsonResponse,"description");
    destination = CkJsonObject_stringOf(jsonResponse,"destination");
    failure_balance_transaction = CkJsonObject_IsNullOf(jsonResponse,"failure_balance_transaction");
    failure_code = CkJsonObject_IsNullOf(jsonResponse,"failure_code");
    failure_message = CkJsonObject_IsNullOf(jsonResponse,"failure_message");
    livemode = CkJsonObject_BoolOf(jsonResponse,"livemode");
    method = CkJsonObject_stringOf(jsonResponse,"method");
    source_type = CkJsonObject_stringOf(jsonResponse,"source_type");
    statement_descriptor = CkJsonObject_IsNullOf(jsonResponse,"statement_descriptor");
    status = CkJsonObject_stringOf(jsonResponse,"status");
    type = CkJsonObject_stringOf(jsonResponse,"type");


    CkRest_Dispose(rest);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jsonResponse);

    }

Sample JSON Response Body

{
  "id": "po_1BnETKGswQrCoh0XeUopRyDR",
  "object": "payout",
  "amount": 1100,
  "arrival_date": 1516662782,
  "automatic": true,
  "balance_transaction": "txn_1BnETKGswQrCoh0X762wrMpF",
  "created": 1516662782,
  "currency": "usd",
  "description": "STRIPE TRANSFER",
  "destination": "ba_1BnETKGswQrCoh0XO5G2kEG5",
  "failure_balance_transaction": null,
  "failure_code": null,
  "failure_message": null,
  "livemode": false,
  "metadata": {},
  "method": "standard",
  "source_type": "card",
  "statement_descriptor": null,
  "status": "in_transit",
  "type": "bank_account"
}