pay 11.0.1 → 11.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7200a013cb88ad073e1de38f397fa6b46e28892dbfd3e70426dd99308422a1f
4
- data.tar.gz: 6397051e6cfaf375f5e66bb5eab4a13c4fd22a7204939876e08452bf4f1f9c55
3
+ metadata.gz: 683137bc5d05a03c2c9dac51eb73c81566f7f7843e1806d4701382bb9f1dd603
4
+ data.tar.gz: 3974ae308b9eb16e473978fb7a6988dc2e62afbbf136bfe2a03a623dac6b0435
5
5
  SHA512:
6
- metadata.gz: 3cbc10ffdf3b6d277c833fe3bc51536f57f09d26fa524db6d2ea8fc876751926b04334e6ca530a2a8ff9911dbcbca672c67f83e7799519a174f2ac2164d86807
7
- data.tar.gz: 81f0182087f30e15f90557cf78442425b2a44316d3db29f3ccc08f759183ad75bdb1bb64a03aa7d7515b953d5dc32b3e244d878308eaab09d5140333feb926d8
6
+ metadata.gz: 04b6d4956b0f68d82908793e4f075c1d197e62bdd9c805ee5f113495577c20278185a7d8f3c53db3a2e9c2346df151ec19619eb4f38e0d25fb29f4f9544259f1
7
+ data.tar.gz: a5013d8bdefd8c1da3ab2be65fe6cce87095172c3bf7e6f1e137fd8b754fbf494606ef47fa29c2a16555bea62929481d443ed879db3e4483778f25b21b30087c
@@ -65,11 +65,13 @@ module Pay
65
65
  create!(attrs.merge(customer: pay_customer, processor_id: object.id))
66
66
  end
67
67
  rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
68
- try += 1
69
- raise unless try <= retries
70
-
71
- sleep 0.1
72
- retry
68
+ if try > retries
69
+ raise
70
+ else
71
+ try += 1
72
+ sleep 0.15**try
73
+ retry
74
+ end
73
75
  end
74
76
 
75
77
  def api_record
@@ -41,12 +41,12 @@ module Pay
41
41
  pay_payment_method.update!(attributes)
42
42
  pay_payment_method
43
43
  rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
44
- try += 1
45
- if try <= retries
46
- sleep 0.1
47
- retry
48
- else
44
+ if try > retries
49
45
  raise
46
+ else
47
+ try += 1
48
+ sleep 0.15**try
49
+ retry
50
50
  end
51
51
  end
52
52
 
@@ -0,0 +1,9 @@
1
+ Extra confirmation is needed to process your payment
2
+
3
+ Your <%= Pay.application_name %> subscription requires confirmation to process your payment to continue access.
4
+
5
+ Confirm your payment: <%= pay.payment_url(params[:payment_intent_id]) %>
6
+
7
+ If you have any questions, please hit reply and let us know.
8
+
9
+ — The <%= Pay.application_name %> Team
@@ -0,0 +1,9 @@
1
+ Your payment was declined
2
+
3
+ We were unable to charge your payment method for your <%= Pay.application_name %> subscription. Please update your billing information.
4
+
5
+ Update billing information: <%= root_url %>
6
+
7
+ Let us know if you have any questions.
8
+
9
+ — The <%= Pay.application_name %> Team
@@ -0,0 +1,20 @@
1
+ We received payment for your <%= Pay.application_name %> subscription. Thanks for your business!
2
+
3
+ Questions? Please reply to this email.
4
+
5
+ ------------------------------------
6
+ RECEIPT - SUBSCRIPTION
7
+
8
+ <%= Pay.application_name %>
9
+ Amount: <%= params[:pay_charge].amount_with_currency %>
10
+
11
+ Charged to: <%= params[:pay_charge].charged_to %>
12
+ Transaction ID: <%= params[:pay_charge].id %>
13
+ Date: <%= l params[:pay_charge].created_at %>
14
+ <% if params[:pay_charge].customer.owner.try(:extra_billing_info?) %>
15
+ <%= params[:pay_charge].customer.owner.extra_billing_info %>
16
+ <% end %>
17
+
18
+ <%= Pay.business_name %>
19
+ <%= Pay.business_address %>
20
+ ------------------------------------
@@ -0,0 +1,21 @@
1
+ We have processed your <%= Pay.application_name %> refund.
2
+ Please allow up to 7 business days for your refund to appear in your account
3
+
4
+ Questions? Please reply to this email.
5
+
6
+ ------------------------------------
7
+ RECEIPT - REFUND
8
+
9
+ <%= Pay.application_name %>
10
+ Amount: <%= params[:pay_charge].amount_refunded_with_currency %>
11
+
12
+ Refunded to: <%= params[:pay_charge].charged_to %>
13
+ Transaction ID: <%= params[:pay_charge].id %>
14
+ Date: <%= l params[:pay_charge].created_at %>
15
+ <% if params[:pay_charge].customer.owner.try(:extra_billing_info?) %>
16
+ <%= params[:pay_charge].customer.owner.extra_billing_info %>
17
+ <% end %>
18
+
19
+ <%= Pay.business_name %>
20
+ <%= Pay.business_address %>
21
+ ------------------------------------
@@ -0,0 +1,8 @@
1
+ Your upcoming <%= Pay.application_name %> subscription renewal
2
+
3
+ This is a friendly reminder that your <%= Pay.application_name %> subscription will renew automatically on <%= l params[:date].to_date, format: :long %>.
4
+
5
+ You may manage your subscription via your account: <%= root_url %>
6
+ If you have any questions, please hit reply and let us know.
7
+
8
+ — The <%= Pay.application_name %> Team
@@ -0,0 +1,8 @@
1
+ Your <%= Pay.application_name %> trial has ended
2
+
3
+ This is just a friendly reminder that your <%= Pay.application_name %> trial has ended.
4
+
5
+ You may manage your subscription via your account: <%= root_url %>
6
+ If you have any questions, please hit reply and let us know.
7
+
8
+ — The <%= Pay.application_name %> Team
@@ -0,0 +1,8 @@
1
+ Your <%= Pay.application_name %> trial is ending soon
2
+
3
+ This is just a friendly reminder that your <%= Pay.application_name %> trial will be ending soon.
4
+
5
+ You may manage your subscription via your account: <%= root_url %>
6
+ If you have any questions, please hit reply and let us know.
7
+
8
+ — The <%= Pay.application_name %> Team
data/lib/pay/stripe.rb CHANGED
@@ -142,16 +142,25 @@ module Pay
142
142
  nil
