Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pay-rails/pay
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Oct 31, 2024
2 parents c0eb2f2 + 38089fc commit b338f3c
Show file tree
Hide file tree
Showing 20 changed files with 547 additions and 493 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

### Unreleased

### 8.1.3

* Raise `Pay::Error` instead of `StandardError` consistently

### 8.1.2

* Allow proration mode argument for Paddle Billing subscriptions
* Fix Lemon Squeezy sync subscription
* Fix typo in Paddle Billing customer `api_record`

### 8.1.1

* Fix `retry_failed_payment` for Stripe subscriptions #1084

### 8.1.0

* Stripe v13
Expand Down
159 changes: 79 additions & 80 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
GIT
remote: https://github.com/thoughtbot/appraisal.git
revision: 24feeea4c5c1d2e7a5f95d053da61858c6bfb2b1
revision: 602cdd9b5f8cb8f36992733422f69312b172f427
specs:
appraisal (2.5.0)
appraisal (3.0.0.rc1)
bundler
rake
thor (>= 0.14.0)

PATH
remote: .
specs:
pay (8.1.0)
pay (8.1.3)
rails (>= 6.0.0)

GEM
remote: https://rubygems.org/
specs:
actioncable (7.2.1)
actionpack (= 7.2.1)
activesupport (= 7.2.1)
actioncable (7.2.1.2)
actionpack (= 7.2.1.2)
activesupport (= 7.2.1.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.2.1)
actionpack (= 7.2.1)
activejob (= 7.2.1)
activerecord (= 7.2.1)
activestorage (= 7.2.1)
activesupport (= 7.2.1)
actionmailbox (7.2.1.2)
actionpack (= 7.2.1.2)
activejob (= 7.2.1.2)
activerecord (= 7.2.1.2)
activestorage (= 7.2.1.2)
activesupport (= 7.2.1.2)
mail (>= 2.8.0)
actionmailer (7.2.1)
actionpack (= 7.2.1)
actionview (= 7.2.1)
activejob (= 7.2.1)
activesupport (= 7.2.1)
actionmailer (7.2.1.2)
actionpack (= 7.2.1.2)
actionview (= 7.2.1.2)
activejob (= 7.2.1.2)
activesupport (= 7.2.1.2)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.2.1)
actionview (= 7.2.1)
activesupport (= 7.2.1)
actionpack (7.2.1.2)
actionview (= 7.2.1.2)
activesupport (= 7.2.1.2)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4, < 3.2)
Expand All @@ -47,35 +47,35 @@ GEM
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (7.2.1)
actionpack (= 7.2.1)
activerecord (= 7.2.1)
activestorage (= 7.2.1)
activesupport (= 7.2.1)
actiontext (7.2.1.2)
actionpack (= 7.2.1.2)
activerecord (= 7.2.1.2)
activestorage (= 7.2.1.2)
activesupport (= 7.2.1.2)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.2.1)
activesupport (= 7.2.1)
actionview (7.2.1.2)
activesupport (= 7.2.1.2)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.2.1)
activesupport (= 7.2.1)
activejob (7.2.1.2)
activesupport (= 7.2.1.2)
globalid (>= 0.3.6)
activemodel (7.2.1)
activesupport (= 7.2.1)
activerecord (7.2.1)
activemodel (= 7.2.1)
activesupport (= 7.2.1)
activemodel (7.2.1.2)
activesupport (= 7.2.1.2)
activerecord (7.2.1.2)
activemodel (= 7.2.1.2)
activesupport (= 7.2.1.2)
timeout (>= 0.4.0)
activestorage (7.2.1)
actionpack (= 7.2.1)
activejob (= 7.2.1)
activerecord (= 7.2.1)
activesupport (= 7.2.1)
activestorage (7.2.1.2)
actionpack (= 7.2.1.2)
activejob (= 7.2.1.2)
activerecord (= 7.2.1.2)
activesupport (= 7.2.1.2)
marcel (~> 1.0)
activesupport (7.2.1)
activesupport (7.2.1.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
Expand Down Expand Up @@ -115,21 +115,21 @@ GEM
hashdiff (1.1.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
importmap-rails (2.0.1)
importmap-rails (2.0.3)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.7.2)
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.7.2)
json (2.7.4)
language_server-protocol (3.17.0.3)
lemonsqueezy (1.0.1)
faraday (~> 2.0)
lint_roller (1.1.0)
logger (1.6.1)
loofah (2.22.0)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
Expand All @@ -142,12 +142,12 @@ GEM
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.25.1)
mocha (2.4.5)
mocha (2.5.0)
ruby2_keywords (>= 0.0.5)
mysql2 (0.5.6)
net-http (0.4.1)
uri
net-imap (0.4.16)
net-imap (0.5.0)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -156,7 +156,7 @@ GEM
timeout
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
nio4r (2.7.4)
nokogiri (1.16.7)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
Expand All @@ -173,7 +173,7 @@ GEM
ast (~> 2.4.1)
racc
pdf-core (0.10.0)
pg (1.5.8)
pg (1.5.9)
prawn (2.5.0)
matrix (~> 0.4)
pdf-core (~> 0.10.0)
Expand All @@ -186,38 +186,38 @@ GEM
puma (6.4.3)
nio4r (~> 2.0)
racc (1.8.1)
rack (3.1.7)
rack (3.1.8)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails (7.2.1)
actioncable (= 7.2.1)
actionmailbox (= 7.2.1)
actionmailer (= 7.2.1)
actionpack (= 7.2.1)
actiontext (= 7.2.1)
actionview (= 7.2.1)
activejob (= 7.2.1)
activemodel (= 7.2.1)
activerecord (= 7.2.1)
activestorage (= 7.2.1)
activesupport (= 7.2.1)
rails (7.2.1.2)
actioncable (= 7.2.1.2)
actionmailbox (= 7.2.1.2)
actionmailer (= 7.2.1.2)
actionpack (= 7.2.1.2)
actiontext (= 7.2.1.2)
actionview (= 7.2.1.2)
activejob (= 7.2.1.2)
activemodel (= 7.2.1.2)
activerecord (= 7.2.1.2)
activestorage (= 7.2.1.2)
activesupport (= 7.2.1.2)
bundler (>= 1.15.0)
railties (= 7.2.1)
railties (= 7.2.1.2)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.2.1)
actionpack (= 7.2.1)
activesupport (= 7.2.1)
railties (7.2.1.2)
actionpack (= 7.2.1.2)
activesupport (= 7.2.1.2)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
Expand All @@ -233,21 +233,20 @@ GEM
regexp_parser (2.9.2)
reline (0.5.10)
io-console (~> 0.5)
rexml (3.3.8)
rubocop (1.65.1)
rexml (3.3.9)
rubocop (1.66.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-performance (1.21.1)
rubocop-performance (1.22.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
Expand All @@ -260,31 +259,31 @@ GEM
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sqlite3 (2.1.0)
sqlite3 (2.1.1)
mini_portile2 (~> 2.8.0)
sqlite3 (2.1.0-x86_64-darwin)
sqlite3 (2.1.0-x86_64-linux-gnu)
standard (1.40.0)
sqlite3 (2.1.1-x86_64-darwin)
sqlite3 (2.1.1-x86_64-linux-gnu)
standard (1.41.1)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.65.0)
rubocop (~> 1.66.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.4)
standard-performance (~> 1.5)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.4.0)
standard-performance (1.5.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0)
rubocop-performance (~> 1.22.0)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.1)
stripe (13.0.0)
stripe (13.0.2)
thor (1.3.2)
timeout (0.4.1)
ttfunk (1.8.0)
bigdecimal (~> 3.1)
turbo-rails (2.0.10)
turbo-rails (2.0.11)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.6)
Expand All @@ -307,7 +306,7 @@ GEM
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.18)
zeitwerk (2.7.1)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion app/models/pay/braintree/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def resumable?

