0
votes

I am using Stripe API and using below code I fetch details -

Customer cu = Customer.retrieve(customerid); // customerid
List<ExternalAccount> object = cu.getSources().getData();
Log.d("customerobj",object + "");

I get this object data

D/customerobj: [
  <com.stripe.model.Card@148232829id=>JSON: {
    "address_city": null,
    "address_country": null,
    "address_line1": null,
    "address_line1_check": null,
    "address_line2": null,
    "address_state": null,
    "address_zip": "71000",
    "address_zip_check": "pass",
    "available_payout_methods": null,
    "brand": "Visa",
    "country": "US",
    "currency": null,
    "cvc_check": "pass",
    "default_for_currency": null,
    "description": null,
    "dynamic_last4": null,
    "exp_month": 4,
    "exp_year": 2021,
    "fingerprint": "EmNhHLSbWLElhMvG",
    "funding": "credit",
    "iin": null,
    "issuer": null,
    "last4": "4242",
    "name": null,
    "recipient": null,
    "status": null,
    "three_d_secure": null,
    "tokenization_method": null,
    "type": null,
    "account": null,
    "customer": "cus_DL2GSWX9bfTZeU",
    "id": "card_1CuMC8A41bIzZYFFlpiW3hZp",
    "metadata": {

    },
    "object": "card"
  }
]

I want to get last 4 digits card number, exp_year, exp_month and address_zip.
Please help me get this String values

1
Get 0th element of object which will return you object of ExternalAccount PoJo. After getting object of ExternalAccount PoJo just use their getters to fetch all values you require - Varad Mondkar

1 Answers

0
votes

To get a specific key you can do:

object.get(index)

For exp_month, you would do object.get(16), for exp_year, you would do object.get(17) and for last4 you would do object.get(22)