pay 3.0.23 → 4.0.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 +1 -1
- data/app/controllers/pay/webhooks/braintree_controller.rb +1 -1
- data/app/controllers/pay/webhooks/paddle_controller.rb +1 -1
- data/app/controllers/pay/webhooks/stripe_controller.rb +1 -1
- data/app/jobs/pay/customer_sync_job.rb +1 -3
- data/app/mailers/pay/application_mailer.rb +1 -1
- data/app/mailers/pay/user_mailer.rb +3 -3
- data/app/models/pay/charge.rb +23 -0
- data/app/models/pay/customer.rb +2 -6
- data/app/models/pay/merchant.rb +6 -0
- data/app/models/pay/subscription.rb +35 -8
- data/app/views/pay/user_mailer/receipt.html.erb +6 -6
- data/app/views/pay/user_mailer/refund.html.erb +6 -6
- data/config/locales/en.yml +31 -24
- data/config/routes.rb +3 -3
- data/lib/pay/attributes.rb +28 -2
- data/lib/pay/billable/sync_customer.rb +3 -3
- data/lib/pay/braintree/billable.rb +61 -48
- data/lib/pay/braintree/subscription.rb +8 -3
- data/lib/pay/braintree/webhooks/subscription_canceled.rb +6 -1
- data/lib/pay/braintree/webhooks/subscription_charged_successfully.rb +2 -2
- data/lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb +1 -1
- data/lib/pay/braintree/webhooks/subscription_trial_ended.rb +1 -1
- data/lib/pay/braintree.rb +6 -2
- data/lib/pay/currency.rb +8 -2
- data/lib/pay/engine.rb +22 -4
- data/lib/pay/fake_processor/billable.rb +11 -8
- data/lib/pay/fake_processor/subscription.rb +11 -3
- data/lib/pay/paddle/billable.rb +0 -4
- data/lib/pay/paddle/subscription.rb +2 -2
- data/lib/pay/paddle/webhooks/signature_verifier.rb +45 -41
- data/lib/pay/paddle/webhooks/subscription_cancelled.rb +7 -2
- data/lib/pay/paddle/webhooks/subscription_payment_refunded.rb +3 -3
- data/lib/pay/paddle/webhooks/subscription_payment_succeeded.rb +7 -7
- data/lib/pay/paddle/webhooks/subscription_updated.rb +15 -15
- data/lib/pay/paddle.rb +14 -2
- data/lib/pay/receipts.rb +106 -32
- data/lib/pay/stripe/billable.rb +58 -21
- data/lib/pay/stripe/charge.rb +93 -11
- data/lib/pay/stripe/merchant.rb +1 -1
- data/lib/pay/stripe/subscription.rb +132 -30
- data/lib/pay/stripe/webhooks/charge_refunded.rb +2 -2
- data/lib/pay/stripe/webhooks/charge_succeeded.rb +2 -2
- data/lib/pay/stripe/webhooks/payment_action_required.rb +6 -6
- data/lib/pay/stripe/webhooks/subscription_renewing.rb +6 -10
- data/lib/pay/stripe/webhooks/subscription_updated.rb +1 -1
- data/lib/pay/stripe.rb +10 -1
- data/lib/pay/version.rb +1 -1
- data/lib/pay.rb +39 -4
- data/lib/tasks/pay.rake +1 -1
- metadata +3 -4
- data/lib/pay/merchant.rb +0 -37
data/lib/pay/stripe.rb
CHANGED
@@ -28,6 +28,12 @@ module Pay
|
|
28
28
|
|
29
29
|
extend Env
|
30
30
|
|
31
|
+
def self.enabled?
|
32
|
+
return false unless Pay.enabled_processors.include?(:stripe) && defined?(::Stripe)
|
33
|
+
|
34
|
+
Pay::Engine.version_matches?(required: "~> 6", current: ::Stripe::VERSION) || (raise "[Pay] stripe gem must be version ~> 6")
|
35
|
+
end
|
36
|
+
|
31
37
|
def self.setup
|
32
38
|
::Stripe.api_key = private_key
|
33
39
|
::Stripe.api_version = "2020-08-27"
|
@@ -35,7 +41,10 @@ module Pay
|
|
35
41
|
# Used by Stripe to identify Pay for support
|
36
42
|
::Stripe.set_app_info("PayRails", partner_id: "pp_partner_IqhY0UExnJYLxg", version: Pay::VERSION, url: "https://github.com/pay-rails/pay")
|
37
43
|
|
38
|
-
|
44
|
+
# Automatically retry requests that fail
|
45
|
+
# This automatically includes idempotency keys in the request to guarantee that retires are safe
|
46
|
+
# https://github.com/stripe/stripe-ruby#configuring-automatic-retries
|
47
|
+
::Stripe.max_network_retries = 2
|
39
48
|
end
|
40
49
|
|
41
50
|
def self.public_key
|
data/lib/pay/version.rb
CHANGED
data/lib/pay.rb
CHANGED
@@ -3,6 +3,8 @@ require "pay/engine"
|
|
3
3
|
require "pay/errors"
|
4
4
|
require "pay/adapter"
|
5
5
|
|
6
|
+
require "active_support/dependencies"
|
7
|
+
|
6
8
|
module Pay
|
7
9
|
autoload :Attributes, "pay/attributes"
|
8
10
|
autoload :Env, "pay/env"
|
@@ -35,10 +37,6 @@ module Pay
|
|
35
37
|
mattr_accessor :business_logo
|
36
38
|
mattr_accessor :support_email
|
37
39
|
|
38
|
-
# Email configuration
|
39
|
-
mattr_accessor :send_emails
|
40
|
-
@@send_emails = true
|
41
|
-
|
42
40
|
mattr_accessor :automount_routes
|
43
41
|
@@automount_routes = true
|
44
42
|
|
@@ -51,7 +49,44 @@ module Pay
|
|
51
49
|
mattr_accessor :routes_path
|
52
50
|
@@routes_path = "/pay"
|
53
51
|
|
52
|
+
mattr_accessor :enabled_processors
|
53
|
+
@@enabled_processors = [:stripe, :braintree, :paddle]
|
54
|
+
|
55
|
+
mattr_accessor :emails
|
56
|
+
@@emails = ActiveSupport::OrderedOptions.new
|
57
|
+
@@emails.payment_action_required = true
|
58
|
+
@@emails.receipt = true
|
59
|
+
@@emails.refund = true
|
60
|
+
# This only applies to Stripe, therefor we supply the second argument of price
|
61
|
+
@@emails.subscription_renewing = ->(pay_subscription, price) {
|
62
|
+
(price&.type == "recurring") && (price.recurring&.interval == "year")
|
63
|
+
}
|
64
|
+
|
65
|
+
@@mailer = "Pay::UserMailer"
|
66
|
+
|
67
|
+
def self.mailer=(value)
|
68
|
+
@@mailer = value
|
69
|
+
@@mailer_ref = nil
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.mailer
|
73
|
+
@@mailer_ref ||= @@mailer&.constantize
|
74
|
+
end
|
75
|
+
|
76
|
+
mattr_accessor :parent_mailer
|
77
|
+
@@parent_mailer = "Pay::ApplicationMailer"
|
78
|
+
|
54
79
|
def self.setup
|
55
80
|
yield self
|
56
81
|
end
|
82
|
+
|
83
|
+
def self.send_email?(email_option, *remaining_args)
|
84
|
+
config_option = emails.send(email_option)
|
85
|
+
|
86
|
+
if config_option.respond_to?(:call)
|
87
|
+
config_option.call(*remaining_args)
|
88
|
+
else
|
89
|
+
config_option
|
90
|
+
end
|
91
|
+
end
|
57
92
|
end
|
data/lib/tasks/pay.rake
CHANGED
@@ -21,7 +21,7 @@ def sync_default_payment_method(pay_customer, retries: 2)
|
|
21
21
|
payment_method_id = pay_customer.customer.invoice_settings.default_payment_method
|
22
22
|
Pay::Stripe::PaymentMethod.sync(payment_method_id) if payment_method_id
|
23
23
|
when "paddle"
|
24
|
-
Pay::Paddle::PaymentMethod.sync(pay_customer)
|
24
|
+
Pay::Paddle::PaymentMethod.sync(pay_customer: pay_customer)
|
25
25
|
end
|
26
26
|
rescue
|
27
27
|
sleep 0.5
|
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:
|
4
|
+
version: 4.0.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:
|
12
|
+
date: 2022-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -153,7 +153,6 @@ files:
|
|
153
153
|
- lib/pay/fake_processor/error.rb
|
154
154
|
- lib/pay/fake_processor/payment_method.rb
|
155
155
|
- lib/pay/fake_processor/subscription.rb
|
156
|
-
- lib/pay/merchant.rb
|
157
156
|
- lib/pay/nano_id.rb
|
158
157
|
- lib/pay/paddle.rb
|
159
158
|
- lib/pay/paddle/billable.rb
|
@@ -217,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
216
|
- !ruby/object:Gem::Version
|
218
217
|
version: '0'
|
219
218
|
requirements: []
|
220
|
-
rubygems_version: 3.
|
219
|
+
rubygems_version: 3.3.7
|
221
220
|
signing_key:
|
222
221
|
specification_version: 4
|
223
222
|
summary: Payments engine for Ruby on Rails
|
data/lib/pay/merchant.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module Pay
|
2
|
-
module Merchant
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
# Keep track of which Merchant models we have
|
6
|
-
class << self
|
7
|
-
attr_reader :includers
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.included(base = nil, &block)
|
11
|
-
@includers ||= []
|
12
|
-
@includers << base if base
|
13
|
-
super
|
14
|
-
end
|
15
|
-
|
16
|
-
included do
|
17
|
-
store_accessor :pay_data, :stripe_connect_account_id
|
18
|
-
store_accessor :pay_data, :onboarding_complete
|
19
|
-
end
|
20
|
-
|
21
|
-
def merchant
|
22
|
-
@merchant ||= merchant_processor_for(merchant_processor).new(self)
|
23
|
-
end
|
24
|
-
|
25
|
-
def merchant_processor_for(name)
|
26
|
-
"Pay::#{name.to_s.classify}::Merchant".constantize
|
27
|
-
end
|
28
|
-
|
29
|
-
def stripe_connect_account_id?
|
30
|
-
!!stripe_connect_account_id
|
31
|
-
end
|
32
|
-
|
33
|
-
def onboarding_complete?
|
34
|
-
!!onboarding_complete
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|