2

我正在尝试在单个用户对象上存储多个源(卡)。

假设我有一个客户已经存储了一个源。

然后使用新的源令牌执行以下操作

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

当我这样做时,客户现有的源将丢失,新的源将被存储。

如何将多个来源存储在同一个客户身上?

4

2 回答 2

2

Using createSource rather than update done the trick.

stripe.customers.createSource(customer, {source:call.request.source}, function(err, updatedCustomer){
   if(err){
     return console.log(err);
   }
   console.log(updatedCustomer.sources.data);     
})
于 2017-11-23T14:51:05.030 回答
0

这对你有用。

客户 = Stripe::Customer.retrieve(stripe_customer_id)

customer.sources.create(stripeToken)

Stripe 令牌是使用 stripe.js 生成的。

于 2017-12-13T09:06:56.440 回答