Visual FoxPro Requires Chilkat v11.7.0+
Visual FoxPro
Stripe: Match an automatic bank payout to its transactions
See more Stripe Examples
Reconcile a selected automatic payout by comparing its amount with the sum of its settlement entries across all result pages.
Stripe documentation and cURL example
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL lcApiKey
LOCAL loCurl
LOCAL loCmd
LOCAL loJson
LOCAL lnReplaced
LOCAL lcFromTime
LOCAL lcUntilTime
LOCAL lcSelectedPayout
LOCAL lcExpectedAmount
LOCAL lcCurrency
LOCAL loPageSuffix
LOCAL lnMore
LOCAL lcCursor
LOCAL i
LOCAL lnCount
LOCAL lcNext
LOCAL lnTotalNet
LOCAL loNumber
LOCAL loPageSuffixTxn
LOCAL lnMoreTxn
LOCAL lcCursorTxn
LOCAL lnITxn
LOCAL lnCountTxn
LOCAL lcNetText
LOCAL lnEntryNet
LOCAL lcNextTxn
lnSuccess = 0
* Requires an unlocked Chilkat bundle. See Global Unlock Sample.
* Supply a restricted sandbox key from merchant-controlled configuration.
lcApiKey = "YOUR_STRIPE_TEST_KEY"
loCurl = CreateObject('Chilkat.HttpCurl')
loCmd = CreateObject('Chilkat.StringBuilder')
loJson = CreateObject('Chilkat.JsonObject')
* Example UTC interval: 1 October 2026 inclusive through 1 November exclusive.
lcFromTime = "1790812800"
lcUntilTime = "1793491200"
lcSelectedPayout = "po_SELECTED_BANK_DEPOSIT"
lcExpectedAmount = ""
lcCurrency = ""
loPageSuffix = CreateObject('Chilkat.StringBuilder')
lnMore = 1
lcCursor = ""
DO WHILE (lnMore = 1)
* curl -X GET "https://api.stripe.com/v1/payouts?created%5Bgte%5D={fromTime}&created%5Blt%5D={untilTime}&limit=100" \
* -u "$STRIPE_API_KEY:" \
* -H "Stripe-Version: 2026-10-28.endive"
loCmd.SetString('curl -X GET "https://api.stripe.com/v1/payouts?created%5Bgte%5D=@FROM@&created%5Blt%5D=@UNTIL@&limit=100@CURSOR@"')
loCmd.Append(' -u "@KEY@:"')
loCmd.Append(' -H "Stripe-Version: 2026-10-28.endive"')
lnReplaced = loCmd.Replace("@CURSOR@",loPageSuffix.GetAsString())
lnReplaced = loCmd.Replace("@FROM@",lcFromTime)
lnReplaced = loCmd.Replace("@UNTIL@",lcUntilTime)
lnReplaced = loCmd.Replace("@KEY@",lcApiKey)
lnSuccess = loCurl.DoYourThing(loCmd.GetAsString())
IF (lnSuccess <> 1) THEN
? "No HTTP response. Chilkat failure code: " + STR(loCurl.FailReason)
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
CANCEL
ENDIF
lnSuccess = loCurl.GetResponseJson(loJson)
IF ((loCurl.StatusCode <> 200) OR (lnSuccess <> 1)) THEN
? "Stripe HTTP " + STR(loCurl.StatusCode) + " Request-Id: " + loCurl.GetResponseHeaderField("Request-Id")
IF (lnSuccess = 1) THEN
? loJson.StringOf("error.message")
ENDIF
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
CANCEL
ENDIF
i = 0
lnCount = loJson.SizeOfArray("data")
DO WHILE (i < lnCount)
loJson.I = i
? loJson.StringOf("data[i].id") + " | " + loJson.StringOf("data[i].amount") + " | " + loJson.StringOf("data[i].currency") + " | " + loJson.StringOf("data[i].reconciliation_status")
IF (loJson.StringOf("data[i].id") = lcSelectedPayout) THEN
IF ((loJson.BoolOf("data[i].automatic") <> 1) OR (loJson.StringOf("data[i].reconciliation_status") <> "completed")) THEN
? "Select an automatic payout with completed reconciliation."
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
CANCEL
ENDIF
lcExpectedAmount = loJson.StringOf("data[i].amount")
lcCurrency = loJson.StringOf("data[i].currency")
ENDIF
i = i + 1
ENDDO
lnMore = loJson.BoolOf("has_more")
IF (lnMore = 1) THEN
lcNext = loJson.StringOf("data[i].id")
IF ((lnCount < 1) OR (lcNext = "") OR (lcNext = lcCursor)) THEN
? "Invalid pagination cursor."
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
CANCEL
ENDIF
lcCursor = lcNext
loPageSuffix.SetString("&starting_after=")
loPageSuffix.Append(lcCursor)
ENDIF
ENDDO
IF (lcExpectedAmount = "") THEN
? "The selected payout was not in this date range."
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
CANCEL
ENDIF
lnTotalNet = 0
* This portable example uses int for arithmetic. Reject an out-of-range entry
* or sum before adding. A larger ledger can sum the exact strings using decimal arithmetic.
loNumber = CreateObject('Chilkat.StringBuilder')
loPageSuffixTxn = CreateObject('Chilkat.StringBuilder')
lnMoreTxn = 1
lcCursorTxn = ""
DO WHILE (lnMoreTxn = 1)
* curl -X GET "https://api.stripe.com/v1/balance_transactions?payout={selectedPayout}&limit=100" \
* -u "$STRIPE_API_KEY:" \
* -H "Stripe-Version: 2026-10-28.endive"
loCmd.SetString('curl -X GET "https://api.stripe.com/v1/balance_transactions?payout=@PAYOUT@&limit=100@CURSOR@"')
loCmd.Append(' -u "@KEY@:"')
loCmd.Append(' -H "Stripe-Version: 2026-10-28.endive"')
lnReplaced = loCmd.Replace("@CURSOR@",loPageSuffixTxn.GetAsString())
lnReplaced = loCmd.Replace("@PAYOUT@",lcSelectedPayout)
lnReplaced = loCmd.Replace("@KEY@",lcApiKey)
lnSuccess = loCurl.DoYourThing(loCmd.GetAsString())
IF (lnSuccess <> 1) THEN
? "No HTTP response. Chilkat failure code: " + STR(loCurl.FailReason)
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
RELEASE loNumber
RELEASE loPageSuffixTxn
CANCEL
ENDIF
lnSuccess = loCurl.GetResponseJson(loJson)
IF ((loCurl.StatusCode <> 200) OR (lnSuccess <> 1)) THEN
? "Stripe HTTP " + STR(loCurl.StatusCode) + " Request-Id: " + loCurl.GetResponseHeaderField("Request-Id")
IF (lnSuccess = 1) THEN
? loJson.StringOf("error.message")
ENDIF
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
RELEASE loNumber
RELEASE loPageSuffixTxn
CANCEL
ENDIF
lnITxn = 0
lnCountTxn = loJson.SizeOfArray("data")
DO WHILE (lnITxn < lnCountTxn)
loJson.I = lnITxn
? loJson.StringOf("data[i].id") + " " + loJson.StringOf("data[i].net")
IF (loJson.StringOf("data[i].currency") <> lcCurrency) THEN
? "Currency mismatch."
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
RELEASE loNumber
RELEASE loPageSuffixTxn
CANCEL
ENDIF
* Exclude the bank withdrawal itself if it appears in this batch.
IF (loJson.StringOf("data[i].source") <> lcSelectedPayout) THEN
lcNetText = loJson.StringOf("data[i].net")
lnEntryNet = loJson.IntOf("data[i].net")
loNumber.IntValue = lnEntryNet
IF (loNumber.GetAsString() <> lcNetText) THEN
? "Entry exceeds the supported int range: " + lcNetText
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
RELEASE loNumber
RELEASE loPageSuffixTxn
CANCEL
ENDIF
IF (lnEntryNet > 0) THEN
IF (lnTotalNet > (2147483647 - lnEntryNet)) THEN
? "Total exceeds the supported int range."
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
RELEASE loNumber
RELEASE loPageSuffixTxn
CANCEL
ENDIF
ENDIF
IF (lnEntryNet < 0) THEN
IF (lnTotalNet < ((0 - 2147483647) - (lnEntryNet + 1))) THEN
? "Total exceeds the supported int range."
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
RELEASE loNumber
RELEASE loPageSuffixTxn
CANCEL
ENDIF
ENDIF
lnTotalNet = lnTotalNet + lnEntryNet
ENDIF
lnITxn = lnITxn + 1
ENDDO
lnMoreTxn = loJson.BoolOf("has_more")
IF (lnMoreTxn = 1) THEN
lcNextTxn = loJson.StringOf("data[i].id")
IF ((lnCountTxn < 1) OR (lcNextTxn = "") OR (lcNextTxn = lcCursorTxn)) THEN
? "Invalid pagination cursor."
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
RELEASE loNumber
RELEASE loPageSuffixTxn
CANCEL
ENDIF
lcCursorTxn = lcNextTxn
loPageSuffixTxn.SetString("&starting_after=")
loPageSuffixTxn.Append(lcCursorTxn)
ENDIF
ENDDO
loNumber.IntValue = lnTotalNet
? "Settlement net: " + STR(lnTotalNet) + " Bank payout: " + lcExpectedAmount + " " + lcCurrency
IF (loNumber.GetAsString() = lcExpectedAmount) THEN
? "Payout reconciled."
ELSE
? "Investigate the difference."
ENDIF
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix
RELEASE loNumber
RELEASE loPageSuffixTxn