puntopagos 0.1.18 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ development:
2
+ environment: "sandbox"
3
+ puntopagos_key: "YOUR-API-KEY"
4
+ puntopagos_secret: "YOUR-APP-SECRET"
5
+ test:
6
+ environment: "sandbox"
7
+ puntopagos_key: "YOUR-API-KEY"
8
+ puntopagos_secret: "YOUR-APP-SECRET"
9
+ production:
10
+ environment: "production"
11
+ puntopagos_key: "YOUR-API-KEY"
12
+ puntopagos_secret: "YOUR-APP-SECRET"
@@ -15,7 +15,6 @@ module PuntoPagos
15
15
  if method == :post
16
16
  resp = RestClient.method(method).call(@@puntopagos_base_url+path, data.to_json, headers)
17
17
  elsif method == :get
18
- puts "METHOD: #{method} URL:#{@@puntopagos_base_url} PATH:#{path}"
19
18
  resp = RestClient.method(method).call(@@puntopagos_base_url+path+"/"+data, headers)
20
19
  end
21
20
  JSON.parse(resp)
@@ -0,0 +1,39 @@
1
+ module PuntoPagos
2
+ class Status
3
+ def initialize env = nil
4
+ @env = env
5
+ @@config ||= PuntoPagos::Config.new(env)
6
+ @@function = "transaccion/traer"
7
+ @@endpoint = "transaccion"
8
+ @@response = nil
9
+ end
10
+
11
+
12
+ def check token, trx_id, amount
13
+ timestamp = get_timestamp
14
+ message = create_message(token, trx_id, amount, timestamp)
15
+ authorization = PuntoPagos::Authorization.new(@env)
16
+ signature = authorization.sign(message)
17
+ executioner = PuntoPagos::Executioner.new(@env)
18
+ @@response = executioner.call_api(token, @@endpoint, :get, signature, timestamp)
19
+ end
20
+
21
+ def valid?
22
+ @@response['respuesta'] == '00'
23
+ end
24
+
25
+ def error
26
+ @@response['error']
27
+ end
28
+
29
+ private
30
+
31
+ def create_message token, trx_id, amount, timestamp
32
+ @@function + "\n" + token + "\n" + trx_id + "\n" + amount + "\n" + timestamp
33
+ end
34
+
35
+ def get_timestamp
36
+ Time.now.strftime("%a, %d %b %Y %H:%M:%S GMT")
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module PuntoPagos
2
- VERSION = "0.1.18"
2
+ VERSION = "0.2"
3
3
  end
data/lib/puntopagos.rb CHANGED
@@ -5,4 +5,5 @@ require File.join(File.dirname(__FILE__),"puntopagos/request")
5
5
  require File.join(File.dirname(__FILE__),"puntopagos/response")
6
6
  require File.join(File.dirname(__FILE__),"puntopagos/notification")
7
7
  require File.join(File.dirname(__FILE__),"puntopagos/verification")
8
+ require File.join(File.dirname(__FILE__),"puntopagos/status")
8
9
  require File.join(File.dirname(__FILE__),"puntopagos/version")
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class CreateRequestTest < Test::Unit::TestCase
4
+ def test_check
5
+ puts "testing check"
6
+ status = PuntoPagos::Status.new("test")
7
+ status.check "MGSQO0IO3GYA13B6", "1358470630", "10.00"
8
+ assert status.valid? == true, "Fail"
9
+ end
10
+ end
@@ -4,7 +4,7 @@ require 'test_helper'
4
4
  class CreateRequestTest < Test::Unit::TestCase
5
5
 
6
6
  def setup
7
- @req = PuntoPagos::Request.new('production')
7
+ @req = PuntoPagos::Request.new('test')
8
8
  end
9
9
 
10
10
  def test_valid_create
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.18
4
+ version: '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-23 00:00:00.000000000 Z
13
+ date: 2013-01-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -40,6 +40,7 @@ files:
40
40
  - LICENSE
41
41
  - README.textile
42
42
  - Rakefile
43
+ - config/puntopagos.yml.example
43
44
  - init.rb
44
45
  - lib/puntopagos.rb
45
46
  - lib/puntopagos/authorization.rb
@@ -48,11 +49,13 @@ files:
48
49
  - lib/puntopagos/notification.rb
49
50
  - lib/puntopagos/request.rb
50
51
  - lib/puntopagos/response.rb
52
+ - lib/puntopagos/status.rb
51
53
  - lib/puntopagos/verification.rb
52
54
  - lib/puntopagos/version.rb
53
55
  - puntopagos.gemspec
54
56
  - test/data/webpay_payload.yml
55
57
  - test/test_helper.rb
58
+ - test/unit/check_status_test.rb
56
59
  - test/unit/create_request_test.rb
57
60
  homepage: https://github.com/acidcl/puntopagos-ruby
58
61
  licenses: []
@@ -81,4 +84,5 @@ summary: Ruby wrapper for PuntoPagos Payment API
81
84
  test_files:
82
85
  - test/data/webpay_payload.yml
83
86
  - test/test_helper.rb
87
+ - test/unit/check_status_test.rb
84
88
  - test/unit/create_request_test.rb