从Stripe中的Charge对象获取卡信息

时间:2017-11-07 09:45:28

标签: php stripe-payments stripe.js

我在网站上集成了条纹支付方式。我想获得卡信息。一切都工作正常。成功付款后,我成功从$charge->id变量中重新获得了付款ID。所以我的问题是当我print_r($charge)它还显示卡片对象时那样的东西

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

我的条纹过程

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

我尝试多次使用$charge$charge->card->address_country变量获取信息卡信息但不能解决任何问题。非常感谢您的帮助

1 个答案:

答案 0 :(得分:1)

费用的付款来源会在sourcecharge object属性中返回,因此您应该可以执行以下操作:

$card = $charge->source;
// Do something with $card, e.g. access the billing address' country
// with $card->address_country