pay 6.0.3 → 6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ffb1d86e804cae26df541cde3e1798a316c6176c271b1da5de66031f5ed99cc
4
- data.tar.gz: a4fd5b34c5f873ef9c47d222688206ea318890cedc747c9059014001934f1c87
3
+ metadata.gz: 17a91b33a5c76733e60014f15e285b51e77d1d4794456afba359691edc4e44c2
4
+ data.tar.gz: f7b991d7a54f7fa57a54a56571f2ee4badeeb1aaaa62dc5f2cc6f889254818d3
5
5
  SHA512:
6
- metadata.gz: d3c872342b43c5fa0ebc2aa797b7a145bdb99e310fd0db1019b6c19b9fe536fe8e242142ee5dc26edbf94a4bcdfca4e9b3aa7bb78444d1b1f3f3c35e3a2d236a
7
- data.tar.gz: c3df896c8ba0056fcb0549c19e7b603322710ccf977832030414f2bfed5c0b14ed60a0574cf50ce237feaa56cc5bcab932cf6cc956fc0b33321d7d8117a6842b
6
+ metadata.gz: 5ef34ddc4e6b0ba75abab2577d216a85af478fa22c0bc8a16d312b5979e782fac467204e66ac72f7fa4f9e0b4dfa16f879aad82b27251ed290e05353c48df92c
7
+ data.tar.gz: e8dd4dbbdc01aa58ce21228b84a69bb70df05a814ab306b9e2b417b3e178bf50732117b73cad0f01dbb04035bbeb834f2aa2052b010c042b1d5e1f7660149188
data/README.md CHANGED
@@ -20,7 +20,7 @@ Want to see how Pay works? Check out our video getting started guide.
20
20
 
21
21
  Our supported payment processors are:
22
22
 
