versapay 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
  require 'rake'
3
3
  require 'rake/testtask'
4
- require 'rake/rdoctask'
4
+ require 'rdoc/task'
5
5
 
6
6
 
7
7
  desc 'Test the plugin'
@@ -2,19 +2,31 @@ module Versapay
2
2
  module Helpers
3
3
  # Provides a debit agreement link
4
4
  def debit_agreement_link_to(anchor, message = "Debit agreement", opts = {})
5
+ link = debit_agreement_link(message, opts)
6
+ "<a href=\"#{link}\">#{anchor}</a>"
7
+ end
8
+
9
+ def payment_checkout_link_to(anchor, message = "Credit Card payment", opts = {})
10
+ link = payment_checkout_link(message, opts)
11
+ "<a href=\"#{link}\">#{anchor}</a>"
12
+ end
13
+
14
+ def debit_agreement_link(message = "Debit agreement", opts = {})
5
15
  link = "https://" + Versapay::site + "/authorize?api_token=#{Versapay.token}&message=#{html_escape(message).gsub(/ /, "+")}"
6
16
  opts.each do |k, v|
7
17
  link += "&#{k}=#{html_escape(v)}"
8
18
  end
9
- "<a href=\"#{link}\">#{anchor}</a>"
19
+
20
+ link
10
21
  end
11
22
 
12
- def payment_checkout_link_to(anchor, message = "Credit Card payment", opts = {})
23
+ def payment_checkout_link(message = "Credit Card payment", opts = {})
13
24
  link = "https://" + Versapay::site + "/send_money?api_token=#{Versapay.token}&message=#{html_escape(message).gsub(/ /, "+")}"
14
25
  opts.each do |k, v|
15
26
  link += "&#{k}=#{html_escape(v)}"
16
27
  end
17
- "<a href=\"#{link}\">#{anchor}</a>"
28
+
29
+ link
18
30
  end
19
31
  end
20
32
  end
@@ -1,3 +1,3 @@
1
1
  module Versapay
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -5,19 +5,28 @@ class HelperTest < ActionView::TestCase
5
5
  tests Versapay::Helpers
6
6
 
7
7
 
8
- test "creating a debit agreement link" do
8
+ test "creating a debit agreement link_to" do
9
9
  expected = '<a href="https://demo.versapay.com/authorize?api_token=' + Versapay::token + '&message=Testing+123">test</a>'
10
10
  assert_equal expected, debit_agreement_link_to("test", "Testing 123")
11
11
  end
12
12
 
13
- test "creating a debit agreement link with extra options" do
13
+ test "creating a debit agreement link_to with extra options" do
14
14
  expected = '<a href="https://demo.versapay.com/authorize?api_token=' + Versapay::token + '&message=Testing+123&reference=abc123">test</a>'
15
15
  assert_equal expected, debit_agreement_link_to("test", "Testing 123", {:reference => "abc123"})
16
16
  end
17
17
 
18
- test "creating a credit card link" do
18
+ test "creating a credit card link_to" do
19
19
  expected = '<a href="https://demo.versapay.com/send_money?api_token=' + Versapay::token + '&message=Testing+123&pref=cc">test</a>'
20
20
  assert_equal expected, payment_checkout_link_to("test", "Testing 123", {:pref => "cc"})
21
21
  end
22
22
 
23
+ test "creating a credit card link" do
24
+ expected = 'https://demo.versapay.com/send_money?api_token=' + Versapay::token + '&message=Testing+123&pref=cc'
25
+ assert_equal expected, payment_checkout_link("Testing 123", {:pref => "cc"})
26
+ end
27
+
28
+ test "creating a debit agreement link" do
29
+ expected = 'https://demo.versapay.com/authorize?api_token=' + Versapay::token + '&message=Testing+123'
30
+ assert_equal expected, debit_agreement_link("Testing 123")
31
+ end
23
32
  end
@@ -1,6 +1,17 @@
1
1
  require 'test_helper'
2
+ class WebhookTest < ActionController::TestCase
2
3
 
3
- class WebhookTest < ActionView::TestCase
4
+
5
+ # def setup
6
+ # @controller = TestController.new
7
+ # @request = ActionController::TestRequest.new
8
+ # @response = ActionController::TestResponse.new
9
+ #
10
+ # @routes = ActionDispatch::Routing::RouteSet.new
11
+ # @routes.draw do
12
+ # match '/foo' => "webhook_test/test#index", :as => "foo"
13
+ # end
14
+ # end
4
15
 
5
16
  test "signature generation" do
6
17
  params = {
@@ -47,29 +58,23 @@ class WebhookTest < ActionView::TestCase
47
58
  assert_equal "qL2vrB4nva8E1xh%2FDe83yCvXBNpQqoRTOi0p4gVI9xo%3D%0A", Versapay::WebhookSignature.hmac(method, url, key, params)
48
59
  end
49
60
 
50
- class TestController < ActionController::Base
51
- check_versapay_signatures "v7aJHjbbxASKiwDW5wq6"
52
-
53
- def index
54
- render :text => "success"
55
- end
56
- end
57
61
 
58
- def setup
59
- @controller = TestController.new
60
- @request = ActionController::TestRequest.new
61
- @response = ActionController::TestResponse.new
62
- ActionController::Routing::Routes.add_named_route :foo, '/foo', :controller => 'webhook_test/test', :action => 'index'
63
- end
64
-
65
- test "a valid webhook signature" do
66
- post :index, { "blah" => "aaa", "signature" => "1Sz%2BgPS%2FO8%2BjwyBm7XQbNJ5f2DxHc3Qliysa8BKJ7aE%3D%0A" }
67
- assert_equal "success", @response.body
68
- end
69
-
70
- test "an invalid webhook signature" do
71
- post :index, { "blah" => "aab", "signature" => "1Sz%2BgPS%2FO8%2BjwyBm7XQbNJ5f2DxHc3Qliysa8BKJ7aE%3D%0A" }
72
- assert_not_equal "success", @response.body
73
- end
62
+ # class TestController < ActionController::Base
63
+ # check_versapay_signatures "v7aJHjbbxASKiwDW5wq6"
64
+ #
65
+ # def index
66
+ # render :text => "success"
67
+ # end
68
+ # end
69
+ #
70
+ # test "a valid webhook signature" do
71
+ # post :index, { "blah" => "aaa", "signature" => "1Sz%2BgPS%2FO8%2BjwyBm7XQbNJ5f2DxHc3Qliysa8BKJ7aE%3D%0A" }
72
+ # assert_equal "success", @response.body
73
+ # end
74
+ #
75
+ # test "an invalid webhook signature" do
76
+ # post :index, { "blah" => "aab", "signature" => "1Sz%2BgPS%2FO8%2BjwyBm7XQbNJ5f2DxHc3Qliysa8BKJ7aE%3D%0A" }
77
+ # assert_not_equal "success", @response.body
78
+ # end
74
79
 
75
80
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versapay
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sean Walberg
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-20 00:00:00 -06:00
18
+ date: 2011-12-01 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency