簡體   English   中英

條紋:將新卡添加到已創建的客戶

[英]Stripe : Add new card to already created customer

我已經添加了條紋客戶,我正在考慮向客戶添加新卡。 我四處搜尋,但找不到任何確定的答案來回答我的以下問題。

  1. 條紋是否有自己的形式添加新卡?
  2. 以下是添加新卡的正確方法嗎?

     $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來收集客戶的卡詳細信息。

向客戶添加新卡的過程如下:

  1. 使用Checkout或Elements [0]收集並標記客戶卡的詳細信息。 這將為您提供代表卡的Stripe令牌。
  2. 將此令牌發送到您的后端,在這里您可以使用類似於以下代碼的方式將卡保存到客戶:
$token = $_POST['stripeToken']; #for example
$customer = \Stripe\Customer::retrieve(Auth::user()->stripe_key);
$customer->sources->create(array("source" => $token));

[0] -https://stripe.com/docs/checkouthttps://stripe.com/docs/stripe-js/elements/quickstart

[1] -https://stripe.com/docs/api/php#create_card

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM