Skip to content

Commit

Permalink
Merge pull request #5 from amo13/patch-1
Browse files Browse the repository at this point in the history
Add missing parameters to Subscription.change_plan
  • Loading branch information
deanpcmad authored Jan 27, 2024
2 parents 11ab993 + 90d2fea commit a4cd646
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ LemonSqueezy::Subscription.cancel id: 123
LemonSqueezy::Subscription.uncancel id: 123

# Change the Plan for a Subscription
LemonSqueezy::Subscription.change_plan id: 123, plan_id: 111, variant_id: 111
# invoice_immediately and disable_prorations are optional and false by default.
LemonSqueezy::Subscription.change_plan id: 123, plan_id: 111, variant_id: 111, invoice_immediately: false, disable_prorations: false
```

### Subscription Invoices
Expand Down
6 changes: 4 additions & 2 deletions lib/lemon_squeezy/models/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ def uncancel(id:)
Subscription.new(response.body["data"]) if response.success?
end

def change_plan(id:, plan_id:, variant_id:)
def change_plan(id:, plan_id:, variant_id:, invoice_immediately: false, disable_prorations: false)
body = {
data: {
type: "subscriptions",
id: id.to_s,
attributes: {
product_id: plan_id,
variant_id: variant_id
variant_id: variant_id,
invoice_immediately: invoice_immediately,
disable_prorations: disable_prorations
}
}
}
Expand Down

0 comments on commit a4cd646

Please sign in to comment.