pxpay 0.2.4 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.2.6
@@ -1,11 +1,15 @@
1
1
  module Pxpay
2
2
  # The base Pxpay class, contains the acceptable currency types and the details that are returned from Payment Express
3
3
  class Base
4
- @@pxpay_request_url = "https://sec.paymentexpress.com/pxpay/pxaccess.aspx"
5
4
 
6
5
  class << self
7
- attr_accessor :pxpay_user_id, :pxpay_key, :url_success, :url_failure, :pxpay_request_url
8
6
 
7
+ attr_accessor :pxpay_user_id, :pxpay_key, :url_success, :url_failure
8
+ attr_writer :pxpay_request_url
9
+
10
+ def pxpay_request_url
11
+ @pxpay_request_url ||= "https://sec.paymentexpress.com/pxpay/pxaccess.aspx"
12
+ end
9
13
  # A list of the acceptable payment currencies
10
14
  # See http://www.paymentexpress.com/technical_resources/ecommerce_hosted/pxpay.html#Properties
11
15
  def currency_types
@@ -15,7 +15,7 @@ module Pxpay
15
15
 
16
16
  # Retrieving the transaction details from Payment Express as an instance of Pxpay::Notification
17
17
  def response
18
- response = ::RestClient.post( 'https://www.paymentexpress.com/pxpay/pxaccess.aspx', self.post )
18
+ response = ::RestClient.post( Pxpay::Base.pxpay_request_url, self.post )
19
19
  return ::Pxpay::Notification.new( response )
20
20
  end
21
21
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "pxpay"
8
- s.version = "0.2.4"
8
+ s.version = "0.2.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bradley Priest"]
12
- s.date = "2011-11-08"
12
+ s.date = "2011-11-27"
13
13
  s.description = "A Ruby wrapper around the DPS-hosted PxPay service"
14
14
  s.email = "bradleypriest@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -2,11 +2,26 @@ require 'helper'
2
2
 
3
3
 
4
4
  class TestPxpay < Test::Unit::TestCase
5
+
6
+ context "valid gem" do
7
+
8
+ should "provide a default pxpay url" do
9
+ assert_match(Pxpay::Base.pxpay_request_url, "https://sec.paymentexpress.com/pxpay/pxaccess.aspx")
10
+ end
11
+
12
+ should "allow pxpay url to be overwritten" do
13
+ Pxpay::Base.pxpay_request_url = "http://example.com"
14
+ assert_match(Pxpay::Base.pxpay_request_url, "http://example.com")
15
+ Pxpay::Base.pxpay_request_url = nil
16
+ end
17
+
18
+ end
19
+
5
20
  context "create a request object" do
6
21
  setup do
7
22
  @request = Pxpay::Request.new( 1, 12.34 )
8
23
  end
9
-
24
+
10
25
  should "generate an xml request" do
11
26
  assert_match(/GenerateRequest/, @request.post )
12
27
  end
@@ -14,11 +29,11 @@ class TestPxpay < Test::Unit::TestCase
14
29
  should "generate an xml request with username and id" do
15
30
  assert_match(/<PxPayUserId>Test_Dev<\/PxPayUserId><PxPayKey>\w{64}<\/PxPayKey>/, @request.post )
16
31
  end
17
-
32
+
18
33
  should "generate an xml request with correct amount" do
19
34
  assert_match(/<AmountInput>12.34<\/AmountInput>/, @request.post)
20
35
  end
21
-
36
+
22
37
  should "generate xml with provided endpoints" do
23
38
  request_with_url = Pxpay::Request.new( 1, 12.34, { :url_success => "http://example.com/success", :url_failure => "http://example.com/success" })
