PureBasic Stripe: Update a Payout

Back to Index

Updates the specified payout by setting the values of the parameters passed. Any parameters not provided will be left unchanged. This request accepts only the metadata as arguments.

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

CURL Command

curl -X POST https://api.stripe.com/v1/payouts/po_1BnETKGswQrCoh0XeUopRyDR \
   -u STRIPE_SECRET_KEY: \
   -d metadata[order_id]=6735

PureBasic Example

IncludeFile "CkRest.pb"
IncludeFile "CkJsonObject.pb"

Procedure ChilkatExample()

    rest.i = CkRest::ckCreate()
    If rest.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    ;  URL: https://api.stripe.com/v1/payouts/po_1BnETKGswQrCoh0XeUopRyDR
    bTls.i = 1
    port.i = 443
    bAutoReconnect.i = 1
    success = CkRest::ckConnect(rest,"api.stripe.com",port,bTls,bAutoReconnect)
    If success <> 1
        Debug "ConnectFailReason: " + Str(CkRest::ckConnectFailReason(rest))
        Debug CkRest::ckLastErrorText(rest)
        CkRest::ckDispose(rest)
        ProcedureReturn
    EndIf

    CkRest::ckSetAuthBasic(rest,"STRIPE_SECRET_KEY","")

    CkRest::ckAddQueryParam(rest,"metadata[order_id]","6735")

    strResponseBody.s = CkRest::ckFullRequestFormUrlEncoded(rest,"POST","/v1/payouts/po_1BnETKGswQrCoh0XeUopRyDR")
    If CkRest::ckLastMethodSuccess(rest) <> 1
        Debug CkRest::ckLastErrorText(rest)
        CkRest::ckDispose(rest)
        ProcedureReturn
    EndIf

    jsonResponse.i = CkJsonObject::ckCreate()
    If jsonResponse.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckLoad(jsonResponse,strResponseBody)

    id.s
    object.s
    amount.i
    arrival_date.i
    automatic.i
    balance_transaction.s
    created.i
    currency.s
    description.s
    destination.s
    failure_balance_transaction.i
    failure_code.i
    failure_message.i
    livemode.i
    method.s
    source_type.s
    statement_descriptor.i
    status.s
    type.s

    id = CkJsonObject::ckStringOf(jsonResponse,"id")
    object = CkJsonObject::ckStringOf(jsonResponse,"object")
    amount = CkJsonObject::ckIntOf(jsonResponse,"amount")
    arrival_date = CkJsonObject::ckIntOf(jsonResponse,"arrival_date")
    automatic = CkJsonObject::ckBoolOf(jsonResponse,"automatic")
    balance_transaction = CkJsonObject::ckStringOf(jsonResponse,"balance_transaction")
    created = CkJsonObject::ckIntOf(jsonResponse,"created")
    currency = CkJsonObject::ckStringOf(jsonResponse,"currency")
    description = CkJsonObject::ckStringOf(jsonResponse,"description")
    destination = CkJsonObject::ckStringOf(jsonResponse,"destination")
    failure_balance_transaction = CkJsonObject::ckIsNullOf(jsonResponse,"failure_balance_transaction")
    failure_code = CkJsonObject::ckIsNullOf(jsonResponse,"failure_code")
    failure_message = CkJsonObject::ckIsNullOf(jsonResponse,"failure_message")
    livemode = CkJsonObject::ckBoolOf(jsonResponse,"livemode")
    method = CkJsonObject::ckStringOf(jsonResponse,"method")
    source_type = CkJsonObject::ckStringOf(jsonResponse,"source_type")
    statement_descriptor = CkJsonObject::ckIsNullOf(jsonResponse,"statement_descriptor")
    status = CkJsonObject::ckStringOf(jsonResponse,"status")
    type = CkJsonObject::ckStringOf(jsonResponse,"type")


    CkRest::ckDispose(rest)
    CkJsonObject::ckDispose(jsonResponse)


    ProcedureReturn
EndProcedure

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