SQL Server 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

SQL Server Example

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @rest int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Rest', @rest OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    --  URL: https://api.stripe.com/v1/payouts?limit=3
    DECLARE @bTls int
    SELECT @bTls = 1
    DECLARE @port int
    SELECT @port = 443
    DECLARE @bAutoReconnect int
    SELECT @bAutoReconnect = 1
    EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'api.stripe.com', STR(@port), STR(@bTls), STR(@bAutoReconnect)
    IF STR(@success) <> 1
      BEGIN

        EXEC sp_OAGetProperty @rest, 'ConnectFailReason', @iTmp0 OUT
        PRINT 'ConnectFailReason: ' + @iTmp0
        EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @rest
        RETURN
      END

    EXEC sp_OAMethod @rest, 'SetAuthBasic', @success OUT, 'STRIPE_SECRET_KEY', ''

    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @rest, 'FullRequestNoBodySb', @success OUT, 'GET', '/v1/payouts?limit=3', STR(@sbResponseBody)
    IF STR(@success) <> 1
      BEGIN
        EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @rest
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END

    DECLARE @jsonResponse int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jsonResponse OUT

    EXEC sp_OAMethod @jsonResponse, 'LoadSb', @success OUT, STR(@sbResponseBody)

    DECLARE @object nvarchar(4000)

    DECLARE @url nvarchar(4000)

    DECLARE @has_more int

    DECLARE @i int

    DECLARE @count_i int

    DECLARE @id nvarchar(4000)

    DECLARE @amount int

    DECLARE @arrival_date int

    DECLARE @automatic int

    DECLARE @balance_transaction nvarchar(4000)

    DECLARE @created int

    DECLARE @currency nvarchar(4000)

    DECLARE @description nvarchar(4000)

    DECLARE @destination nvarchar(4000)

    DECLARE @failure_balance_transaction int

    DECLARE @failure_code int

    DECLARE @failure_message int

    DECLARE @livemode int

    DECLARE @method nvarchar(4000)

    DECLARE @source_type nvarchar(4000)

    DECLARE @statement_descriptor int

    DECLARE @status nvarchar(4000)

    DECLARE @type nvarchar(4000)

    EXEC sp_OAMethod @jsonResponse, 'StringOf', @object OUT, 'object'
    EXEC sp_OAMethod @jsonResponse, 'StringOf', @url OUT, 'url'
    EXEC sp_OAMethod @jsonResponse, 'BoolOf', @has_more OUT, 'has_more'
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'data'
    WHILE STR(@i) < STR(@count_i)
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', STR(@i)
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @id OUT, 'data[i].id'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @object OUT, 'data[i].object'
        EXEC sp_OAMethod @jsonResponse, 'IntOf', @amount OUT, 'data[i].amount'
        EXEC sp_OAMethod @jsonResponse, 'IntOf', @arrival_date OUT, 'data[i].arrival_date'
        EXEC sp_OAMethod @jsonResponse, 'BoolOf', @automatic OUT, 'data[i].automatic'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @balance_transaction OUT, 'data[i].balance_transaction'
        EXEC sp_OAMethod @jsonResponse, 'IntOf', @created OUT, 'data[i].created'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @currency OUT, 'data[i].currency'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @description OUT, 'data[i].description'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @destination OUT, 'data[i].destination'
        EXEC sp_OAMethod @jsonResponse, 'IsNullOf', @failure_balance_transaction OUT, 'data[i].failure_balance_transaction'
        EXEC sp_OAMethod @jsonResponse, 'IsNullOf', @failure_code OUT, 'data[i].failure_code'
        EXEC sp_OAMethod @jsonResponse, 'IsNullOf', @failure_message OUT, 'data[i].failure_message'
        EXEC sp_OAMethod @jsonResponse, 'BoolOf', @livemode OUT, 'data[i].livemode'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @method OUT, 'data[i].method'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @source_type OUT, 'data[i].source_type'
        EXEC sp_OAMethod @jsonResponse, 'IsNullOf', @statement_descriptor OUT, 'data[i].statement_descriptor'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @status OUT, 'data[i].status'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @type OUT, 'data[i].type'
        SELECT @i = STR(@i) + 1
      END

    EXEC @hr = sp_OADestroy @rest
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jsonResponse


END
GO

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