pay 2.1.2 → 2.1.3
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 +7 -0
- data/Rakefile +13 -13
- data/app/mailers/pay/user_mailer.rb +2 -2
- data/lib/pay.rb +7 -1
- data/lib/pay/braintree/billable.rb +8 -0
- data/lib/pay/stripe/billable.rb +3 -2
- data/lib/pay/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 883c55bf9abc32584d98fe56c9a710e92906bebc5322b1ec9ed9dadf92fcd9dc
|
4
|
+
data.tar.gz: da1849f216e7d5e3a8365b3427a4bebf914d51e1c41e9736bc3b8df726f58ef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab3d62146de9a533a9598e0d87970a019f8b23646a92110c3d62ef64ec8385c2158c7435c7b255648faa4740360634f59d5b3a16f95c44347e7aeedc004f9674
|
7
|
+
data.tar.gz: 598d32db66f8fd5b43cfb27766826223d4a7dd80c73204e23e6a5bb36783775f8c521d8682e4c466f059e6f71541b8c799cfed5bab1330fc4992901c06cb62cc
|
data/README.md
CHANGED
@@ -237,6 +237,13 @@ def subscribe(name: 'default', plan: 'default', **options)
|
|
237
237
|
end
|
238
238
|
```
|
239
239
|
|
240
|
+
For example, you can pass the `quantity` option to subscribe to a plan with for per-seat pricing.
|
241
|
+
|
242
|
+
```ruby
|
243
|
+
|
244
|
+
user.subscribe(name: "default", plan: "default", quantity: 3)
|
245
|
+
```
|
246
|
+
|
240
247
|
##### Name
|
241
248
|
|
242
249
|
Name is an internally used name for the subscription.
|
data/Rakefile
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require "bundler/setup"
|
3
3
|
rescue LoadError
|
4
|
-
puts
|
4
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
5
5
|
end
|
6
6
|
|
7
|
-
require
|
7
|
+
require "rdoc/task"
|
8
8
|
|
9
9
|
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir =
|
11
|
-
rdoc.title
|
12
|
-
rdoc.options <<
|
13
|
-
rdoc.rdoc_files.include(
|
14
|
-
rdoc.rdoc_files.include(
|
10
|
+
rdoc.rdoc_dir = "rdoc"
|
11
|
+
rdoc.title = "Pay"
|
12
|
+
rdoc.options << "--line-numbers"
|
13
|
+
rdoc.rdoc_files.include("README.md")
|
14
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
15
15
|
end
|
16
16
|
|
17
17
|
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
18
|
-
load
|
18
|
+
load "rails/tasks/engine.rake"
|
19
19
|
|
20
|
-
load
|
20
|
+
load "rails/tasks/statistics.rake"
|
21
21
|
|
22
22
|
unless Rails.env.test?
|
23
23
|
require "bundler/gem_tasks"
|
24
24
|
end
|
25
25
|
|
26
|
-
require
|
26
|
+
require "rake/testtask"
|
27
27
|
|
28
28
|
Rake::TestTask.new(:test) do |t|
|
29
|
-
t.libs <<
|
30
|
-
t.pattern =
|
29
|
+
t.libs << "test"
|
30
|
+
t.pattern = "test/**/*_test.rb"
|
31
31
|
t.verbose = false
|
32
32
|
end
|
33
33
|
|
data/lib/pay.rb
CHANGED
@@ -105,11 +105,17 @@ module Pay
|
|
105
105
|
class BraintreeError < Error
|
106
106
|
attr_reader :result
|
107
107
|
|
108
|
-
def initialize(result)
|
108
|
+
def initialize(result=nil)
|
109
109
|
@result = result
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
+
class BraintreeAuthorizationError < BraintreeError
|
114
|
+
def message
|
115
|
+
"Either the data you submitted is malformed and does not match the API or the API key you used may not be authorized to perform this action."
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
113
119
|
class InvalidPaymentMethod < Error
|
114
120
|
attr_reader :payment
|
115
121
|
|
@@ -24,6 +24,8 @@ module Pay
|
|
24
24
|
|
25
25
|
result.customer
|
26
26
|
end
|
27
|
+
rescue ::Braintree::AuthorizationError => e
|
28
|
+
raise BraintreeAuthorizationError
|
27
29
|
rescue ::Braintree::BraintreeError => e
|
28
30
|
raise BraintreeError, e.message
|
29
31
|
end
|
@@ -42,6 +44,8 @@ module Pay
|
|
42
44
|
raise BraintreeError.new(result), result.message unless result.success?
|
43
45
|
|
44
46
|
save_braintree_transaction(result.transaction)
|
47
|
+
rescue ::Braintree::AuthorizationError => e
|
48
|
+
raise BraintreeAuthorizationError
|
45
49
|
rescue ::Braintree::BraintreeError => e
|
46
50
|
raise BraintreeError, e.message
|
47
51
|
end
|
@@ -67,6 +71,8 @@ module Pay
|
|
67
71
|
raise BraintreeError.new(result), result.message unless result.success?
|
68
72
|
|
69
73
|
create_subscription(result.subscription, "braintree", name, plan, status: :active)
|
74
|
+
rescue ::Braintree::AuthorizationError => e
|
75
|
+
raise BraintreeAuthorizationError
|
70
76
|
rescue ::Braintree::BraintreeError => e
|
71
77
|
raise BraintreeError, e.message
|
72
78
|
end
|
@@ -88,6 +94,8 @@ module Pay
|
|
88
94
|
update_braintree_card_on_file result.payment_method
|
89
95
|
update_subscriptions_to_payment_method(result.payment_method.token)
|
90
96
|
true
|
97
|
+
rescue ::Braintree::AuthorizationError => e
|
98
|
+
raise BraintreeAuthorizationError
|
91
99
|
rescue ::Braintree::BraintreeError => e
|
92
100
|
raise BraintreeError, e.message
|
93
101
|
end
|
data/lib/pay/stripe/billable.rb
CHANGED
@@ -48,9 +48,10 @@ module Pay
|
|
48
48
|
#
|
49
49
|
# Returns Pay::Subscription
|
50
50
|
def create_stripe_subscription(name, plan, options = {})
|
51
|
+
quantity = options.delete(:quantity) || 1
|
51
52
|
opts = {
|
52
53
|
expand: ["pending_setup_intent", "latest_invoice.payment_intent"],
|
53
|
-
items: [plan: plan],
|
54
|
+
items: [plan: plan, quantity: quantity],
|
54
55
|
off_session: true
|
55
56
|
}.merge(options)
|
56
57
|
|
@@ -58,7 +59,7 @@ module Pay
|
|
58
59
|
opts[:trial_from_plan] = true unless opts[:trial_period_days]
|
59
60
|
|
60
61
|
stripe_sub = customer.subscriptions.create(opts)
|
61
|
-
subscription = create_subscription(stripe_sub, "stripe", name, plan, status: stripe_sub.status)
|
62
|
+
subscription = create_subscription(stripe_sub, "stripe", name, plan, status: stripe_sub.status, quantity: quantity)
|
62
63
|
|
63
64
|
# No trial, card requires SCA
|
64
65
|
if subscription.incomplete?
|
data/lib/pay/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Charnes
|
8
8
|
- Chris Oliver
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-06-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -258,7 +258,7 @@ homepage: https://github.com/jasoncharnes/pay
|
|
258
258
|
licenses:
|
259
259
|
- MIT
|
260
260
|
metadata: {}
|
261
|
-
post_install_message:
|
261
|
+
post_install_message:
|
262
262
|
rdoc_options: []
|
263
263
|
require_paths:
|
264
264
|
- lib
|
@@ -273,8 +273,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
273
|
- !ruby/object:Gem::Version
|
274
274
|
version: '0'
|
275
275
|
requirements: []
|
276
|
-
rubygems_version: 3.1.
|
277
|
-
signing_key:
|
276
|
+
rubygems_version: 3.1.4
|
277
|
+
signing_key:
|
278
278
|
specification_version: 4
|
279
279
|
summary: A Ruby on Rails subscription engine.
|
280
280
|
test_files: []
|