我已经添加了条纹客户,我正在考虑向客户添加新卡。我四处搜寻,但找不到任何确定的内容可以回答以下问题。
以下是添加新卡的正确方法吗?
$customer = \Stripe\Customer::retrieve(Auth::user()->stripe_key);
// Got the customer details successfully from the above call.
$card = $customer->cards->create(
array(
"card" =>
array(
"number"=> "4242424242424242",
"exp_month" => "12",
"exp_year" => "2016",
"cvc" => "123"
)
)
);
答案 0 :(得分:1)
Stripe没有专门用于向客户添加新卡的直接表单,但是您可以使用Checkout或Elements来收集客户的卡详细信息。
向客户添加新卡的过程如下:
$token = $_POST['stripeToken']; #for example
$customer = \Stripe\Customer::retrieve(Auth::user()->stripe_key);
$customer->sources->create(array("source" => $token));
[0]-https://stripe.com/docs/checkout或https://stripe.com/docs/stripe-js/elements/quickstart