PowerBuilder Stripe: List all Charges

Back to Index

Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.

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

CURL Command

curl https://api.stripe.com/v1/charges?limit=3 \
   -u STRIPE_SECRET_KEY: \
   -G

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_Object
string ls_Url
integer li_Has_more
integer i
integer li_Count_i
string ls_Id
integer li_Amount
integer li_Amount_refunded
integer li_Application
integer li_Application_fee
string ls_Balance_transaction
integer li_Captured
integer li_Created
string ls_Currency
integer li_Customer
string ls_Description
integer li_Destination
integer li_Dispute
integer li_Failure_code
integer li_Failure_message
integer li_Invoice
integer li_Livemode
integer li_On_behalf_of
integer li_Order
integer li_Outcome
integer li_Paid
integer li_Receipt_email
integer li_Receipt_number
integer li_Refunded
string ls_RefundsObject
integer li_RefundsHas_more
integer li_RefundsTotal_count
string ls_RefundsUrl
integer li_Review
integer li_Shipping
string ls_SourceId
string ls_SourceObject
integer li_SourceAddress_city
integer li_SourceAddress_country
integer li_SourceAddress_line1
integer li_SourceAddress_line1_check
integer li_SourceAddress_line2
integer li_SourceAddress_state
integer li_SourceAddress_zip
integer li_SourceAddress_zip_check
string ls_SourceBrand
string ls_SourceCountry
integer li_SourceCustomer
integer li_SourceCvc_check
integer li_SourceDynamic_last4
integer li_SourceExp_month
integer li_SourceExp_year
string ls_SourceFingerprint
string ls_SourceFunding
string ls_SourceLast4
integer li_SourceName
integer li_SourceTokenization_method
integer li_Source_transfer
integer li_Statement_descriptor
string ls_Status
integer li_Transfer_group
integer j
integer li_Count_j

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/charges?limit=3
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/charges?limit=3",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_Object = loo_JsonResponse.StringOf("object")
ls_Url = loo_JsonResponse.StringOf("url")
li_Has_more = loo_JsonResponse.BoolOf("has_more")
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("data")
do while i < li_Count_i
    loo_JsonResponse.I = i
    ls_Id = loo_JsonResponse.StringOf("data[i].id")
    ls_Object = loo_JsonResponse.StringOf("data[i].object")
    li_Amount = loo_JsonResponse.IntOf("data[i].amount")
    li_Amount_refunded = loo_JsonResponse.IntOf("data[i].amount_refunded")
    li_Application = loo_JsonResponse.IsNullOf("data[i].application")
    li_Application_fee = loo_JsonResponse.IsNullOf("data[i].application_fee")
    ls_Balance_transaction = loo_JsonResponse.StringOf("data[i].balance_transaction")
    li_Captured = loo_JsonResponse.BoolOf("data[i].captured")
    li_Created = loo_JsonResponse.IntOf("data[i].created")
    ls_Currency = loo_JsonResponse.StringOf("data[i].currency")
    li_Customer = loo_JsonResponse.IsNullOf("data[i].customer")
    ls_Description = loo_JsonResponse.StringOf("data[i].description")
    li_Destination = loo_JsonResponse.IsNullOf("data[i].destination")
    li_Dispute = loo_JsonResponse.IsNullOf("data[i].dispute")
    li_Failure_code = loo_JsonResponse.IsNullOf("data[i].failure_code")
    li_Failure_message = loo_JsonResponse.IsNullOf("data[i].failure_message")
    li_Invoice = loo_JsonResponse.IsNullOf("data[i].invoice")
    li_Livemode = loo_JsonResponse.BoolOf("data[i].livemode")
    li_On_behalf_of = loo_JsonResponse.IsNullOf("data[i].on_behalf_of")
    li_Order = loo_JsonResponse.IsNullOf("data[i].order")
    li_Outcome = loo_JsonResponse.IsNullOf("data[i].outcome")
    li_Paid = loo_JsonResponse.BoolOf("data[i].paid")
    li_Receipt_email = loo_JsonResponse.IsNullOf("data[i].receipt_email")
    li_Receipt_number = loo_JsonResponse.IsNullOf("data[i].receipt_number")
    li_Refunded = loo_JsonResponse.BoolOf("data[i].refunded")
    ls_RefundsObject = loo_JsonResponse.StringOf("data[i].refunds.object")
    li_RefundsHas_more = loo_JsonResponse.BoolOf("data[i].refunds.has_more")
    li_RefundsTotal_count = loo_JsonResponse.IntOf("data[i].refunds.total_count")
    ls_RefundsUrl = loo_JsonResponse.StringOf("data[i].refunds.url")
    li_Review = loo_JsonResponse.IsNullOf("data[i].review")
    li_Shipping = loo_JsonResponse.IsNullOf("data[i].shipping")
    ls_SourceId = loo_JsonResponse.StringOf("data[i].source.id")
    ls_SourceObject = loo_JsonResponse.StringOf("data[i].source.object")
    li_SourceAddress_city = loo_JsonResponse.IsNullOf("data[i].source.address_city")
    li_SourceAddress_country = loo_JsonResponse.IsNullOf("data[i].source.address_country")
    li_SourceAddress_line1 = loo_JsonResponse.IsNullOf("data[i].source.address_line1")
    li_SourceAddress_line1_check = loo_JsonResponse.IsNullOf("data[i].source.address_line1_check")
    li_SourceAddress_line2 = loo_JsonResponse.IsNullOf("data[i].source.address_line2")
    li_SourceAddress_state = loo_JsonResponse.IsNullOf("data[i].source.address_state")
    li_SourceAddress_zip = loo_JsonResponse.IsNullOf("data[i].source.address_zip")
    li_SourceAddress_zip_check = loo_JsonResponse.IsNullOf("data[i].source.address_zip_check")
    ls_SourceBrand = loo_JsonResponse.StringOf("data[i].source.brand")
    ls_SourceCountry = loo_JsonResponse.StringOf("data[i].source.country")
    li_SourceCustomer = loo_JsonResponse.IsNullOf("data[i].source.customer")
    li_SourceCvc_check = loo_JsonResponse.IsNullOf("data[i].source.cvc_check")
    li_SourceDynamic_last4 = loo_JsonResponse.IsNullOf("data[i].source.dynamic_last4")
    li_SourceExp_month = loo_JsonResponse.IntOf("data[i].source.exp_month")
    li_SourceExp_year = loo_JsonResponse.IntOf("data[i].source.exp_year")
    ls_SourceFingerprint = loo_JsonResponse.StringOf("data[i].source.fingerprint")
    ls_SourceFunding = loo_JsonResponse.StringOf("data[i].source.funding")
    ls_SourceLast4 = loo_JsonResponse.StringOf("data[i].source.last4")
    li_SourceName = loo_JsonResponse.IsNullOf("data[i].source.name")
    li_SourceTokenization_method = loo_JsonResponse.IsNullOf("data[i].source.tokenization_method")
    li_Source_transfer = loo_JsonResponse.IsNullOf("data[i].source_transfer")
    li_Statement_descriptor = loo_JsonResponse.IsNullOf("data[i].statement_descriptor")
    ls_Status = loo_JsonResponse.StringOf("data[i].status")
    li_Transfer_group = loo_JsonResponse.IsNullOf("data[i].transfer_group")
    j = 0
    li_Count_j = loo_JsonResponse.SizeOfArray("data[i].refunds.data")
    do while j < li_Count_j
        loo_JsonResponse.J = j
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Rest
destroy loo_SbResponseBody
destroy loo_JsonResponse

