6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/rbraspag/order.rb', line 6
def self.status(order_id)
connection = Braspag::Connection.instance
raise InvalidOrderId unless Braspag::PaymentMethod.valid_order_id?(order_id)
request = ::HTTPI::Request.new(self.status_url)
request.body = {
:loja => connection.merchant_id, :numeroPedido => order_id.to_s
}
response = ::HTTPI.post(request)
response = Utils::convert_to_map(response.body, {
:authorization => "CodigoAutorizacao",
:error_code => "CodigoErro",
:error_message => "MensagemErro",
:payment_method => "CodigoPagamento",
:payment_method_name => "FormaPagamento",
:installments => "NumeroParcelas",
:status => "Status",
:amount => "Valor",
:cancelled_at => "DataCancelamento",
:paid_at => "DataPagamento",
:order_date => "DataPedido",
:transaction_id => "TransId",
:tid => "BraspagTid"
})
raise InvalidData if response[:authorization].nil?
response
end
|