pxpay 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -23,7 +23,7 @@ Usage
23
23
  -----
24
24
  >> require 'nokogiri'
25
25
  >> require 'pxpay'
26
- >> request = Pxpay::Request.new( 1, 12.00 )
26
+ >> request = Pxpay::Request.new( 1, 12.00, {:url_success => 'http://example.com/success/', :url_failure => 'http://example.com/failure'})
27
27
  => #<Pxpay::Request:0x00000101c9a840 >
28
28
  >> request.url
29
29
  => "https://sec2.paymentexpress.com/pxpay/pxpay.aspx?userid=Fake_Dev&request=xxxxxxxxxx"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -13,7 +13,7 @@ module Pxpay
13
13
  end
14
14
 
15
15
  class << self
16
- attr_accessor :pxpay_user_id, :pxpay_key, :success_url, :failure_url
16
+ attr_accessor :pxpay_user_id, :pxpay_key, :url_success, :url_failure
17
17
  end
18
18
  end
19
19
  end
@@ -11,12 +11,19 @@ module Pxpay
11
11
  # Create a new instance of Pxpay::Request
12
12
  # Pxpay::Request.new( id, amount, options = {} )
13
13
  # Current available options are:
14
- # :currency, currency for transaction, default is NZD, can be any of Pxpay::Base.currency_types
15
- # :reference, a reference field, default is the id.
16
- # :email, email address of user, default is nil.
17
- # :token_billing, boolean value, set to true to enable token billing.
18
- # :billing_id, optional billing_id field only used if token_billing is set to true.
19
- # :txn_type, can be set to :auth for Auth transaction, defaults to Purchase
14
+ # :currency_input, currency for transaction, default is NZD, can be any of Pxpay::Base.currency_types
15
+ # :reference, a reference field, default is the id.
16
+ # :email_address, email address of user, optional.
17
+ # :token_billing, boolean value, set to true to enable token billing.
18
+ # :billing_id, optional billing_id field only used if token_billing is set to true.
19
+ # :txn_type, can be set to :auth for Auth transaction, defaults to Purchase
20
+ # :url_success, Success URL, can optionally be set globally via Pxpay::Base.url_success=
21
+ # :url_failure, Failure URL, can optionally be set globally via Pxpay::Base.url_failure=
22
+ # :txn_data1, Optional data
23
+ # :txn_data2, Optional data
24
+ # :txn_data3, Optional data
25
+ # :txn_data4, Optional data
26
+ # :opt, Optional data
20
27
 
21
28
  def initialize( id , price, options = {} )
22
29
  @post = build_xml( id, price, options )
@@ -29,7 +36,7 @@ module Pxpay
29
36
  if response_text.at_css("Request").attributes["valid"].value == "1"
30
37
  url = response_text.at_css("URI").inner_html
31
38
  else
32
- if Pxpay::Base.pxpay_user_id
39
+ if Pxpay::Base.pxpay_user_id && Pxpay::Base.pxpay_key
33
40
  raise Pxpay::Error, response_text.at_css("Request").inner_html
34
41
  else
35
42
  raise Pxpay::MissingKey, "Your Pxpay config is not set up properly, run rails generate pxpay:install"
@@ -43,18 +50,23 @@ module Pxpay
43
50
  def build_xml( id, price, options )
44
51
  xml = ::Builder::XmlMarkup.new
45
52
  xml.GenerateRequest do
