diff --git a/app/models/pay/paddle_billing/subscription.rb b/app/models/pay/paddle_billing/subscription.rb index 4d79f524..58327069 100644 --- a/app/models/pay/paddle_billing/subscription.rb +++ b/app/models/pay/paddle_billing/subscription.rb @@ -102,7 +102,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 @@ -148,12 +152,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