dinero_mail_ipn 1.1.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,30 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hrbg_dinero_mail_ipn (1.0.2)
4
+ dinero_mail_ipn (2.0.2)
5
+ chronic
5
6
  httparty (~> 0.8.1)
6
7
  nokogiri (~> 1.5.0)
7
8
 
8
9
  GEM
9
10
  remote: http://rubygems.org/
10
11
  specs:
12
+ chronic (0.8.0)
13
+ coderay (1.0.8)
11
14
  fakeweb (1.3.0)
12
15
  httparty (0.8.1)
13
16
  multi_json
14
17
  multi_xml
18
+ method_source (0.8.1)
15
19
  multi_json (1.0.4)
16
20
  multi_xml (0.4.1)
17
21
  nokogiri (1.5.0)
22
+ pry (0.9.10)
23
+ coderay (~> 1.0.5)
24
+ method_source (~> 0.8)
25
+ slop (~> 3.3.1)
26
+ rake (0.9.2.2)
18
27
  redcarpet (2.0.1)
19
28
  shoulda (2.11.3)
29
+ slop (3.3.3)
20
30
  yard (0.7.4)
21
31
 
22
32
  PLATFORMS
23
33
  ruby
24
34
 
25
35
  DEPENDENCIES
36
+ dinero_mail_ipn!
26
37
  fakeweb (~> 1.3.0)
27
- hrbg_dinero_mail_ipn!
38
+ pry
39
+ rake
28
40
  redcarpet (~> 2.0.1)
29
41
  shoulda (~> 2.11.3)
30
42
  yard (~> 0.7.4)
@@ -30,4 +30,6 @@ Gem::Specification.new do |s|
30
30
  s.add_development_dependency 'fakeweb', '~> 1.3.0'
31
31
  s.add_development_dependency 'yard', '~> 0.7.4'
32
32
  s.add_development_dependency 'redcarpet', '~> 2.0.1'
33
+ s.add_development_dependency 'rake'
34
+ s.add_development_dependency 'pry'
33
35
  end
@@ -23,14 +23,14 @@ module DineroMailIpn
23
23
  #
24
24
  # ## Nota
25
25
  #
26
- # Por ahora las collections de la consulta solo se pueden consultar por un hash (response.hash)
26
+ # Por ahora las collections de la consulta solo se pueden consultar por un hash (response.dm_hash)
27
27
  #
28
28
  # ## TODO
29
29
  #
30
30
  # Agregar más métodos de 'negocio' que tengan métodos útiles.
31
31
  class ConsultaPagoResponse
32
32
 
33
- attr_accessor :hash
33
+ attr_accessor :dm_hash
34
34
 
35
35
  STATE_DESCRIPTIONS = {0 => 'Los parámetros no respetan el formato requerido', 1 => 'La consulta se realizó correctamente', 2 => 'Los valores son incorrectos para realizar la consulta'}
36
36
 
@@ -43,7 +43,7 @@ module DineroMailIpn
43
43
  # "State"=>"1", "Pays"=>nil, "Collections"=>nil, "Tickets"=>nil, "Receptions"=>nil,
44
44
  # "Retreats"=>nil, "Credits"=>nil, "Debits"=>nil}})
45
45
  def initialize(_hash)
46
- self.hash = _hash
46
+ self.dm_hash = _hash
47
47
  end
48
48
 
49
49
  # Devuelve true si la respuesta no devolvió error
@@ -68,11 +68,14 @@ module DineroMailIpn
68
68
 
69
69
  @payments = []
70
70
  begin
71
- pays = self.hash["Report"]["Pays"]
71
+ pays = self.dm_hash["Report"]["Pays"]["Pay"]
72
72
 
73
73
  if pays
74
- pays.each do |key, payment_hash|
75
- @payments << Payment.new(payment_hash)
74
+ case pays.class.name
75
+ when "Hash"
76
+ @payments << Payment.new(pays)
77
+ when "Array"
78
+ pays.each { |pay| @payments << Payment.new(pay) }
76
79
  end
