PowerBuilder Stripe: Retrieve a charge

Back to Index

Retrieves the details of a charge that has previously been created.

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

CURL Command

curl https://api.stripe.com/v1/charges/ch_1BnETJGswQrCoh0XTs0EERBj \
   -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_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 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/charges/ch_1BnETJGswQrCoh0XTs0EERBj
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/ch_1BnETJGswQrCoh0XTs0EERBj",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_Amount_refunded = loo_JsonResponse.IntOf("amount_refunded")
li_Application = loo_JsonResponse.IsNullOf("application")
li_Application_fee = loo_JsonResponse.IsNullOf("application_fee")
ls_Balance_transaction = loo_JsonResponse.StringOf("balance_transaction")
li_Captured = loo_JsonResponse.BoolOf("captured")
li_Created = loo_JsonResponse.IntOf("created")
ls_Currency = loo_JsonResponse.StringOf("currency")
li_Customer = loo_JsonResponse.IsNullOf("customer")
ls_Description = loo_JsonResponse.StringOf("description")
li_Destination = loo_JsonResponse.IsNullOf("destination")
li_Dispute = loo_JsonResponse.IsNullOf("dispute")
li_Failure_code = loo_JsonResponse.IsNullOf("failure_code")
li_Failure_message = loo_JsonResponse.IsNullOf("failure_message")
li_Invoice = loo_JsonResponse.IsNullOf("invoice")
li_Livemode = loo_JsonResponse.BoolOf("livemode")
li_On_behalf_of = loo_JsonResponse.IsNullOf("on_behalf_of")
li_Order = loo_JsonResponse.IsNullOf("order")
li_Outcome = loo_JsonResponse.IsNullOf("outcome")
li_Paid = loo_JsonResponse.BoolOf("paid")
li_Receipt_email = loo_JsonResponse.IsNullOf("receipt_email")
li_Receipt_number = loo_JsonResponse.IsNullOf("receipt_number")
li_Refunded = loo_JsonResponse.BoolOf("refunded")
ls_RefundsObject = loo_JsonResponse.StringOf("refunds.object")
li_RefundsHas_more = loo_JsonResponse.BoolOf("refunds.has_more")
li_RefundsTotal_count = loo_JsonResponse.IntOf("refunds.total_count")
ls_RefundsUrl = loo_JsonResponse.StringOf("refunds.url")
li_Review = loo_JsonResponse.IsNullOf("review")
li_Shipping = loo_JsonResponse.IsNullOf("shipping")
ls_SourceId = loo_JsonResponse.StringOf("source.id")
ls_SourceObject = loo_JsonResponse.StringOf("source.object")
li_SourceAddress_city = loo_JsonResponse.IsNullOf("source.address_city")
li_SourceAddress_country = loo_JsonResponse.IsNullOf("source.address_country")
li_SourceAddress_line1 = loo_JsonResponse.IsNullOf("source.address_line1")
li_SourceAddress_line1_check = loo_JsonResponse.IsNullOf("source.address_line1_check")
li_SourceAddress_line2 = loo_JsonResponse.IsNullOf("source.address_line2")
li_SourceAddress_state = loo_JsonResponse.IsNullOf("source.address_state")
li_SourceAddress_zip = loo_JsonResponse.IsNullOf("source.address_zip")
li_SourceAddress_zip_check = loo_JsonResponse.IsNullOf("source.address_zip_check")
ls_SourceBrand = loo_JsonResponse.StringOf("source.brand")
ls_SourceCountry = loo_JsonResponse.StringOf("source.country")
li_SourceCustomer = loo_JsonResponse.IsNullOf("source.customer")
li_SourceCvc_check = loo_JsonResponse.IsNullOf("source.cvc_check")
li_SourceDynamic_last4 = loo_JsonResponse.IsNullOf("source.dynamic_last4")
li_SourceExp_month = loo_JsonResponse.IntOf("source.exp_month")
li_SourceExp_year = loo_JsonResponse.IntOf("source.exp_year")
ls_SourceFingerprint = loo_JsonResponse.StringOf("source.fingerprint")
ls_SourceFunding = loo_JsonResponse.StringOf("source.funding")
ls_SourceLast4 = loo_JsonResponse.StringOf("source.last4")
li_SourceName = loo_JsonResponse.IsNullOf("source.name")
li_SourceTokenization_method = loo_JsonResponse.IsNullOf("source.tokenization_method")
li_Source_transfer = loo_JsonResponse.IsNullOf("source_transfer")
li_Statement_descriptor = loo_JsonResponse.IsNullOf("statement_descriptor")
ls_Status = loo_JsonResponse.StringOf("status")
li_Transfer_group = loo_JsonResponse.IsNullOf("transfer_group")
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("refunds.data")
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": "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
}