def resume
unless resumable?
raise StandardError, "You can only resume subscriptions within their grace period."
raise Error, "You can only resume subscriptions within their grace period."
end

if canceled? && on_trial?
Expand Down
2 changes: 1 addition & 1 deletion app/models/pay/fake_processor/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def resumable?

def resume
unless resumable?
raise StandardError, "You can only resume subscriptions within their grace period."
raise Error, "You can only resume subscriptions within their grace period."
end

update(status: :active, trial_ends_at: nil, ends_at: nil)
Expand Down
8 changes: 4 additions & 4 deletions app/models/pay/lemon_squeezy/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.sync(subscription_id, object: nil, name: Pay.default_product_name)

attributes = {
current_period_end: object.renews_at,
ends_at: (object.ends_at ? Time.parse(object..ends_at) : nil),
ends_at: (object.ends_at ? Time.parse(object.ends_at) : nil),
pause_starts_at: (object.pause&.resumes_at ? Time.parse(object.pause.resumes_at) : nil),
status: object.status,
processor_plan: object.first_subscription_item.price_id,
Expand Down Expand Up @@ -100,7 +100,7 @@ def resumable?

def resume
unless resumable?
raise StandardError, "You can only resume paused or cancelled subscriptions"
raise Error, "You can only resume paused or cancelled subscriptions"
end

if paused? && pause_starts_at? && Time.current < pause_starts_at
Expand All @@ -117,8 +117,8 @@ def resume
# Lemon Squeezy requires both the Product ID and Variant ID.
# The Variant ID will be saved as the processor_plan
def swap(plan, **options)
raise StandardError, "A plan_id is required to swap a subscription" unless plan
raise StandardError, "A variant_id is required to swap a subscription" unless options[:variant_id]
raise Error, "A plan_id is required to swap a subscription" unless plan
raise Error, "A variant_id is required to swap a subscription" unless options[:variant_id]

::LemonSqueezy::Subscription.change_plan id: processor_id, plan_id: plan, variant_id: options[:variant_id]

Expand Down
8 changes: 8 additions & 0 deletions app/models/pay/paddle_billing/charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ def self.sync(charge_id, object: nil, try: 0, retries: 1)
else
pay_customer.charges.create!(attrs.merge(processor_id: object.id))
end
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
try += 1
if try <= retries
sleep 0.1
retry
else
raise
end
end
end
end
Expand Down
Loading

0 comments on commit b338f3c

Please sign in to comment.