puntopagos 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/puntopagos/authorization.rb +2 -1
- data/lib/puntopagos/notification.rb +14 -3
- data/lib/puntopagos/version.rb +1 -1
- data/lib/puntopagos.rb +1 -0
- data/test/unit/create_request_test.rb +8 -0
- metadata +3 -3
@@ -8,7 +8,8 @@ module PuntoPagos
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def sign(string)
|
11
|
-
|
11
|
+
encoded_string = Base64.encode64(OpenSSL::HMAC.digest('sha1',@@config.puntopagos_secret, string)).chomp
|
12
|
+
"PP "+@@config.puntopagos_key+":"+ encoded_string
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -6,11 +6,14 @@ module PuntoPagos
|
|
6
6
|
@@function = "transaccion/notificar"
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
9
|
+
def valid? headers, params
|
10
|
+
timestamp = get_timestamp headers
|
11
|
+
|
12
|
+
message = create_message params["token"], params["trx_id"], params["monto"], timestamp
|
11
13
|
authorization = Authorization.new(@env)
|
12
14
|
signature = authorization.sign(message)
|
13
|
-
signature == pp_signature
|
15
|
+
signature == pp_signature(headers)
|
16
|
+
|
14
17
|
end
|
15
18
|
|
16
19
|
private
|
@@ -18,5 +21,13 @@ module PuntoPagos
|
|
18
21
|
def create_message token, trx_id, amount, timestamp
|
19
22
|
@@function + "\n" + token + "\n" + trx_id + "\n" + amount + "\n" + timestamp
|
20
23
|
end
|
24
|
+
|
25
|
+
def pp_signature headers
|
26
|
+
headers['Autorizacion']
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_timestamp headers
|
30
|
+
headers['Fecha']
|
31
|
+
end
|
21
32
|
end
|
22
33
|
end
|
data/lib/puntopagos/version.rb
CHANGED
data/lib/puntopagos.rb
CHANGED
@@ -3,4 +3,5 @@ require File.join(File.dirname(__FILE__),"puntopagos/authorization")
|
|
3
3
|
require File.join(File.dirname(__FILE__),"puntopagos/executioner")
|
4
4
|
require File.join(File.dirname(__FILE__),"puntopagos/request")
|
5
5
|
require File.join(File.dirname(__FILE__),"puntopagos/response")
|
6
|
+
require File.join(File.dirname(__FILE__),"puntopagos/notification")
|
6
7
|
require File.join(File.dirname(__FILE__),"puntopagos/version")
|
@@ -35,4 +35,12 @@ class CreateRequestTest < Test::Unit::TestCase
|
|
35
35
|
|
36
36
|
end
|
37
37
|
|
38
|
+
def test_notification
|
39
|
+
puts "testing notification"
|
40
|
+
notification = PuntoPagos::Notification.new('production')
|
41
|
+
headers = {'Fecha' => 'Thu, 14 Jun 2012 22:52:47 GMT', 'Autorizacion' => 'PP rkdXmAGWLHCKdPyyk6ig:qOSavthLY3ElqsRCtxFEl02lL1s='}
|
42
|
+
params = {'token' => 'M5N1DAE6PALVAF8K', 'monto' => '1000000.00', 'trx_id' => '9787415132'}
|
43
|
+
assert notification.valid?(headers, params) == true
|
44
|
+
end
|
45
|
+
|
38
46
|
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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ date: 2012-06-15 00:00:00.000000000Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
17
|
-
requirement: &
|
17
|
+
requirement: &2161561760 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: 1.6.7
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2161561760
|
26
26
|
description: Ruby wrapper for PuntoPagos Payment API
|
27
27
|
email:
|
28
28
|
- imella@acid.cl
|