pay 2.6.8 → 2.6.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pay might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2e815585d6d3e171b89f184781db67eafddbd7d10ec8e5635b1d6e53b6475ab
4
- data.tar.gz: 178f9466b98867c2bbaaa16047f78d5a55f35f4056bc964cd39d9bc29023c1d6
3
+ metadata.gz: 1f949f6c58c035891245506ba0da8f891a7bdf3a45f6ba25c84b3189908967e2
4
+ data.tar.gz: 103ce517061db04dadfd0221b064da6045e86a11bc64a9b0ec55d76b316ad98a
5
5
  SHA512:
6
- metadata.gz: fb149c7f58a970019d4f65aa1d461e62bbc3d58a8478f715d9f8f3b858accaa6b9d12e951ea159472bc087635040601ab95d3a270bc9f544c777951f6964e513
7
- data.tar.gz: efb10c4e80ea59dda1b0f9d24a835dcbfebb91feb13a0e882b9acf0ca6d446d1930369c922ef5353562bdf1c7690a5702f6ea81b27a667743fccadcaa2d541ca
6
+ metadata.gz: c28e3d599a33bbe368502ac1ffbefad92ebaa36eea88915c87dd4343365a71cdc15e26a3e6d2fd7d02a6f2525635feb80a3e4f84c421fcd02f798151f6e0438e
7
+ data.tar.gz: e959cec2e79585142b6cc0f3a69cb4491dba516113591cfc62c904d2dbff283dbd9e7295b052dc31c7ac4ee29f17781a8bcc731971a41b1bfa1f06d205bd35b7
@@ -19,7 +19,9 @@ module Pay
19
19
  # Returns Braintree::Customer
20
20
  def customer
21
21
  if processor_id?
22
- gateway.customer.find(processor_id)
22
+ customer = gateway.customer.find(processor_id)
23
+ update_card card_token if card_token.present?
24
+ customer
23
25
  else
24
26
  result = gateway.customer.create(
25
27
  email: email,
@@ -26,23 +26,22 @@ module Pay
26
26
  #
27
27
  # Returns Stripe::Customer
28
28
  def customer
29
- if processor_id?
29
+ stripe_customer = if processor_id?
30
30
  ::Stripe::Customer.retrieve(processor_id)
31
31
  else
32
- stripe_customer = ::Stripe::Customer.create(email: email, name: customer_name)
33
- billable.update(processor: :stripe, processor_id: stripe_customer.id)
34
-
35
- # Update the user's card on file if a token was passed in
36
- if card_token.present?
37
- payment_method = ::Stripe::PaymentMethod.attach(card_token, {customer: stripe_customer.id})
38
- stripe_customer.invoice_settings.default_payment_method = payment_method.id
39
- stripe_customer.save
40
-
41
- update_card_on_file ::Stripe::PaymentMethod.retrieve(card_token).card
42
- end
32
+ sc = ::Stripe::Customer.create(email: email, name: customer_name)
33
+ billable.update(processor: :stripe, processor_id: sc.id)
34
+ sc
35
+ end
43
36
 
44
- stripe_customer
37
+ # Update the user's card on file if a token was passed in
38
+ if card_token.present?
39
+ payment_method = ::Stripe::PaymentMethod.attach(card_token, customer: stripe_customer.id)
40
+ stripe_customer = ::Stripe::Customer.update(stripe_customer.id, invoice_settings: {default_payment_method: payment_method.id})
41
+ update_card_on_file(payment_method.card)
45
42
  end
43
+
44
+ stripe_customer
46
45
  rescue ::Stripe::StripeError => e
47
46
  raise Pay::Stripe::Error, e
48
47
  end
@@ -84,6 +83,7 @@ module Pay
84
83
  # Inherit trial from plan unless trial override was specified
85
84
  opts[:trial_from_plan] = true unless opts[:trial_period_days]
86
85
 
86
+ # Load the Stripe customer to verify it exists and update card if needed
87
87
  opts[:customer] = customer.id
88
88
 
89
89
  stripe_sub = ::Stripe::Subscription.create(opts)
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "2.6.8"
2
+ VERSION = "2.6.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.8
4
+ version: 2.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes