class Portmone::Responses::OrderStatus
Public Instance Methods
actual_amount()
click to toggle source
# File lib/portmone/responses/order_status.rb, line 39 def actual_amount amount + reversed_amount end
amount()
click to toggle source
# File lib/portmone/responses/order_status.rb, line 27 def amount transactions.select(&:paid?) .map { |t| t.bill_amount } .inject(:+) || transactions.first&.bill_amount end
order()
click to toggle source
# File lib/portmone/responses/order_status.rb, line 68 def order @order ||= begin if data Portmone::Transaction.new(data.first.merge(data.last).merge(timezone: @timezone, currency: @currency)) else Portmone::Transaction.new(timezone: @timezone, currency: @currency) end end end
paid?()
click to toggle source
статусы “оплачено” и “авторизовано”
# File lib/portmone/responses/order_status.rb, line 44 def paid? transactions.any?(&:paid?) end
reversed?()
click to toggle source
# File lib/portmone/responses/order_status.rb, line 48 def reversed? transactions.any?(&:reversed?) end
reversed_amount()
click to toggle source
# File lib/portmone/responses/order_status.rb, line 33 def reversed_amount transactions.select(&:reversed?) .map { |t| t.bill_amount } .inject(:+) || 0 end
success?()
click to toggle source
# File lib/portmone/responses/order_status.rb, line 52 def success? order.present? && error_code == '0' end
transactions()
click to toggle source
# File lib/portmone/responses/order_status.rb, line 56 def transactions @transactions ||= begin if data data.map do |h| Portmone::Transaction.new(h.merge(timezone: @timezone, currency: @currency)) end else [] end end end
Private Instance Methods
data()
click to toggle source
# File lib/portmone/responses/order_status.rb, line 80 def data data = @xml_data.dig('portmoneresult', 'orders', 'order') || @xml_data.dig('portmoneresult', 'order') data = [data] if data.is_a?(Hash) # cannot use Array() on Hash data&.sort_by { |h| h['pay_date'] && ActiveSupport::TimeZone[@timezone].parse(h['pay_date']) } end