Search code examples
stripe-paymentsstripe-connectstripe.js

Stripe - storing multiple sources on a user


I am trying to store multiple sources (cards) on a single user object.

Lets say I have a customer that already has one source stored.

With a new source token I then do the following

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

When I do this, the customers existing source is lost and the new one is stored.

How can I store multiple sources on the same customer??


Solution

  • 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);     
    })