risepay 1.0.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 +7 -0
- data/lib/risepays.rb +235 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 97b5ac2d16774208533abe29d99572970a6eeab0
|
|
4
|
+
data.tar.gz: c640bfd63bbcd5910f2e6d8460b5f458c61e8ed9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 45118039f7aeb4bea972a892078c9d20e95c7c8a920958c0f9093cb2acfd2b3d2acd658c874be9ceb153ff746fc4a5290957793c3eed35f121970cc5e2afea86
|
|
7
|
+
data.tar.gz: 35df62307548bccb1012452109365de38673a9d838ff327a9823b479aca75c1f4affbb91496b4b308da5306b20fab366da57a84593fca12573898fa65e39d918
|
data/lib/risepays.rb
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Risepay API helper
|
|
3
|
+
|
|
4
|
+
@category API helper
|
|
5
|
+
@package Risepay
|
|
6
|
+
@author support@risepay.com
|
|
7
|
+
@copyright Copyright (c) 2014
|
|
8
|
+
@version 1.0
|
|
9
|
+
|
|
10
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
11
|
+
|
|
12
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
13
|
+
|
|
14
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
19
|
+
=end
|
|
20
|
+
|
|
21
|
+
require 'uri'
|
|
22
|
+
require 'net/http'
|
|
23
|
+
require 'rubygems'
|
|
24
|
+
require 'ostruct'
|
|
25
|
+
require 'date'
|
|
26
|
+
require 'time'
|
|
27
|
+
require 'active_support'
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class Risepays
|
|
31
|
+
|
|
32
|
+
attr_accessor :UserName, :Password, :url, :defFileds, :info, :RespMSG, :formData
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def initialize(user,pass)
|
|
36
|
+
@UserName = user;
|
|
37
|
+
@Password = pass;
|
|
38
|
+
@defFileds = ['TransType', 'NameOnCard','CardNum','ExpDate','Amount','CVNum','InvNum',
|
|
39
|
+
'Zip','Street', 'MagData', 'Amount','PNRef'];
|
|
40
|
+
|
|
41
|
+
@formData = [];
|
|
42
|
+
@url ="https://gateway1.risepay.com/ws/transact.asmx/ProcessCreditCard"
|
|
43
|
+
@amountFields = ['Amount', 'TipAmt', 'TaxAmt'];
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def get_gateway_url()
|
|
49
|
+
|
|
50
|
+
return @url
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def set_gateway_url(url)
|
|
54
|
+
@url = url
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def getDefFileds
|
|
58
|
+
|
|
59
|
+
return @defFileds
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def amountConvert(num)
|
|
63
|
+
amount = '%.2f' % num
|
|
64
|
+
return amount
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def sale(opt = null)
|
|
69
|
+
if opt
|
|
70
|
+
|
|
71
|
+
@formData = opt
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
@formData["TransType"]="Sale"
|
|
76
|
+
|
|
77
|
+
return prepare()
|
|
78
|
+
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def auth(opt = null)
|
|
83
|
+
|
|
84
|
+
if opt
|
|
85
|
+
|
|
86
|
+
@formData = opt
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
@formData["TransType"]="Auth"
|
|
90
|
+
|
|
91
|
+
return prepare()
|
|
92
|
+
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def returnTrans(opt = null)
|
|
96
|
+
|
|
97
|
+
if opt
|
|
98
|
+
|
|
99
|
+
@formData = opt
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
@formData["TransType"]="Return"
|
|
103
|
+
|
|
104
|
+
return prepare()
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def void(opt = null)
|
|
109
|
+
|
|
110
|
+
if opt
|
|
111
|
+
|
|
112
|
+
@formData = opt
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
@formData["TransType"]="Void"
|
|
116
|
+
|
|
117
|
+
return prepare()
|
|
118
|
+
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def capture(opt = null)
|
|
122
|
+
|
|
123
|
+
if opt
|
|
124
|
+
@formData = opt
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
@formData["TransType"]="Force"
|
|
128
|
+
|
|
129
|
+
return prepare()
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def prepare()
|
|
134
|
+
|
|
135
|
+
@data = {};
|
|
136
|
+
@data["UserName"] = @UserName
|
|
137
|
+
@data["Password"] = @Password
|
|
138
|
+
@data["ExtData"] = ''
|
|
139
|
+
|
|
140
|
+
#fix amounts
|
|
141
|
+
@amountFields.each do |f|
|
|
142
|
+
@amountFields[2] = ''
|
|
143
|
+
if @formData[f]
|
|
144
|
+
@formData[f] = amountConvert(@formData[f])
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
#Construct ExtData
|
|
149
|
+
@formData.each do |f , value|
|
|
150
|
+
if !((@defFileds).include? f)
|
|
151
|
+
|
|
152
|
+
@data['ExtData']<< "<#{f}>#{value}</#{f}>";
|
|
153
|
+
@formData.delete(f)
|
|
154
|
+
else
|
|
155
|
+
@data[f] = value;
|
|
156
|
+
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# set defaults fields
|
|
161
|
+
@defFileds.each do |f|
|
|
162
|
+
if @data[f] == nil
|
|
163
|
+
@data[f] = '';
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
return post(@data)
|
|
168
|
+
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def convert_response(obj)
|
|
172
|
+
|
|
173
|
+
#ConvertExtData
|
|
174
|
+
#Split plain data and XML into @matches hash
|
|
175
|
+
s = obj['ExtData']
|
|
176
|
+
s = s.match(/([,=0-9a-zA-Z]*)(\<.*\>)?/)
|
|
177
|
+
@str = s[1]
|
|
178
|
+
@str2 = s[2]
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@str.split(",").each do |f|
|
|
182
|
+
arr = f.split('=');
|
|
183
|
+
arr[1] && (obj[arr[0]] = arr[1])
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
#Process XML Part
|
|
187
|
+
|
|
188
|
+
@xmldata = Hash.from_xml(@str2)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
if @xmldata
|
|
192
|
+
for x in @xmldata
|
|
193
|
+
obj[x] = @xmldata[x]
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
@jsonlist = ['xmlns:xsd', 'xmlns:xsi', 'xmlns', 'ExtData']
|
|
198
|
+
|
|
199
|
+
@jsonlist.each do |j|
|
|
200
|
+
obj.delete(j)
|
|
201
|
+
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
return obj
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def post(opts)
|
|
209
|
+
|
|
210
|
+
uri = URI.parse(@url)
|
|
211
|
+
|
|
212
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
213
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
|
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);
|
|
224
|
+
|
|
225
|
+
approved = false
|
|
226
|
+
if(json['Result'] == "0")
|
|
227
|
+
approved = true;
|
|
228
|
+
|
|
229
|
+
end
|
|
230
|
+
json['Approved']=approved
|
|
231
|
+
return json
|
|
232
|
+
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: risepay
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Francisco Perez
|
|
8
|
+
- Jhonnatan Rodriguez
|
|
9
|
+
- Kamel Bacha
|
|
10
|
+
autorequire:
|
|
11
|
+
bindir: bin
|
|
12
|
+
cert_chain: []
|
|
13
|
+
date: 2010-09-08 00:00:00.000000000 Z
|
|
14
|
+
dependencies: []
|
|
15
|
+
description: Risepay API library on Ruby
|
|
16
|
+
email: contactus@risepay.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- lib/risepays.rb
|
|
22
|
+
homepage: http://www.risepay.com/
|
|
23
|
+
licenses:
|
|
24
|
+
- risepay
|
|
25
|
+
metadata: {}
|
|
26
|
+
post_install_message:
|
|
27
|
+
rdoc_options: []
|
|
28
|
+
require_paths:
|
|
29
|
+
- lib
|
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - '>='
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - '>='
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
requirements: []
|
|
41
|
+
rubyforge_project:
|
|
42
|
+
rubygems_version: 2.0.14
|
|
43
|
+
signing_key:
|
|
44
|
+
specification_version: 4
|
|
45
|
+
summary: Risepay API library
|
|
46
|
+
test_files: []
|