Sha256: db60184bf3d4a24ef572994456f6d01d7700c5d71799132811addd66b6b2f62f
Contents?: true
Size: 1.31 KB
Versions: 11
Compression:
Stored size: 1.31 KB
Contents
module Spree module Mollie class Order def initialize(order) @order = order @mollie_order = mollie_order end attr_accessor :mollie_order, :order def mollie_order ::Mollie::Order.get(mollie_order_id, api_key: api_key) end def get_line_by_id(line_item_id) @mollie_order.lines.detect { |line| line.sku.start_with?("#{line_item_id}-") } end def id @mollie_order.id end def shipping_fees @mollie_order.lines.select { |line| line.type === 'shipping_fee' && line.status === 'authorized' } end def discounts @mollie_order.lines.select { |line| line.type === 'discount' && line.status === 'authorized' } end def collect_fees_on_first_shipment? gateway.get_preference(:collect_shipping_costs_and_discounts_on_first_shipment) end private def mollie_order_id payment.source.payment_id end def has_mollie_order? payment.source.is_a? Spree::MolliePaymentSource end def payment @order.payments.last end def gateway Spree::PaymentMethod.find_by_type 'Spree::Gateway::MollieGateway' end def api_key gateway.get_preference(:api_key) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems