Delphi ActiveX 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 ActiveX Example

var
rest: TChilkatRest;
success: Integer;
bTls: Integer;
port: Integer;
bAutoReconnect: Integer;
sbResponseBody: TChilkatStringBuilder;
jsonResponse: TChilkatJsonObject;
id: WideString;
object: WideString;
amount: Integer;
available_on: Integer;
created: Integer;
currency: WideString;
description: Integer;
exchange_rate: Integer;
fee: Integer;
net: Integer;
source: WideString;
status: WideString;
type: WideString;
i: Integer;
count_i: Integer;

begin
rest := TChilkatRest.Create(Self);

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

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

sbResponseBody := TChilkatStringBuilder.Create(Self);
success := rest.FullRequestNoBodySb('GET','/v1/balance/history/txn_1BnETJGswQrCoh0XxO2tGYr7',sbResponseBody.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;

jsonResponse := TChilkatJsonObject.Create(Self);
jsonResponse.LoadSb(sbResponseBody.ControlInterface);

id := jsonResponse.StringOf('id');
object := jsonResponse.StringOf('object');
amount := jsonResponse.IntOf('amount');
available_on := jsonResponse.IntOf('available_on');
created := jsonResponse.IntOf('created');
currency := jsonResponse.StringOf('currency');
description := jsonResponse.IsNullOf('description');
exchange_rate := jsonResponse.IsNullOf('exchange_rate');
fee := jsonResponse.IntOf('fee');
net := jsonResponse.IntOf('net');
source := jsonResponse.StringOf('source');
status := jsonResponse.StringOf('status');
type := jsonResponse.StringOf('type');
i := 0;
count_i := jsonResponse.SizeOfArray('fee_details');
while i < count_i do
  begin
    jsonResponse.I := i;
    i := i + 1;
  end;

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