Delphi DLL Stripe: Retrieve a Balance Transaction

Back to Index

Retrieves the balance transaction with the given ID.

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

CURL Command

curl https://api.stripe.com/v1/balance/history/txn_1BnETJGswQrCoh0XxO2tGYr7 \
   -u STRIPE_SECRET_KEY:

Delphi DLL Example

var
rest: HCkRest;
success: Boolean;
bTls: Boolean;
port: Integer;
bAutoReconnect: Boolean;
sbResponseBody: HCkStringBuilder;
jsonResponse: HCkJsonObject;
id: PWideChar;
object: PWideChar;
amount: Integer;
available_on: Integer;
created: Integer;
currency: PWideChar;
description: Boolean;
exchange_rate: Boolean;
fee: Integer;
net: Integer;
source: PWideChar;
status: PWideChar;
type: PWideChar;
i: Integer;
count_i: Integer;

begin
rest := CkRest_Create();

//  URL: https://api.stripe.com/v1/balance/history/txn_1BnETJGswQrCoh0XxO2tGYr7
bTls := True;
port := 443;
bAutoReconnect := True;
success := CkRest_Connect(rest,'api.stripe.com',port,bTls,bAutoReconnect);
if (success <> True) then
  begin
    Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

CkRest_SetAuthBasic(rest,'STRIPE_SECRET_KEY','');

sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/v1/balance/history/txn_1BnETJGswQrCoh0XxO2tGYr7',sbResponseBody);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

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

id := CkJsonObject__stringOf(jsonResponse,'id');
object := CkJsonObject__stringOf(jsonResponse,'object');
amount := CkJsonObject_IntOf(jsonResponse,'amount');
available_on := CkJsonObject_IntOf(jsonResponse,'available_on');
created := CkJsonObject_IntOf(jsonResponse,'created');
currency := CkJsonObject__stringOf(jsonResponse,'currency');
description := CkJsonObject_IsNullOf(jsonResponse,'description');
exchange_rate := CkJsonObject_IsNullOf(jsonResponse,'exchange_rate');
fee := CkJsonObject_IntOf(jsonResponse,'fee');
net := CkJsonObject_IntOf(jsonResponse,'net');
source := CkJsonObject__stringOf(jsonResponse,'source');
status := CkJsonObject__stringOf(jsonResponse,'status');
type := CkJsonObject__stringOf(jsonResponse,'type');
i := 0;
count_i := CkJsonObject_SizeOfArray(jsonResponse,'fee_details');
while i < count_i do
  begin
CkJsonObject_putI(jsonResponse,i);
    i := i + 1;
  end;

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

Sample JSON Response Body

{
  "id": "txn_1BnETJGswQrCoh0XxO2tGYr7",
  "object": "balance_transaction",
  "amount": 100,
  "available_on": 1516662781,
  "created": 1516662781,
  "currency": "usd",
  "description": null,
  "exchange_rate": null,
  "fee": 0,
  "fee_details": [
  ],
  "net": 100,
  "source": "ch_1BnETJGswQrCoh0XTs0EERBj",
  "status": "pending",
  "type": "charge"
}