DataFlex 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

DataFlex Example

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Boolean iBTls
    Integer iPort
    Boolean iBAutoReconnect
    String sStrResponseBody
    Handle hoJsonResponse
    String sId
    String sObject
    Integer iAmount
    Integer iArrival_date
    Boolean iAutomatic
    String sBalance_transaction
    Integer iCreated
    String sCurrency
    String sDescription
    String sDestination
    Boolean iFailure_balance_transaction
    Boolean iFailure_code
    Boolean iFailure_message
    Boolean iLivemode
    String sMethod
    String sSource_type
    Boolean iStatement_descriptor
    String sStatus
    String sType
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    //  URL: https://api.stripe.com/v1/payouts
    Move True To iBTls
    Move 443 To iPort
    Move True To iBAutoReconnect
    Get ComConnect Of hoRest "api.stripe.com" iPort iBTls iBAutoReconnect To iSuccess
    If (iSuccess <> True) Begin
        Get ComConnectFailReason Of hoRest To iTemp1
        Showln "ConnectFailReason: " iTemp1
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComSetAuthBasic Of hoRest "STRIPE_SECRET_KEY" "" To iSuccess

    Get ComAddQueryParam Of hoRest "amount" "400" To iSuccess
    Get ComAddQueryParam Of hoRest "currency" "usd" To iSuccess

    Get ComFullRequestFormUrlEncoded Of hoRest "POST" "/v1/payouts" To sStrResponseBody
    Get ComLastMethodSuccess Of hoRest To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse
    If (Not(IsComObjectCreated(hoJsonResponse))) Begin
        Send CreateComObject of hoJsonResponse
    End
    Get ComLoad Of hoJsonResponse sStrResponseBody To iSuccess

    Get ComStringOf Of hoJsonResponse "id" To sId
    Get ComStringOf Of hoJsonResponse "object" To sObject
    Get ComIntOf Of hoJsonResponse "amount" To iAmount
    Get ComIntOf Of hoJsonResponse "arrival_date" To iArrival_date
    Get ComBoolOf Of hoJsonResponse "automatic" To iAutomatic
    Get ComStringOf Of hoJsonResponse "balance_transaction" To sBalance_transaction
    Get ComIntOf Of hoJsonResponse "created" To iCreated
    Get ComStringOf Of hoJsonResponse "currency" To sCurrency
    Get ComStringOf Of hoJsonResponse "description" To sDescription
    Get ComStringOf Of hoJsonResponse "destination" To sDestination
    Get ComIsNullOf Of hoJsonResponse "failure_balance_transaction" To iFailure_balance_transaction
    Get ComIsNullOf Of hoJsonResponse "failure_code" To iFailure_code
    Get ComIsNullOf Of hoJsonResponse "failure_message" To iFailure_message
    Get ComBoolOf Of hoJsonResponse "livemode" To iLivemode
    Get ComStringOf Of hoJsonResponse "method" To sMethod
    Get ComStringOf Of hoJsonResponse "source_type" To sSource_type
    Get ComIsNullOf Of hoJsonResponse "statement_descriptor" To iStatement_descriptor
    Get ComStringOf Of hoJsonResponse "status" To sStatus
    Get ComStringOf Of hoJsonResponse "type" To sType


End_Procedure

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