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

时间:2014-05-30 14:20:36

标签: php stripe-payments

我有以下代码为客户添加卡,该卡工作正常并遵循条带API。但是我需要检索刚进入的那个的cardid。创建客户时,我可以使用expand方法,但不确定添加卡方法吗?

// 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;

1 个答案:

答案 0 :(得分:1)

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

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