【发布时间】:2015-08-07 10:44:00
【问题描述】:
我想使用 Stripe 获取客户卡的最后 4 位数字。 我已经使用以下方式存储了客户:
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create a Customer
$StripeCustomer = \Stripe\Customer::create(array(
"description" => "$username",
"card" => $token
));
现在我想访问并存储卡的最后 4 位数字。 (就上下文而言,我想向用户展示他们使用 Stripe 存储了哪些卡以供将来付款 - 这不是订阅服务)。
我已经搜索了一个解决方案,但是很多帖子都在收费后保存最后 4 位数字,并从收费中提取信息,例如:
$last4 = null;
try {
$charge = Stripe_Charge::create(array(
"amount" => $grandTotal, // amount in cents, again
"currency" => "usd",
"card" => $token,
"description" => "Candy Kingdom Order")
);
$last4 = $charge->card->last4;
我想在收费之前做同样的事情,所以我想从客户对象中提取最后 4 个。 Stripe API 文档显示了来自客户的 last4 的属性路径,customer->sources->data->last4
但是,这似乎没有给我正确的最后 4 位数字。$last4 = $StripeCustomer->sources->data->last4;
我想我误解了如何在 Stripe API 中使用属性。有人能指出我正确的方向吗?
【问题讨论】:
标签: php stripe-payments