class SolidusShipstation::ShipmentNotice
Attributes
shipment_number[R]
shipment_tracking[R]
Public Class Methods
from_payload(params)
click to toggle source
# File lib/solidus_shipstation/shipment_notice.rb, line 8 def from_payload(params) new( shipment_number: params[:order_number], shipment_tracking: params[:tracking_number], ) end
new(shipment_number:, shipment_tracking:)
click to toggle source
# File lib/solidus_shipstation/shipment_notice.rb, line 16 def initialize(shipment_number:, shipment_tracking:) @shipment_number = shipment_number @shipment_tracking = shipment_tracking end
Public Instance Methods
apply()
click to toggle source
# File lib/solidus_shipstation/shipment_notice.rb, line 21 def apply unless shipment raise ShipmentNotFoundError, shipment end process_payment ship_shipment shipment end
Private Instance Methods
process_payment()
click to toggle source
# File lib/solidus_shipstation/shipment_notice.rb, line 38 def process_payment return if shipment.order.paid? unless SolidusShipstation.configuration.capture_at_notification raise OrderNotPaidError, shipment.order end shipment.order.payments.pending.each do |payment| payment.capture! rescue ::Spree::Core::GatewayError raise PaymentError, payment end end
ship_shipment()
click to toggle source
# File lib/solidus_shipstation/shipment_notice.rb, line 52 def ship_shipment shipment.update!(tracking: shipment_tracking) shipment.ship! if shipment.can_ship? shipment.order.recalculate end
shipment()
click to toggle source
# File lib/solidus_shipstation/shipment_notice.rb, line 34 def shipment @shipment ||= ::Spree::Shipment.find_by(number: shipment_number) end