46
- xml.PxPayUserId ::Pxpay::Base.pxpay_user_id
47
- xml.PxPayKey ::Pxpay::Base.pxpay_key
48
- xml.AmountInput sprintf("%.2f", price)
49
- xml.CurrencyInput options[:currency] || "NZD"
50
- xml.MerchantReference options[:reference] || id.to_s
51
- xml.EmailAddress options[:email]
52
- xml.TxnType options[:txn_type] ? options[:txn_type].to_s.capitalize : "Purchase"
53
- xml.TxnId id
54
- xml.UrlSuccess ::Pxpay::Base.success_url
55
- xml.UrlFail ::Pxpay::Base.failure_url
56
- xml.EnableAddBillCard 1 if options[:token_billing]
57
- xml.BillingId options[:billing_id] if options[:token_billing]
53
+ xml.PxPayUserId ::Pxpay::Base.pxpay_user_id
54
+ xml.PxPayKey ::Pxpay::Base.pxpay_key
55
+ xml.AmountInput sprintf("%.2f", price)
56
+ xml.TxnId id
57
+ xml.TxnType options[:txn_type] ? options[:txn_type].to_s.capitalize : "Purchase"
58
+ xml.CurrencyInput options[:currency_input] || "NZD"
59
+ xml.MerchantReference options[:reference] || id.to_s
60
+ xml.UrlSuccess options[:url_success] || ::Pxpay::Base.url_success
61
+ xml.UrlFail options[:url_failure] || ::Pxpay::Base.url_failure
62
+ xml.EmailAddress options[:email_address] if options[:email_address]
63
+ xml.TxnData1 options[:txn_data1] if options[:txn_data1]
64
+ xml.TxnData2 options[:txn_data2] if options[:txn_data2]
65
+ xml.TxnData3 options[:txn_data3] if options[:txn_data3]
66
+ xml.TxnData4 options[:txn_data4] if options[:txn_data4]
67
+ xml.Opt options[:opt] if options[:opt]
68
+ xml.EnableAddBillCard 1 if options[:token_billing]
69
+ xml.BillingId options[:billing_id] if options[:token_billing]
58
70
  end
59
71
  end
60
72
  end
@@ -5,7 +5,8 @@ Pxpay::Base.pxpay_user_id = 'ExampleUser'
5
5
  Pxpay::Base.pxpay_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
6
6
 
7
7
  # Return Endpoints for payment confirmation
8
- Pxpay::Base.success_url = 'http://localhost:3000/success'
9
- Pxpay::Base.failure_url = 'http://localhost:3000/failure'
8
+ # Uncomment for global success & failure URLs
9
+ # Pxpay::Base.url_success = 'http://localhost:3000/success'
10
+ # Pxpay::Base.url_failure = 'http://localhost:3000/failure'
10
11
 
11
12
  # Coming Soon Global Variables
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pxpay}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
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 = %q{2011-04-20}
12
+ s.date = %q{2011-04-27}
13
13
  s.description = %q{A Ruby wrapper around the DPS-hosted PxPay service}
