akitaonrails-lw-pagto-certo 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lw-pagto-certo.rb +19 -11
- data/lib/lw-pagto-certo/version.rb +1 -1
- metadata +1 -1
data/lib/lw-pagto-certo.rb
CHANGED
@@ -104,14 +104,14 @@ class LwPagtoCerto
|
|
104
104
|
payload = IniciaTransacao.new( self.chave_vendedor, self.url_retorno, transacao )
|
105
105
|
response = LwPagtoCerto.soap.iniciaTransacao(payload)
|
106
106
|
response = Hash.from_xml(response.iniciaTransacaoResult)
|
107
|
-
response = response["
|
107
|
+
response = response["LocaWeb"]["Transacao"].symbolize_keys
|
108
108
|
|
109
109
|
response[:data] = Time.parse(response[:data].gsub(/(\d+)\/(\d+)\/(\d+)\s(.*)/,
|
110
110
|
"#{$3}-#{$2}-#{$1}T#{$4}")) if response[:data]
|
111
|
-
if response[:
|
111
|
+
if response[:CodRetorno]
|
112
112
|
response.instance_eval do
|
113
113
|
def cod_retorno_mensagem
|
114
|
-
LwPagtoCerto::INICIA_COD_RETORNO[self[:
|
114
|
+
LwPagtoCerto::INICIA_COD_RETORNO[self[:CodRetorno].to_sym]
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
@@ -123,25 +123,33 @@ class LwPagtoCerto
|
|
123
123
|
# lw = LwPagtoCerto.new(:chave_vendedor => "xxxxx", :url_retorno => "http://dominio.com/pagto")
|
124
124
|
# retorno = lw.consulta("xxxxxxxx") # passa Id da transação retornada ao chamar "inicia"
|
125
125
|
#
|
126
|
-
# puts retorno[:
|
127
|
-
# puts retorno[:
|
128
|
-
# puts retorno[:
|
126
|
+
# puts retorno[:CodRetorno]
|
127
|
+
# puts retorno[:IdTransacao]
|
128
|
+
# puts retorno[:Codigo]
|
129
129
|
# puts retorno[:data] # => "26/3/2009 15:19:41"
|
130
|
-
# puts retorno[:
|
130
|
+
# puts retorno[:MensagemRetorno]
|
131
131
|
def consulta(id_transacao = "")
|
132
132
|
payload = ConsultaTransacao.new self.chave_vendedor, id_transacao
|
133
133
|
response = LwPagtoCerto.soap.consultaTransacao(payload)
|
134
134
|
response = Hash.from_xml(response.consultaTransacaoResult)
|
135
|
-
response = response["
|
136
|
-
if response[:
|
135
|
+
response = response["LocaWeb"]["Transacao"].symbolize_keys
|
136
|
+
if response[:CodRetorno]
|
137
137
|
response.instance_eval do
|
138
138
|
def cod_retorno_mensagem
|
139
|
-
LwPagtoCerto::FINALIZA_COD_RETORNO[self[:
|
139
|
+
LwPagtoCerto::FINALIZA_COD_RETORNO[self[:CodRetorno].to_sym]
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
143
143
|
response
|
144
144
|
end
|
145
|
+
|
146
|
+
def consultaPedido(id_transacao = "")
|
147
|
+
payload = ConsultaTransacao.new self.chave_vendedor, id_transacao
|
148
|
+
response = LwPagtoCerto.soap.consultaTransacao(payload)
|
149
|
+
response = Hash.from_xml(response.consultaTransacaoResult)
|
150
|
+
return response["LocaWeb"]["Pedido"].symbolize_keys if response["LocaWeb"]["Pedido"]
|
151
|
+
return []
|
152
|
+
end
|
145
153
|
|
146
154
|
# Usado internamento pelo Inicia Transacao para gerar o XML
|
147
155
|
# que define a transacao sendo iniciada. Utilize os accessors
|
@@ -199,4 +207,4 @@ class LwPagtoCerto
|
|
199
207
|
def endpoint_url(url)
|
200
208
|
soap.endpoint_url = url
|
201
209
|
end
|
202
|
-
end
|
210
|
+
end
|