DataFlex 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:

DataFlex Example

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Boolean iBTls
    Integer iPort
    Boolean iBAutoReconnect
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJsonResponse
    String sId
    String sObject
    Integer iAmount
    Boolean iBalance_transaction
    String sCharge
    Integer iCreated
    String sCurrency
    Boolean iReason
    Boolean iReceipt_number
    String sStatus
    String sTemp1
    Integer iTemp1

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

    //  URL: https://api.stripe.com/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0
    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 Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestNoBodySb Of hoRest "GET" "/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0" vSbResponseBody To iSuccess
    If (iSuccess <> 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 pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJsonResponse vSbResponseBody To iSuccess

    Get ComStringOf Of hoJsonResponse "id" To sId
    Get ComStringOf Of hoJsonResponse "object" To sObject
    Get ComIntOf Of hoJsonResponse "amount" To iAmount
    Get ComIsNullOf Of hoJsonResponse "balance_transaction" To iBalance_transaction
    Get ComStringOf Of hoJsonResponse "charge" To sCharge
    Get ComIntOf Of hoJsonResponse "created" To iCreated
    Get ComStringOf Of hoJsonResponse "currency" To sCurrency
    Get ComIsNullOf Of hoJsonResponse "reason" To iReason
    Get ComIsNullOf Of hoJsonResponse "receipt_number" To iReceipt_number
    Get ComStringOf Of hoJsonResponse "status" To sStatus


End_Procedure

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