Visual FoxPro Stripe: Retrieve a Refund

Back to Index

Retrieves the details of an existing refund.

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

CURL Command

curl https://api.stripe.com/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0 \
   -u STRIPE_SECRET_KEY:

Visual FoxPro Example

LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loSbResponseBody
LOCAL loJsonResponse
LOCAL lcId
LOCAL lcObject
LOCAL lnAmount
LOCAL lnBalance_transaction
LOCAL lcCharge
LOCAL lnCreated
LOCAL lcCurrency
LOCAL lnReason
LOCAL lnReceipt_number
LOCAL lcStatus

loRest = CreateObject('Chilkat_9_5_0.Rest')

*  URL: https://api.stripe.com/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("api.stripe.com",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

loRest.SetAuthBasic("STRIPE_SECRET_KEY","")

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0",loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.LoadSb(loSbResponseBody)

lcId = loJsonResponse.StringOf("id")
lcObject = loJsonResponse.StringOf("object")
lnAmount = loJsonResponse.IntOf("amount")
lnBalance_transaction = loJsonResponse.IsNullOf("balance_transaction")
lcCharge = loJsonResponse.StringOf("charge")
lnCreated = loJsonResponse.IntOf("created")
lcCurrency = loJsonResponse.StringOf("currency")
lnReason = loJsonResponse.IsNullOf("reason")
lnReceipt_number = loJsonResponse.IsNullOf("receipt_number")
lcStatus = loJsonResponse.StringOf("status")

RELEASE loRest
RELEASE loSbResponseBody
RELEASE loJsonResponse

Sample JSON Response Body

{
  "id": "re_1BnETKGswQrCoh0XT2qLx7S0",
  "object": "refund",
  "amount": 100,
  "balance_transaction": null,
  "charge": "ch_1BnETKGswQrCoh0XE7kJI2wj",
  "created": 1516662782,
  "currency": "usd",
  "metadata": {},
  "reason": null,
  "receipt_number": null,
  "status": "succeeded"
}