PowerBuilder 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:

PowerBuilder Example

integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
oleobject loo_SbResponseBody
oleobject loo_JsonResponse
string ls_Id
string ls_Object
integer li_Amount
integer li_Available_on
integer li_Created
string ls_Currency
integer li_Description
integer li_Exchange_rate
integer li_Fee
integer li_Net
string ls_Source
string ls_Status
string ls_Type
integer i
integer li_Count_i

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  URL: https://api.stripe.com/v1/balance/history/txn_1BnETJGswQrCoh0XxO2tGYr7
li_BTls = 1
li_Port = 443
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("api.stripe.com",li_Port,li_BTls,li_BAutoReconnect)
if li_Success <> 1 then
    Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    return
end if

loo_Rest.SetAuthBasic("STRIPE_SECRET_KEY","")

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestNoBodySb("GET","/v1/balance/history/txn_1BnETJGswQrCoh0XxO2tGYr7",loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_SbResponseBody
    return
end if

loo_JsonResponse = create oleobject
li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JsonResponse.LoadSb(loo_SbResponseBody)

ls_Id = loo_JsonResponse.StringOf("id")
ls_Object = loo_JsonResponse.StringOf("object")
li_Amount = loo_JsonResponse.IntOf("amount")
li_Available_on = loo_JsonResponse.IntOf("available_on")
li_Created = loo_JsonResponse.IntOf("created")
ls_Currency = loo_JsonResponse.StringOf("currency")
li_Description = loo_JsonResponse.IsNullOf("description")
li_Exchange_rate = loo_JsonResponse.IsNullOf("exchange_rate")
li_Fee = loo_JsonResponse.IntOf("fee")
li_Net = loo_JsonResponse.IntOf("net")
ls_Source = loo_JsonResponse.StringOf("source")
ls_Status = loo_JsonResponse.StringOf("status")
ls_Type = loo_JsonResponse.StringOf("type")
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("fee_details")
do while i < li_Count_i
    loo_JsonResponse.I = i
    i = i + 1
loop


destroy loo_Rest
destroy loo_SbResponseBody
destroy loo_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"
}