payxml 0.1.1 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2742d2abadbff374382533a6ad2b2127db1e8cbe
4
- data.tar.gz: db942750f2cebe4c83105e8d8b6268a21a700ae0
3
+ metadata.gz: 9aa8092c3672fd193153bae70b7f3d4017cabe96
4
+ data.tar.gz: f6faf73ea00787d7f50e23ea66ddcc0c3f3ae25d
5
5
  SHA512:
6
- metadata.gz: 6ed336bcdf8475d57cd32178b92c20276b94057ba2943ec3b68eba939f4053258993636c0b1eceda11e3ea093d472503c3430403f701f289646ef2425ea2236b
7
- data.tar.gz: 98c7485666102a18048513c329f5d8105fd4a8ad3a86cefc6332b592e90d7f736e62be247fa4ee06892f22f65cf5325a2341aa07bc561650639835a505488084
6
+ metadata.gz: 7d00a1d7d919c5334b9ce247910a32f3f50bf029e64b937085f68ef2111fcac1183a9b27654f423c9ca7fa9ada7985cd8125c20177c2f3414c1c4931bfe02a77
7
+ data.tar.gz: 31c6cc1670ed80b3f5f8335375594804f9cb3592c2fc65d14ec07b6aee18d7752074bdde96ac650bff43324b389cad20273f5b65e93ef95facc051928e22f531
data/lib/payxml.rb CHANGED
@@ -10,10 +10,6 @@ require 'net/http'
10
10
 
11
11
  module PayXML
12
12
  class PayXML
13
- # PayXML API version number
14
- PAYXML_VERSION_NUMBER = '4.0'
15
-
16
- PAYXML_URL = 'https://www.paygate.co.za/payxml/process.trans'
17
13
 
18
14
  def initialize(paygate_id, paygate_password)
19
15
  @paygate_id = paygate_id
@@ -29,20 +25,13 @@ module PayXML
29
25
  authtx.currency = options[:currency]
30
26
  authtx.amount = options[:amount]
31
27
  authtx.cvv = options[:cvv]
32
-
33
28
  authtx.customer_ip_address = options[:customer_ip_address]
34
29
  authtx.notify_callback_url = options[:notify_callback_url]
35
30
  authtx.response_url = options[:response_url]
36
31
 
37
32
  response = post_request_body(authtx.xml_string)
38
-
39
- if !(response.body =~ /errorrx/i).nil?
40
- response_object = Error.allocate
41
- response_object.parse(response.body)
42
- else
43
- response_object = Auth::Response.allocate
44
- response_object.parse(response.body)
45
- end
33
+ response_object = Auth::Response.allocate
34
+ response_object.parse(response.body)
46
35
 
47
36
  response_object
48
37
  end
@@ -54,6 +43,14 @@ module PayXML
54
43
  end
55
44
 
56
45
  protected
46
+
47
+ # PayXML API version number
48
+ PAYXML_VERSION_NUMBER = '4.0'
49
+ PAYXML_URL = 'https://www.paygate.co.za/payxml/process.trans'
50
+ TEST_USER_3D_SECURE = '10011013800'
51
+ TEST_USER_NO_3D_SECURE = ''
52
+ TEST_PASSWORD = 'test'
53
+
57
54
  def post_request_body(xml_body)
58
55
  uri = URI.parse PAYXML_URL
59
56
  request = Net::HTTP::Post.new uri.path
data/lib/payxml/auth.rb CHANGED
@@ -76,6 +76,8 @@ module PayXML
76
76
  attr_reader :risk
77
77
  attr_reader :secure_redirect_url
78
78
  attr_reader :secure_checksum
79
+ attr_reader :error_code
80
+ attr_reader :error_description
79
81
 
80
82
  def requires_secure_redirect?
81
83
  !self.secure_redirect_url.nil?
@@ -84,25 +86,32 @@ module PayXML
84
86
  def parse(xml_string)
85
87
  super(xml_string)
86
88
 
87
- doc = Nokogiri::XML(xml_string)
88
- authrx = doc.xpath("//authrx").first
89
- securerx = doc.xpath("//securerx").first
90
- if !authrx.nil?
91
- @customer_reference = authrx['cref'] unless authrx['cref'].nil?
92
- @transaction_id = authrx['tid'] unless authrx['tid'].nil?
93
- @card_type = authrx['ctype'] unless authrx['ctype'].nil?
94
- @transaction_status = authrx['stat'] unless authrx['stat'].nil?
95
- @transaction_status_description = authrx['sdesc'] unless authrx['sdesc'].nil?
96
- @bno = authrx['bno'] unless authrx['bno'].nil?
97
- @result_code = authrx['res'] unless authrx['res'].nil?
98
- @result_description = authrx['rdesc'] unless authrx['rdesc'].nil?
99
- @authorisation_code = authrx['auth'] unless authrx['auth'].nil?
100
- @risk = authrx['risk'] unless authrx['risk'].nil?
101
- elsif !securerx.nil?
102
- @customer_reference = securerx['cref'] unless securerx['cref'].nil?
103
- @transaction_id = securerx['tid'] unless securerx['tid'].nil?
104
- @secure_redirect_url = securerx['url'] unless securerx['url'].nil?
105
- @secure_checksum = securerx['chk'] unless securerx['chk'].nil?
89
+ if !(xml_string =~ /errorrx/i).nil?
90
+ error = Error.allocate
91
+ error.parse(xml_string)
92
+ @error_code = error.code
93
+ @error_description = error.description
94
+ else
95
+ doc = Nokogiri::XML(xml_string)
96
+ authrx = doc.xpath("//authrx").first
97
+ securerx = doc.xpath("//securerx").first
98
+ if !authrx.nil?
99
+ @customer_reference = authrx['cref'] unless authrx['cref'].nil?
100
+ @transaction_id = authrx['tid'] unless authrx['tid'].nil?
101
+ @card_type = authrx['ctype'] unless authrx['ctype'].nil?
102
+ @transaction_status = authrx['stat'] unless authrx['stat'].nil?
103
+ @transaction_status_description = authrx['sdesc'] unless authrx['sdesc'].nil?
104
+ @bno = authrx['bno'] unless authrx['bno'].nil?
105
+ @result_code = authrx['res'] unless authrx['res'].nil?
106
+ @result_description = authrx['rdesc'] unless authrx['rdesc'].nil?
107
+ @authorisation_code = authrx['auth'] unless authrx['auth'].nil?
108
+ @risk = authrx['risk'] unless authrx['risk'].nil?
109
+ elsif !securerx.nil?
110
+ @customer_reference = securerx['cref'] unless securerx['cref'].nil?
111
+ @transaction_id = securerx['tid'] unless securerx['tid'].nil?
112
+ @secure_checksum = securerx['chk'] unless securerx['chk'].nil?
113
+ @secure_redirect_url = "#{securerx['url']}?PAYGATE_ID=#{self.paygate_id}&TRANS_ID=#{self.transaction_id}&CHECKSUM=#{self.secure_checksum}" unless securerx['url'].nil?
114
+ end
106
115
  end
107
116
  end
108
117
  end
@@ -1,3 +1,3 @@
1
1
  module PayXML
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico du Plessis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-09 00:00:00.000000000 Z
11
+ date: 2016-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,7 +103,6 @@ files:
103
103
  - lib/payxml/credit_card_types.rb
104
104
  - lib/payxml/error.rb
105
105
  - lib/payxml/message.rb
106
- - lib/payxml/protocol.rb
107
106
  - lib/payxml/result_codes.rb
108
107
  - lib/payxml/version.rb
109
108
  - payxml.gemspec
@@ -1,9 +0,0 @@
1
- module PayXML
2
- class Protocol
3
- attr_accessor :paygate_id
4
- attr_accessor :password
5
-
6
- def to_s
7
- end
8
- end
9
- end