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 +4 -4
- data/README.md +3 -0
- data/lib/pay.rb +8 -0
- data/lib/pay/braintree/billable.rb +11 -9
- data/lib/pay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 026eec665e0972815526e10a0f8082c9dc7de99c8df6dfe890aa34630f902828
|
4
|
+
data.tar.gz: 44a6a608fcc55f9d235191716b78a55b1d3f595e8e9233f630ecdd1b3ca0d3e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
-
|
43
|
-
|
44
|
-
|
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
|
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
|
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
|
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
|
92
|
+
raise BraintreeError, e.message
|
91
93
|
end
|
92
94
|
|
93
95
|
def update_braintree_email!
|
data/lib/pay/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2020-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|