2017-11-23 11 views
2

複数のソース(カード)を1つのユーザーオブジェクトに保存しようとしています。ストライプ - 複数のソースをユーザーに保存する

私はすでに顧客が1つのソースが保存されていると言います。私はその後、私はこれを行うと、次の

stripe.customers.update(customer, {source:call.request.source}, function(err, updatedCustomer){ 
    if(err){ 
     return console.log(err); 
    } 
    console.log(updatedCustomer.sources.data);  
}) 

は、顧客の既存のソースが失われない、新しいものが格納されている新しいソーストークンで

複数のソースを同じ顧客に保存するにはどうすればよいですか?

答えて

2

トリックを更新するのではなく、createSourceを使用します。

stripe.customers.createSource(customer, {source:call.request.source}, function(err, updatedCustomer){ 
    if(err){ 
    return console.log(err); 
    } 
    console.log(updatedCustomer.sources.data);  
}) 
0

これはあなたに役立ちます。

顧客=ストライプ:: Customer.retrieve(stripe_customer_id)

customer.sources.create(stripeToken)

ストライプトークンがstripe.jsを使用して生成されます。

関連する問題