Class: Portmone::Responses::OrderStatus
Instance Attribute Summary
Attributes inherited from BaseResponse
#response, #xml_data
Instance Method Summary
collapse
#http_status, #initialize
Instance Method Details
#actual_amount ⇒ Object
39
40
41
|
# File 'lib/portmone/responses/order_status.rb', line 39
def actual_amount
amount + reversed_amount
end
|
#amount ⇒ Object
27
28
29
30
31
|
# 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 ⇒ Object
68
69
70
71
72
73
74
75
76
|
# 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? ⇒ Boolean
статусы “оплачено” и “авторизовано”
44
45
46
|
# File 'lib/portmone/responses/order_status.rb', line 44
def paid?
transactions.any?(&:paid?)
end
|
#reversed? ⇒ Boolean
48
49
50
|
# File 'lib/portmone/responses/order_status.rb', line 48
def reversed?
transactions.any?(&:reversed?)
end
|
#reversed_amount ⇒ Object
33
34
35
36
37
|
# File 'lib/portmone/responses/order_status.rb', line 33
def reversed_amount
transactions.select(&:reversed?)
.map { |t| t.bill_amount }
.inject(:+) || 0
end
|
#success? ⇒ Boolean
52
53
54
|
# File 'lib/portmone/responses/order_status.rb', line 52
def success?
order.present? && error_code == '0'
end
|
#transactions ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
|
# 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
|