Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Delphi ActiveX) Stripe: Retrieve BalanceRetrieves the current Stripe.com account balance.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_v9_5_0_TLB; ... procedure TForm1.Button1Click(Sender: TObject); var http: TChilkatHttp; jsonResponse: WideString; json: TChilkatJsonObject; amountAvailable: Integer; amountPending: Integer; begin // This example assumes the Chilkat HTTP API to have been previously unlocked. // See Global Unlock Sample for sample code. http := TChilkatHttp.Create(Self); // Set the Authorization header using your secret key, // which looks something like this: sk_test_Oxo7a3Atz3UMRz5IRiafjkf7 http.SetRequestHeader('Authorization','Bearer STRIPE_SECRET_KEY'); jsonResponse := http.QuickGetStr('https://api.stripe.com/v1/balance'); if (http.LastMethodSuccess <> 1) then begin Memo1.Lines.Add(http.LastErrorText); Exit; end; json := TChilkatJsonObject.Create(Self); json.Load(jsonResponse); json.EmitCompact := 0; if (http.LastStatus <> 200) then begin // The request failed. Show the error. Memo1.Lines.Add(json.Emit()); Memo1.Lines.Add('Error status returned.'); Exit; end; // Show the successful response. Memo1.Lines.Add(json.Emit()); // A sample result: // { // "object": "balance", // "available": [ // { // "currency": "usd", // "amount": 0, // "source_types": { // "card": 0 // } // } // ], // "livemode": false, // "pending": [ // { // "currency": "usd", // "amount": 0, // "source_types": { // "card": 0 // } // } // ] // } // To get some information from the JSON: amountAvailable := json.IntOf('available[0].amount'); Memo1.Lines.Add('available amount = ' + IntToStr(amountAvailable)); amountPending := json.IntOf('pending[0].amount'); Memo1.Lines.Add('pending amount = ' + IntToStr(amountPending)); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.