77
80
  end
78
81
  rescue Exception => e
@@ -81,14 +84,14 @@ module DineroMailIpn
81
84
  @payments
82
85
  end
83
86
 
84
- # Devuelve el código de estado de la respuesta.
87
+ # Devuelve el código de estado de la respuesta.
85
88
  #
86
89
  # Posibilidades: "0", "1" o "2".
87
90
  #
88
91
  # @raise [MalformedResponseError] Si la respuesta no tiene /Report/State
89
92
  def state
90
93
  begin
91
- self.hash["Report"]["State"]
94
+ self.dm_hash["Report"]["State"]
92
95
  rescue Exception => e
93
96
  raise MalformedResponseError.new("No se encontró /Report/State en el XML de respuesta")
94
97
  end
@@ -21,8 +21,8 @@ module DineroMailIpn
21
21
  class Item
22
22
 
23
23
  # @private
24
- def initialize(hash)
25
- @hash = hash
24
+ def initialize(_h)
25
+ @hash = _h
26
26
  end
27
27
 
28
28
  # Devuelve un {String} o nil
@@ -25,14 +25,14 @@ module DineroMailIpn
25
25
  class Payment
26
26
 
27
27
  # @private
28
- def initialize(hash)
29
- @hash = hash
28
+ def initialize(_h)
29
+ @dm_hash = _h
30
30
  end
31
31
 
32
32
  # Devuelve un {String} o nil
33
33
  # @return [String]
34
34
  def [](key)
35
- @hash[key]
35
+ @dm_hash[key]
36
36
  end
37
37
 
38
38
  # Devuelve un {Array} de objetos tipo {Item}
@@ -42,9 +42,9 @@ module DineroMailIpn
42
42
 
43
43
  @items = []
44
44
 
45
- unless @hash["Items"].nil?
46
- @hash["Items"].each do |key, hash|
47
- @items << Item.new(hash)
45
+ unless @dm_hash["Items"].nil?
46
+ @dm_hash["Items"].each do |key, _h|
47
+ @items << Item.new(_h)
48
48
  end
49
49
  end
50
50
 
@@ -1,3 +1,3 @@
1
1
  module DineroMailIpn
