pay 3.0.18 → 3.0.22
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/app/jobs/pay/customer_sync_job.rb +1 -1
- data/app/views/pay/payments/show.html.erb +1 -1
- data/app/views/pay/user_mailer/receipt.html.erb +1 -1
- data/app/views/pay/user_mailer/refund.html.erb +1 -1
- data/lib/pay/braintree/billable.rb +9 -1
- data/lib/pay/fake_processor/billable.rb +4 -0
- data/lib/pay/paddle/billable.rb +4 -0
- data/lib/pay/paddle/subscription.rb +9 -2
- data/lib/pay/receipts.rb +2 -2
- data/lib/pay/stripe/billable.rb +6 -0
- data/lib/pay/version.rb +1 -1
- metadata +2 -9
- data/lib/generators/active_record/billable_generator.rb +0 -44
- data/lib/generators/active_record/merchant_generator.rb +0 -44
- data/lib/generators/active_record/templates/billable_migration.rb +0 -17
- data/lib/generators/active_record/templates/merchant_migration.rb +0 -12
- data/lib/generators/pay/billable_generator.rb +0 -17
- data/lib/generators/pay/merchant_generator.rb +0 -17
- data/lib/generators/pay/orm_helpers.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dfae5ada22ac1b2cecc080e154223aed66740ce53327fcaf012fa28ed2e6580
|
4
|
+
data.tar.gz: cfdf57b6ee3c1e011a67bf67923d55ca8da9bb6b0cffa8334af4713296aac33c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbe399383317007d063340568d983e7fcdc928f352ccfe3126ea2ec686e5c7ed96978ba576af9774226d1c702e4b4f8c2c3dee6cb8be0e5d823f2a267bfff3a2
|
7
|
+
data.tar.gz: 00eb2d8b09de4457a7aa3fe861e393b212d87ad74065817a4fffe53f04eb6e6fc05ba9d4d7bb6ed8a483a01c8f3334f438ecd4cc75d93c1e03e3f6b682400861
|
@@ -5,7 +5,7 @@ module Pay
|
|
5
5
|
def perform(pay_customer_id)
|
6
6
|
Pay::Customer.find(pay_customer_id).update_customer!
|
7
7
|
rescue ActiveRecord::RecordNotFound
|
8
|
-
Rails.logger.info "Couldn't find a
|
8
|
+
Rails.logger.info "Couldn't find a Pay::Customer with ID = #{id}"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -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://cdn.skypack.dev/stimulus'
|
69
|
+
import { Application, Controller } from 'https://cdn.skypack.dev/@hotwired/stimulus'
|
70
70
|
const application = Application.start()
|
71
71
|
|
72
72
|
application.register('payment-intent', class extends Controller {
|
@@ -10,7 +10,7 @@ Amount: <%= params[:charge].amount_with_currency %><br/>
|
|
10
10
|
Charged to: <%= params[:charge].charged_to %><br/>
|
11
11
|
Transaction ID: <%= params[:charge].id %><br/>
|
12
12
|
Date: <%= params[:charge].created_at %><br/>
|
13
|
-
<% if params[:charge].customer.owner.extra_billing_info? %>
|
13
|
+
<% if params[:charge].customer.owner.try(:extra_billing_info?) %>
|
14
14
|
<%= params[:charge].customer.owner.extra_billing_info %><br/>
|
15
15
|
<% end %>
|
16
16
|
<br/>
|
@@ -11,7 +11,7 @@ Amount: <%= params[:charge].amount_refunded_with_currency %><br/>
|
|
11
11
|
Refunded to: <%= params[:charge].charged_to %><br/>
|
12
12
|
Transaction ID: <%= params[:charge].id %><br/>
|
13
13
|
Date: <%= params[:charge].created_at %><br/>
|
14
|
-
<% if params[:charge].customer.owner.extra_billing_info? %>
|
14
|
+
<% if params[:charge].customer.owner.try(:extra_billing_info?) %>
|
15
15
|
<%= params[:charge].customer.owner.extra_billing_info %><br/>
|
16
16
|
<% end %>
|
17
17
|
<br/>
|
@@ -30,7 +30,8 @@ module Pay
|
|
30
30
|
|
31
31
|
customer
|
32
32
|
else
|
33
|
-
|
33
|
+
first_name, last_name = customer_name.split(" ", 2)
|
34
|
+
result = gateway.customer.create(email: email, first_name: first_name, last_name: last_name, payment_method_nonce: payment_method_token)
|
34
35
|
raise Pay::Braintree::Error, result unless result.success?
|
35
36
|
pay_customer.update!(processor_id: result.customer.id)
|
36
37
|
|
@@ -47,6 +48,13 @@ module Pay
|
|
47
48
|
raise Pay::Braintree::Error, e
|
48
49
|
end
|
49
50
|
|
51
|
+
# Syncs name and email to Braintree::Customer
|
52
|
+
def update_customer!
|
53
|
+
return unless processor_id?
|
54
|
+
first_name, last_name = customer_name.split(" ", 2)
|
55
|
+
gateway.customer.update(processor_id, first_name: first_name, last_name: last_name, email: email)
|
56
|
+
end
|
57
|
+
|
50
58
|
def charge(amount, options = {})
|
51
59
|
args = {
|
52
60
|
amount: amount.to_i / 100.0,
|
data/lib/pay/paddle/billable.rb
CHANGED
@@ -75,7 +75,14 @@ module Pay
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def cancel
|
78
|
-
ends_at = on_trial?
|
78
|
+
ends_at = if on_trial?
|
79
|
+
trial_ends_at
|
80
|
+
elsif paused?
|
81
|
+
paddle_paused_from
|
82
|
+
else
|
83
|
+
processor_subscription.next_payment&.fetch(:date) || Time.current
|
84
|
+
end
|
85
|
+
|
79
86
|
PaddlePay::Subscription::User.cancel(processor_id)
|
80
87
|
pay_subscription.update(status: :canceled, ends_at: ends_at)
|
81
88
|
|
@@ -106,7 +113,7 @@ module Pay
|
|
106
113
|
def pause
|
107
114
|
attributes = {pause: true}
|
108
115
|
response = PaddlePay::Subscription::User.update(processor_id, attributes)
|
109
|
-
pay_subscription.update(paddle_paused_from: Time.zone.parse(response
|
116
|
+
pay_subscription.update(paddle_paused_from: Time.zone.parse(response.dig(:next_payment, :date)))
|
110
117
|
rescue ::PaddlePay::PaddlePayError => e
|
111
118
|
raise Pay::Paddle::Error, e
|
112
119
|
end
|
data/lib/pay/receipts.rb
CHANGED
@@ -21,7 +21,7 @@ module Pay
|
|
21
21
|
[I18n.t("pay.receipt.amount"), Pay::Currency.format(amount, currency: currency)],
|
22
22
|
[I18n.t("pay.receipt.charged_to"), charged_to]
|
23
23
|
]
|
24
|
-
line_items << [I18n.t("pay.receipt.additional_info"), customer.owner.extra_billing_info] if customer.owner.extra_billing_info?
|
24
|
+
line_items << [I18n.t("pay.receipt.additional_info"), customer.owner.extra_billing_info] if customer.owner.try(:extra_billing_info?)
|
25
25
|
line_items << [I18n.t("pay.receipt.refunded"), Pay::Currency.format(amount_refunded, currency: currency)] if refunded?
|
26
26
|
|
27
27
|
defaults = {
|
@@ -49,7 +49,7 @@ module Pay
|
|
49
49
|
|
50
50
|
def invoice_pdf(**options)
|
51
51
|
bill_to = [customer.owner.name]
|
52
|
-
bill_to += [customer.owner.extra_billing_info] if customer.owner.extra_billing_info?
|
52
|
+
bill_to += [customer.owner.extra_billing_info] if customer.owner.try(:extra_billing_info?)
|
53
53
|
bill_to += [nil, customer.owner.email]
|
54
54
|
|
55
55
|
total = Pay::Currency.format(amount, currency: currency)
|
data/lib/pay/stripe/billable.rb
CHANGED
@@ -44,6 +44,12 @@ module Pay
|
|
44
44
|
raise Pay::Stripe::Error, e
|
45
45
|
end
|
46
46
|
|
47
|
+
# Syncs name and email to Stripe::Customer
|
48
|
+
def update_customer!
|
49
|
+
return unless processor_id?
|
50
|
+
::Stripe::Customer.update(processor_id, {name: customer_name, email: email}, stripe_options)
|
51
|
+
end
|
52
|
+
|
47
53
|
def charge(amount, options = {})
|
48
54
|
add_payment_method(payment_method_token, default: true) if payment_method_token?
|
49
55
|
|
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: 3.0.
|
4
|
+
version: 3.0.22
|
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: 2021-
|
12
|
+
date: 2021-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -123,14 +123,7 @@ files:
|
|
123
123
|
- config/locales/en.yml
|
124
124
|
- config/routes.rb
|
125
125
|
- db/migrate/1_create_pay_tables.rb
|
126
|
-
- lib/generators/active_record/billable_generator.rb
|
127
|
-
- lib/generators/active_record/merchant_generator.rb
|
128
|
-
- lib/generators/active_record/templates/billable_migration.rb
|
129
|
-
- lib/generators/active_record/templates/merchant_migration.rb
|
130
|
-
- lib/generators/pay/billable_generator.rb
|
131
126
|
- lib/generators/pay/email_views_generator.rb
|
132
|
-
- lib/generators/pay/merchant_generator.rb
|
133
|
-
- lib/generators/pay/orm_helpers.rb
|
134
127
|
- lib/generators/pay/views_generator.rb
|
135
128
|
- lib/pay.rb
|
136
129
|
- lib/pay/adapter.rb
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails/generators/active_record"
|
4
|
-
require "generators/pay/orm_helpers"
|
5
|
-
|
6
|
-
module ActiveRecord
|
7
|
-
module Generators
|
8
|
-
class BillableGenerator < ActiveRecord::Generators::Base
|
9
|
-
include Pay::Generators::OrmHelpers
|
10
|
-
source_root File.expand_path("../templates", __FILE__)
|
11
|
-
|
12
|
-
def copy_pay_billable_migration
|
13
|
-
if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name))
|
14
|
-
migration_template "billable_migration.rb", "#{migration_path}/add_pay_billable_to_#{table_name}.rb", migration_version: migration_version
|
15
|
-
else
|
16
|
-
say "#{model_path} does not exist.", :red
|
17
|
-
say "⚠️ Make sure the #{name} model exists before running this generator."
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# If the file already contains the contents, the user will receive this warning:
|
22
|
-
#
|
23
|
-
# File unchanged! The supplied flag value not found!
|
24
|
-
#
|
25
|
-
# This can be ignored as it just means the contents already exist and the file is unchanged.
|
26
|
-
# Thor will be updated to improve this message: https://github.com/rails/thor/issues/706
|
27
|
-
def inject_pay_billable_content
|
28
|
-
return unless model_exists?
|
29
|
-
|
30
|
-
content = model_contents
|
31
|
-
class_path = (namespaced? ? class_name.to_s.split("::") : [class_name])
|
32
|
-
indent_depth = class_path.size - 1
|
33
|
-
content = content.split("\n").map { |line| " " * indent_depth + line }.join("\n") << "\n"
|
34
|
-
inject_into_class(model_path, class_path.last, content)
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def model_contents
|
40
|
-
" include Pay::Billable"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails/generators/active_record"
|
4
|
-
require "generators/pay/orm_helpers"
|
5
|
-
|
6
|
-
module ActiveRecord
|
7
|
-
module Generators
|
8
|
-
class MerchantGenerator < ActiveRecord::Generators::Base
|
9
|
-
include Pay::Generators::OrmHelpers
|
10
|
-
source_root File.expand_path("../templates", __FILE__)
|
11
|
-
|
12
|
-
def copy_pay_merchant_migration
|
13
|
-
if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name))
|
14
|
-
migration_template "merchant_migration.rb", "#{migration_path}/add_pay_merchant_to_#{table_name}.rb", migration_version: migration_version
|
15
|
-
else
|
16
|
-
say "#{model_path} does not exist.", :red
|
17
|
-
say "⚠️ Make sure the #{name} model exists before running this generator."
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# If the file already contains the contents, the user will receive this warning:
|
22
|
-
#
|
23
|
-
# File unchanged! The supplied flag value not found!
|
24
|
-
#
|
25
|
-
# This can be ignored as it just means the contents already exist and the file is unchanged.
|
26
|
-
# Thor will be updated to improve this message: https://github.com/rails/thor/issues/706
|
27
|
-
def inject_pay_merchant_content
|
28
|
-
return unless model_exists?
|
29
|
-
|
30
|
-
content = model_contents
|
31
|
-
class_path = (namespaced? ? class_name.to_s.split("::") : [class_name])
|
32
|
-
indent_depth = class_path.size - 1
|
33
|
-
content = content.split("\n").map { |line| " " * indent_depth + line }.join("\n") << "\n"
|
34
|
-
inject_into_class(model_path, class_path.last, content)
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def model_contents
|
40
|
-
" include Pay::Merchant"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class AddPayBillableTo<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
def change
|
5
|
-
change_table :<%= table_name %>, bulk: true do |t|
|
6
|
-
t.string :processor
|
7
|
-
t.string :processor_id
|
8
|
-
t.public_send(Pay::Adapter.json_column_type, :pay_data)
|
9
|
-
t.datetime :trial_ends_at
|
10
|
-
t.string :card_type
|
11
|
-
t.string :card_last4
|
12
|
-
t.string :card_exp_month
|
13
|
-
t.string :card_exp_year
|
14
|
-
t.text :extra_billing_info
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class AddPayMerchantTo<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
def change
|
5
|
-
add_column table_name, :merchant_processor, :string
|
6
|
-
|
7
|
-
# We may already have the pay_data column if a Pay::Billable object is also a Pay::Merchant
|
8
|
-
unless ActiveRecord::Base.connection.column_exists?(table_name, :pay_data)
|
9
|
-
add_column :<%= table_name %>, :pay_data, Pay::Adapter.json_column_type
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails/generators/named_base"
|
4
|
-
|
5
|
-
module Pay
|
6
|
-
module Generators
|
7
|
-
class BillableGenerator < Rails::Generators::NamedBase
|
8
|
-
include Rails::Generators::ResourceHelpers
|
9
|
-
|
10
|
-
source_root File.expand_path("../templates", __FILE__)
|
11
|
-
|
12
|
-
desc "Generates a migration to add Pay::Billable fields to a model."
|
13
|
-
|
14
|
-
hook_for :orm
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails/generators/named_base"
|
4
|
-
|
5
|
-
module Pay
|
6
|
-
module Generators
|
7
|
-
class MerchantGenerator < Rails::Generators::NamedBase
|
8
|
-
include Rails::Generators::ResourceHelpers
|
9
|
-
|
10
|
-
source_root File.expand_path("../templates", __FILE__)
|
11
|
-
|
12
|
-
desc "Generates a migration to add Pay::Merchant fields to a model."
|
13
|
-
|
14
|
-
hook_for :orm
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Pay
|
4
|
-
module Generators
|
5
|
-
module OrmHelpers
|
6
|
-
private
|
7
|
-
|
8
|
-
def model_exists?
|
9
|
-
File.exist?(File.join(destination_root, model_path))
|
10
|
-
end
|
11
|
-
|
12
|
-
def migration_exists?(table_name)
|
13
|
-
Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_add_devise_to_#{table_name}.rb$/).first
|
14
|
-
end
|
15
|
-
|
16
|
-
def migration_path
|
17
|
-
if Rails.version >= "5.0.3"
|
18
|
-
db_migrate_path
|
19
|
-
else
|
20
|
-
@migration_path ||= File.join("db", "migrate")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def model_path
|
25
|
-
@model_path ||= File.join("app", "models", "#{file_path}.rb")
|
26
|
-
end
|
27
|
-
|
28
|
-
def migration_version
|
29
|
-
if rails5_and_up?
|
30
|
-
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def rails5_and_up?
|
35
|
-
Rails::VERSION::MAJOR >= 5
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|