Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
Stripe /cards endpoint does not update a customer.
Browse files Browse the repository at this point in the history
  • Loading branch information
michelle committed Dec 31, 2013
1 parent 245322e commit 82c7254
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/active_merchant/billing/gateways/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,26 @@ def refund_application_fee(money, identification, options = {})
# Note: creating a new credit card will not change the customer's existing default credit card (use :set_default => true)
def store(creditcard, options = {})
post = {}
add_creditcard(post, creditcard, options)
post[:description] = options[:description]
post[:email] = options[:email]
card_params = {}
add_creditcard(card_params, creditcard, options)
post[:description] = options[:description] if options[:description]
post[:email] = options[:email] if options[:email]

if options[:customer]
MultiResponse.run(:first) do |r|
r.process { commit(:post, "customers/#{CGI.escape(options[:customer])}/cards", post, options) }
# The /cards endpoint does not update other customer parameters.
r.process { commit(:post, "customers/#{CGI.escape(options[:customer])}/cards", card_params, options) }

return r unless options[:set_default] and r.success? and !r.params["id"].blank?
if options[:set_default] and r.success? and !r.params['id'].blank?
post[:default_card] = r.params['id']
end

r.process { update_customer(options[:customer], :default_card => r.params["id"]) }
if post.count > 0
r.process { update_customer(options[:customer], post) }
end
end
else
commit(:post, 'customers', post, options)
commit(:post, 'customers', post.merge(card_params), options)
end
end

Expand Down

0 comments on commit 82c7254

Please sign in to comment.