143
143
  end
144
144
 
145
- def self.sync_checkout_session(session_id, stripe_account: nil)
145
+ # Subscriptions aren't always immediately associated, so we want to retry by default
146
+ def self.sync_checkout_session(session_id, stripe_account: nil, try: 0, retries: 5)
146
147
  checkout_session = ::Stripe::Checkout::Session.retrieve({id: session_id, expand: ["payment_intent.latest_charge"]}, {stripe_account: stripe_account}.compact)
147
148
  case checkout_session.mode
148
149
  when "payment"
149
150
  if (id = checkout_session.payment_intent.try(:latest_charge)&.id)
150
- Pay::Stripe::Charge.sync(id, stripe_account: stripe_account)
151
+ Pay::Stripe::Charge.sync(id, stripe_account: stripe_account, retries: 5)
151
152
  end
152
153
  when "subscription"
153
154
  Pay::Stripe::Subscription.sync(checkout_session.subscription, stripe_account: stripe_account)
154
155
  end
156
+ rescue ::Stripe::InvalidRequestError
157
+ if try > retries
158
+ raise
159
+ else
160
+ try += 1
161
+ sleep 0.15**try
162
+ retry
163
+ end
155
164
  end
156
165
  end
157
166
  end
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "11.0.1"
2
+ VERSION = "11.1.1"
3
3
  end
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: 11.0.1
4
+ version: 11.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes
@@ -89,12 +89,19 @@ files:
89
89
  - app/views/layouts/pay/application.html.erb
90
90
  - app/views/pay/payments/show.html.erb
91
91
  - app/views/pay/user_mailer/payment_action_required.html.erb
92
+ - app/views/pay/user_mailer/payment_action_required.text.erb
92
93
  - app/views/pay/user_mailer/payment_failed.html.erb
94
+ - app/views/pay/user_mailer/payment_failed.text.erb
93
95
  - app/views/pay/user_mailer/receipt.html.erb
96
+ - app/views/pay/user_mailer/receipt.text.erb
94
97
  - app/views/pay/user_mailer/refund.html.erb
98
+ - app/views/pay/user_mailer/refund.text.erb
95
99
  - app/views/pay/user_mailer/subscription_renewing.html.erb
100
+ - app/views/pay/user_mailer/subscription_renewing.text.erb
96
101
  - app/views/pay/user_mailer/subscription_trial_ended.html.erb
102
+ - app/views/pay/user_mailer/subscription_trial_ended.text.erb
97
103
  - app/views/pay/user_mailer/subscription_trial_will_end.html.erb
104
+ - app/views/pay/user_mailer/subscription_trial_will_end.text.erb
98
105
  - config/currencies/iso.json
99
106
  - config/locales/en.yml
100
107
  - config/routes.rb