Php 成功付款后获取信用卡的最后4位数字
我有下面的代码,它使用Stripe处理用户信用卡上的费用Php 成功付款后获取信用卡的最后4位数字,php,stripe-payments,Php,Stripe Payments,我有下面的代码,它使用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" =&g
// 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个。如果可能的话,我不知道如何检索这些信息。请帮忙?有你想要的答案$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
}
您不知道如何将任何数据拉入
substr($cardNumber,-4)代码>现在是$charge->source->last4