puntopagos 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -1,3 +1,5 @@
1
+ "!https://codeclimate.com/github/acidlabs/puntopagos-ruby.png!":https://codeclimate.com/github/acidlabs/puntopagos-ruby
2
+
1
3
  h1. PuntoPagos
2
4
 
3
5
  This development is in a very early stage, please use it at your own risk and feel free to improve it and send Pull Requests.
@@ -54,6 +56,14 @@ h3. Verify notification sent by PuntoPagos
54
56
 
55
57
  </pre>
56
58
 
59
+ h3. Check status of a transaction
60
+
61
+ <pre>
62
+ status = PuntoPagos::Status.new
63
+ status.check token, trx_id, amount
64
+ status.valid? # if there's an error you can call status.error
65
+ </pre>
66
+
57
67
 
58
68
  h2. Test Data
59
69
 
@@ -5,6 +5,7 @@ module PuntoPagos
5
5
  @env = env
6
6
  @@config ||= PuntoPagos::Config.new(@env)
7
7
  @@function = "transaccion/notificacion"
8
+ @verification = nil
8
9
  end
9
10
 
10
11
  # Public: Validates the message sent by PuntoPagos in the
@@ -20,11 +21,15 @@ module PuntoPagos
20
21
  message = create_message params["token"], params["trx_id"], params["monto"].to_s, timestamp
21
22
  authorization = Authorization.new(@env)
22
23
  signature = authorization.sign(message)
23
- verification = PuntoPagos::Verification.new(@env)
24
- (signature == pp_signature(headers)) and (verification.verify(params["token"], params["trx_id"], params["monto"].to_i.to_s + ".00"))
24
+ @verification = PuntoPagos::Verification.new(@env)
25
+ (signature == pp_signature(headers)) and (@verification.verify(params["token"], params["trx_id"], params["monto"].to_i.to_s + ".00"))
25
26
 
26
27
  end
27
28
 
29
+ def error
30
+ @verification.error
31
+ end
32
+
28
33
  private
29
34
 
30
35
  # Internal: Creates the message to be signed which will be
@@ -8,6 +8,7 @@ module PuntoPagos
8
8
  @@config ||= PuntoPagos::Config.new(env)
9
9
  @@function = "transaccion/traer"
10
10
  @@path = "transaccion"
11
+ @response = nil
11
12
  end
12
13
 
13
14
  # Public: Signs a string using the secret and api-key defined in puntopagos.yml
@@ -24,15 +25,19 @@ module PuntoPagos
24
25
  puts "SIGNATURE: #{signature} TIMESTAMP: #{timestamp} TOKEN: #{token} TRX: #{trx_id}"
25
26
  puts "MESSAGE: #{message}"
26
27
 
27
- response = executioner.call_api(token, @@path, :get, signature, timestamp)
28
+ @response = executioner.call_api(token, @@path, :get, signature, timestamp)
28
29
 
29
- valid?(response)
30
+ valid?(@response)
30
31
  end
31
32
 
32
33
  def valid? response
33
34
  response["respuesta"] == "00"
34
35
  end
35
36
 
37
+ def error
38
+ @response['error']
39
+ end
40
+
36
41
  private
37
42
 
38
43
  def get_timestamp
@@ -1,3 +1,3 @@
1
1
  module PuntoPagos
2
- VERSION = "0.2"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puntopagos
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
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: 2013-01-28 00:00:00.000000000 Z
13
+ date: 2014-03-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client