我看过很多类似的帖子,但找不到能回答我问题的帖子。我能够检索现有客户及其卡,但无法弄清楚如何使用此方法创建令牌。我发现的所有示例都需要卡信息(例如卡号cvv等...),如果您通过API检索卡我无法访问。我确信它很简单,我很遗憾:
$customer = \Stripe\Customer::retrieve($customer_id);
$card = $customer->sources->retrieve($card_id);
$token = \Stripe\Token::create(array(
"card" => // What to put here???
)
);
答案 0 :(得分:-1)
正如@zico在评论中解释的那样,一旦您使用客户对象保存了卡片,就不需要创建新的令牌。您只需在customer
参数中传递客户的ID,并在source
参数中选择卡的ID(如果客户有多张卡,并且您想要为非默认卡充电)。
$charge = \Stripe\Charge::create(array(
"amount" => 400,
"currency" => "usd",
"customer" => "cus_...", // ID of the customer you want to charge
"source" => "card_...", // ID of the specific card, only needed if the customer has
// multiple cards and you want to charge a different
// card than the default one
));