14
14
  s.email = %q{bradleypriest@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
41
41
  s.homepage = %q{http://github.com/bradleypriest/pxpay}
42
42
  s.licenses = ["MIT"]
43
43
  s.require_paths = ["lib"]
44
- s.rubygems_version = %q{1.3.7}
44
+ s.rubygems_version = %q{1.5.2}
45
45
  s.summary = %q{Ruby wrapper for the Payment Express' PxPay API}
46
46
  s.test_files = [
47
47
  "test/helper.rb",
@@ -49,7 +49,6 @@ Gem::Specification.new do |s|
49
49
  ]
50
50
 
51
51
  if s.respond_to? :specification_version then
52
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
53
52
  s.specification_version = 3
54
53
 
55
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -18,8 +18,8 @@ require 'rest_client'
18
18
 
19
19
  Pxpay::Base.pxpay_user_id = 'Test_Dev'
20
20
  Pxpay::Base.pxpay_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
21
- Pxpay::Base.success_url = 'http://localhost:3000/success'
22
- Pxpay::Base.failure_url = 'http://localhost:3000/failure'
21
+ Pxpay::Base.url_success = 'http://localhost:3000/success'
22
+ Pxpay::Base.url_failure = 'http://localhost:3000/failure'
23
23
 
24
24
  class Test::Unit::TestCase
25
25
  end
@@ -19,6 +19,11 @@ class TestPxpay < Test::Unit::TestCase
19
19
  assert_match(/<AmountInput>12.34<\/AmountInput>/, @request.post)
20
20
  end
21
21
 
22
+ should "generate xml with provided endpoints" do
23
+ request_with_url = Pxpay::Request.new( 1, 12.34, { :url_success => "http://example.com/success", :url_failure => "http://example.com/success" })
24
+ assert_match %r(<UrlSuccess>http://example.com/success</UrlSuccess><UrlFail>http://example.com/success</UrlFail>), request_with_url.post
25
+ assert_no_match /localhost/, request_with_url.post
26
+ end
22
27
  # should "return a URL" do
23
28
  # assert_match(/https:\/\/sec2.paymentexpress.com\/pxpay\/pxpay.aspx\?userid=\w{64}&request=\S{270}/, @request.url)
24
29
  # end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pxpay
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
4
+ prerelease:
5
+ version: 0.2.1
10
6
  platform: ruby
11
7
  authors:
12
8
  - Bradley Priest
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-04-20 00:00:00 +12:00
13
+ date: 2011-04-27 00:00:00 +12:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -24,8 +20,6 @@ dependencies:
24
20
  requirements:
25
21
  - - ">="
26
22
  - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
23
  version: "0"
30
24
  type: :development
31
25
  prerelease: false
@@ -37,10 +31,6 @@ dependencies:
37
31
  requirements:
38
32
  - - ~>
39
33
  - !ruby/object:Gem::Version
40
- segments:
41
- - 1
42
- - 0
43
- - 0
44
34
  version: 1.0.0
45
35
  type: :development
46
36
  prerelease: false
@@ -52,10 +42,6 @@ dependencies:
52
42
  requirements:
53
43
  - - ~>
54
44
  - !ruby/object:Gem::Version
55
- segments:
56
- - 1
57
- - 5
58
- - 2
59
45
  version: 1.5.2
60
46
  type: :development
61
47
  prerelease: false
@@ -67,8 +53,6 @@ dependencies:
67
53
  requirements:
68
54
  - - ">="
69
55
  - !ruby/object:Gem::Version
70
- segments:
71
- - 0
72
56
  version: "0"
73
57
  type: :development
74
58
  prerelease: false
@@ -80,8 +64,6 @@ dependencies:
80
64
  requirements:
81
65
  - - ">="
82
66
  - !ruby/object:Gem::Version
83
- segments:
84
- - 0
85
67
  version: "0"
86
68
  type: :development
87
69
  prerelease: false
@@ -93,8 +75,6 @@ dependencies:
93
75
  requirements:
94
76
  - - ">="
95
77
  - !ruby/object:Gem::Version
96
- segments:
97
- - 0
98
78
  version: "0"
99
79
  type: :development
100
80
  prerelease: false
@@ -106,8 +86,6 @@ dependencies:
106
86
  requirements:
107
87
  - - ">="
108
88
  - !ruby/object:Gem::Version
109
- segments:
110
- - 0
111
89
  version: "0"
112
90
  type: :development
113
91
  prerelease: false
@@ -119,8 +97,6 @@ dependencies:
119
97
  requirements:
120
98
  - - ">="
121
99
  - !ruby/object:Gem::Version
122
- segments:
123
- - 0
124
100
  version: "0"
125
101
  type: :runtime
126
102
  prerelease: false
@@ -132,8 +108,6 @@ dependencies:
132
108
  requirements:
133
109
  - - ">="
134
110
  - !ruby/object:Gem::Version
135
- segments:
136
- - 0
137
111
  version: "0"
138
112
  type: :runtime
139
113
  prerelease: false
@@ -145,8 +119,6 @@ dependencies:
145
119
  requirements:
146
120
  - - ">="
147
121
  - !ruby/object:Gem::Version
148
- segments:
149
- - 0
150
122
  version: "0"
151
123
  type: :runtime
152
124
  prerelease: false
@@ -195,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
167
  requirements:
196
168
  - - ">="
197
169
  - !ruby/object:Gem::Version
198
- hash: 617512467652124965
170
+ hash: -3326667328160921882
199
171
  segments:
200
172
  - 0
201
173
  version: "0"
@@ -204,13 +176,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
176
  requirements:
205
177
  - - ">="
206
178
  - !ruby/object:Gem::Version
207
- segments:
208
- - 0
209
179
  version: "0"
210
180
  requirements: []
211
181
 
212
182
  rubyforge_project:
213
- rubygems_version: 1.3.7
183
+ rubygems_version: 1.5.2
214
184
  signing_key:
215
185
  specification_version: 3
216
186
  summary: Ruby wrapper for the Payment Express' PxPay API