Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Agregué un ejemplo de respuesta para ipn v1 con Pays

Agregué tests para chequear que payments e items funcionen OK.
  • Loading branch information...
commit acc03bcf96e93c71db3ba3b602d03316d3f0e1ab 1 parent 384f605
etagwerker authored
View
42 test/fixtures/ConsultaPagoOkWithPays.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<Report>
+ <Email>ernesto@ombushop.com</Email>
+ <Acount>17128254</Acount>
+ <Pin>AYCN7IXDTM</Pin>
+ <StartDate>20110620</StartDate>
+ <EndDate>20110703</EndDate>
+ <XML>1</XML>
+ <State>1</State>
+ <Pays>
+ <Pay trx_id="R163000000">
+ <Trx_Date>2011-12-20 05:44:56</Trx_Date>
+ <Trx_NombreComprador>Juan Perez</Trx_NombreComprador>
+ <Trx_Email>juanperez@ombushop.com</Trx_Email>
+ <Trx_Payment>108.00</Trx_Payment>
+ <Trx_ShipAddress></Trx_ShipAddress>
+ <Trx_Comment></Trx_Comment>
+ <Trx_MontoNeto>100.97</Trx_MontoNeto>
+ <Trx_SellerDocumentType>DNI</Trx_SellerDocumentType>
+ <Trx_SellerDocumentNumber>26.000.000</Trx_SellerDocumentNumber>
+ <Trx_Number>12345678</Trx_Number>
+ <Trx_PaymentMethod>Codigo de Barras</Trx_PaymentMethod>
+ <Trx_PaymentMean>Pago Facil</Trx_PaymentMean>
+ <Trx_BuyerDocumentType>DNI</Trx_BuyerDocumentType>
+ <Trx_BuyerDocumentNumber>26000000</Trx_BuyerDocumentNumber>
+ <Trx_BuyerPhone>+540351844232</Trx_BuyerPhone>
+ <Items>
+ <Item Item_Code="SKU123">
+ <Item_Quantity>1</Item_Quantity>
+ <Item_Description>Zapatos de Cuero</Item_Description>
+ <Item_Payment>68.00</Item_Payment>
+ </Item>
+ </Items>
+ </Pay>
+ </Pays>
+ <Collections />
+ <Tickets />
+ <Reception />
+ <Retreats />
+ <Credits />
+ <Debits />
+</Report>
View
45 test/test_dinero_mail_ipn.rb
@@ -1,5 +1,4 @@
# encoding: utf-8
-
require File.expand_path('../helper', __FILE__)
class TestDineroMailIpn < Test::Unit::TestCase
@@ -9,48 +8,76 @@ class TestDineroMailIpn < Test::Unit::TestCase
should "return OK for the query with valid Pin and Account parameters" do
stub_get("/vender/ConsultaPago.asp?XML=1&Acount=17128254&Pin=AYCN7IXDTM&Email=ernesto%40ombushop.com&StartDate=20110702&EndDate=20110703",
"ConsultaPagoOkWithoutCollections.xml")
- client = DineroMailIpn::Client.new(:email => 'ernesto@ombushop.com', :account => '17128254', :pin => 'AYCN7IXDTM')
+ client = DineroMailIpn::Client.new(:email => 'ernesto@ombushop.com',
+ :account => '17128254',
+ :pin => 'AYCN7IXDTM')
+ response = client.consulta_pago(Date.new(2011,7,2), Date.new(2011,7,3))
+ assert_equal response.state, "1"
+ assert response.ok?
+ assert_equal response.state_description, "La consulta se realizó correctamente"
+ end
+
+ should "return OK with a collection of payments" do
+ stub_get("/vender/ConsultaPago.asp?XML=1&Acount=17128254&Pin=AYCN7IXDTM&Email=ernesto%40ombushop.com&StartDate=20110702&EndDate=20110703",
+ "ConsultaPagoOkWithPays.xml")
+ client = DineroMailIpn::Client.new(:email => 'ernesto@ombushop.com',
+ :account => '17128254',
+ :pin => 'AYCN7IXDTM')
response = client.consulta_pago(Date.new(2011,7,2), Date.new(2011,7,3))
assert_equal response.state, "1"
+ assert response.ok?
assert_equal response.state_description, "La consulta se realizó correctamente"
+ assert !response.payments.empty?
+ payment = response.payments.first
+ assert_equal payment["Trx_Email"], "juanperez@ombushop.com"
+ assert_equal payment["trx_id"], "R163000000"
+ assert payment["Trx_Numbr"].nil?
+ assert !payment.items.empty?
+ item = payment.items.first
+ assert_equal item["Item_Code"], "SKU123"
+ assert_equal item["Item_Payment"], "68.00"
+ assert item["item_quantity"].nil?
end
should "return Error for the query" do
stub_get("/vender/ConsultaPago.asp?XML=1&Acount=123&Pin=UasdM&Email=ernesto%40ombushop.com&StartDate=20110702&EndDate=20110703",
"ConsultaPagoErrorBadCredentials.xml")
- client = DineroMailIpn::Client.new(:email => 'ernesto@ombushop.com', :account => '123', :pin => 'UasdM')
+ client = DineroMailIpn::Client.new(:email => 'ernesto@ombushop.com',
+ :account => '123',
+ :pin => 'UasdM')
response = client.consulta_pago(Date.new(2011,7,2), Date.new(2011,7,3))
assert_equal response.state, "2"
+ assert response.error?
assert_equal response.state_description, "Los valores son incorrectos para realizar la consulta"
end
end
context "when I query for some transactions" do
-
+
should "return a new report object" do
stub_post("/Vender/Consulta_IPN.asp", "ConsultaTransacciones1-2Success.xml",
{:url => {:https => false}})
client = DineroMailIpn::Client.new(:password => 'fuckingipnpasswordinplaintext', :account => '17128254')
- reporter = client.consulta_transacciones(1,2)
+ reporter = client.consulta_transacciones([1,2])
assert reporter.kind_of?(DineroMailIpn::Reporter)
assert_equal 2, reporter.reports.size
end
end
-
+
context "when I query for a transactions" do
-
+
should "return a new report object" do
stub_post("/Vender/Consulta_IPN.asp", "ConsultaTransacciones1Success.xml",
{:url => {:https => false}})
client = DineroMailIpn::Client.new(:password => 'fuckingipnpasswordinplaintext', :account => '17128254')
- reporter = client.consulta_transacciones(1)
+ reporter = client.consulta_transacciones([1])
assert reporter.kind_of?(DineroMailIpn::Reporter)
assert_equal 1, reporter.reports.size
end
end
-end
+end
View
2  test/test_reporter.rb
@@ -14,7 +14,7 @@ def test_invalid_report_should_return_invalid
reporter = DineroMailIpn::Reporter.new(xml_response)
assert !reporter.valid?
end
-
+
def test_invalid_report_should_has_no_reports
xml_response = <<-XML
<?xml version="1.0" encoding="ISO-8859-1"?>
Please sign in to comment.
Something went wrong with that request. Please try again.