Class: SpreeSquare::OrderBuilder
- Inherits:
-
Object
- Object
- SpreeSquare::OrderBuilder
- Defined in:
- app/services/spree_square/order_builder.rb
Overview
Builds the Square CreateOrder payload for a completed Spree::Order. Deliberately omits pricing beyond per-line-item base_price_money/modifiers — no taxes/discounts sent — so Square's computed total_money is exactly what OrderPusher then charges via the EXTERNAL payment, with nothing for Square's own tax/discount engine to add on top and create a mismatch.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call ⇒ Object
8 |
# File 'app/services/spree_square/order_builder.rb', line 8 def self.call(...) = new.call(...) |
Instance Method Details
#call(order) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/services/spree_square/order_builder.rb', line 10 def call(order) location_mapping = location_mapping_for(order) raise "No Square location mapped for order #{order.number}" unless location_mapping { location_id: location_mapping.square_location_id, reference_id: order.number, line_items: order.line_items.map { |line_item| build_line_item(line_item) }, fulfillments: [build_fulfillment(order)] } end |