pay 2.1.0 → 2.1.1

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: c17e00d646e15b10c34d222479c5dc636c36b7eb5caa52ef8783613234c71408
4
- data.tar.gz: 0f9eed7cf14a994b3aabbb45dbf635e297212a59d1e6ec6f30246f21de458b47
3
+ metadata.gz: 026eec665e0972815526e10a0f8082c9dc7de99c8df6dfe890aa34630f902828
4
+ data.tar.gz: 44a6a608fcc55f9d235191716b78a55b1d3f595e8e9233f630ecdd1b3ca0d3e8
5
5
  SHA512:
6
- metadata.gz: 362c0ba3348eb01c07e7965262bdcbf71c7c19a0e5287899d5821223bc20658e5cb088e480064f0efa3d44d5a16eb0f4eca74513ba89fb1f91f2c790f4068252
7
- data.tar.gz: e49bd76481889087ae37095717311a77662aa6c011e6bcd5d1b3c79917b6207f62074a6de07c19f579561d6d17fa86c0247d895b61f68bea71d18804a68edbe9
6
+ metadata.gz: cb4cf20991b9ff113c6cad8d86df842bae567c4dc24d0a0c8b862ef8430380d36adfda3dfaaceaa0f28e2b84904cd35ee832981ec3a71c822e0f00ac008a17ad
7
+ data.tar.gz: 507a29aa827680ffb1dc36cf66142ad94d96f8aa25ead267dfb96fbbda9e431687eae4d410bd6bf7f3ecf8bc07a4d8ca4bf05441795f657a10ba713470b3c1e8
data/README.md CHANGED
@@ -228,6 +228,9 @@ You may pass optional arguments that will be directly passed on to
228
228
  either Stripe or Braintree. You can use these options to charge
229
229
  different currencies, etc.
230
230
 
231
+ On failure, a `Pay::Error` will be raised with details about the payment
232
+ failure.
233
+
231
234
  #### Creating a Subscription
232
235
 
233
236
  ```ruby
data/lib/pay.rb CHANGED
@@ -102,6 +102,14 @@ module Pay
102
102
  class Error < StandardError
103
103
  end
104
104
 
105
+ class BraintreeError < Error
106
+ attr_reader :result
107
+
108
+ def initialize(result)
109
+ @result = result
110
+ end
111
+ end
112
+
105
113
  class InvalidPaymentMethod < Error
106
114
  attr_reader :payment
107
115
 
@@ -14,7 +14,7 @@ module Pay
14
14
  last_name: try(:last_name),
15
15
  payment_method_nonce: card_token
16
16
  )
17
- raise Pay::Error.new(result.message) unless result.success?
17
+ raise BraintreeError.new(result), result.message unless result.success?
18
18
 
19
19
  update(processor: "braintree", processor_id: result.customer.id)
20
20
 
@@ -25,7 +25,7 @@ module Pay
25
25
  result.customer
26
26
  end
27
27
  rescue ::Braintree::BraintreeError => e
28
- raise Error, e.message
28
+ raise BraintreeError, e.message
29
29
  end
30
30
 
31
31
  # Handles Billable#charge
@@ -39,9 +39,11 @@ module Pay
39
39
  }.merge(options)
40
40
 
41
41
  result = gateway.transaction.sale(args)
42
- save_braintree_transaction(result.transaction) if result.success?
43
- rescue ::BraintreeError => e
44
- raise Error, e.message
42
+ raise BraintreeError.new(result), result.message unless result.success?
43
+
44
+ save_braintree_transaction(result.transaction)
45
+ rescue ::Braintree::BraintreeError => e
46
+ raise BraintreeError, e.message
45
47
  end
46
48
 
47
49
  # Handles Billable#subscribe
@@ -62,11 +64,11 @@ module Pay
62
64
  )
63
65
 
64
66
  result = gateway.subscription.create(subscription_options)
65
- raise Pay::Error.new(result.message) unless result.success?
67
+ raise BraintreeError.new(result), result.message unless result.success?
66
68
 
67
69
  create_subscription(result.subscription, "braintree", name, plan, status: :active)
68
70
  rescue ::Braintree::BraintreeError => e
69
- raise Error, e.message
71
+ raise BraintreeError, e.message
70
72
  end
71
73
 
72
74
  # Handles Billable#update_card
@@ -81,13 +83,13 @@ module Pay
81
83
  verify_card: true
82
84
  }
83
85
  )
84
- raise Pay::Error.new(result.message) unless result.success?
86
+ raise BraintreeError.new(result), result.message unless result.success?
85
87
 
86
88
  update_braintree_card_on_file result.payment_method
87
89
  update_subscriptions_to_payment_method(result.payment_method.token)
88
90
  true
89
91
  rescue ::Braintree::BraintreeError => e
90
- raise Error, e.message
92
+ raise BraintreeError, e.message
91
93
  end
92
94
 
93
95
  def update_braintree_email!
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
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.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-26 00:00:00.000000000 Z
12
+ date: 2020-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails