pay 6.3.1 → 6.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/pay/payments_controller.rb +10 -1
- data/app/models/pay/customer.rb +0 -2
- data/app/models/pay/subscription.rb +5 -4
- data/app/views/pay/payments/show.html.erb +2 -2
- data/lib/pay/env.rb +8 -0
- data/lib/pay/fake_processor/billable.rb +5 -2
- data/lib/pay/version.rb +1 -1
- data/lib/pay.rb +6 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5edf40fbd4c73316121bba2d278819cac41f0f4bb6000bc8d216d000fcac59ff
|
4
|
+
data.tar.gz: b93a89d4c256ac814bc133f7b2b5071220187006623eeff76000c3a829780577
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e81185537e0d87f658fbf8a27b4e44f7d9942bef953a61ac8f94de2e005bd81625e43970a355fac38c27133f65e08f31067b4d5c62de7fe25bb05b1457d26538
|
7
|
+
data.tar.gz: 673fc7acfe41d96f3ef829279f89e4c9c831f6637ea57cd927acf40206fc1f42bd75b645ceb4b2a9b27cf29a91057c577b0c144408e739baa9d9bdea1c462d9c
|
@@ -2,9 +2,18 @@ module Pay
|
|
2
2
|
class PaymentsController < ApplicationController
|
3
3
|
layout "pay/application"
|
4
4
|
|
5
|
+
before_action :set_redirect_to
|
6
|
+
|
5
7
|
def show
|
6
|
-
@redirect_to = params[:back].presence || root_path
|
7
8
|
@payment = Payment.from_id(params[:id])
|
8
9
|
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# Ensure the back parameter is a valid path
|
14
|
+
# This safely handles XSS or external redirects
|
15
|
+
def set_redirect_to
|
16
|
+
@redirect_to = URI.parse(params[:back].to_s).path || root_path
|
17
|
+
end
|
9
18
|
end
|
10
19
|
end
|
data/app/models/pay/customer.rb
CHANGED
@@ -13,8 +13,6 @@ module Pay
|
|
13
13
|
validates :processor, presence: true
|
14
14
|
validates :processor_id, allow_blank: true, uniqueness: {scope: :processor, case_sensitive: true}
|
15
15
|
|
16
|
-
attribute :plan, :string
|
17
|
-
attribute :quantity, :integer
|
18
16
|
attribute :payment_method_token, :string
|
19
17
|
|
20
18
|
# Account(s) for marketplace payments
|
@@ -83,12 +83,13 @@ module Pay
|
|
83
83
|
trial_ends_at?
|
84
84
|
end
|
85
85
|
|
86
|
+
# Does not include the last second of the trial
|
86
87
|
def on_trial?
|
87
|
-
trial_ends_at? && trial_ends_at
|
88
|
+
trial_ends_at? && trial_ends_at > Time.current
|
88
89
|
end
|
89
90
|
|
90
91
|
def trial_ended?
|
91
|
-
trial_ends_at? && trial_ends_at
|
92
|
+
trial_ends_at? && trial_ends_at <= Time.current
|
92
93
|
end
|
93
94
|
|
94
95
|
def canceled?
|
@@ -100,11 +101,11 @@ module Pay
|
|
100
101
|
end
|
101
102
|
|
102
103
|
def ended?
|
103
|
-
ends_at? && Time.current
|
104
|
+
ends_at? && ends_at <= Time.current
|
104
105
|
end
|
105
106
|
|
106
107
|
def on_grace_period?
|
107
|
-
(ends_at? && Time.current
|
108
|
+
(ends_at? && ends_at > Time.current) ||
|
108
109
|
((status == "paused" || pause_behavior == "void") && will_pause?)
|
109
110
|
end
|
110
111
|
|
@@ -54,7 +54,7 @@
|
|
54
54
|
</div>
|
55
55
|
<% end %>
|
56
56
|
|
57
|
-
<%= link_to
|
57
|
+
<%= sanitize link_to(t("pay.back"), @redirect_to, class: "inline-block w-full px-4 py-3 bg-gray-100 hover:bg-gray-200 text-center text-gray-600 rounded-lg") %>
|
58
58
|
</div>
|
59
59
|
|
60
60
|
<p class="text-center text-gray-500 text-sm">
|
@@ -66,7 +66,7 @@
|
|
66
66
|
<script type="module">
|
67
67
|
window.stripe = Stripe('<%= Pay::Stripe.public_key %>');
|
68
68
|
|
69
|
-
import { Application, Controller } from 'https://
|
69
|
+
import { Application, Controller } from 'https://unpkg.com/@hotwired/stimulus'
|
70
70
|
const application = Application.start()
|
71
71
|
|
72
72
|
application.register('payment-intent', class extends Controller {
|
data/lib/pay/env.rb
CHANGED
@@ -11,6 +11,14 @@ module Pay
|
|
11
11
|
# 1. Check environment variable
|
12
12
|
# 2. Check environment scoped credentials, then secrets
|
13
13
|
# 3. Check unscoped credentials, then secrets
|
14
|
+
#
|
15
|
+
# For example, find_value_by_name("stripe", "private_key") will check the following in order until it finds a value:
|
16
|
+
#
|
17
|
+
# ENV["STRIPE_PRIVATE_KEY"]
|
18
|
+
# Rails.application.credentials.dig(:production, :stripe, :private_key)
|
19
|
+
# Rails.application.secrets.dig(:production, :stripe, :private_key)
|
20
|
+
# Rails.application.credentials.dig(:stripe, :private_key)
|
21
|
+
# Rails.application.secrets.dig(:stripe, :private_key)
|
14
22
|
def find_value_by_name(scope, name)
|
15
23
|
ENV["#{scope.upcase}_#{name.upcase}"] ||
|
16
24
|
credentials&.dig(env, scope, name) ||
|
@@ -19,8 +19,9 @@ module Pay
|
|
19
19
|
pay_customer
|
20
20
|
end
|
21
21
|
|
22
|
-
def update_customer!
|
23
|
-
#
|
22
|
+
def update_customer!(**attributes)
|
23
|
+
# return customer to fake an update
|
24
|
+
customer
|
24
25
|
end
|
25
26
|
|
26
27
|
def charge(amount, options = {})
|
@@ -56,6 +57,8 @@ module Pay
|
|
56
57
|
attributes[:trial_ends_at] = trial_period_days.to_i.days.from_now
|
57
58
|
end
|
58
59
|
|
60
|
+
attributes.delete(:promotion_code)
|
61
|
+
|
59
62
|
pay_customer.subscriptions.create!(attributes)
|
60
63
|
end
|
61
64
|
|
data/lib/pay/version.rb
CHANGED
data/lib/pay.rb
CHANGED
@@ -3,7 +3,8 @@ require "pay/engine"
|
|
3
3
|
require "pay/errors"
|
4
4
|
require "pay/adapter"
|
5
5
|
|
6
|
-
require "
|
6
|
+
require "action_mailer"
|
7
|
+
require "active_support"
|
7
8
|
|
8
9
|
module Pay
|
9
10
|
autoload :Attributes, "pay/attributes"
|
@@ -38,7 +39,7 @@ module Pay
|
|
38
39
|
mattr_accessor :support_email
|
39
40
|
|
40
41
|
def self.support_email=(value)
|
41
|
-
@@support_email = value.is_a?(Mail::Address) ? value : Mail::Address.new(value)
|
42
|
+
@@support_email = value.is_a?(::Mail::Address) ? value : ::Mail::Address.new(value)
|
42
43
|
end
|
43
44
|
|
44
45
|
mattr_accessor :automount_routes
|
@@ -95,10 +96,10 @@ module Pay
|
|
95
96
|
# Should return String or Array of email recipients
|
96
97
|
mattr_accessor :mail_to
|
97
98
|
@@mail_to = -> {
|
98
|
-
if ActionMailer::Base.respond_to?(:email_address_with_name)
|
99
|
-
ActionMailer::Base.email_address_with_name(params[:pay_customer].email, params[:pay_customer].customer_name)
|
99
|
+
if ::ActionMailer::Base.respond_to?(:email_address_with_name)
|
100
|
+
::ActionMailer::Base.email_address_with_name(params[:pay_customer].email, params[:pay_customer].customer_name)
|
100
101
|
else
|
101
|
-
Mail::Address.new.tap do |builder|
|
102
|
+
::Mail::Address.new.tap do |builder|
|
102
103
|
builder.address = params[:pay_customer].email
|
103
104
|
builder.display_name = params[:pay_customer].customer_name.presence
|
104
105
|
end.to_s
|
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: 6.3.
|
4
|
+
version: 6.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Charnes
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
rubygems_version: 3.4.
|
171
|
+
rubygems_version: 3.4.12
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Payments engine for Ruby on Rails
|