Visual FoxPro Stripe: List all Payouts

Back to Index

Returns a list of existing payouts sent to third-party bank accounts or that Stripe has sent you. The payouts are returned in sorted order, with the most recently created payouts appearing first.

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

CURL Command

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

Visual FoxPro Example

LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loSbResponseBody
LOCAL loJsonResponse
LOCAL lcObject
LOCAL lcUrl
LOCAL lnHas_more
LOCAL i
LOCAL lnCount_i
LOCAL lcId
LOCAL lnAmount
LOCAL lnArrival_date
LOCAL lnAutomatic
LOCAL lcBalance_transaction
LOCAL lnCreated
LOCAL lcCurrency
LOCAL lcDescription
LOCAL lcDestination
LOCAL lnFailure_balance_transaction
LOCAL lnFailure_code
LOCAL lnFailure_message
LOCAL lnLivemode
LOCAL lcMethod
LOCAL lcSource_type
LOCAL lnStatement_descriptor
LOCAL lcStatus
LOCAL lcType

loRest = CreateObject('Chilkat_9_5_0.Rest')

*  URL: https://api.stripe.com/v1/payouts?limit=3
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("api.stripe.com",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

loRest.SetAuthBasic("STRIPE_SECRET_KEY","")

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/v1/payouts?limit=3",loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.LoadSb(loSbResponseBody)

lcObject = loJsonResponse.StringOf("object")
lcUrl = loJsonResponse.StringOf("url")
lnHas_more = loJsonResponse.BoolOf("has_more")
i = 0
lnCount_i = loJsonResponse.SizeOfArray("data")
DO WHILE i < lnCount_i
    loJsonResponse.I = i
    lcId = loJsonResponse.StringOf("data[i].id")
    lcObject = loJsonResponse.StringOf("data[i].object")
    lnAmount = loJsonResponse.IntOf("data[i].amount")
    lnArrival_date = loJsonResponse.IntOf("data[i].arrival_date")
    lnAutomatic = loJsonResponse.BoolOf("data[i].automatic")
    lcBalance_transaction = loJsonResponse.StringOf("data[i].balance_transaction")
    lnCreated = loJsonResponse.IntOf("data[i].created")
    lcCurrency = loJsonResponse.StringOf("data[i].currency")
    lcDescription = loJsonResponse.StringOf("data[i].description")
    lcDestination = loJsonResponse.StringOf("data[i].destination")
    lnFailure_balance_transaction = loJsonResponse.IsNullOf("data[i].failure_balance_transaction")
    lnFailure_code = loJsonResponse.IsNullOf("data[i].failure_code")
    lnFailure_message = loJsonResponse.IsNullOf("data[i].failure_message")
    lnLivemode = loJsonResponse.BoolOf("data[i].livemode")
    lcMethod = loJsonResponse.StringOf("data[i].method")
    lcSource_type = loJsonResponse.StringOf("data[i].source_type")
    lnStatement_descriptor = loJsonResponse.IsNullOf("data[i].statement_descriptor")
    lcStatus = loJsonResponse.StringOf("data[i].status")
    lcType = loJsonResponse.StringOf("data[i].type")
    i = i + 1
ENDDO

RELEASE loRest
RELEASE loSbResponseBody
RELEASE loJsonResponse

Sample JSON Response Body

{
  "object": "list",
  "url": "/v1/payouts",
  "has_more": false,
  "data": [
    {
      "id": "po_1BnETKGswQrCoh0XeUopRyDR",
      "object": "payout",
      "amount": 1100,
      "arrival_date": 1516662782,
      "automatic": true,
      "balance_transaction": "txn_1BnETKGswQrCoh0X762wrMpF",
      "created": 1516662782,
      "currency": "usd",
      "description": "STRIPE TRANSFER",
      "destination": "ba_1BnETKGswQrCoh0XO5G2kEG5",
      "failure_balance_transaction": null,
      "failure_code": null,
      "failure_message": null,
      "livemode": false,
      "metadata": {},
      "method": "standard",
      "source_type": "card",
      "statement_descriptor": null,
      "status": "in_transit",
      "type": "bank_account"
    }
  ]
}