0

I have integrated stripe payment method in website . I want to get Card Information. Everything is work fine .After successful payment i successfully retrived payment id from $charge->id variable .So my question is that when i print_r($charge) it also show Card Object Something like That

 Stripe_Card Object ( [_apiKey:protected] => sk_test_...                       
 [_values:protected] => Array ( [id] => card_1BLSPnJ6IzxnlSnmegEq6dbH 
[object] => card [address_city] => Lahire [address_country] => Pakistan

my stripe process

$customer =Stripe_Customer::create(array(
'email' => $_GET['email'],));
$charge = Stripe_Charge::create(array(       
"amount" => $amount_cents,"currency" => "usd","source" => 
$_POST['stripeToken'],"description" => $description,      
 )              
 );

I try many times to get card information from $charge variable using $charge->card->address_country But not work any solution .Your help would be greatly appreciated

Ywain
  • 16,854
  • 4
  • 51
  • 67
Hashaam
  • 125
  • 1
  • 14

1 Answers1

1

The payment source of a charge is returned in the source attribute of the charge object, so you should be able to do something like this:

$card = $charge->source;
// Do something with $card, e.g. access the billing address' country
// with $card->address_country
Ywain
  • 16,854
  • 4
  • 51
  • 67
  • 1
    Ywain another how do i get last digit of card from `$charge` ? – Hashaam Nov 07 '17 at 11:24
  • 2
    `$card` will contain a [card object](https://stripe.com/docs/api#card_object), so you access any attribute of a card object, e.g. [`last4`](https://stripe.com/docs/api#card_object-last4). – Ywain Nov 07 '17 at 12:29
  • how can i get information from customer object , i tried `$source=$customer->source` , `$source->id` , it not work for me ,so i tired `$customer['id']` its work fine , but now how can i get card information from `$customer` object .Thanks – Hashaam Nov 08 '17 at 07:48