Mehul Patel Mehul Patel - 8 days ago 12
Android Question

Stripe Card id using token in Android

I am integrating Stripe Payment module in my application. In that I use this Stripe Library.
Now using this code I generating token. Using this token I need card

id
before payment
.

How to get this card id'. ?


Here I show you response of Stripe.

When I enter Card Information about the card Like this :

Stripe_Token::create(array(
"card" => array(
"number" => "4242424242424242",
"exp_month" => 8,
"exp_year" => 2015,
"cvc" => "314"
)
));


After that Stripe give me this response :

{
"id": "tok_14WdJ02eZvKYlo2CyaZ49ZP7",
"livemode": false,
"created": 1409272314,
"used": false,
"object": "token",
"type": "card",
"card": {
"id": "card_14WdJ02eZvKYlo2C5nE5XjtP",
"object": "card",
"last4": "4242",
"brand": "Visa",
"funding": "credit",
"exp_month": 8,
"exp_year": 2015,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"country": "US",
"name": null,
"address_line1": null,
"address_line2": null,
"address_city": null,
"address_state": null,
"address_zip": null,
"address_country": null,
"customer": null
}
}


Before payment and after token created
I need this card id :


"card": {
"id": "card_14WdJ02eZvKYlo2C5nE5XjtP",
}


Hope you get my question.

Answer

After Generating token Use this...

Customer.all(new HashMap<String, Object>());

Using this finally i got Cardid which i want.

Here is the total response of Customer.

{
  "data": [
    com.stripe.model.Customer JSON: {
      "object": "customer",
      "created": 1410001523,
      "id": "cus_4j9JlwfZ5arO4M",
      "livemode": false,
      "description": null,
      "email": "customer@example.com",
      "delinquent": false,
      "metadata": {
      },
      "subscriptions": {
        "object": "list",
        "total_count": 0,
        "has_more": false,
        "url": "/v1/customers/cus_4j9JlwfZ5arO4M/subscriptions",
        "data": [

        ]
      },
      "discount": null,
      "account_balance": 0,
      "currency": "usd",
      "cards": {
        "object": "list",
        "total_count": 1,
        "has_more": false,
        "url": "/v1/customers/cus_4j9JlwfZ5arO4M/cards",
        "data": [
          {
            "id": "card_14Zh0M2eZvKYlo2CAl9gQ262",
            "object": "card",
            "last4": "4242",
            "brand": "Visa",
            "funding": "credit",
            "exp_month": 12,
            "exp_year": 2015,
            "fingerprint": "Xt5EWLLDS7FJjR1c",
            "country": "US",
            "name": "akinci_yasin@hotmail.com",
            "address_line1": null,
            "address_line2": null,
            "address_city": null,
            "address_state": null,
            "address_zip": null,
            "address_country": null,
            "cvc_check": null,
            "address_line1_check": null,
            "address_zip_check": null,
            "customer": "cus_4j9JlwfZ5arO4M"
          }
        ]
      },
      "default_card": "card_14Zh0M2eZvKYlo2CAl9gQ262"
    },
    #<com.stripe.model.Customer[...] ...>,
    #<com.stripe.model.Customer[...] ...>
  ],
  "has_more": false
}

Hope it may help for You. Thanks