africastalking-ruby 2.1.8 → 2.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 +4 -4
- data/Gemfile.lock +152 -91
- data/README.md +16 -209
- data/africastalking-ruby.gemspec +5 -5
- data/lib/AfricasTalking/Mobiledata.rb +159 -0
- data/lib/AfricasTalking/version.rb +1 -1
- data/lib/AfricasTalking.rb +22 -15
- metadata +21 -27
- data/lib/AfricasTalking/Payments.rb +0 -688
@@ -1,688 +0,0 @@
|
|
1
|
-
class Payments
|
2
|
-
include AfricasTalking
|
3
|
-
HTTP_CREATED = 201
|
4
|
-
HTTP_OK = 200
|
5
|
-
BANK_CODES = {
|
6
|
-
'FCMB_NG' => 234001,
|
7
|
-
'ZENITH_NG' => 234002,
|
8
|
-
'ACCESS_NG' => 234003,
|
9
|
-
'GTBANK_NG' => 234004,
|
10
|
-
'ECOBANK_NG' => 234005,
|
11
|
-
'DIAMOND_NG' => 234006,
|
12
|
-
'PROVIDUS_NG' => 234007,
|
13
|
-
'UNITY_NG' => 234008,
|
14
|
-
'STANBIC_NG' => 234009,
|
15
|
-
'STERLING_NG' => 234010,
|
16
|
-
'PARKWAY_NG' => 234011,
|
17
|
-
'AFRIBANK_NG' => 234012,
|
18
|
-
'ENTREPRISE_NG' => 234013,
|
19
|
-
'FIDELITY_NG' => 234014,
|
20
|
-
'HERITAGE_NG' => 234015,
|
21
|
-
'KEYSTONE_NG' => 234016,
|
22
|
-
'SKYE_NG' => 234017,
|
23
|
-
'STANCHART_NG' => 234018,
|
24
|
-
'UNION_NG' => 234019,
|
25
|
-
'UBA_NG' => 234020,
|
26
|
-
'WEMA_NG' => 234021,
|
27
|
-
'FIRST_NG' => 234022,
|
28
|
-
}
|
29
|
-
PROVIDERS = {
|
30
|
-
'MPESA' => 'Mpesa',
|
31
|
-
'SEGOVIA' => 'Segovia',
|
32
|
-
'FLUTTERWAVE' => 'Flutterwave',
|
33
|
-
'ADMIN' => 'Admin',
|
34
|
-
'ATHENA' => 'Athena',
|
35
|
-
}
|
36
|
-
def initialize username, apikey
|
37
|
-
@username = username
|
38
|
-
@apikey = apikey
|
39
|
-
end
|
40
|
-
|
41
|
-
def mobileCheckout options
|
42
|
-
validateParamsPresence? options, %w(productName phoneNumber currencyCode amount)
|
43
|
-
parameters = {
|
44
|
-
'username' => @username,
|
45
|
-
'productName' => options['productName'],
|
46
|
-
'phoneNumber' => options['phoneNumber'],
|
47
|
-
'currencyCode' => options['currencyCode'],
|
48
|
-
'amount' => options['amount']
|
49
|
-
}
|
50
|
-
parameters['providerChannel'] = options['providerChannel'] if !(options['providerChannel'].nil? || options['providerChannel'].empty?)
|
51
|
-
parameters['metadata'] = options['metadata'] if !(options['metadata'].nil? || options['metadata'].empty?)
|
52
|
-
url = getMobilePaymentCheckoutUrl()
|
53
|
-
response = sendJSONRequest(url, parameters)
|
54
|
-
if @response_code == HTTP_CREATED
|
55
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
56
|
-
#
|
57
|
-
if (resultObj['status'] == 'PendingConfirmation')
|
58
|
-
return MobileCheckoutResponse.new resultObj['status'], resultObj['description'], resultObj['transactionId'], resultObj['providerChannel']
|
59
|
-
end
|
60
|
-
raise AfricasTalkingException, resultObj['description']
|
61
|
-
end
|
62
|
-
raise AfricasTalkingException, response
|
63
|
-
end
|
64
|
-
|
65
|
-
def mobileB2B options
|
66
|
-
validateParamsPresence? options, %w(productName providerData currencyCode amount metadata)
|
67
|
-
validateParamsPresence? options['providerData'], %w(provider destinationAccount destinationChannel transferType)
|
68
|
-
parameters = {
|
69
|
-
'username' => @username,
|
70
|
-
'productName' => options['productName'],
|
71
|
-
'provider' => options['providerData']['provider'],
|
72
|
-
'destinationChannel' => options['providerData']['destinationChannel'],
|
73
|
-
'destinationAccount' => options['providerData']['destinationAccount'],
|
74
|
-
'transferType' => options['providerData']['transferType'],
|
75
|
-
'currencyCode' => options['currencyCode'],
|
76
|
-
'amount' => options['amount'],
|
77
|
-
'metadata' => options['metadata']
|
78
|
-
}
|
79
|
-
url = getMobilePaymentB2BUrl()
|
80
|
-
if options.key?('requester')
|
81
|
-
parameters['requester'] = options['requester']
|
82
|
-
end
|
83
|
-
response = sendJSONRequest(url, parameters)
|
84
|
-
if (@response_code == HTTP_CREATED)
|
85
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
86
|
-
#
|
87
|
-
return MobileB2BResponse.new resultObj['status'], resultObj['transactionId'], resultObj['transactionFee'], resultObj['providerChannel'], resultObj['errorMessage']
|
88
|
-
end
|
89
|
-
raise AfricasTalkingException, response
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
def mobileB2C options
|
94
|
-
validateParamsPresence? options, %w(recipients productName)
|
95
|
-
parameters = {
|
96
|
-
'username' => @username,
|
97
|
-
'productName' => options['productName'],
|
98
|
-
'recipients' => options['recipients']
|
99
|
-
}
|
100
|
-
url = getMobilePaymentB2CUrl()
|
101
|
-
response = sendJSONRequest(url, parameters)
|
102
|
-
if (@response_code == HTTP_CREATED)
|
103
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
104
|
-
if (resultObj['entries'].length > 0)
|
105
|
-
results = resultObj['entries'].collect{ |subscriber|
|
106
|
-
MobileB2CResponse.new subscriber['provider'], subscriber['phoneNumber'], subscriber['providerChannel'], subscriber['transactionFee'], subscriber['status'], subscriber['value'], subscriber['transactionId'], subscriber['errorMessage']
|
107
|
-
}
|
108
|
-
#
|
109
|
-
return results
|
110
|
-
end
|
111
|
-
|
112
|
-
raise AfricasTalkingException, resultObj['errorMessage']
|
113
|
-
end
|
114
|
-
raise AfricasTalkingException, response
|
115
|
-
end
|
116
|
-
|
117
|
-
def mobileData options
|
118
|
-
validateParamsPresence? options, %w(productName)
|
119
|
-
recipients = options['recipients'].each{|item|
|
120
|
-
validateParamsPresence? item, %w(phoneNumber quantity unit validity metadata)
|
121
|
-
}
|
122
|
-
parameters = {
|
123
|
-
'username' => @username,
|
124
|
-
'productName' => options['productName'],
|
125
|
-
'recipients' => recipients,
|
126
|
-
}
|
127
|
-
url = getMobileDataUrl()
|
128
|
-
response = sendJSONRequest(url, parameters)
|
129
|
-
if (@response_code == HTTP_CREATED)
|
130
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
131
|
-
if (resultObj['entries'].length > 0)
|
132
|
-
results = resultObj['entries'].collect{ |data|
|
133
|
-
MobileDataResponse.new data['phoneNumber'], data['provider'], data['status'], data['transactionId'], data['value'], data['errorMessage']
|
134
|
-
}
|
135
|
-
#
|
136
|
-
return results
|
137
|
-
end
|
138
|
-
|
139
|
-
raise AfricasTalkingException, resultObj['errorMessage']
|
140
|
-
end
|
141
|
-
raise AfricasTalkingException, response
|
142
|
-
end
|
143
|
-
|
144
|
-
def bankCheckoutCharge options
|
145
|
-
validateParamsPresence? options, %w(bankAccount productName currencyCode amount narration metadata)
|
146
|
-
parameters = {
|
147
|
-
'username' => @username,
|
148
|
-
'productName' => options['productName'],
|
149
|
-
'bankAccount' => options['bankAccount'],
|
150
|
-
'currencyCode' => options['currencyCode'],
|
151
|
-
'amount' => options['amount'],
|
152
|
-
'narration' => options['narration'],
|
153
|
-
'metadata' => options['metadata']
|
154
|
-
}
|
155
|
-
url = getBankChargeCheckoutUrl()
|
156
|
-
response = sendJSONRequest(url, parameters)
|
157
|
-
if (@response_code == HTTP_CREATED)
|
158
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
159
|
-
#
|
160
|
-
return InitiateBankCheckoutResponse.new resultObj['status'], resultObj['transactionId'], resultObj['description']
|
161
|
-
end
|
162
|
-
raise AfricasTalkingException, response
|
163
|
-
end
|
164
|
-
|
165
|
-
def bankCheckoutValidate options
|
166
|
-
validateParamsPresence? options, %w(transactionId otp)
|
167
|
-
parameters = {
|
168
|
-
'username' => @username,
|
169
|
-
'transactionId' => options['transactionId'],
|
170
|
-
'otp' => options['otp']
|
171
|
-
}
|
172
|
-
#
|
173
|
-
url = getValidateBankCheckoutUrl()
|
174
|
-
response = sendJSONRequest(url, parameters)
|
175
|
-
if (@response_code == HTTP_CREATED)
|
176
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
177
|
-
return ValidateBankCheckoutResponse.new resultObj['status'], resultObj['description']
|
178
|
-
end
|
179
|
-
raise AfricasTalkingException, response
|
180
|
-
end
|
181
|
-
|
182
|
-
def bankTransfer options
|
183
|
-
validateParamsPresence? options, %w(productName recipients)
|
184
|
-
parameters = {
|
185
|
-
'username' => @username,
|
186
|
-
'productName' => options['productName'],
|
187
|
-
'recipients' => options['recipients']
|
188
|
-
}
|
189
|
-
url = getBankTransferRequestUrl()
|
190
|
-
response = sendJSONRequest(url, parameters)
|
191
|
-
if (@response_code == HTTP_CREATED)
|
192
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
193
|
-
|
194
|
-
if (resultObj['entries'].length > 0)
|
195
|
-
results = resultObj['entries'].collect{ |item|
|
196
|
-
BankTransferEntries.new item['accountNumber'], item['status'], item['transactionId'], item['transactionFee'], item['errorMessage']
|
197
|
-
}
|
198
|
-
|
199
|
-
|
200
|
-
return BankTransferResponse.new results, resultObj['errorMessage']
|
201
|
-
end
|
202
|
-
|
203
|
-
raise AfricasTalkingException, resultObj['errorMessage']
|
204
|
-
end
|
205
|
-
raise AfricasTalkingException, response
|
206
|
-
|
207
|
-
end
|
208
|
-
|
209
|
-
def cardCheckoutCharge options
|
210
|
-
validateParamsPresence? options, %w(productName currencyCode amount narration metadata)
|
211
|
-
parameters = {
|
212
|
-
'username' => @username,
|
213
|
-
'productName' => options['productName'],
|
214
|
-
'currencyCode' => options['currencyCode'],
|
215
|
-
'amount' => options['amount'],
|
216
|
-
'narration' => options['narration'],
|
217
|
-
'metadata' => options['metadata']
|
218
|
-
}
|
219
|
-
if (options['checkoutToken'] == nil && options['paymentCard'] == nil)
|
220
|
-
raise AfricasTalkingException, "Please make sure either the checkoutToken or paymentCard parameter is not empty"
|
221
|
-
elsif (options['checkoutToken'] != nil && options['paymentCard'] != nil)
|
222
|
-
raise AfricasTalkingException, "If you have a checkoutToken please make sure paymentCard parameter is empty"
|
223
|
-
end
|
224
|
-
if (options['checkoutToken'] != nil)
|
225
|
-
parameters['checkoutToken'] = options['checkoutToken']
|
226
|
-
end
|
227
|
-
if (options['paymentCard'] != nil)
|
228
|
-
if validateParamsPresence?(options['paymentCard'], ['number', 'cvvNumber', 'expiryMonth', 'expiryYear', 'countryCode', 'authToken'])
|
229
|
-
parameters['paymentCard'] = options['paymentCard']
|
230
|
-
end
|
231
|
-
end
|
232
|
-
url = getCardCheckoutChargeUrl()
|
233
|
-
response = sendJSONRequest(url, parameters)
|
234
|
-
if (@response_code == HTTP_CREATED)
|
235
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
236
|
-
#
|
237
|
-
return InitiateCardCheckoutResponse.new resultObj['status'], resultObj['description'], resultObj['transactionId']
|
238
|
-
end
|
239
|
-
raise AfricasTalkingException, response
|
240
|
-
|
241
|
-
end
|
242
|
-
|
243
|
-
def cardCheckoutValidate options
|
244
|
-
validateParamsPresence? options, %w(transactionId otp)
|
245
|
-
parameters = {
|
246
|
-
'username' => @username,
|
247
|
-
'transactionId' => options['transactionId'],
|
248
|
-
'otp' => options['otp']
|
249
|
-
}
|
250
|
-
url = getValidateCardCheckoutUrl()
|
251
|
-
response = sendJSONRequest(url, parameters)
|
252
|
-
if (@response_code == HTTP_CREATED)
|
253
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
254
|
-
return ValidateCardCheckoutResponse.new resultObj['status'], resultObj['description'], resultObj['checkoutToken']
|
255
|
-
#
|
256
|
-
end
|
257
|
-
raise AfricasTalkingException, response
|
258
|
-
end
|
259
|
-
|
260
|
-
def walletTransfer options
|
261
|
-
validateParamsPresence? options, %w(productName targetProductCode currencyCode amount metadata)
|
262
|
-
parameters = {
|
263
|
-
'username' => @username,
|
264
|
-
'productName' => options['productName'],
|
265
|
-
'targetProductCode' => options['targetProductCode'],
|
266
|
-
'currencyCode' => options['currencyCode'],
|
267
|
-
'amount' => options['amount'],
|
268
|
-
'metadata' => options['metadata']
|
269
|
-
}
|
270
|
-
url = getWalletTransferUrl()
|
271
|
-
response = sendJSONRequest(url, parameters)
|
272
|
-
if (@response_code == HTTP_CREATED)
|
273
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
274
|
-
#
|
275
|
-
return WalletTransferResponse.new resultObj['status'], resultObj['description'], resultObj['transactionId']
|
276
|
-
end
|
277
|
-
raise AfricasTalkingException, response
|
278
|
-
end
|
279
|
-
|
280
|
-
def topupStash options
|
281
|
-
validateParamsPresence? options, %w(productName currencyCode amount metadata)
|
282
|
-
parameters = {
|
283
|
-
'username' => @username,
|
284
|
-
'productName' => options['productName'],
|
285
|
-
'currencyCode' => options['currencyCode'],
|
286
|
-
'amount' => options['amount'],
|
287
|
-
'metadata' => options['metadata']
|
288
|
-
}
|
289
|
-
url = getTopupStashUrl()
|
290
|
-
response = sendJSONRequest(url, parameters)
|
291
|
-
if (@response_code == HTTP_CREATED)
|
292
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
293
|
-
return TopupStashResponse.new resultObj['status'], resultObj['description'], resultObj['transactionId']
|
294
|
-
end
|
295
|
-
raise AfricasTalkingException, response
|
296
|
-
end
|
297
|
-
|
298
|
-
def fetchProductTransactions options
|
299
|
-
validateParamsPresence? options, %w(productName filters)
|
300
|
-
filters = options['filters']
|
301
|
-
validateParamsPresence? filters, %w(pageNumber count)
|
302
|
-
parameters = {
|
303
|
-
'username' => @username,
|
304
|
-
'productName' => options['productName'],
|
305
|
-
'pageNumber' => filters['pageNumber'],
|
306
|
-
'count' => filters['count']
|
307
|
-
}
|
308
|
-
parameters['startDate'] = filters['startDate'] if !(filters['startDate'].nil? || filters['startDate'].empty?)
|
309
|
-
parameters['endDate'] = filters['endDate'] if !(filters['endDate'].nil? || filters['endDate'].empty?)
|
310
|
-
parameters['category'] = filters['category'] if !(filters['category'].nil? || filters['category'].empty?)
|
311
|
-
parameters['status'] = filters['status'] if !(filters['status'].nil? || filters['status'].empty?)
|
312
|
-
parameters['source'] = filters['source'] if !(filters['source'].nil? || filters['source'].empty?)
|
313
|
-
parameters['destination'] = filters['destination'] if !(filters['destination'].nil? || filters['destination'].empty?)
|
314
|
-
parameters['providerChannel'] = filters['providerChannel'] if !(filters['providerChannel'].nil? || filters['providerChannel'].empty?)
|
315
|
-
url = getFetchTransactionsUrl()
|
316
|
-
response = sendJSONRequest(url, parameters, true)
|
317
|
-
if (@response_code == HTTP_OK)
|
318
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
319
|
-
results = []
|
320
|
-
if (resultObj['responses'].length > 0)
|
321
|
-
results = resultObj['responses'].collect{ |item|
|
322
|
-
FetchTransactionsEntries.new item['sourceType'], item['source'], item['provider'], item['destinationType'], item['description'], item['providerChannel'], item['providerMetadata'],
|
323
|
-
item['status'], item['productName'], item['category'], item['destination'], item['value'], item['transactionId'], item['creationTime'], item['requestMetadata']
|
324
|
-
}
|
325
|
-
end
|
326
|
-
return FetchTransactionsResponse.new resultObj['status'], resultObj['description'], results
|
327
|
-
end
|
328
|
-
raise AfricasTalkingException, response
|
329
|
-
end
|
330
|
-
|
331
|
-
def fetchWalletTransactions options
|
332
|
-
validateParamsPresence? options, ['filters']
|
333
|
-
filters = options['filters']
|
334
|
-
validateParamsPresence? filters, %w(pageNumber count)
|
335
|
-
parameters = {
|
336
|
-
'username' => @username,
|
337
|
-
'pageNumber' => filters['pageNumber'],
|
338
|
-
'count' => filters['count']
|
339
|
-
}
|
340
|
-
parameters['startDate'] = filters['startDate'] if !(filters['startDate'].nil? || filters['startDate'].empty?)
|
341
|
-
parameters['endDate'] = filters['endDate'] if !(filters['endDate'].nil? || filters['endDate'].empty?)
|
342
|
-
parameters['categories'] = filters['categories'] if !(filters['categories'].nil? || filters['categories'].empty?)
|
343
|
-
url = getFetchWalletUrl()
|
344
|
-
response = sendJSONRequest(url, parameters, true)
|
345
|
-
if (@response_code == HTTP_OK)
|
346
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
347
|
-
results = []
|
348
|
-
if (resultObj['responses'].length > 0)
|
349
|
-
results = resultObj['responses'].collect{ |item|
|
350
|
-
transactionData = TransactionData.new item['transactionData']['requestMetadata'], item['transactionData']['sourceType'],
|
351
|
-
item['transactionData']['source'], item['transactionData']['provider'], item['transactionData']['destinationType'],item['transactionData']['description'],
|
352
|
-
item['transactionData']['providerChannel'], item['transactionData']['providerRefId'], item['transactionData']['providerMetadata'],item['transactionData']['status'],
|
353
|
-
item['transactionData']['productName'], item['transactionData']['category'], item['transactionData']['transactionDate'], item['transactionData']['destination'],
|
354
|
-
item['transactionData']['value'], item['transactionData']['transactionId'], item['transactionData']['creationTime']
|
355
|
-
FetchWalletEntries.new item['description'], item['balance'], item['date'], item['category'], item['value'], item['transactionId'], transactionData
|
356
|
-
}
|
357
|
-
end
|
358
|
-
return FetchWalletResponse.new resultObj['status'], resultObj['description'], results
|
359
|
-
end
|
360
|
-
raise AfricasTalkingException, response
|
361
|
-
end
|
362
|
-
|
363
|
-
def findTransaction options
|
364
|
-
validateParamsPresence? options, ['transactionId']
|
365
|
-
parameters = {
|
366
|
-
'username' => @username,
|
367
|
-
'transactionId' => options['transactionId']
|
368
|
-
}
|
369
|
-
url = getFindTransactionUrl()
|
370
|
-
response = sendJSONRequest(url, parameters, true)
|
371
|
-
if (@response_code == HTTP_OK)
|
372
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
373
|
-
transactionData = nil
|
374
|
-
if resultObj['status'] === 'Success'
|
375
|
-
transactionData = TransactionData.new resultObj['data']['requestMetadata'], resultObj['data']['sourceType'],resultObj['data']['source'], resultObj['data']['provider'], resultObj['data']['destinationType'],resultObj['data']['description'],
|
376
|
-
resultObj['data']['providerChannel'], resultObj['data']['providerRefId'], resultObj['data']['providerMetadata'],resultObj['data']['status'], resultObj['data']['productName'], resultObj['data']['category'],
|
377
|
-
resultObj['data']['transactionDate'], resultObj['data']['destination'], resultObj['data']['value'], resultObj['data']['transactionId'], resultObj['data']['creationTime']
|
378
|
-
end
|
379
|
-
return FindTransactionResponse.new resultObj['status'], transactionData
|
380
|
-
end
|
381
|
-
raise AfricasTalkingException, response
|
382
|
-
end
|
383
|
-
|
384
|
-
def fetchWalletBalance
|
385
|
-
parameters = { 'username' => @username }
|
386
|
-
url = getFetchWalletBalanceUrl()
|
387
|
-
response = sendJSONRequest(url, parameters, true)
|
388
|
-
if (@response_code == HTTP_OK)
|
389
|
-
resultObj = JSON.parse(response, :quirky_mode =>true)
|
390
|
-
|
391
|
-
return FetchWalletBalanceResponse.new resultObj['status'], resultObj['balance']
|
392
|
-
end
|
393
|
-
raise AfricasTalkingException, response
|
394
|
-
end
|
395
|
-
|
396
|
-
private
|
397
|
-
|
398
|
-
def getPaymentHost()
|
399
|
-
if(@username == "sandbox")
|
400
|
-
return "https://payments.sandbox.africastalking.com"
|
401
|
-
else
|
402
|
-
return "https://payments.africastalking.com"
|
403
|
-
end
|
404
|
-
end
|
405
|
-
|
406
|
-
def getMobilePaymentCheckoutUrl()
|
407
|
-
return getPaymentHost() + "/mobile/checkout/request"
|
408
|
-
end
|
409
|
-
|
410
|
-
def getMobilePaymentB2CUrl()
|
411
|
-
return getPaymentHost() + "/mobile/b2c/request"
|
412
|
-
end
|
413
|
-
|
414
|
-
def getMobileDataUrl()
|
415
|
-
return getPaymentHost() + "/mobile/data/request"
|
416
|
-
end
|
417
|
-
|
418
|
-
def getMobilePaymentB2BUrl()
|
419
|
-
return getPaymentHost() + "/mobile/b2b/request"
|
420
|
-
end
|
421
|
-
|
422
|
-
def getBankChargeCheckoutUrl()
|
423
|
-
return getPaymentHost() + "/bank/checkout/charge"
|
424
|
-
end
|
425
|
-
|
426
|
-
def getValidateBankCheckoutUrl()
|
427
|
-
return getPaymentHost() + "/bank/checkout/validate"
|
428
|
-
end
|
429
|
-
|
430
|
-
def getBankTransferRequestUrl()
|
431
|
-
return getPaymentHost() + "/bank/transfer"
|
432
|
-
end
|
433
|
-
|
434
|
-
def getCardCheckoutChargeUrl()
|
435
|
-
return getPaymentHost() + "/card/checkout/charge"
|
436
|
-
end
|
437
|
-
|
438
|
-
def getValidateCardCheckoutUrl()
|
439
|
-
return getPaymentHost() + "/card/checkout/validate"
|
440
|
-
end
|
441
|
-
|
442
|
-
def getWalletTransferUrl()
|
443
|
-
return getPaymentHost() + "/transfer/wallet"
|
444
|
-
end
|
445
|
-
|
446
|
-
def getTopupStashUrl()
|
447
|
-
return getPaymentHost() + "/topup/stash"
|
448
|
-
end
|
449
|
-
|
450
|
-
def getFetchWalletUrl()
|
451
|
-
return getPaymentHost() + "/query/wallet/fetch"
|
452
|
-
end
|
453
|
-
|
454
|
-
def getFetchWalletBalanceUrl()
|
455
|
-
return getPaymentHost() + "/query/wallet/balance"
|
456
|
-
end
|
457
|
-
|
458
|
-
def getFetchTransactionsUrl()
|
459
|
-
return getPaymentHost() + "/query/transaction/fetch"
|
460
|
-
end
|
461
|
-
|
462
|
-
def getFindTransactionUrl()
|
463
|
-
return getPaymentHost() + "/query/transaction/find"
|
464
|
-
end
|
465
|
-
|
466
|
-
def getApiHost()
|
467
|
-
if(@username == "sandbox")
|
468
|
-
return "https://api.sandbox.africastalking.com"
|
469
|
-
else
|
470
|
-
return "https://api.africastalking.com"
|
471
|
-
end
|
472
|
-
end
|
473
|
-
|
474
|
-
end
|
475
|
-
|
476
|
-
|
477
|
-
class MobileB2CResponse
|
478
|
-
attr_reader :provider, :phoneNumber, :providerChannel, :transactionFee, :status, :value, :transactionId, :errorMessage
|
479
|
-
|
480
|
-
def initialize provider_, phoneNumber_, providerChannel_, transactionFee_, status_, value_, transactionId_, errorMessage_
|
481
|
-
@provider = provider_
|
482
|
-
@phoneNumber = phoneNumber_
|
483
|
-
@providerChannel = providerChannel_
|
484
|
-
@transactionFee = transactionFee_
|
485
|
-
@status = status_
|
486
|
-
@value = value_
|
487
|
-
@transactionId = transactionId_
|
488
|
-
@errorMessage = errorMessage_
|
489
|
-
end
|
490
|
-
end
|
491
|
-
|
492
|
-
class MobileDataResponse
|
493
|
-
attr_reader :phoneNumber, :provider, :status, :transactionId, :value, :errorMessage
|
494
|
-
|
495
|
-
def initialize phoneNumber_, provider_, status_, transactionId_, value_, errorMessage_
|
496
|
-
@phoneNumber = phoneNumber_
|
497
|
-
@provider = provider_
|
498
|
-
@status = status_
|
499
|
-
@transactionId = transactionId_
|
500
|
-
@value = value_
|
501
|
-
@errorMessage = errorMessage_
|
502
|
-
end
|
503
|
-
end
|
504
|
-
|
505
|
-
class MobileB2BResponse
|
506
|
-
attr_reader :status, :transactionId, :transactionFee, :providerChannel, :errorMessage
|
507
|
-
|
508
|
-
def initialize status_, transactionId_, transactionFee_, providerChannel_, errorMessage_
|
509
|
-
@providerChannel = providerChannel_
|
510
|
-
@transactionId = transactionId_
|
511
|
-
@transactionFee = transactionFee_
|
512
|
-
@status = status_
|
513
|
-
@errorMessage = errorMessage_
|
514
|
-
end
|
515
|
-
end
|
516
|
-
|
517
|
-
class BankTransferEntries
|
518
|
-
attr_reader :accountNumber, :status, :transactionId, :transactionFee, :errorMessage
|
519
|
-
def initialize accountNumber, status, transactionId, transactionFee, errorMessage
|
520
|
-
@accountNumber = accountNumber
|
521
|
-
@status = status
|
522
|
-
@transactionId = transactionId
|
523
|
-
@transactionFee = transactionFee
|
524
|
-
@errorMessage = errorMessage
|
525
|
-
end
|
526
|
-
end
|
527
|
-
|
528
|
-
class BankTransferResponse
|
529
|
-
attr_reader :entries, :errorMessage
|
530
|
-
def initialize entries_, errorMessage_
|
531
|
-
@entries = entries_
|
532
|
-
@errorMessage = errorMessage_
|
533
|
-
end
|
534
|
-
end
|
535
|
-
|
536
|
-
class MobileCheckoutResponse
|
537
|
-
attr_reader :status, :description, :transactionId, :providerChannel
|
538
|
-
def initialize status_, description_, transactionId_, providerChannel_
|
539
|
-
@description = description_
|
540
|
-
@status = status_
|
541
|
-
@transactionId = transactionId_
|
542
|
-
@providerChannel = providerChannel_
|
543
|
-
end
|
544
|
-
end
|
545
|
-
class InitiateBankCheckoutResponse
|
546
|
-
attr_reader :status, :description, :transactionId
|
547
|
-
def initialize status_, transactionId_, description_
|
548
|
-
@description = description_
|
549
|
-
@status = status_
|
550
|
-
@transactionId = transactionId_
|
551
|
-
end
|
552
|
-
end
|
553
|
-
class ValidateBankCheckoutResponse
|
554
|
-
attr_reader :status, :description
|
555
|
-
def initialize status_, description_
|
556
|
-
@description = description_
|
557
|
-
@status = status_
|
558
|
-
end
|
559
|
-
end
|
560
|
-
|
561
|
-
class InitiateCardCheckoutResponse
|
562
|
-
attr_reader :status, :description, :transactionId
|
563
|
-
def initialize status_, description_, transactionId_
|
564
|
-
@description = description_
|
565
|
-
@status = status_
|
566
|
-
@transactionId = transactionId_
|
567
|
-
end
|
568
|
-
end
|
569
|
-
|
570
|
-
class ValidateCardCheckoutResponse
|
571
|
-
attr_reader :status, :description, :checkoutToken
|
572
|
-
def initialize status_, description_, checkoutToken_
|
573
|
-
@description = description_
|
574
|
-
@status = status_
|
575
|
-
@checkoutToken = checkoutToken_
|
576
|
-
end
|
577
|
-
end
|
578
|
-
|
579
|
-
class WalletTransferResponse
|
580
|
-
attr_reader :status, :description, :transactionId
|
581
|
-
def initialize status_, description_, transactionId_
|
582
|
-
@description = description_
|
583
|
-
@status = status_
|
584
|
-
@transactionId = transactionId_
|
585
|
-
end
|
586
|
-
end
|
587
|
-
|
588
|
-
class TopupStashResponse
|
589
|
-
attr_reader :status, :description, :transactionId
|
590
|
-
def initialize status_, description_, transactionId_
|
591
|
-
@description = description_
|
592
|
-
@status = status_
|
593
|
-
@transactionId = transactionId_
|
594
|
-
end
|
595
|
-
end
|
596
|
-
|
597
|
-
class FetchTransactionsEntries
|
598
|
-
attr_reader :sourceType, :source, :provider, :destinationType, :description, :providerChannel,
|
599
|
-
:providerMetadata, :status, :productName, :category, :destination, :value, :transactionId, :creationTime, :requestMetadata
|
600
|
-
|
601
|
-
def initialize sourceType_, source_, provider_, destinationType_, description_, providerChannel_, providerMetadata_, status_, productName_, category_, destination_, value_, transactionId_, creationTime_, requestMetadata_
|
602
|
-
@sourceType = sourceType_
|
603
|
-
@source = source_
|
604
|
-
@provider = provider_
|
605
|
-
@destinationType = destinationType_
|
606
|
-
@description = description_
|
607
|
-
@providerChannel = providerChannel_
|
608
|
-
@providerMetadata = providerMetadata_
|
609
|
-
@status = status_
|
610
|
-
@productName = productName_
|
611
|
-
@category = category_
|
612
|
-
@destination = destination_
|
613
|
-
@value = value_
|
614
|
-
@transactionId = transactionId_
|
615
|
-
@creationTime = creationTime_
|
616
|
-
@requestMetadata = requestMetadata_
|
617
|
-
end
|
618
|
-
end
|
619
|
-
|
620
|
-
class FetchTransactionsResponse
|
621
|
-
attr_reader :status, :description, :entries
|
622
|
-
def initialize status_, description_, entries_
|
623
|
-
@description = description_
|
624
|
-
@status = status_
|
625
|
-
@entries = entries_
|
626
|
-
end
|
627
|
-
end
|
628
|
-
|
629
|
-
class FetchWalletBalanceResponse
|
630
|
-
attr_reader :status, :balance
|
631
|
-
def initialize status_, balance_
|
632
|
-
@status = status_
|
633
|
-
@balance = balance_
|
634
|
-
end
|
635
|
-
end
|
636
|
-
|
637
|
-
class FetchWalletResponse
|
638
|
-
attr_reader :status, :description, :responses
|
639
|
-
def initialize status_, description_, responses_
|
640
|
-
@description = description_
|
641
|
-
@status = status_
|
642
|
-
@responses = responses_
|
643
|
-
end
|
644
|
-
end
|
645
|
-
|
646
|
-
class FetchWalletEntries
|
647
|
-
attr_reader :description, :balance, :date, :category, :value, :transactionId, :transactionData
|
648
|
-
def initialize description_, balance_, date_, category_, value_, transactionId_, transactionData_
|
649
|
-
@description = description_
|
650
|
-
@balance = balance_
|
651
|
-
@date = date_
|
652
|
-
@category = category_
|
653
|
-
@value = value_
|
654
|
-
@transactionId = transactionId_
|
655
|
-
@transactionData = transactionData_
|
656
|
-
end
|
657
|
-
end
|
658
|
-
|
659
|
-
class FindTransactionResponse
|
660
|
-
attr_reader :status, :transactionData
|
661
|
-
def initialize status_, transactionData_
|
662
|
-
@status = status_
|
663
|
-
@transactionData = transactionData_
|
664
|
-
end
|
665
|
-
end
|
666
|
-
|
667
|
-
class TransactionData
|
668
|
-
attr_reader :requestMetadata, :sourceType, :source, :provider, :destinationType, :description, :providerChannel, :providerRefId, :providerMetadata, :status, :productName, :category, :transactionDate, :destination, :value, :transactionId, :creationTime
|
669
|
-
def initialize requestMetadata_, sourceType_, source_, provider_, destinationType_, description_, providerChannel_, providerRefId_, providerMetadata_, status_, productName_, category_, transactionDate_, destination_, value_, transactionId_, creationTime_
|
670
|
-
@requestMetadata =requestMetadata_
|
671
|
-
@sourceType = sourceType_
|
672
|
-
@source = source_
|
673
|
-
@provider = provider_
|
674
|
-
@destinationType = destinationType_
|
675
|
-
@description = description_
|
676
|
-
@providerChannel = providerChannel_
|
677
|
-
@providerRefId = providerRefId_
|
678
|
-
@providerMetadata = providerMetadata_
|
679
|
-
@status = status_
|
680
|
-
@productName = productName_
|
681
|
-
@category = category_
|
682
|
-
@transactionDate = transactionDate_
|
683
|
-
@destination = destination_
|
684
|
-
@value = value_
|
685
|
-
@transactionId = transactionId_
|
686
|
-
@creationTime = creationTime_
|
687
|
-
end
|
688
|
-
end
|