risepay 1.0.1 → 1.0.2
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 +4 -4
- data/lib/risepays.rb +77 -48
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c64f6ac0e7c2b686ec830e8b0a7219d922bf696d
|
|
4
|
+
data.tar.gz: 207c02aecb0d4b5c74880e245b51ec8a7c9d9907
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cac45e0a0ef2996ae38266176e30fedf9c8673bbc56b6e7ff27613e42e7d0e156b6ee5c9491898ba91da6505d9b7ca741c103c11a096d58004d0b9db3ca06d0a
|
|
7
|
+
data.tar.gz: c81576a3169cf55fc64791de8829bc5728c9620328a9535399476b51608acf481aee03782967cb826e209dd747e72d687bb64fc1ae9f23c250c513737148a04e
|
data/lib/risepays.rb
CHANGED
|
@@ -29,7 +29,7 @@ require 'active_support'
|
|
|
29
29
|
|
|
30
30
|
class Risepays
|
|
31
31
|
|
|
32
|
-
attr_accessor :UserName, :Password, :url, :defFileds, :info, :RespMSG, :formData
|
|
32
|
+
attr_accessor :UserName, :Password, :url, :defFileds, :info, :RespMSG, :formData, :resp
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
def initialize(user,pass)
|
|
@@ -41,7 +41,7 @@ class Risepays
|
|
|
41
41
|
@formData = [];
|
|
42
42
|
@url ="https://gateway1.risepay.com/ws/transact.asmx/ProcessCreditCard"
|
|
43
43
|
@amountFields = ['Amount', 'TipAmt', 'TaxAmt'];
|
|
44
|
-
|
|
44
|
+
@resp = ''
|
|
45
45
|
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -130,6 +130,10 @@ class Risepays
|
|
|
130
130
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
|
+
def stringStartsWith(haystack, needle)
|
|
134
|
+
return haystack.index(needle) === 0
|
|
135
|
+
end
|
|
136
|
+
|
|
133
137
|
def prepare()
|
|
134
138
|
|
|
135
139
|
@data = {};
|
|
@@ -170,66 +174,91 @@ class Risepays
|
|
|
170
174
|
|
|
171
175
|
def convert_response(obj)
|
|
172
176
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
@resp = obj
|
|
178
|
+
@resp['Approved'] = false
|
|
179
|
+
|
|
180
|
+
#Add Approved Value
|
|
181
|
+
if(@resp['Result'] == "0")
|
|
182
|
+
@resp['Approved']= true
|
|
183
|
+
|
|
184
|
+
#ConvertExtData
|
|
185
|
+
#Split plain data and XML into @matches hash
|
|
186
|
+
matches = @resp['ExtData']
|
|
187
|
+
matches = matches.match(/([,=0-9a-zA-Z]*)(\<.*\>)?/)
|
|
188
|
+
@str = matches[1]
|
|
189
|
+
|
|
190
|
+
#Process plain text coma separated keypairs
|
|
191
|
+
@str.split(",").each do |f|
|
|
192
|
+
arr = f.split('=');
|
|
193
|
+
arr[1] && (@resp[arr[0]] = arr[1])
|
|
194
|
+
end
|
|
187
195
|
|
|
188
|
-
|
|
196
|
+
#Process XML Part
|
|
197
|
+
if(matches.length == 2)
|
|
198
|
+
@xmldata = Hash.from_xml(matches[2])
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
if @xmldata
|
|
202
|
+
for x in @xmldata
|
|
203
|
+
@resp[x] = @xmldata[x]
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
189
207
|
|
|
190
|
-
|
|
191
|
-
if @xmldata
|
|
192
|
-
for x in @xmldata
|
|
193
|
-
obj[x] = @xmldata[x]
|
|
194
|
-
end
|
|
195
208
|
end
|
|
196
|
-
|
|
197
209
|
@jsonlist = ['xmlns:xsd', 'xmlns:xsi', 'xmlns', 'ExtData']
|
|
198
210
|
|
|
199
211
|
@jsonlist.each do |j|
|
|
200
|
-
|
|
212
|
+
@resp.delete(j)
|
|
201
213
|
|
|
202
214
|
end
|
|
203
215
|
|
|
204
|
-
return obj
|
|
205
|
-
end
|
|
206
216
|
|
|
217
|
+
if(!@resp['Message'])
|
|
218
|
+
@resp['Message'] = "";
|
|
219
|
+
end
|
|
207
220
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
http.use_ssl = (uri.scheme == "https")
|
|
215
|
-
request = Net::HTTP::Post.new(uri.request_uri)
|
|
216
|
-
|
|
217
|
-
request.set_form_data(opts);
|
|
218
|
-
|
|
219
|
-
response = http.request(request)
|
|
220
|
-
xml= response.body
|
|
221
|
-
session = Hash.from_xml(xml)
|
|
222
|
-
res = session['Response']
|
|
223
|
-
json = convert_response(res);
|
|
221
|
+
if(@resp['RespMSG'])
|
|
222
|
+
@resp['Message'] = @resp['Message'] + " " + @resp['RespMSG'];
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
return @resp
|
|
226
|
+
end
|
|
224
227
|
|
|
225
|
-
approved = false
|
|
226
|
-
if(json['Result'] == "0")
|
|
227
|
-
approved = true;
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
json['Approved']=approved
|
|
231
|
-
return json
|
|
229
|
+
def post(opts)
|
|
232
230
|
|
|
231
|
+
begin
|
|
232
|
+
|
|
233
|
+
uri = URI.parse(@url)
|
|
234
|
+
|
|
235
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
236
|
+
http.read_timeout = 120
|
|
237
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
|
238
|
+
http.use_ssl = (uri.scheme == "https")
|
|
239
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
|
240
|
+
|
|
241
|
+
request.set_form_data(opts);
|
|
242
|
+
|
|
243
|
+
response = http.request(request)
|
|
244
|
+
xml= response.body
|
|
245
|
+
session = Hash.from_xml(xml)
|
|
246
|
+
res = session['Response']
|
|
247
|
+
|
|
248
|
+
if (stringStartsWith(xml, "<?xml"))
|
|
249
|
+
convert_response(res);
|
|
250
|
+
else
|
|
251
|
+
@resp['Result'] = -999
|
|
252
|
+
@resp['Message'] = "Gateway error" + xml
|
|
253
|
+
return @resp
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
return @resp
|
|
257
|
+
rescue Exception => e
|
|
258
|
+
@resp['Result'] = -999
|
|
259
|
+
@resp['Message'] = "Gateway error" + xml
|
|
260
|
+
return @resp
|
|
261
|
+
end
|
|
233
262
|
end
|
|
234
263
|
|
|
235
264
|
end
|