From 113aab93b4c5a6bf58d37668dd2a54b1ddecd6ef Mon Sep 17 00:00:00 2001 From: Chris Oliver Date: Mon, 7 Oct 2024 09:46:49 -0500 Subject: [PATCH] Refactor --- app/models/pay/paddle_billing/subscription.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/models/pay/paddle_billing/subscription.rb b/app/models/pay/paddle_billing/subscription.rb index 6ac37aba..65f26d01 100644 --- a/app/models/pay/paddle_billing/subscription.rb +++ b/app/models/pay/paddle_billing/subscription.rb @@ -102,9 +102,11 @@ def change_quantity(quantity, **options) quantity: quantity }] - proration_billing_mode = options.delete(:proration_billing_mode) || "prorated_immediately" - - ::Paddle::Subscription.update(id: processor_id, items: items, proration_billing_mode: proration_billing_mode) + ::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 @@ -157,9 +159,11 @@ def swap(plan, **options) quantity: quantity || 1 }] - proration_billing_mode = options.delete(:proration_billing_mode) || "prorated_immediately" - - ::Paddle::Subscription.update(id: processor_id, items: items, proration_billing_mode: proration_billing_mode) + ::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