Sample JSON Response Body

{
  "object": "list",
  "url": "/v1/charges",
  "has_more": false,
  "data": [
    {
      "id": "ch_1BnETJGswQrCoh0XTs0EERBj",
      "object": "charge",
      "amount": 100,
      "amount_refunded": 0,
      "application": null,
      "application_fee": null,
      "balance_transaction": "txn_1BnETJGswQrCoh0XxO2tGYr7",
      "captured": false,
      "created": 1516662781,
      "currency": "usd",
      "customer": null,
      "description": "My First Test Charge (created for API docs)",
      "destination": null,
      "dispute": null,
      "failure_code": null,
      "failure_message": null,
      "fraud_details": {},
      "invoice": null,
      "livemode": false,
      "metadata": {},
      "on_behalf_of": null,
      "order": null,
      "outcome": null,
      "paid": true,
      "receipt_email": null,
      "receipt_number": null,
      "refunded": false,
      "refunds": {
        "object": "list",
        "data": [
        ],
        "has_more": false,
        "total_count": 0,
        "url": "/v1/charges/ch_1BnETJGswQrCoh0XTs0EERBj/refunds"
      },
      "review": null,
      "shipping": null,
      "source": {
        "id": "card_18ropuGswQrCoh0XjCJ5Zvma",
        "object": "card",
        "address_city": null,
        "address_country": null,
        "address_line1": null,
        "address_line1_check": null,
        "address_line2": null,
        "address_state": null,
        "address_zip": null,
        "address_zip_check": null,
        "brand": "Visa",
        "country": "US",
        "customer": null,
        "cvc_check": null,
        "dynamic_last4": null,
        "exp_month": 8,
        "exp_year": 2017,
        "fingerprint": "F9mANtIt1TaukpRJ",
        "funding": "credit",
        "last4": "4242",
        "metadata": {},
        "name": null,
        "tokenization_method": null
      },
      "source_transfer": null,
      "statement_descriptor": null,
      "status": "succeeded",
      "transfer_group": null
    }
  ]
}