[英]Stripe : New customer created even when customer_id is not empty?
[英]Stripe : Add new card to already created customer
我已經添加了條紋客戶,我正在考慮向客戶添加新卡。 我四處搜尋,但找不到任何確定的答案來回答我的以下問題。
以下是添加新卡的正確方法嗎?
$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" ) ) );
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.