2
- VERSION = "1.1.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -0,0 +1,70 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <Report>
3
+ <Email>ernesto@ombushop.com</Email>
4
+ <Acount>17128254</Acount>
5
+ <Pin>AYCN7IXDTM</Pin>
6
+ <StartDate>20110620</StartDate>
7
+ <EndDate>20110703</EndDate>
8
+ <XML>1</XML>
9
+ <State>1</State>
10
+ <Pays>
11
+ <Pay trx_id="R163000000">
12
+ <Trx_Date>2011-12-20 05:44:56</Trx_Date>
13
+ <Trx_NombreComprador>Juan Perez</Trx_NombreComprador>
14
+ <Trx_Email>juanperez@ombushop.com</Trx_Email>
15
+ <Trx_Payment>108.00</Trx_Payment>
16
+ <Trx_ShipAddress></Trx_ShipAddress>
17
+ <Trx_Comment></Trx_Comment>
18
+ <Trx_MontoNeto>100.97</Trx_MontoNeto>
19
+ <Trx_SellerDocumentType>DNI</Trx_SellerDocumentType>
20
+ <Trx_SellerDocumentNumber>26.000.000</Trx_SellerDocumentNumber>
21
+ <Trx_Number>12345678</Trx_Number>
22
+ <Trx_PaymentMethod>Codigo de Barras</Trx_PaymentMethod>
23
+ <Trx_PaymentMean>Pago Facil</Trx_PaymentMean>
24
+ <Trx_BuyerDocumentType>DNI</Trx_BuyerDocumentType>
25
+ <Trx_BuyerDocumentNumber>26000000</Trx_BuyerDocumentNumber>
26
+ <Trx_BuyerPhone>+540351844232</Trx_BuyerPhone>
27
+ <Items>
28
+ <Item Item_Code="SKU123">
29
+ <Item_Quantity>1</Item_Quantity>
30
+ <Item_Description>Zapatos de Cuero</Item_Description>
31
+ <Item_Payment>68.00</Item_Payment>
32
+ </Item>
33
+ </Items>
34
+ </Pay>
35
+ <Pay trx_id="R163000001">
36
+ <Trx_Date>2011-12-21 05:44:56</Trx_Date>
37
+ <Trx_NombreComprador>Derp Herp</Trx_NombreComprador>
38
+ <Trx_Email>derp_herp@ombushop.com</Trx_Email>
39
+ <Trx_Payment>108.00</Trx_Payment>
40
+ <Trx_ShipAddress></Trx_ShipAddress>
41
+ <Trx_Comment></Trx_Comment>
42
+ <Trx_MontoNeto>100.97</Trx_MontoNeto>
43
+ <Trx_SellerDocumentType>DNI</Trx_SellerDocumentType>
44
+ <Trx_SellerDocumentNumber>25.000.000</Trx_SellerDocumentNumber>
45
+ <Trx_Number>12345679</Trx_Number>
46
+ <Trx_PaymentMethod>Codigo de Barras</Trx_PaymentMethod>
47
+ <Trx_PaymentMean>Pago Facil</Trx_PaymentMean>
48
+ <Trx_BuyerDocumentType>DNI</Trx_BuyerDocumentType>
49
+ <Trx_BuyerDocumentNumber>25000000</Trx_BuyerDocumentNumber>
50
+ <Trx_BuyerPhone>+540351844231</Trx_BuyerPhone>
51
+ <Items>
52
+ <Item Item_Code="SKU123">
53
+ <Item_Quantity>1</Item_Quantity>
54
+ <Item_Description>Zapatos de Cuero</Item_Description>
55
+ <Item_Payment>68.00</Item_Payment>
56
+ </Item>
57
+ </Items>
58
+ </Pay>
59
+ </Pays>
60
+ <Collections />
61
+ <Tickets />
62
+ <Receptions />
63
+ <Retreats />
64
+ <Credits />
65
+ <Debits />
66
+ </Report>
67
+
68
+ <!-- client = DineroMailIpn::Client.new(email: "isaac.attie@cir-med.com", account: "21353370", pin: "BZLOG9UB72")
69
+ params = {:XML => 1, :Acount => "21353370", :Pin => "BZLOG9UB72", :Email => "isaac.attie@cir-med.com"}.merge({:StartDate => client.format_date(Date.today - 7), :EndDate => client.format_date(Date.today)})
70
+ xml = client.class.get("https://argentina.dineromail.com/vender/ConsultaPago.asp", :query => params) -->
@@ -17,25 +17,49 @@ class TestDineroMailIpn < Test::Unit::TestCase
17
17
  assert_equal response.state_description, "La consulta se realizó correctamente"
18
18
  end
19
19
 
20
- should "return OK with a collection of payments" do
20
+ should "return OK with 1 payment" do
21
21
  stub_get("/vender/ConsultaPago.asp?XML=1&Acount=17128254&Pin=AYCN7IXDTM&Email=ernesto%40ombushop.com&StartDate=20110702&EndDate=20110703",
22
- "ConsultaPagoOkWithPays.xml")
22
+ "ConsultaPagoOKWith1Pay.xml")
23
23
  client = DineroMailIpn::Client.new(:email => 'ernesto@ombushop.com',
24
24
  :account => '17128254',
25
25
  :pin => 'AYCN7IXDTM')
26
26
  response = client.consulta_pago(Date.new(2011,7,2), Date.new(2011,7,3))
