SVClient 1.0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f33a0988b40491e1ba93f5bfe8c31b42a31da04b
4
+ data.tar.gz: 1a6db3c401a1ad44be462d296b166758dbbcf2dc
5
+ SHA512:
6
+ metadata.gz: 676eba0435d9bb49a33357fd144ed7559db375a8fef16f44100e88f0a867838e546f64c91734e0426b22bb1563a37125c219e02382cd5bad0466622a0f503939
7
+ data.tar.gz: d6bb6939a16f0ced7f49d1d69da89183a2df93f009f8721f999ff25b1a84097dafad15e53d0a0f6bd2483518d65a905d153c3d0f8183167c694d285fa0503f1b
@@ -0,0 +1,338 @@
1
+ #
2
+ # © 2011 QwikCilver Solutions Private Limited, All Rights Reserved.
3
+ #
4
+ # @author Nityananda
5
+ #
6
+
7
+ require 'SVClient/SVUtils'
8
+ require 'SVClient/SVClient'
9
+ require 'SVClient/SVProperties'
10
+ require 'SVClient/SVBalanceEnquiry'
11
+ require 'SVClient/SVRedeem'
12
+ require 'SVClient/SVCancelRedeem'
13
+
14
+ #
15
+ # This Class provides the Gift Card related API for a QwikCilver WebPos Client to interface with QwikCilver Server.
16
+ #
17
+ # This class provides:
18
+ # - A method to initialize this library
19
+ # - A set of factory methods to get/create an SVRequest instance pertaining to the operation that needs to be performed
20
+ #
21
+ # *NOTE:* The caller must first initialize this library by calling GCWebPos::initlibrary method
22
+ # before any operation can be performed by this library. This method needs to be called after starting
23
+ # the web server and needs to be called only once.
24
+ #
25
+ # After this library has been initialized the caller calls the appropriate factory method to create
26
+ # an instance of SVRequest that will be used to perform the desired operation.
27
+ #
28
+ # Once an SVRequest instance has been created/obtained the caller can
29
+ # set any optional attributes, as desired, by calling the SVRequest.setvalue() method
30
+ #
31
+ # Once the desired attributes have been set the caller must call
32
+ # SVRequest.execute() method to perform the operation.
33
+ # SVRequest.execute() method will return SVResponse object.
34
+ #
35
+ # To check if the operation was performed successfully by QwikCilver Server
36
+ # call SVResponse.getErrorCode() method.
37
+ #
38
+ # If the return value of SVResponse.geterrorcode() method is NOT EQUAL TO SVStatus.SUCCESS then the caller should call
39
+ # SVResponse.geterrormessage() to get a detailed error message on why the operation failed.
40
+ #
41
+ # If the return value of SVResponse.geterrorcode() method
42
+ # is EQUAL TO SVStatus.SUCCESS then the caller should call
43
+ # the appropriate getters in SVResponse object to get the
44
+ # data returned by QwikCilver Server after successful execution of this operation.
45
+ class GCWebPos
46
+
47
+ # This method is used to initialize the SVClient Library.
48
+ # This method needs to be called once before using this library.
49
+ #
50
+ # The required/mandatory attributes for initializing this library are pre-assigned
51
+ # by QwikCilver and provided to the Caller.
52
+ #
53
+ # The list of mandatory and optional
54
+ # attributes are:
55
+ # * serverURL (Mandatory) - Server URL provided by QwikCilver
56
+ # * forwardingEntityId (Mandatory) - Forwarding Entity Id provided by QwikCilver
57
+ # * forwardingEntityPassword (Mandatory) - Forwarding Entity Password provided by QwikCilver
58
+ # * terminalId (Mandatory) - TerminalId is provided by QwikCilver
59
+ # * username (Mandatory) - username provided by QwikCilver
60
+ # * password (Mandatory) - password provided by QwikCilver
61
+ # * connectionTimeout (Optional) - default value is 17 seconds (17000 milliseconds). Actual value is provided by QwikCilver
62
+ # * transactionTimeout (Optional) - default value is 17 seconds (17000 milliseconds). Actual value is provided by QwikCilver
63
+ #
64
+ # To initialize this library the caller needs to create an instance of SVProperties and set the Mandatory attributes and optional
65
+ # attributes, as needed, and call this method by passing the SVProperties instance as a parameter to this method.
66
+ #
67
+ # ===params
68
+ # SVProperties - SVProperties instance that contains the attributes for initializing
69
+ # this library
70
+ #
71
+ # ===return
72
+ # SVProperties which contains QwikCilver server specific data
73
+ # to check if the GCWebPos.initlibrary() operation was performed successfully by QwikCilver Server
74
+ # call SVProperties.geterrorcode() method and check its return value.
75
+ # If the return value of SVProperties.geterrorcode() method
76
+ # is NOT EQUAL TO SVStatus.SUCCESS then the caller should call
77
+ # SVProperties.geterrormessage() to get a detailed error message on why the operation failed.
78
+ # If the return value is EQUAL TO SVStatus.SUCCESS then save this object
79
+ # as it needs to be passed to subsequent calls to perform card related operations.
80
+ #
81
+ # ===raises
82
+ # Exception If input parameter is nil or if any of the *Mandatory*
83
+ # attributes are nil or empty.
84
+ def self.initlibrary(webposprops)
85
+
86
+ if(webposprops == nil)
87
+ raise "Input is null"
88
+ end
89
+ if( (SVUtils::isnullorempty(webposprops.getserverurl())) ||
90
+ (SVUtils::isnullorempty(webposprops.getforwardingentityid())) ||
91
+ (SVUtils::isnullorempty(webposprops.getforwardingentitypassword())) ||
92
+ (SVUtils::isnullorempty(webposprops.getterminalid())) ||
93
+ (SVUtils::isnullorempty(webposprops.getusername())) ||
94
+ (SVUtils::isnullorempty(webposprops.getpassword())))
95
+ raise "One or More of the Mandatory attributes does not have a valid value"
96
+ end
97
+
98
+ webposprops.setsvtype(SVType::WEBPOS_GIFTCARD)
99
+ return SVClient::initlibrary(webposprops)
100
+ end
101
+
102
+ # Use this factory method to create an instance of SVRequest
103
+ # that can be used to perform *BalanceEnquiry* operation.
104
+ #
105
+ # After the caller gets the SVRequest instance, the caller
106
+ # may set any of the optional attributes using the SVRequest.setvalue() method
107
+ #
108
+ # Then call SVRequest.execute() method.
109
+ # SVRequest.execute() method returns an instance of SVResponse.
110
+ # To check if the operation was performed successfully by QwikCilver Server
111
+ # call SVResponse.geterrorcode() method and check its return value.
112
+ #
113
+ # If the return value is EQUAL TO SVStatus.SUCCESS
114
+ # then read the values of the following attributes returned by QwikCilver Server
115
+ # using the appropriate getters
116
+ #
117
+ # * SVResponse.gettransactionid()
118
+ # * SVResponse.getcardbalance()
119
+ # * SVResponse.getcardexpiry()
120
+ # * SVResponse.getapprovalcode()
121
+ #
122
+ # ===params
123
+ # SVProperties - *Mandatory* - Data returned by QwikCilver Server in the GCWebPos.initlibrary() call.
124
+ #
125
+ # String - *Mandatory* - Card Number
126
+ #
127
+ # String - *Mandatory* - Card Pin
128
+ #
129
+ # Fixnum - *Mandatory* - Transaction ID
130
+ #
131
+ # String - *Optional* - Track Data. Can be nil
132
+ #
133
+ # String - *Optional* - Notes use as any unique cross-reference, e.g. ApprovalCode, RRN etc. Can be nil
134
+ #
135
+ # ===return
136
+ # SVRequest instance that should be used to perform <B>BalanceEnquiry</B> operation
137
+ #
138
+ # ===raises
139
+ # Exception If any input parameter that is *Mandatory* is nil or empty
140
+ def self.balanceenquiry(
141
+ serverproperties, #mandatory
142
+ cardnumber, #mandatory
143
+ cardpin, #mandatory
144
+ transactionid, #mandatory
145
+ trackdata = nil, #optional
146
+ notes = nil ) #optional, Use as any unique cross-reference, e.g. ApprovalCode, RRN etc, can also be nil
147
+
148
+ #Validate Mandatory attributes
149
+ if( ( (serverproperties == nil) ) ||
150
+ ( SVUtils::isnullorempty(cardnumber) ) ||
151
+ ( SVUtils::isnullorempty(cardpin) ) ||
152
+ ( SVUtils::isnullorempty(transactionid) )
153
+ )
154
+ raise "One or More of the Mandatory attributes does not have a valid value"
155
+ end
156
+
157
+ serverproperties.setsvtype(SVType::WEBPOS_GIFTCARD)
158
+ @svrequest = SVBalanceEnquiry.new(serverproperties)
159
+ @svrequest.setcardnumber(cardnumber)
160
+ @svrequest.setcardpin(cardpin)
161
+ @svrequest.settransactionid(transactionid)
162
+ @svrequest.settrackdata(trackdata)
163
+ @svrequest.setnotes(notes)
164
+ return @svrequest
165
+ end
166
+
167
+ # Use this factory method to create an instance of @link SVRequest SVRequestend
168
+ # that can be used to perform <B>Redeem</B> operation.
169
+ #
170
+ # After the caller gets the SVRequest instance, the caller
171
+ # may set any of the optional attributes using the SVRequest.setvalue method
172
+ #
173
+ # Then call SVRequest.execute() method.
174
+ # SVRequest.execute() method returns an instance of SVResponse
175
+ # to check if the operation was performed successfully by QwikCilver Server
176
+ # call SVResponse.geterrorcode() method and check its return value.
177
+ #
178
+ # If the return value is EQUAL TO SVStatus.SUCCESS
179
+ # then read the values of the following attributes returned by QwikCilver Server
180
+ # using the appropriate getters
181
+ # * SVResponse.gettransactionid()
182
+ # * SVResponse.getcardbalance()
183
+ # * SVResponse.getcardexpiry()
184
+ # * SVResponse.getapprovalcode()
185
+ # * SVResponse.getterminalid()
186
+ # * SVResponse.gettransfercardnumber()
187
+ # * SVResponse.gettransfercardbalance()
188
+ # * SVResponse.gettransfercardexpiry()
189
+ #
190
+ # ===params
191
+ # SVProperties [Mandatory] Data returned by QwikCilver Server in the initLibrary call
192
+ #
193
+ # String - *Mandatory* - Card Number
194
+ #
195
+ # String - *Mandatory* - Card Pin
196
+ #
197
+ # Fixnum - *Mandatory* - Transaction ID
198
+ #
199
+ # String - *Mandatory* - Invoice Number
200
+ #
201
+ # Float - *Mandatory* - Amount to redeem on the Card
202
+ #
203
+ # String - *Optional* - Track Data
204
+ #
205
+ # String - *Optional* - Notes use as any unique cross-reference, e.g. ApprovalCode, RRN etc. Can be nil
206
+ #
207
+ # Float - *Optional* Total Bill Amount
208
+ #
209
+ # ===return
210
+ # SVRequest SVRequest instance that should be used to perform <B>Redeem</B> operation
211
+ #
212
+ # ===raises
213
+ # Exception If any input parameter that is *Mandatory* is nil or empty
214
+ def self.redeem(
215
+ serverproperties, #mandatory
216
+ cardnumber, #mandatory
217
+ cardpin, #mandatory
218
+ invoicenumber, #mandatory
219
+ amount, #mandatory
220
+ transactionid, #mandatory
221
+ trackdata = nil, #optional
222
+ notes = nil, #optional, Use as any unique cross-reference, e.g. ApprovalCode, RRN etc, can also be nil
223
+ billamount = nil) #optional
224
+
225
+ #Validate Mandatory attributes
226
+ if( ( (serverproperties == nil) ) ||
227
+ ( SVUtils::isnullorempty(cardnumber) ) ||
228
+ ( SVUtils::isnullorempty(cardpin) ) ||
229
+ ( SVUtils::isnullorempty(transactionid) ) ||
230
+ ( SVUtils::isnullorempty(invoicenumber) ) ||
231
+ ( amount <= 0 )
232
+ )
233
+ raise "One or More of the Mandatory attributes does not have a valid value"
234
+ end
235
+
236
+ serverproperties.setsvtype(SVType::WEBPOS_GIFTCARD)
237
+ @svrequest = SVRedeem.new(serverproperties)
238
+ @svrequest.setcardnumber(cardnumber)
239
+ @svrequest.setcardpin(cardpin)
240
+ @svrequest.settransactionid(transactionid)
241
+ @svrequest.setinvoicenumber(invoicenumber)
242
+ @svrequest.setamount(amount)
243
+ @svrequest.setbillamount(billamount) if ( billamount != nil )
244
+ @svrequest.settrackdata(trackdata)
245
+ @svrequest.setnotes(notes)
246
+ return @svrequest
247
+ end
248
+
249
+ # Use this factory method to create an instance of SVRequest
250
+ # that can be used to perform <B>CancelRedeem</B> operation.
251
+ #
252
+ # After the caller gets the SVRequest instance, the caller
253
+ # may set any of the optional attributes using the SVRequest.setvalue method
254
+ #
255
+ # Then call SVRequest.execute() method.
256
+ # SVRequest.execute() method returns an instance of SVResponse
257
+ # to check if the operation was performed successfully by QwikCilver Server
258
+ # call SVResponse.geterrorcode() method and check its return value.
259
+ #
260
+ # If the return value is EQUAL TO SVStatus.SUCCESS
261
+ # then read the values of the following attributes returned by QwikCilver Server
262
+ # using the appropriate getters
263
+ #
264
+ # * SVResponse.gettransactionid
265
+ # * SVResponse.getcardbalance
266
+ # * SVResponse.getcardexpiry
267
+ # * SVResponse.getapprovalcode
268
+ # * SVResponse.getterminalid
269
+ # * SVResponse.gettransfercardnumber
270
+ # * SVResponse.gettransfercardbalance
271
+ # * SVResponse.gettransfercardexpiry
272
+ #
273
+ # ===param
274
+ # SVProperties - *Mandatory* - Data returned by QwikCilver Server in the GCWebPos.initlibrary call
275
+ #
276
+ # String - *Mandatory* - Card Number
277
+ #
278
+ # String - *Mandatory* - Original Invoice Number
279
+ #
280
+ # Bignum - *Mandatory* - Original Transaction Id of the Redeem operation we are trying to Cancel
281
+ #
282
+ # Bignum - *Mandatory* - Original Batch Number
283
+ #
284
+ # Float - *Mandatory* - Original Amount
285
+ #
286
+ # Bignum - *Mandatory* - Transaction Id of the Redeem operation we are trying to Cancel
287
+ #
288
+ # String - *Optional* - Original Approval Code of the Redeem operation we are trying to Cancel. Can be nil
289
+ #
290
+ # String - *Optional* - Track Data. Can be nil
291
+ #
292
+ # String - *Optional* - Use as any unique cross-reference, e.g. ApprovalCode, RRN etc. Can be nil
293
+ #
294
+ # ===return
295
+ # SVRequest instance that should be used to perform <B>CancelRedeem</B> operation
296
+ #
297
+ # ===raises
298
+ # Exception If any input parameter that is *Mandatory* is nil or empty
299
+ #
300
+ def self.cancelredeem(
301
+ serverproperties, #mandatory
302
+ cardnumber, #mandatory
303
+ originalinvoicenumber, #mandatory
304
+ originaltransactionid, #mandatory
305
+ originalbatchno, #mandatory
306
+ originalamount, #mandatory
307
+ transactionid, #mandatory
308
+ cardpin = nil, #optional
309
+ originalapprovalcode = nil, #Optional
310
+ trackdata = nil, #Optional
311
+ notes = nil ) #optional, Use as any unique cross-reference, e.g. ApprovalCode, RRN etci, can also be nil
312
+
313
+ #Validate Mandatory attributes
314
+ if( ( (serverproperties == nil) ) ||
315
+ ( SVUtils::isnullorempty(cardnumber) ) ||
316
+ ( SVUtils::isnullorempty(originalinvoicenumber) ) ||
317
+ ( originaltransactionid <= 0 ) ||
318
+ ( originalbatchno <= 0 ) ||
319
+ ( originalamount <= 0 ) ||
320
+ ( SVUtils::isnullorempty(transactionid) )
321
+ )
322
+ raise "One or More of the Mandatory attributes does not have a valid value"
323
+ end
324
+
325
+ serverproperties.setsvtype(SVType::WEBPOS_GIFTCARD)
326
+ @svrequest = SVCancelRedeem.new(serverproperties)
327
+ @svrequest.setcardnumber(cardnumber)
328
+ @svrequest.setoriginalinvoicenumber(originalinvoicenumber)
329
+ @svrequest.setoriginaltransactionid(originaltransactionid)
330
+ @svrequest.setoriginalbatchnumber(originalbatchno)
331
+ @svrequest.setoriginalapprovalcode(originalapprovalcode)
332
+ @svrequest.setoriginalamount(originalamount)
333
+ @svrequest.settransactionid(transactionid)
334
+ @svrequest.setcardpin(cardpin)
335
+ @svrequest.setnotes(notes)
336
+ return @svrequest
337
+ end
338
+ end
@@ -0,0 +1,28 @@
1
+ #
2
+ # © 2011 QwikCilver Solutions Private Limited, All Rights Reserved.
3
+ #
4
+ # @author Nityananda
5
+ #
6
+ #=Overview
7
+ # Class used by GCWebPos to perform Balance Enquiry transaction
8
+ #
9
+
10
+ require 'SVClient/SVRequest'
11
+ require 'SVClient/SVGiftCardCodes'
12
+ require 'SVClient/SVType'
13
+
14
+ class SVBalanceEnquiry < SVRequest
15
+ def initialize(type)
16
+ super(type)
17
+ end
18
+
19
+ protected
20
+ def gettransactiontypeid
21
+ @txntypeid = 0
22
+ case @requestType
23
+ when SVType::WEBPOS_GIFTCARD
24
+ @txntypeid = SVGiftCardCodes::BALANCE
25
+ end
26
+ return @txntypeid
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ #
2
+ # © 2011 QwikCilver Solutions Private Limited, All Rights Reserved.
3
+ #
4
+ # @author Nityananda
5
+ #
6
+ #=Overview
7
+ # Class used by GCWebPos to perform Balance Enquiry transaction
8
+ #
9
+
10
+ require 'SVClient/SVRequest'
11
+ require 'SVClient/SVGiftCardCodes'
12
+ require 'SVClient/SVType'
13
+
14
+ class SVCancelRedeem < SVRequest
15
+ def initialize(type)
16
+ super(type)
17
+ end
18
+
19
+ protected
20
+ def gettransactiontypeid
21
+ @txntypeid = 0
22
+ case @requestType
23
+ when SVType::WEBPOS_GIFTCARD
24
+ @txntypeid = SVGiftCardCodes::CANCEL_REDEEM
25
+ end
26
+ return @txntypeid
27
+ end
28
+ end
@@ -0,0 +1,65 @@
1
+ #
2
+ # © 2011 QwikCilver Solutions Private Limited, All Rights Reserved.
3
+ #
4
+ # @author Nityananda
5
+ #
6
+
7
+ require 'SVClient/SVParamDownload'
8
+
9
+ class SVClient
10
+ public
11
+ def self.initlibrary(svprops)
12
+ return SVClient::getparamsfromserver(svprops)
13
+ end
14
+
15
+ private
16
+ def self.getparamsfromserver(svprops)
17
+ if(svprops == nil)
18
+ @retprops = SVProperties.new()
19
+ @retprops.seterrorcode(SVStatus::INVALID_PARAM)
20
+ @retprops.seterrormessage(SVStatus::getmessage(SVStatus::INVALID_PARAM))
21
+ return @retprops
22
+ end
23
+
24
+ case svprops.getsvtype
25
+ when SVType::WEBPOS_GIFTCARD
26
+ @svrequest = SVClient::getwebposgiftcardparamdownload(svprops)
27
+ else
28
+ return SVStatus::UNSUPPORTED_TYPE_ERROR
29
+ end
30
+
31
+ @svresponse = @svrequest.execute()
32
+ @retval = @svresponse.geterrorcode()
33
+ if (@retval != SVStatus::SUCCESS.to_i)
34
+ @retprops = SVProperties.new()
35
+ @retprops.seterrorcode(@retval)
36
+ @retprops.seterrormessage(@svresponse.geterrormessage())
37
+ return @retprops
38
+ end
39
+
40
+ @serverprops = SVProperties.new(svprops)
41
+ @serverprops.settransactionid(@svresponse.gettransactionid)
42
+ @serverprops.setposentrymode(@svresponse.getposentrymode)
43
+ @serverprops.setpostypeid(@svresponse.getpostypeid)
44
+ @serverprops.setacquirerid(@svresponse.getacquirerid)
45
+ @serverprops.setorganizationname(@svresponse.getorganizationname)
46
+ @serverprops.setmerchantname(@svresponse.getmerchantname)
47
+ @serverprops.setmerchantoutletname(@svresponse.getmerchantoutletname)
48
+ @serverprops.setposname(@svresponse.getposname)
49
+ @serverprops.setcurrentbatchnumber(@svresponse.getcurrentbatchnumber)
50
+ @serverprops.seterrorcode(@svresponse.geterrorcode)
51
+ @serverprops.seterrormessage(@svresponse.geterrormessage)
52
+ return @serverprops
53
+ end
54
+
55
+ def self.getwebposgiftcardparamdownload(svprops)
56
+ @svrequest = SVParamDownload.new(svprops)
57
+ @svrequest.setforwardingentityid(svprops.getforwardingentityid())
58
+ @svrequest.setforwardingentitypassword(svprops.getforwardingentitypassword())
59
+ @svrequest.setterminalid(svprops.getterminalid())
60
+ @svrequest.setusername(svprops.getusername())
61
+ @svrequest.setpassword(svprops.getpassword())
62
+ @svrequest.settransactionid(1)
63
+ return @svrequest
64
+ end
65
+ end