pay 11.1.0 → 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 +4 -4
- data/app/models/pay/stripe/charge.rb +7 -5
- data/app/models/pay/stripe/payment_method.rb +5 -5
- data/lib/pay/stripe.rb +11 -2
- data/lib/pay/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 683137bc5d05a03c2c9dac51eb73c81566f7f7843e1806d4701382bb9f1dd603
|
4
|
+
data.tar.gz: 3974ae308b9eb16e473978fb7a6988dc2e62afbbf136bfe2a03a623dac6b0435
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
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
|
|
data/lib/pay/stripe.rb
CHANGED
@@ -142,16 +142,25 @@ module Pay
|
|
142
142
|
nil
|
143
143
|
end
|
144
144
|
|
145
|
-
|
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