24
39
  assert_match %r(<UrlSuccess>http://example.com/success</UrlSuccess><UrlFail>http://example.com/success</UrlFail>), request_with_url.post
@@ -28,13 +43,13 @@ class TestPxpay < Test::Unit::TestCase
28
43
  # assert_match(/https:\/\/sec2.paymentexpress.com\/pxpay\/pxpay.aspx\?userid=\w{64}&request=\S{270}/, @request.url)
29
44
  # end
30
45
  end
31
-
46
+
32
47
  context "create a response object" do
33
48
  setup do
34
49
  @response_text = "v5l4alYudyoKcCD1vSADyfiuWv4QqCKyJVdaXCuJR0_7jUyj9reTWi7Jdhe5-xtbDRlwLpPG56qO7AOKR-h65Awaa886kw9vjf5YglO1fz2wyyshMsaJT5XrEhGFBsNLycaqou0rxwRxF4Y0chcA_laRn8Ev1sOqpNNXafUwP2fDMQVQ7gla11Ibdv7K5v0TIvV28rPVLZgnbty5rtnK_AdR0W9XOXpo6w4NlNzh81KcFJeVc_5n_4QITRZ1zVYrrCGzg3T3S902ej1kgqBGGJf904IWEgNfbjc8teg3ereUWLYhDK-E3FrP-v3L06VxRwR96wZkkO2rucYUrxc2drOQfZipqijabZTRjyoLK37jFQkg5JfrQPOvXZaQeY6eby2Voh_XLAYtoUawPPvkupiEI3b5_TlANhnOLl0_fUS95ObLG1VIHenw=="
35
50
  @response = Pxpay::Response.new(:userid => 'Test_Dev', :result => @response_text )
36
51
  end
37
-
52
+
38
53
  should "generate an xml request" do
39
54
  assert_match(/ProcessResponse/, @response.post )
40
55
  end
@@ -42,21 +57,21 @@ class TestPxpay < Test::Unit::TestCase
42
57
  should "generate an xml request with username and id" do
43
58
  assert_match(/<PxPayUserId>#{Pxpay::Base.pxpay_user_id}<\/PxPayUserId><PxPayKey>#{Pxpay::Base.pxpay_key}<\/PxPayKey>/, @response.post )
44
59
  end
45
-
60
+
46
61
  should "generate an xml request with the correct response text" do
47
62
  assert_match( %r(<Response>#{@response_text}</Response), @response.post)
48
- end
63
+ end
49
64
  end
50
-
65
+
51
66
  context "create a notification" do
52
67
  setup do
53
68
  @notification = Pxpay::Notification.new( File.read('test/response.xml') )
54
69
  end
55
-
70
+
56
71
  should "parse xml to hash" do
57
72
  assert_instance_of(Hash, @notification.to_hash )
58
73
  end
59
-
74
+
60
75
  should "return info in hash" do
61
76
  assert_match(@notification.to_hash[:success], "1")
62
77
  assert_match(@notification.to_hash[:valid], "1")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pxpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-08 00:00:00.000000000 Z
12
+ date: 2011-11-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
- requirement: &70169712566860 !ruby/object:Gem::Requirement
16
+ requirement: &70265355199880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70169712566860
24
+ version_requirements: *70265355199880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70169712582340 !ruby/object:Gem::Requirement
27
+ requirement: &70265355199060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70169712582340
35
+ version_requirements: *70265355199060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &70169712581440 !ruby/object:Gem::Requirement
38
+ requirement: &70265355196520 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.6'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70169712581440
46
+ version_requirements: *70265355196520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &70169712580740 !ruby/object:Gem::Requirement
49
+ requirement: &70265355194560 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70169712580740
57
+ version_requirements: *70265355194560
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: builder
60
- requirement: &70169712579840 !ruby/object:Gem::Requirement
60
+ requirement: &70265355205360 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70169712579840
68
+ version_requirements: *70265355205360
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: nokogiri
71
- requirement: &70169712578400 !ruby/object:Gem::Requirement
71
+ requirement: &70265355236400 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70169712578400
79
+ version_requirements: *70265355236400
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rest-client
82
- requirement: &70169712575240 !ruby/object:Gem::Requirement
82
+ requirement: &70265355231720 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70169712575240
90
+ version_requirements: *70265355231720
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: nokogiri
93
- requirement: &70169712589760 !ruby/object:Gem::Requirement
93
+ requirement: &70265355271480 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70169712589760
101
+ version_requirements: *70265355271480
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rest-client
104
- requirement: &70169712588300 !ruby/object:Gem::Requirement
104
+ requirement: &70265355151680 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70169712588300
112
+ version_requirements: *70265355151680
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: builder
115
- requirement: &70169712587200 !ruby/object:Gem::Requirement
115
+ requirement: &70265355149740 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *70169712587200
123
+ version_requirements: *70265355149740
124
124
  description: A Ruby wrapper around the DPS-hosted PxPay service
125
125
  email: bradleypriest@gmail.com
126
126
  executables: []
@@ -164,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  segments:
166
166
  - 0
167
- hash: -3129400018934760420
167
+ hash: 4577156217100058883
168
168
  required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  none: false
170
170
  requirements: