Sha256: 7648f97df3efbb892fdf4fd05e0f9531252c2914037c0c6f2f03817773532fee

Contents?: true

Size: 588 Bytes

Versions: 3

Compression:

Stored size: 588 Bytes

Contents

module SpreeKomoju
  module Callbacks
    class Callback
      attr_reader :params

      def initialize(callback_params)
        @params = callback_params
      end

      protected

      def order_number
        params[:data][:external_order_num].split("-").try(:first)
      end

      def payment_number
        params[:data][:external_order_num].split("-").try(:last)
      end

      def order
        @order ||= Spree::Order.find_by_number!(order_number)
      end

      def payment
        @payment ||= order.payments.find_by_number!(payment_number)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_komoju-0.1.4 lib/spree_komoju/callbacks/callback.rb
spree_komoju-0.1.3 lib/spree_komoju/callbacks/callback.rb
spree_komoju-0.1.2 lib/spree_komoju/callbacks/callback.rb