【问题标题】:Get Card Information from Charge object in Stripe从 Stripe 中的 Charge 对象获取卡片信息
【发布时间】:2017-11-07 18:03:24
【问题描述】:

我已经在网站上集成了条带支付方式。我想获取卡信息。一切正常。付款成功后,我成功地从$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->card->address_country$charge 变量中获取卡信息,但没有任何解决方案。非常感谢您的帮助

【问题讨论】:

  • 感谢指正

标签: php stripe-payments stripe.js


【解决方案1】:

费用的支付来源在charge objectsource 属性中返回,因此您应该可以执行以下操作:

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

【讨论】:

  • Ywain 另一个我如何从$charge 获得卡的最后一位数字?
  • $card 将包含card object,因此您可以访问卡片对象的任何属性,例如last4.
  • 我如何从客户对象中获取信息,我试过$source=$customer->source$source->id,它不适合我,所以我厌倦了$customer['id'] 它工作正常,但现在我怎样才能获得卡来自$customer对象的信息。谢谢
猜你喜欢
  • 1970-01-01
  • 2019-10-28
  • 2019-03-20
  • 2021-03-16
  • 1970-01-01
  • 2018-12-04
  • 2020-03-28
  • 2018-04-25
  • 1970-01-01
相关资源
最近更新 更多