summaryrefslogtreecommitdiff
path: root/lib/solidus_subscriptions/order_creator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/solidus_subscriptions/order_creator.rb')
-rw-r--r--lib/solidus_subscriptions/order_creator.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/solidus_subscriptions/order_creator.rb b/lib/solidus_subscriptions/order_creator.rb
new file mode 100644
index 0000000..a2db8ce
--- /dev/null
+++ b/lib/solidus_subscriptions/order_creator.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module SolidusSubscriptions
+ class OrderCreator
+ def initialize(installment)
+ @installment = installment
+ end
+
+ def call
+ ::Spree::Order.create(
+ user: installment.subscription.user,
+ email: installment.subscription.user.email,
+ store: installment.subscription.store || ::Spree::Store.default,
+ subscription_order: true,
+ subscription: installment.subscription,
+ currency: installment.subscription.currency,
+ **extra_attributes
+ )
+ end
+
+ private
+
+ def extra_attributes
+ {}
+ end
+
+ attr_reader :installment
+ end
+end