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 24, 2024
2 parents d2848c0 + 3ea097f commit 3f8a1f0
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 66 deletions.
110 changes: 55 additions & 55 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ GIT
PATH
remote: .
specs:
pay (8.1.1)
pay (8.1.2)
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.1)
actionpack (= 7.2.1.1)
activesupport (= 7.2.1.1)
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.1)
actionpack (= 7.2.1.1)
activejob (= 7.2.1.1)
activerecord (= 7.2.1.1)
activestorage (= 7.2.1.1)
activesupport (= 7.2.1.1)
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.1)
actionpack (= 7.2.1.1)
actionview (= 7.2.1.1)
activejob (= 7.2.1.1)
activesupport (= 7.2.1.1)
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.1)
actionview (= 7.2.1.1)
activesupport (= 7.2.1.1)
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.1)
actionpack (= 7.2.1.1)
activerecord (= 7.2.1.1)
activestorage (= 7.2.1.1)
activesupport (= 7.2.1.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.2.1)
activesupport (= 7.2.1)
actionview (7.2.1.1)
activesupport (= 7.2.1.1)
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.1)
activesupport (= 7.2.1.1)
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.1)
activesupport (= 7.2.1.1)
activerecord (7.2.1.1)
activemodel (= 7.2.1.1)
activesupport (= 7.2.1.1)
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.1)
actionpack (= 7.2.1.1)
activejob (= 7.2.1.1)
activerecord (= 7.2.1.1)
activesupport (= 7.2.1.1)
marcel (~> 1.0)
activesupport (7.2.1)
activesupport (7.2.1.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
Expand Down Expand Up @@ -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.1)
actioncable (= 7.2.1.1)
actionmailbox (= 7.2.1.1)
actionmailer (= 7.2.1.1)
actionpack (= 7.2.1.1)
actiontext (= 7.2.1.1)
actionview (= 7.2.1.1)
activejob (= 7.2.1.1)
activemodel (= 7.2.1.1)
activerecord (= 7.2.1.1)
activestorage (= 7.2.1.1)
activesupport (= 7.2.1.1)
bundler (>= 1.15.0)
railties (= 7.2.1)
railties (= 7.2.1.1)
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.1)
actionpack (= 7.2.1.1)
activesupport (= 7.2.1.1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
Expand Down
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion app/models/pay/paddle_billing/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def api_record
pc
else
pc = ::Paddle::Customer.create(email: email, name: customer_name)
update!(processor_id: sc.id)
update!(processor_id: pc.id)
pc
end
rescue ::Paddle::Error => e
Expand Down
14 changes: 12 additions & 2 deletions app/models/pay/paddle_billing/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ def change_quantity(quantity, **options)
quantity: quantity
}]

::Paddle::Subscription.update(id: processor_id, items: items, proration_billing_mode: "prorated_immediately")
::Paddle::Subscription.update(
id: processor_id,
items: items,
proration_billing_mode: options.delete(:proration_billing_mode) || "prorated_immediately"
)
update(quantity: quantity)
rescue ::Paddle::Error => e
raise Pay::PaddleBilling::Error, e
Expand Down Expand Up @@ -156,12 +160,18 @@ def resume
end

def swap(plan, **options)
raise ArgumentError, "plan must be a string" unless plan.is_a?(String)

items = [{
price_id: plan,
quantity: quantity || 1
}]

::Paddle::Subscription.update(id: processor_id, items: items, proration_billing_mode: "prorated_immediately")
::Paddle::Subscription.update(
id: processor_id,
items: items,
proration_billing_mode: options.delete(:proration_billing_mode) || "prorated_immediately"
)
update(processor_plan: plan, ends_at: nil, status: :active)
end

Expand Down
2 changes: 1 addition & 1 deletion docs/paddle_billing/1_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Paddle now works similar to Stripe. You create a customer, which subscriptions b
@user.set_payment_processor :paddle_billing

# Create the customer on Paddle
@user.payment_processor.customer
@user.payment_processor.api_record
```

## Prices & Plans
Expand Down
3 changes: 3 additions & 0 deletions docs/stripe/8_stripe_checkout.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ First, create a session in your controller:
class SubscriptionsController < ApplicationController
def index
@portal_session = current_user.payment_processor.billing_portal
# You can customize the billing_portal return_url (default is root_url):
# @portal_session = current_user.payment_processor.billing_portal(return_url: your_url)
end
end
```
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_6_1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GIT
PATH
remote: ..
specs:
pay (8.1.1)
pay (8.1.2)
rails (>= 6.0.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_7.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GIT
PATH
remote: ..
specs:
pay (8.1.1)
pay (8.1.2)
rails (>= 6.0.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_7_1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GIT
PATH
remote: ..
specs:
pay (8.1.1)
pay (8.1.2)
rails (>= 6.0.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_7_2.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GIT
PATH
remote: ..
specs:
pay (8.1.1)
pay (8.1.2)
rails (>= 6.0.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_main.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ GIT
PATH
remote: ..
specs:
pay (8.1.1)
pay (8.1.2)
rails (>= 6.0.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion lib/pay/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Pay
VERSION = "8.1.1"
VERSION = "8.1.2"
end

0 comments on commit 3f8a1f0

Please sign in to comment.