检索添加到条带客户的最后一张卡的卡片


retrieve the cardid of last card added to stripe customer

我有以下代码为客户添加一张卡,它工作良好,并遵循条纹API。但是我需要找回我刚输入的那张卡。创建客户时,我可以使用扩展方法,但不确定是否使用添加卡方法?

// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Add a Card
$cu = Stripe_Customer::retrieve( $consumerCCID );
$cu->cards->create(array("card" => $token));
$defcard = $cu->card->id;
$last4 = $cu->card->last4;
$cardtype = $cu->card->type;
$expmonth = $cu->card->exp_month;
$expyear = $cu->card->exp_year;

Stripe的库返回修改或创建的对象。如果你想要那个对象,就不要丢弃它:

$new_card = $cu->cards->create(array("card" => $token));