我有以下代码,使用Stripe处理用户信用卡上的费用。
// Create the charge on Stripe's servers - this will charge the user's card
try {
$charge = Stripe_Charge::create(array(
"amount" => $grandTotal, // amount in cents, again
"currency" => "usd",
"card" => $token,
"description" => "Candy Kingdom Order")
);
} catch(Stripe_CardError $e) {
// The card has been declined
}
现在,我希望能够显示在订单确认页面上使用的卡的最后4位数字。但我想以一种不存储完整卡号的方式来执行此操作。仅是最后4个。如果可能,我不确定如何检索此信息。请帮助?
最佳答案
API Documentation提供您正在寻找的答案。 $ charge-> card-> last4应该具有您要查找的值。以您的示例为例,以下方法将起作用:
$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;
} catch(Stripe_CardError $e) {
// The card has been declined
}
关于php - 成功完成Stripe付款后,获取信用卡的最后4位数字,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21493373/