27
- assert_equal response.state, "1"
27
+ assert_equal "1", response.state
28
+ assert_equal 1, response.payments.size
29
+ assert response.ok?
30
+ assert_equal "La consulta se realizó correctamente", response.state_description
31
+ assert !response.payments.empty?
32
+ payment = response.payments.first
33
+ assert_equal "juanperez@ombushop.com", payment["Trx_Email"]
34
+ assert_equal "R163000000", payment["trx_id"]
35
+ assert payment["Trx_Numbr"].nil?
36
+ assert !payment.items.empty?
37
+ item = payment.items.first
38
+ assert_equal "SKU123", item["Item_Code"]
39
+ assert_equal "68.00", item["Item_Payment"]
40
+ assert item["item_quantity"].nil?
41
+ end
42
+
43
+ should "return OK with 2 payments" do
44
+ stub_get("/vender/ConsultaPago.asp?XML=1&Acount=17128254&Pin=AYCN7IXDTM&Email=ernesto%40ombushop.com&StartDate=20110702&EndDate=20110703",
45
+ "ConsultaPagoOKWith2Pays.xml")
46
+ client = DineroMailIpn::Client.new(:email => 'ernesto@ombushop.com',
47
+ :account => '17128254',
48
+ :pin => 'AYCN7IXDTM')
49
+ response = client.consulta_pago(Date.new(2011,7,2), Date.new(2011,7,3))
50
+ assert_equal "1", response.state
51
+ assert_equal 2, response.payments.size
28
52
  assert response.ok?
29
53
  assert_equal response.state_description, "La consulta se realizó correctamente"
30
54
  assert !response.payments.empty?
31
55
  payment = response.payments.first
32
- assert_equal payment["Trx_Email"], "juanperez@ombushop.com"
33
- assert_equal payment["trx_id"], "R163000000"
56
+ assert_equal "juanperez@ombushop.com", payment["Trx_Email"]
57
+ assert_equal "R163000000", payment["trx_id"]
34
58
  assert payment["Trx_Numbr"].nil?
35
59
  assert !payment.items.empty?
36
60
  item = payment.items.first
37
- assert_equal item["Item_Code"], "SKU123"
38
- assert_equal item["Item_Payment"], "68.00"
61
+ assert_equal "SKU123", item["Item_Code"]
62
+ assert_equal "68.00", item["Item_Payment"]
39
63
  assert item["item_quantity"].nil?
40
64
  end
41
65
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dinero_mail_ipn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-31 00:00:00.000000000 Z
13
+ date: 2012-11-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -124,6 +124,38 @@ dependencies:
124
124
  - - ~>
125
125
  - !ruby/object:Gem::Version
126
126
  version: 2.0.1
127
+ - !ruby/object:Gem::Dependency
128
+ name: rake
129
+ requirement: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ - !ruby/object:Gem::Dependency
144
+ name: pry
145
+ requirement: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ! '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ type: :development
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
127
159
  description: Dinero Mail IPN stub
128
160
  email:
129
161
  - ernesto@ombushop.com
@@ -152,7 +184,8 @@ files:
152
184
  - resources/IPN_es.pdf
153
185
  - script/console
154
186
  - test/fixtures/ConsultaPagoErrorBadCredentials.xml
155
- - test/fixtures/ConsultaPagoOkWithPays.xml
187
+ - test/fixtures/ConsultaPagoOKWith2Pays.xml
188
+ - test/fixtures/ConsultaPagoOkWith1Pay.xml
156
189
  - test/fixtures/ConsultaPagoOkWithoutCollections.xml
157
190
  - test/fixtures/ConsultaTransacciones1-2Success.xml
158
191
  - test/fixtures/ConsultaTransacciones1Success.xml
@@ -172,12 +205,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
205
  - - ! '>='
173
206
  - !ruby/object:Gem::Version
174
207
  version: '0'
208
+ segments:
209
+ - 0
210
+ hash: -2281383812012634155
175
211
  required_rubygems_version: !ruby/object:Gem::Requirement
176
212
  none: false
177
213
  requirements:
178
214
  - - ! '>='
179
215
  - !ruby/object:Gem::Version
180
216
  version: '0'
217
+ segments:
218
+ - 0
219
+ hash: -2281383812012634155
181
220
  requirements: []
182
221
  rubyforge_project: dinero_mail_ipn
183
222
  rubygems_version: 1.8.24