Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stripe - No way to add new card for existing customer #3136

Open
ravindra9278 opened this issue Feb 5, 2019 · 2 comments
Open

Stripe - No way to add new card for existing customer #3136

ravindra9278 opened this issue Feb 5, 2019 · 2 comments

Comments

@ravindra9278
Copy link

Here I am trying to add new card to the customer but there is no way to add it. As per your documentation we have two methods to update customer details one is
#update_customer(customer_id, options = {}) ⇒ Object and
#update(customer_id, card_id, options = {}) ⇒ Object.

But here if I have new card then I don't have card_id for that so second method will not work.

params = {
  login: 'sk_test_abcdes'
}
stripe_gateway ||= ActiveMerchant::Billing::StripeGateway.new params

c = stripe_gateway.store 'tok_es', email: "[email protected]", set_default: true ==> Create new customer: (this will create new customer and set default card details to this customer)

stripe_gateway.update_customer(cust_id, default_source: token) ==>
Update default card details: (This will delete the old default card and update new card details)

stripe_gateway.update(cust_id, card_id) ==>
This will update customer with default card_id

So now I need to add normal card not default card then how can I manage this?

If you will see Stripe documentation

require "stripe"
Stripe.api_key = "sk_test_PhiY7wyjq6vCW7GkY71Xb8Ae"

customer = Stripe::Customer.retrieve("cus_ETJQy9LPoLMOJL")
customer.sources.create(source: "tok_amex")
@mengqing
Copy link
Contributor

mengqing commented Apr 10, 2019

I believe you can add a new card to an existing customer by using the store method, and pass the customer_id as an option.

https://github.com/activemerchant/active_merchant/blob/master/lib/active_merchant/billing/gateways/stripe.rb#L189

  ActiveMerchant::Billing::StripeGateway.store(credit_card, customer: customer_id)

@curiousepic
Copy link
Contributor

Marking this "of interest" before a cleanup of stale issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants