DataFlex Stripe: Retrieve a Card

Back to Index

Retrieve details about a specific card stored on the customer or recipient.

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

CURL Command

curl https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL \
   -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
    Boolean iAddress_city
    Boolean iAddress_country
    Boolean iAddress_line1
    Boolean iAddress_line1_check
    Boolean iAddress_line2
    Boolean iAddress_state
    Boolean iAddress_zip
    Boolean iAddress_zip_check
    String sBrand
    String sCountry
    String sCustomer
    Boolean iCvc_check
    Boolean iDynamic_last4
    Integer iExp_month
    Integer iExp_year
    String sFingerprint
    String sFunding
    String sLast4
    Boolean iName
    Boolean iTokenization_method
    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/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL
    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/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL" 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 ComIsNullOf Of hoJsonResponse "address_city" To iAddress_city
    Get ComIsNullOf Of hoJsonResponse "address_country" To iAddress_country
    Get ComIsNullOf Of hoJsonResponse "address_line1" To iAddress_line1
    Get ComIsNullOf Of hoJsonResponse "address_line1_check" To iAddress_line1_check
    Get ComIsNullOf Of hoJsonResponse "address_line2" To iAddress_line2
    Get ComIsNullOf Of hoJsonResponse "address_state" To iAddress_state
    Get ComIsNullOf Of hoJsonResponse "address_zip" To iAddress_zip
    Get ComIsNullOf Of hoJsonResponse "address_zip_check" To iAddress_zip_check
    Get ComStringOf Of hoJsonResponse "brand" To sBrand
    Get ComStringOf Of hoJsonResponse "country" To sCountry
    Get ComStringOf Of hoJsonResponse "customer" To sCustomer
    Get ComIsNullOf Of hoJsonResponse "cvc_check" To iCvc_check
    Get ComIsNullOf Of hoJsonResponse "dynamic_last4" To iDynamic_last4
    Get ComIntOf Of hoJsonResponse "exp_month" To iExp_month
    Get ComIntOf Of hoJsonResponse "exp_year" To iExp_year
    Get ComStringOf Of hoJsonResponse "fingerprint" To sFingerprint
    Get ComStringOf Of hoJsonResponse "funding" To sFunding
    Get ComStringOf Of hoJsonResponse "last4" To sLast4
    Get ComIsNullOf Of hoJsonResponse "name" To iName
    Get ComIsNullOf Of hoJsonResponse "tokenization_method" To iTokenization_method


End_Procedure

Sample JSON Response Body

{
  "id": "card_1BnETKGswQrCoh0Xhu1A6BfL",
  "object": "card",
  "address_city": null,
  "address_country": null,
  "address_line1": null,
  "address_line1_check": null,
  "address_line2": null,
  "address_state": null,
  "address_zip": null,
  "address_zip_check": null,
  "brand": "Visa",
  "country": "US",
  "customer": "cus_CBbg3iRMzWBjoe",
  "cvc_check": null,
  "dynamic_last4": null,
  "exp_month": 8,
  "exp_year": 2019,
  "fingerprint": "F9mANtIt1TaukpRJ",
  "funding": "credit",
  "last4": "4242",
  "metadata": {},
  "name": null,
  "tokenization_method": null
}