PowerBuilder Stripe: Create a Payout

Back to Index

To send funds to your own bank account, you create a new payout object.

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

CURL Command

curl -X POST https://api.stripe.com/v1/payouts \
   -u STRIPE_SECRET_KEY: \
   -d amount=400 \
   -d currency=usd

PowerBuilder Example

integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
string ls_StrResponseBody
oleobject loo_JsonResponse
string ls_Id
string ls_Object
integer li_Amount
integer li_Arrival_date
integer li_Automatic
string ls_Balance_transaction
integer li_Created
string ls_Currency
string ls_Description
string ls_Destination
integer li_Failure_balance_transaction
integer li_Failure_code
integer li_Failure_message
integer li_Livemode
string ls_Method
string ls_Source_type
integer li_Statement_descriptor
string ls_Status
string ls_Type

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/payouts
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_Rest.AddQueryParam("amount","400")
loo_Rest.AddQueryParam("currency","usd")

ls_StrResponseBody = loo_Rest.FullRequestFormUrlEncoded("POST","/v1/payouts")
if loo_Rest.LastMethodSuccess <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    return
end if

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

loo_JsonResponse.Load(ls_StrResponseBody)

ls_Id = loo_JsonResponse.StringOf("id")
ls_Object = loo_JsonResponse.StringOf("object")
li_Amount = loo_JsonResponse.IntOf("amount")
li_Arrival_date = loo_JsonResponse.IntOf("arrival_date")
li_Automatic = loo_JsonResponse.BoolOf("automatic")
ls_Balance_transaction = loo_JsonResponse.StringOf("balance_transaction")
li_Created = loo_JsonResponse.IntOf("created")
ls_Currency = loo_JsonResponse.StringOf("currency")
ls_Description = loo_JsonResponse.StringOf("description")
ls_Destination = loo_JsonResponse.StringOf("destination")
li_Failure_balance_transaction = loo_JsonResponse.IsNullOf("failure_balance_transaction")
li_Failure_code = loo_JsonResponse.IsNullOf("failure_code")
li_Failure_message = loo_JsonResponse.IsNullOf("failure_message")
li_Livemode = loo_JsonResponse.BoolOf("livemode")
ls_Method = loo_JsonResponse.StringOf("method")
ls_Source_type = loo_JsonResponse.StringOf("source_type")
li_Statement_descriptor = loo_JsonResponse.IsNullOf("statement_descriptor")
ls_Status = loo_JsonResponse.StringOf("status")
ls_Type = loo_JsonResponse.StringOf("type")


destroy loo_Rest
destroy loo_JsonResponse

Sample JSON Response Body

{
  "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"
}