23
- - Stripe ([SCA Compatible](https://stripe.com/docs/strong-customer-authentication) using API version `2022-08-01`)
23
+ - Stripe ([SCA Compatible](https://stripe.com/docs/strong-customer-authentication) using API version `2022-11-15`)
24
24
  - Paddle (SCA Compatible & supports PayPal)
25
25
  - Braintree (supports PayPal)
26
26
  - [Fake Processor](docs/fake_processor/1_overview.md) (used for generic trials without cards, free subscriptions, testing, etc)
@@ -31,7 +31,7 @@ module Pay
31
31
  private
32
32
 
33
33
  def mail_arguments
34
- Pay.mail_arguments.call(mailer_name, params)
34
+ instance_exec(&Pay.mail_arguments)
35
35
  end
36
36
  end
37
37
  end
@@ -1,6 +1,6 @@
1
1
  <h3>Extra confirmation is needed to process your payment</h3>
2
- <p>Your <%= Pay.business_name %> subscription requires confirmation to process your payment to continue access.</p>
2
+ <p>Your <%= Pay.application_name %> subscription requires confirmation to process your payment to continue access.</p>
3
3
 
4
4
  <p><%= link_to "Click here to confirm your payment", pay.payment_url(params[:payment_intent_id]) %>. If you have any questions, please hit reply and let us know.</p>
5
5
 
6
- <p>- The <%= Pay.business_name %> Team</p>
6
+ <p>— The <%= Pay.application_name %> Team</p>
@@ -1,20 +1,21 @@
1
- We received payment for your subscription. Thanks for your business!<br/>
1
+ We received payment for your <%= link_to Pay.application_name, root_url %> subscription. Thanks for your business!<br/>
2
2
  <br/>
3
3
  Questions? Please reply to this email.<br/>
4
4
  <br/>
5
5
  ------------------------------------<br/>
6
6
  RECEIPT - SUBSCRIPTION<br/>
7
7
  <br/>
8
+
9
+ <%= Pay.application_name %><br/>
8
10
  Amount: <%= params[:pay_charge].amount_with_currency %><br/>
9
11
  <br/>
10
12
  Charged to: <%= params[:pay_charge].charged_to %><br/>
11
13
  Transaction ID: <%= params[:pay_charge].id %><br/>
12
- Date: <%= params[:pay_charge].created_at %><br/>
14
+ Date: <%= l params[:pay_charge].created_at %><br/>
13
15
  <% if params[:pay_charge].customer.owner.try(:extra_billing_info?) %>
14
16
  <%= params[:pay_charge].customer.owner.extra_billing_info %><br/>
15
17
  <% end %>
16
18
  <br/>
17
19
  <br/>
18
- <%= Pay.business_name %><br/>
19
- <%= simple_format Pay.business_address %>
20
+ <%= simple_format [Pay.business_name, Pay.business_address].join("\n") %>
20
21
  ------------------------------------<br/>
@@ -1,4 +1,4 @@
1
- We have processed your refund.<br/>
1
+ We have processed your <%= link_to Pay.application_name, root_url %> refund.<br/>
2
2
  Please allow up to 7 business days for your refund to appear in your account<br/>
3
3
  <br/>
4
4
  Questions? Please reply to this email.<br/>
@@ -6,16 +6,16 @@ Questions? Please reply to this email.<br/>
6
6
  ------------------------------------<br/>
7
7
  RECEIPT - REFUND<br/>
8
8
  <br/>
9
+ <%= Pay.application_name %><br/>
9
10
  Amount: <%= params[:pay_charge].amount_refunded_with_currency %><br/>
10
11
  <br/>
11
12
  Refunded to: <%= params[:pay_charge].charged_to %><br/>
12
13
  Transaction ID: <%= params[:pay_charge].id %><br/>
13
- Date: <%= params[:pay_charge].created_at %><br/>
14
+ Date: <%= l params[:pay_charge].created_at %><br/>
14
15
  <% if params[:pay_charge].customer.owner.try(:extra_billing_info?) %>
15
16
  <%= params[:pay_charge].customer.owner.extra_billing_info %><br/>
16
17
  <% end %>
17
18
  <br/>
18
19
  <br/>
19
- <%= Pay.business_name %><br/>
20
- <%= simple_format Pay.business_address %>
20
+ <%= simple_format [Pay.business_name, Pay.business_address].join("\n") %>
21
21
  ------------------------------------<br/>
@@ -1,6 +1,6 @@
1
- <h3>Your upcoming subscription renewal</h3>
2
- <p>This is just a friendly reminder that your <%= Pay.business_name %> subscription will renew automatically on <%= l params[:date].to_date, format: :long %>.</p>
1
+ <h3>Your upcoming <%= Pay.application_name %> subscription renewal</h3>
2
+ <p>This is just a friendly reminder that your <%= link_to Pay.application_name, root_url %> subscription will renew automatically on <%= l params[:date].to_date, format: :long %>.</p>
3
3
 
4
- <p>You may manage your subscription via your account. If you have any questions, please hit reply and let us know.</p>
4
+ <p>You may <%= link_to "manage your subscription", root_url %> via your account. If you have any questions, please hit reply and let us know.</p>
5
5
 
6
- <p>- The <%= Pay.business_name %> Team</p>
6
+ <p>— The <%= Pay.application_name %> Team</p>
@@ -1,6 +1,6 @@
1
- <h3>Your <%= Pay.business_name %> trial has ended</h3>
2
- <p>This is just a friendly reminder that your <%= Pay.business_name %> trial has ended.</p>
1
+ <h3>Your <%= Pay.application_name %> trial has ended</h3>
2
+ <p>This is just a friendly reminder that your <%= link_to Pay.application_name, root_url %> trial has ended.</p>
3
3
 
4
- <p>You may manage your subscription via your account. If you have any questions, please hit reply and let us know.</p>
4
+ <p>You may <%= link_to "manage your subscription", root_url %> via your account. If you have any questions, please hit reply and let us know.</p>
5
5
 
6
- <p>- The <%= Pay.business_name %> Team</p>
6
+ <p>— The <%= Pay.application_name %> Team</p>
@@ -1,6 +1,6 @@
1
- <h3>Your <%= Pay.business_name %> trial is ending soon</h3>
2
- <p>This is just a friendly reminder that your <%= Pay.business_name %> trial will be ending soon.</p>
1
+ <h3>Your <%= Pay.application_name %> trial is ending soon</h3>
2
+ <p>This is just a friendly reminder that your <%= link_to Pay.application_name, root_url %> trial will be ending soon.</p>
3
3
 
4
- <p>You may manage your subscription via your account. If you have any questions, please hit reply and let us know.</p>
4
+ <p>You may <%= link_to "manage your subscription", root_url %> via your account. If you have any questions, please hit reply and let us know.</p>
5
5
 
6
- <p>- The <%= Pay.business_name %> Team</p>
6
+ <p>— The <%= Pay.application_name %> Team</p>
@@ -49,14 +49,14 @@ en:
49
49
  authorization: "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."
50
50
  user_mailer:
51
51
  receipt:
52
- subject: "Payment receipt"
52
+ subject: "[%{application}] Payment receipt"
53
53
  refund:
54
- subject: "Payment refunded"
54
+ subject: "[%{application}] Payment refunded"
55
55
  subscription_renewing:
56
- subject: "Your upcoming subscription renewal"
56
+ subject: "[%{application}] Your upcoming subscription renewal"
57
57
  payment_action_required:
58
- subject: "Confirm your payment"
58
+ subject: "[%{application}] Confirm your payment"
59
59
  subscription_trial_will_end:
60
- subject: "Your trial is ending soon"
60
+ subject: "[%{application}] Your trial is ending soon"
61
61
  subscription_trial_ended:
62
- subject: "Your trial has ended"
62
+ subject: "[%{application}] Your trial has ended"
@@ -217,7 +217,7 @@ module Pay
217
217
  add: [
218
218
  {
219
219
  inherited_from_id: "plan-credit",
220
- amount: discount.amount,
220
+ amount: discount.amount.round(2),
221
221
  number_of_billing_cycles: discount.number_of_billing_cycles
222
222
  }
223
223
  ]
@@ -225,9 +225,10 @@ module Pay
225
225
  }
226
226
  end
227
227
 
228
- cancel_now!
229
-
228
+ # If subscribe fails we will raise a Pay::Braintree::Error and not cancel the current subscription
230
229
  customer.subscribe(**options.merge(name: name, plan: plan.id))
230
+
231
+ cancel_now!
231
232
  end
232
233
  end
233
234
  end
data/lib/pay/receipts.rb CHANGED
@@ -119,7 +119,7 @@ module Pay
119
119
  company: {
120
120
  name: Pay.business_name,
121
121
  address: Pay.business_address,
122
- email: Pay.support_email,
122
+ email: Pay.support_email.address,
123
123
  logo: Pay.business_logo
124
124
  },
125
125
  line_items: receipt_line_items
@@ -155,7 +155,7 @@ module Pay
155
155
  company: {
156
156
  name: Pay.business_name,
157
157
  address: Pay.business_address,
158
- email: Pay.support_email,
158
+ email: Pay.support_email.address,
159
159
  logo: Pay.business_logo
160
160
  },
161
161
  line_items: pdf_line_items
@@ -125,7 +125,7 @@ module Pay
125
125
  # refund!(5_00, refund_application_fee: true)
126
126
  def refund!(amount_to_refund, **options)
127
127
  if invoice_id.present?
128
- description = options.delete(:description) || I18n.t("refund")
128
+ description = options.delete(:description) || I18n.t("pay.refund")
129
129
  lines = [{type: :custom_line_item, description: description, quantity: 1, unit_amount: amount_to_refund}]
130
130
  credit_note!(**options.merge(refund_amount: amount_to_refund, lines: lines))
131
131
  else
@@ -3,15 +3,11 @@ module Pay
3
3
  module Webhooks
4
4
  class CheckoutSessionCompleted
5
5
  def call(event)
6
- # TODO: Also handle payment intents
7
-
8
6
  locate_owner(event.data.object)
9
7
 
10
8
  if (payment_intent_id = event.data.object.payment_intent)
11
- payment_intent = ::Stripe::PaymentIntent.retrieve(payment_intent_id, {stripe_account: event.try(:account)}.compact)
12
- payment_intent.charges.each do |charge|
13
- Pay::Stripe::Charge.sync(charge.id, stripe_account: event.try(:account))
14
- end
9
+ payment_intent = ::Stripe::PaymentIntent.retrieve({id: payment_intent_id, expand: ["latest_charge"]}, {stripe_account: event.try(:account)}.compact)
10
+ Pay::Stripe::Charge.sync(payment_intent.latest_charge.id, object: payment_intent.latest_charge, stripe_account: event.try(:account))
15
11
  end
16
12
 
17
13
  if (subscription_id = event.data.object.subscription)
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "6.0.3"
2
+ VERSION = "6.1.1"
3
3
  end
data/lib/pay.rb CHANGED
@@ -37,6 +37,10 @@ module Pay
37
37
  mattr_accessor :business_logo
38
38
  mattr_accessor :support_email
39
39
 
40
+ def self.support_email=(value)
41
+ @@support_email = value.is_a?(Mail::Address) ? value : Mail::Address.new(value)
42
+ end
43
+
40
44
  mattr_accessor :automount_routes
41
45
  @@automount_routes = true
42
46
 
@@ -80,15 +84,16 @@ module Pay
80
84
 
81
85
  # Should return a hash of arguments for the `mail` call in UserMailer
82
86
  mattr_accessor :mail_arguments
83
- @@mail_arguments = ->(mailer, params) {
87
+ @@mail_arguments = -> {
84
88
  {
85
- to: Pay.mail_to.call(mailer, params)
89
+ to: instance_exec(&Pay.mail_to),
90
+ subject: default_i18n_subject(application: Pay.application_name)
86
91
  }
87
92
  }
88
93
 
89
94
  # Should return String or Array of email recipients
90
95
  mattr_accessor :mail_to
91
- @@mail_to = ->(mailer, params) {
96
+ @@mail_to = -> {
92
97
  if ActionMailer::Base.respond_to?(:email_address_with_name)
93
98
  ActionMailer::Base.email_address_with_name(params[:pay_customer].email, params[:pay_customer].customer_name)
94
99
  else
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.0.3
4
+ version: 6.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: 2022-11-22 00:00:00.000000000 Z
12
+ date: 2022-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails