net_registry 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/README.md +20 -16
- data/Rakefile +3 -0
- data/lib/net_registry/client.rb +10 -3
- data/lib/net_registry/response_builder.rb +81 -55
- data/lib/net_registry/version.rb +1 -1
- data/net_registry.gemspec +4 -4
- data/spec/client_spec.rb +28 -28
- data/spec/response_builder_spec.rb +67 -43
- data/spec/spec_helper.rb +2 -0
- data/spec/transaction_spec.rb +1 -1
- metadata +16 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffc8284b97a1579527e37287ab2ee29687b14de3
|
4
|
+
data.tar.gz: 9d3a53579f5c0c538957f5cdf89c63ee9bfc5ee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c34f3c55479f9f4f0c3e25dcdd2d90c1d659fffdd44943047b6f5c5059ff711507370ea29813435867db04042012367d4b2f15c2f4430c5236a9d7374991cf8a
|
7
|
+
data.tar.gz: 6e53d57e63e158d514f1edc32d48f132ff5b522a1fcc7e9ff635e74b1f0fdda98ce8f1ced531be4eaefca6ee1058d64efa5957411badcd23f1502f1067760e29
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
# NetRegistry
|
2
|
+
[![Build
|
3
|
+
Status](https://travis-ci.org/CarNextDoor/net_registry.svg?branch=master)](https://travis-ci.org/CarNextDoor/net_registry)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/net_registry.svg)](http://badge.fury.io/rb/net_registry)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/CarNextDoor/net_registry/badge.svg?branch=master&service=github)](https://coveralls.io/github/CarNextDoor/net_registry?branch=master)
|
2
6
|
|
3
7
|
This gem serves as a Ruby wrapper for the NetRegistry Payment Gateway's
|
4
8
|
API. Official documentation can be found [http://www.netregistry.com.au/ee-images/uploads/support/NR-ecom-gateway8.pdf](here)
|
@@ -42,14 +46,14 @@ Input:
|
|
42
46
|
|
43
47
|
``` ruby
|
44
48
|
{
|
45
|
-
AMOUNT: (Integer, Float, or String). The amount you would like to
|
46
|
-
charge. Don't add
|
49
|
+
AMOUNT: "(Integer, Float, or String). The amount you would like to
|
50
|
+
charge. Don't add '$', just the numerical amount.",
|
47
51
|
|
48
|
-
CCNUM: (Integer, String). The credit card number. NO SPACES OR
|
49
|
-
DASH,
|
52
|
+
CCNUM: "(Integer, String). The credit card number. NO SPACES OR
|
53
|
+
DASH",
|
50
54
|
|
51
|
-
CCEXP: (String). Credit card expiry date. Must be in the format of
|
52
|
-
|
55
|
+
CCEXP: "(String). Credit card expiry date. Must be in the format of
|
56
|
+
'mm/yy'."
|
53
57
|
}
|
54
58
|
```
|
55
59
|
|
@@ -60,10 +64,10 @@ Returns: NetRegistry::Response object.
|
|
60
64
|
Input:
|
61
65
|
``` ruby
|
62
66
|
{
|
63
|
-
AMOUNT: (Integer, Float, or String). The amount you would like to
|
64
|
-
charge. Don't add
|
67
|
+
AMOUNT: "(Integer, Float, or String). The amount you would like to
|
68
|
+
charge. Don't add '$', just the numerical amount.",
|
65
69
|
|
66
|
-
TXNREF: (String). Transaction reference number
|
70
|
+
TXNREF: "(String). Transaction reference number"
|
67
71
|
}
|
68
72
|
```
|
69
73
|
|
@@ -75,14 +79,14 @@ Input:
|
|
75
79
|
|
76
80
|
``` ruby
|
77
81
|
{
|
78
|
-
AMOUNT: (Integer, Float, or String). The amount you would like to
|
79
|
-
charge. Don't add
|
82
|
+
AMOUNT: "(Integer, Float, or String). The amount you would like to
|
83
|
+
charge. Don't add '$', just the numerical amount.",
|
80
84
|
|
81
|
-
CCNUM: (Integer, String). The credit card number. NO SPACES OR
|
82
|
-
DASH,
|
85
|
+
CCNUM: "(Integer, String). The credit card number. NO SPACES OR
|
86
|
+
DASH",
|
83
87
|
|
84
|
-
CCEXP: (String). Credit card expiry date. Must be in the format of
|
85
|
-
|
88
|
+
CCEXP: "(String). Credit card expiry date. Must be in the format of
|
89
|
+
'mm/yy'".
|
86
90
|
}
|
87
91
|
```
|
88
92
|
|
@@ -93,7 +97,7 @@ Returns: NetRegistry::Response object.
|
|
93
97
|
Input:
|
94
98
|
``` ruby
|
95
99
|
{
|
96
|
-
TXNREF: (String). Transaction reference number
|
100
|
+
TXNREF: "(String). Transaction reference number"
|
97
101
|
}
|
98
102
|
```
|
99
103
|
|
data/Rakefile
CHANGED
data/lib/net_registry/client.rb
CHANGED
@@ -35,7 +35,7 @@ module NetRegistry
|
|
35
35
|
@login = "#{@merchant_id}/#{@password}"
|
36
36
|
@base_url = "https://paygate.ssllock.net/external2.pl"
|
37
37
|
@uri = URI(@base_url)
|
38
|
-
@
|
38
|
+
@builder = NetRegistry::ResponseBuilder.new
|
39
39
|
end
|
40
40
|
|
41
41
|
# Alias for
|
@@ -66,17 +66,24 @@ module NetRegistry
|
|
66
66
|
request(params.merge!(COMMAND: "preauth"))
|
67
67
|
end
|
68
68
|
|
69
|
+
# Alias for
|
70
|
+
# require(COMMAND: "completion", PREAUTHNUM: .... etc)
|
71
|
+
def completion(params = {})
|
72
|
+
raise TypeError, "params is not a hash" if !params.is_a?(Hash)
|
73
|
+
request(params.merge!(COMMAND: "completion"))
|
74
|
+
end
|
75
|
+
|
69
76
|
def request(params = {})
|
70
77
|
raise TypeError, "params is not a hash" if !params.is_a?(Hash)
|
71
78
|
params.merge!(LOGIN: @login)
|
72
|
-
@
|
79
|
+
@builder.verify_params(params) ? send_request(params) : @builder.create
|
73
80
|
end
|
74
81
|
|
75
82
|
private
|
76
83
|
|
77
84
|
def send_request(params)
|
78
85
|
res = Net::HTTP.post_form(@uri, params)
|
79
|
-
@
|
86
|
+
@builder.parse(res.body).create
|
80
87
|
end
|
81
88
|
|
82
89
|
end
|
@@ -38,8 +38,8 @@ module NetRegistry
|
|
38
38
|
# purchase, refund, preauth, status.
|
39
39
|
# params (Hash): Variables to pass to NetRegistry
|
40
40
|
def verify_params(params = {})
|
41
|
-
success
|
42
|
-
params
|
41
|
+
success = false
|
42
|
+
params = process_params(params)
|
43
43
|
case params[:COMMAND]
|
44
44
|
when "purchase"
|
45
45
|
@response.text, success = validate_purchase_params(params)
|
@@ -49,8 +49,10 @@ module NetRegistry
|
|
49
49
|
@response.text, success = validate_preauth_params(params)
|
50
50
|
when "status"
|
51
51
|
@response.text, success = validate_status_params(params)
|
52
|
+
when "completion"
|
53
|
+
@response.text, success = validate_completion_params(params)
|
52
54
|
else
|
53
|
-
@response.text = "Invalid command. Only [purchase status preauth refund] are valid."
|
55
|
+
@response.text = "Invalid command. Only [purchase status preauth refund completion] are valid."
|
54
56
|
success = false
|
55
57
|
end
|
56
58
|
@response.code = 0 if success
|
@@ -65,66 +67,22 @@ module NetRegistry
|
|
65
67
|
end
|
66
68
|
|
67
69
|
# parse HTTP request response body into a response object
|
68
|
-
# return
|
70
|
+
# return builder itself.
|
69
71
|
# To get the response object, use #create method
|
70
72
|
def parse(response)
|
71
73
|
raise TypeError, "Response is not a string" if !response.is_a?(String)
|
72
74
|
@full_response = response.split("\n").map(&:strip)
|
73
75
|
if @full_response.first == "failed"
|
74
|
-
|
75
|
-
lines = @full_response.drop_while { |x| x != "." }
|
76
|
-
if lines.empty?
|
77
|
-
@response.text = @full_response[1]
|
78
|
-
else
|
79
|
-
lines.shift
|
80
|
-
lines[0].slice!("response_text=")
|
81
|
-
@response.text = lines[0]
|
82
|
-
end
|
83
|
-
@response.status = "failed"
|
84
|
-
@response.code = -1
|
76
|
+
parse_failed_response
|
85
77
|
else
|
86
78
|
@full_response.each do |line|
|
87
|
-
data
|
88
|
-
|
89
|
-
when "card_number", "card_no"
|
90
|
-
@response.transaction.card.number = data[1]
|
91
|
-
when "response_text"
|
92
|
-
@response.text = data[1].to_s
|
93
|
-
when "amount", "total_amount"
|
94
|
-
@response.transaction.amount = data[1]
|
95
|
-
when "status"
|
96
|
-
@response.status = data[1]
|
97
|
-
when "txnref", "txn_ref"
|
98
|
-
@response.transaction.reference = data[1]
|
99
|
-
when "transaction_no"
|
100
|
-
@response.transaction.number = data[1]
|
101
|
-
when "bank_ref"
|
102
|
-
@response.transaction.bank_reference = data[1]
|
103
|
-
when "card_desc"
|
104
|
-
@response.transaction.card.description = data[1]
|
105
|
-
when "response_code"
|
106
|
-
@response.code = data[1]
|
107
|
-
when "card_type"
|
108
|
-
@response.transaction.card.type = data[1]
|
109
|
-
when "time"
|
110
|
-
@response.transaction.time = data[1]
|
111
|
-
when "command"
|
112
|
-
@response.transaction.command = data[1]
|
113
|
-
when "card_expiry"
|
114
|
-
@response.transaction.card.expiry = data[1]
|
115
|
-
when "result"
|
116
|
-
@response.result = data[1]
|
117
|
-
when "settlement_date"
|
118
|
-
@response.transaction.settlement_date = data[1]
|
119
|
-
when "rrn"
|
120
|
-
@response.transaction.rrn = data[1]
|
121
|
-
when "MID"
|
122
|
-
@response.transaction.merchant_id = data[1]
|
123
|
-
else
|
124
|
-
end
|
79
|
+
data = line.split("=")
|
80
|
+
parse_success_line(key: data[0], value: data[1])
|
125
81
|
end
|
126
|
-
@receipt = @full_response.drop_while { |line| !line.include?("Reciept
|
127
|
-
if @receipt.include?("Reciept
|
82
|
+
@receipt = @full_response.drop_while { |line| !line.include?("Reciept follows") }
|
83
|
+
if @receipt.include?("Reciept follows")
|
84
|
+
# Don't want the "Reciept follows" line, nor the "." and "done" line.
|
85
|
+
# Only want the receipt in between
|
128
86
|
@receipt = @receipt[1...-2]
|
129
87
|
@response.transaction.receipt = @receipt.join("\n")
|
130
88
|
end
|
@@ -134,6 +92,59 @@ module NetRegistry
|
|
134
92
|
end
|
135
93
|
|
136
94
|
protected
|
95
|
+
def parse_failed_response
|
96
|
+
# remove all spaces until the dot
|
97
|
+
lines = @full_response.drop_while { |x| x != "." }
|
98
|
+
if lines.empty?
|
99
|
+
@response.text = @full_response[1]
|
100
|
+
else
|
101
|
+
lines.shift
|
102
|
+
lines[0].slice!("response_text=")
|
103
|
+
@response.text = lines[0]
|
104
|
+
end
|
105
|
+
@response.status = "failed"
|
106
|
+
@response.code = -1
|
107
|
+
end
|
108
|
+
|
109
|
+
def parse_success_line(key:, value:)
|
110
|
+
case key
|
111
|
+
when "card_number", "card_no"
|
112
|
+
@response.transaction.card.number = value
|
113
|
+
when "response_text"
|
114
|
+
@response.text = value
|
115
|
+
when "response_code"
|
116
|
+
@response.code = value
|
117
|
+
when "status"
|
118
|
+
@response.status = value
|
119
|
+
when "result"
|
120
|
+
@response.result = value
|
121
|
+
when "amount", "total_amount"
|
122
|
+
@response.transaction.amount = value
|
123
|
+
when "time"
|
124
|
+
@response.transaction.time = value
|
125
|
+
when "command"
|
126
|
+
@response.transaction.command = value
|
127
|
+
when "txnref", "txn_ref"
|
128
|
+
@response.transaction.reference = value
|
129
|
+
when "transaction_no"
|
130
|
+
@response.transaction.number = value
|
131
|
+
when "bank_ref"
|
132
|
+
@response.transaction.bank_reference = value
|
133
|
+
when "settlement_date"
|
134
|
+
@response.transaction.settlement_date = value
|
135
|
+
when "rrn"
|
136
|
+
@response.transaction.rrn = value
|
137
|
+
when "MID"
|
138
|
+
@response.transaction.merchant_id = value
|
139
|
+
when "card_type"
|
140
|
+
@response.transaction.card.type = value
|
141
|
+
when "card_expiry"
|
142
|
+
@response.transaction.card.expiry = value
|
143
|
+
when "card_desc"
|
144
|
+
@response.transaction.card.description = value
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
137
148
|
# Preliminary validation for the purchase method
|
138
149
|
# Returns a Response Object
|
139
150
|
def validate_purchase_params(params)
|
@@ -182,6 +193,21 @@ module NetRegistry
|
|
182
193
|
end
|
183
194
|
end
|
184
195
|
|
196
|
+
def validate_completion_params(params)
|
197
|
+
if params[:PREAUTHNUM].nil? || params[:PREAUTHNUM].empty?
|
198
|
+
return "PREAUTHNUM not found", false
|
199
|
+
elsif params[:CCNUM].nil? || params[:CCNUM].empty?
|
200
|
+
return "CCNUM not found", false
|
201
|
+
elsif params[:CCEXP].nil? || params[:CCEXP].empty?
|
202
|
+
return "CCEXP not found", false
|
203
|
+
elsif !valid_expiry_format?(params[:CCEXP])
|
204
|
+
return "CCEXP invalid format", false
|
205
|
+
elsif params[:AMOUNT].nil? || params[:AMOUNT].empty?
|
206
|
+
return "AMOUNT not found", false
|
207
|
+
else
|
208
|
+
return "", true
|
209
|
+
end
|
210
|
+
end
|
185
211
|
|
186
212
|
def valid_expiry_format?(card_expiry)
|
187
213
|
raise TypeError if !card_expiry.is_a?(String)
|
data/lib/net_registry/version.rb
CHANGED
data/net_registry.gemspec
CHANGED
@@ -44,10 +44,10 @@ API. Official documentation can be found at http://www.netregistry.com.au/ee-ima
|
|
44
44
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
45
45
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
46
46
|
spec.require_paths = ["lib"]
|
47
|
-
spec.required_ruby_version = '>= 2.0'
|
47
|
+
spec.required_ruby_version = '>= 2.1.0'
|
48
48
|
|
49
49
|
spec.add_development_dependency "bundler", "~> 1.6"
|
50
|
-
spec.add_development_dependency "rake"
|
51
|
-
spec.add_development_dependency "rspec"
|
52
|
-
spec.add_development_dependency "webmock"
|
50
|
+
spec.add_development_dependency "rake", "~> 10.4.2"
|
51
|
+
spec.add_development_dependency "rspec", "~> 3.3.0"
|
52
|
+
spec.add_development_dependency "webmock", "~> 1.21.0"
|
53
53
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -41,7 +41,7 @@ RSpec.describe NetRegistry::Client do
|
|
41
41
|
<<-STATUS
|
42
42
|
card_number=#{params[:CCNUM]}
|
43
43
|
settlement_date=31/07/00
|
44
|
-
response_text=INVALID
|
44
|
+
response_text=INVALID TRANSACTION
|
45
45
|
amount=#{params[:AMOUNT]}
|
46
46
|
status=complete
|
47
47
|
txnref=#{params[:TXNREF]}
|
@@ -51,7 +51,7 @@ RSpec.describe NetRegistry::Client do
|
|
51
51
|
card_expiry=01/01
|
52
52
|
MID=24
|
53
53
|
card_type=6
|
54
|
-
time=2000
|
54
|
+
time=2000-07-31 14:28:20
|
55
55
|
command=purchase
|
56
56
|
result=0
|
57
57
|
.
|
@@ -74,9 +74,9 @@ RSpec.describe NetRegistry::Client do
|
|
74
74
|
response_code=12
|
75
75
|
receipt_array=ARRAY(0x8221b9c)
|
76
76
|
cashout_amount=0
|
77
|
-
account_type=CREDIT
|
77
|
+
account_type=CREDIT A/C
|
78
78
|
rrn=000782000024
|
79
|
-
response_text=INVALID
|
79
|
+
response_text=INVALID TRANSACTION
|
80
80
|
txn_ref=0007311458332546
|
81
81
|
card_no=4111111111111111
|
82
82
|
total_amount=100
|
@@ -84,27 +84,27 @@ RSpec.describe NetRegistry::Client do
|
|
84
84
|
card_expiry=01/01
|
85
85
|
card_type=6
|
86
86
|
result=0
|
87
|
-
Reciept
|
88
|
-
Transaction
|
89
|
-
|
90
|
-
TYRELL
|
91
|
-
MERCH
|
92
|
-
TERM
|
93
|
-
COUNTRY
|
94
|
-
31/07/00
|
95
|
-
RRN
|
87
|
+
Reciept follows
|
88
|
+
Transaction No: 00332546
|
89
|
+
---------------
|
90
|
+
TYRELL CORPORATION
|
91
|
+
MERCH ID 99999999
|
92
|
+
TERM ID Y9TB99
|
93
|
+
COUNTRY CODE AU
|
94
|
+
31/07/00 14:32
|
95
|
+
RRN 000782000024
|
96
96
|
VISA
|
97
|
-
411111
|
98
|
-
CREDIT
|
99
|
-
AUTHORISATION
|
100
|
-
DECLINED
|
101
|
-
PURCHASE
|
102
|
-
TOTAL
|
103
|
-
PLEASE
|
104
|
-
OF
|
105
|
-
(SUBJECT
|
106
|
-
ACCEPTANCE)
|
107
|
-
|
97
|
+
411111-111
|
98
|
+
CREDIT A/C 01/01
|
99
|
+
AUTHORISATION NO:
|
100
|
+
DECLINED 12
|
101
|
+
PURCHASE $1.00
|
102
|
+
TOTAL AUD $1.00
|
103
|
+
PLEASE RETAIN AS RECORD
|
104
|
+
OF PURCHASE
|
105
|
+
(SUBJECT TO CARDHOLDER'S
|
106
|
+
ACCEPTANCE)
|
107
|
+
---------------
|
108
108
|
.
|
109
109
|
done=1
|
110
110
|
PURCHASE
|
@@ -146,7 +146,7 @@ RSpec.describe NetRegistry::Client do
|
|
146
146
|
|
147
147
|
response = client.purchase(params)
|
148
148
|
expect(response.class).to eq(NetRegistry::Response)
|
149
|
-
expect(response.text).to eq("INVALID
|
149
|
+
expect(response.text).to eq("INVALID TRANSACTION")
|
150
150
|
expect(response.code).to eq(12)
|
151
151
|
expect(response.status).to eq("declined")
|
152
152
|
end
|
@@ -173,7 +173,7 @@ RSpec.describe NetRegistry::Client do
|
|
173
173
|
.to_return(status: 200, body: purchase_success_response, headers: {})
|
174
174
|
response = client.purchase(params)
|
175
175
|
expect(response.class).to eq(NetRegistry::Response)
|
176
|
-
expect(response.text).to eq("INVALID
|
176
|
+
expect(response.text).to eq("INVALID TRANSACTION")
|
177
177
|
expect(response.code).to eq(12)
|
178
178
|
expect(response.status).to eq("declined")
|
179
179
|
end
|
@@ -215,7 +215,7 @@ RSpec.describe NetRegistry::Client do
|
|
215
215
|
.to_return(status: 200, body: purchase_success_response, headers: {})
|
216
216
|
response = client.refund(params)
|
217
217
|
expect(response.class).to eq(NetRegistry::Response)
|
218
|
-
expect(response.text).to eq("INVALID
|
218
|
+
expect(response.text).to eq("INVALID TRANSACTION")
|
219
219
|
expect(response.code).to eq(12)
|
220
220
|
expect(response.status).to eq("declined")
|
221
221
|
end
|
@@ -242,7 +242,7 @@ RSpec.describe NetRegistry::Client do
|
|
242
242
|
.to_return(status: 200, body: purchase_success_response, headers: {})
|
243
243
|
response = client.refund(params)
|
244
244
|
expect(response.class).to eq(NetRegistry::Response)
|
245
|
-
expect(response.text).to eq("INVALID
|
245
|
+
expect(response.text).to eq("INVALID TRANSACTION")
|
246
246
|
expect(response.code).to eq(12)
|
247
247
|
expect(response.status).to eq("declined")
|
248
248
|
end
|
@@ -57,7 +57,7 @@ RSpec.describe NetRegistry::ResponseBuilder do
|
|
57
57
|
card_expiry=01/01
|
58
58
|
MID=24
|
59
59
|
card_type=6
|
60
|
-
time=2000
|
60
|
+
time=2000-07-31 14:28:20
|
61
61
|
command=purchase
|
62
62
|
result=0
|
63
63
|
.
|
@@ -79,9 +79,9 @@ RSpec.describe NetRegistry::ResponseBuilder do
|
|
79
79
|
response_code=12
|
80
80
|
receipt_array=ARRAY(0x8221b9c)
|
81
81
|
cashout_amount=0
|
82
|
-
account_type=CREDIT
|
82
|
+
account_type=CREDIT A/C
|
83
83
|
rrn=000782000024
|
84
|
-
response_text=INVALID
|
84
|
+
response_text=INVALID TRANSACTION
|
85
85
|
txn_ref=0007311458332546
|
86
86
|
card_no=4111111111111111
|
87
87
|
total_amount=100
|
@@ -89,27 +89,27 @@ RSpec.describe NetRegistry::ResponseBuilder do
|
|
89
89
|
card_expiry=01/01
|
90
90
|
card_type=6
|
91
91
|
result=0
|
92
|
-
Reciept
|
93
|
-
Transaction
|
94
|
-
|
95
|
-
TYRELL
|
96
|
-
MERCH
|
97
|
-
TERM
|
98
|
-
COUNTRY
|
99
|
-
31/07/00
|
100
|
-
RRN
|
92
|
+
Reciept follows
|
93
|
+
Transaction No: 00332546
|
94
|
+
---------------
|
95
|
+
TYRELL CORPORATION
|
96
|
+
MERCH ID 99999999
|
97
|
+
TERM ID Y9TB99
|
98
|
+
COUNTRY CODE AU
|
99
|
+
31/07/00 14:32
|
100
|
+
RRN 000782000024
|
101
101
|
VISA
|
102
|
-
411111
|
103
|
-
CREDIT
|
102
|
+
411111-111
|
103
|
+
CREDIT A/C 01/01
|
104
104
|
AUTHORISATION NO:
|
105
|
-
DECLINED
|
106
|
-
PURCHASE
|
107
|
-
TOTAL
|
108
|
-
PLEASE
|
109
|
-
OF
|
110
|
-
(SUBJECT
|
111
|
-
ACCEPTANCE)
|
112
|
-
|
105
|
+
DECLINED 12
|
106
|
+
PURCHASE $1.00
|
107
|
+
TOTAL AUD $1.00
|
108
|
+
PLEASE RETAIN AS RECORD
|
109
|
+
OF PURCHASE
|
110
|
+
(SUBJECT TO CARDHOLDER'S
|
111
|
+
ACCEPTANCE)
|
112
|
+
---------------
|
113
113
|
.
|
114
114
|
done=1
|
115
115
|
RESPONSE
|
@@ -151,7 +151,7 @@ RSpec.describe NetRegistry::ResponseBuilder do
|
|
151
151
|
|
152
152
|
it { expect(@response.transaction.amount).to eq("100") }
|
153
153
|
it { expect(@response.transaction.reference).to eq("0007311428202312") }
|
154
|
-
it { expect(@response.transaction.time).to eq("2000
|
154
|
+
it { expect(@response.transaction.time).to eq("2000-07-31 14:28:20")}
|
155
155
|
it { expect(@response.transaction.command).to eq("purchase")}
|
156
156
|
it { expect(@response.transaction.settlement_date).to eq("31/07/00")}
|
157
157
|
it { expect(@response.transaction.bank_reference).to eq("000731000024")}
|
@@ -168,29 +168,29 @@ RSpec.describe NetRegistry::ResponseBuilder do
|
|
168
168
|
before :each do
|
169
169
|
@response = factory.parse(purchase_invalid_transaction).create
|
170
170
|
@receipt = <<-RECEIPT.gsub(/^\s+/, "")
|
171
|
-
Transaction
|
172
|
-
|
173
|
-
TYRELL
|
174
|
-
MERCH
|
175
|
-
TERM
|
176
|
-
COUNTRY
|
177
|
-
31/07/00
|
178
|
-
RRN
|
171
|
+
Transaction No: 00332546
|
172
|
+
---------------
|
173
|
+
TYRELL CORPORATION
|
174
|
+
MERCH ID 99999999
|
175
|
+
TERM ID Y9TB99
|
176
|
+
COUNTRY CODE AU
|
177
|
+
31/07/00 14:32
|
178
|
+
RRN 000782000024
|
179
179
|
VISA
|
180
|
-
411111
|
181
|
-
CREDIT
|
180
|
+
411111-111
|
181
|
+
CREDIT A/C 01/01
|
182
182
|
AUTHORISATION NO:
|
183
|
-
DECLINED
|
184
|
-
PURCHASE
|
185
|
-
TOTAL
|
186
|
-
PLEASE
|
187
|
-
OF
|
188
|
-
(SUBJECT
|
189
|
-
ACCEPTANCE)
|
190
|
-
|
183
|
+
DECLINED 12
|
184
|
+
PURCHASE $1.00
|
185
|
+
TOTAL AUD $1.00
|
186
|
+
PLEASE RETAIN AS RECORD
|
187
|
+
OF PURCHASE
|
188
|
+
(SUBJECT TO CARDHOLDER'S
|
189
|
+
ACCEPTANCE)
|
190
|
+
---------------
|
191
191
|
RECEIPT
|
192
192
|
end
|
193
|
-
it { expect(@response.text).to eq("INVALID
|
193
|
+
it { expect(@response.text).to eq("INVALID TRANSACTION") }
|
194
194
|
it { expect(@response.transaction.reference).to eq("0007311458332546") }
|
195
195
|
it { expect(@response.transaction.rrn).to eq("000782000024")}
|
196
196
|
it { expect(@response.result).to eq(0)}
|
@@ -224,7 +224,7 @@ RSpec.describe NetRegistry::ResponseBuilder do
|
|
224
224
|
it "has not provided with a COMMAND" do
|
225
225
|
factory.verify_params(invalid_status_params)
|
226
226
|
response = factory.create
|
227
|
-
expect(response.text).to eq("Invalid command. Only [purchase status preauth refund] are valid.")
|
227
|
+
expect(response.text).to eq("Invalid command. Only [purchase status preauth refund completion] are valid.")
|
228
228
|
expect(response.status).to eq("failed")
|
229
229
|
expect(response.code).to eq(-1)
|
230
230
|
end
|
@@ -323,4 +323,28 @@ RSpec.describe NetRegistry::ResponseBuilder do
|
|
323
323
|
expect(factory.send(:validate_purchase_params, params.merge!(CCEXP: "What's up"))).to eq(["CCEXP invalid format", false])
|
324
324
|
end
|
325
325
|
end
|
326
|
+
|
327
|
+
describe "#validate_completion_params" do
|
328
|
+
let(:params) { {AMOUNT: "100", CCNUM: "111111111111", CCEXP: "10/15", PREAUTHNUM: "111111111"}}
|
329
|
+
it { expect(factory.send(:validate_completion_params, params)).to eq(["", true]) }
|
330
|
+
it "does not have amount in params hash" do
|
331
|
+
expect(factory.send(:validate_completion_params, params.merge!(AMOUNT: nil))).to eq(["AMOUNT not found", false])
|
332
|
+
expect(factory.send(:validate_completion_params, params.merge!(AMOUNT: ""))).to eq(["AMOUNT not found", false])
|
333
|
+
end
|
334
|
+
|
335
|
+
it "does not have CCNUM in params hash" do
|
336
|
+
expect(factory.send(:validate_completion_params, params.merge!(CCNUM: nil))).to eq(["CCNUM not found", false])
|
337
|
+
expect(factory.send(:validate_completion_params, params.merge!(CCNUM: ""))).to eq(["CCNUM not found", false])
|
338
|
+
end
|
339
|
+
|
340
|
+
it "does not have CCEXP in params hash" do
|
341
|
+
expect(factory.send(:validate_completion_params, params.merge!(CCEXP: nil))).to eq(["CCEXP not found", false])
|
342
|
+
expect(factory.send(:validate_completion_params, params.merge!(CCEXP: ""))).to eq(["CCEXP not found", false])
|
343
|
+
end
|
344
|
+
|
345
|
+
it "invalid CCEXP format" do
|
346
|
+
expect(factory.send(:validate_completion_params, params.merge!(CCEXP: "12/29/2015"))).to eq(["CCEXP invalid format", false])
|
347
|
+
expect(factory.send(:validate_completion_params, params.merge!(CCEXP: "What's up"))).to eq(["CCEXP invalid format", false])
|
348
|
+
end
|
349
|
+
end
|
326
350
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -23,6 +23,8 @@ Bundler.setup
|
|
23
23
|
require 'webmock/rspec'
|
24
24
|
WebMock.disable_net_connect!(allow_localost: true)
|
25
25
|
require 'net_registry'
|
26
|
+
require 'coveralls'
|
27
|
+
Coveralls.wear!
|
26
28
|
RSpec.configure do |config|
|
27
29
|
# rspec-expectations config goes here. You can use an alternate
|
28
30
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
data/spec/transaction_spec.rb
CHANGED
@@ -86,7 +86,7 @@ RSpec.describe NetRegistry::Transaction do
|
|
86
86
|
|
87
87
|
describe "#time" do
|
88
88
|
it "assigns time" do
|
89
|
-
time = "2000
|
89
|
+
time = "2000-07-31 14:28:20"
|
90
90
|
expect(transaction.time).to be_nil
|
91
91
|
transaction.time = time
|
92
92
|
expect(transaction.time).to eq(time)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net_registry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Tung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,44 +28,44 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 10.4.2
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 10.4.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.3.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.3.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: webmock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.21.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.21.0
|
69
69
|
description: |-
|
70
70
|
This gem serves as a Ruby wrapper for the NetRegistry Payment Gateway's
|
71
71
|
API. Official documentation can be found at http://www.netregistry.com.au/ee-images/uploads/support/NR-ecom-gateway8.pdf. Source can be found on https://github.com/carnextnoor/net_registry
|
@@ -77,6 +77,7 @@ extra_rdoc_files: []
|
|
77
77
|
files:
|
78
78
|
- ".gitignore"
|
79
79
|
- ".rspec"
|
80
|
+
- ".travis.yml"
|
80
81
|
- Gemfile
|
81
82
|
- LICENSE.txt
|
82
83
|
- README.md
|
@@ -109,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
110
|
requirements:
|
110
111
|
- - ">="
|
111
112
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
113
|
+
version: 2.1.0
|
113
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
115
|
requirements:
|
115
116
|
- - ">="
|