paymentsds-mpesa 0.1.0.pre.alpha.30 → 0.1.0.pre.alpha.31
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/paymentsds/mpesa/service.rb +123 -17
- data/lib/paymentsds/mpesa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f911b96060e60656a509701471434cbf8ed2ece7db47b80805fe0b92271020d
|
4
|
+
data.tar.gz: 6bce0fba1f4504da771bc69d9ffc0dd4c9a2f9d887037706ca0b173f7ab64156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f44c1fa5e5e0170a49406157eb7ae7c6440499cef384dc143ea86da156044fda8c89b93a209fd453512a2ab78af00d3ac9682f2f4d616e88b252e5b343663cf
|
7
|
+
data.tar.gz: 57eff61c070b0ee0859317f00fdb218d32266d7441cb7d73279d0a49a8c6a8637e0f64b4d81175189d396ed0bac4722b4d951e4f1202f283e8a2052ae53adfd8
|
@@ -3,6 +3,8 @@ require 'json'
|
|
3
3
|
require 'faraday'
|
4
4
|
require 'faraday_middleware'
|
5
5
|
|
6
|
+
require_relative "errors/errors"
|
7
|
+
|
6
8
|
module Paymentsds
|
7
9
|
module MPesa
|
8
10
|
class Service
|
@@ -59,11 +61,9 @@ module Paymentsds
|
|
59
61
|
when /^[0-9]{5,6}$/
|
60
62
|
:B2B_PAYMENT
|
61
63
|
end
|
62
|
-
|
63
|
-
# Should raise an exception
|
64
64
|
end
|
65
65
|
|
66
|
-
|
66
|
+
raise InvalidDestination
|
67
67
|
end
|
68
68
|
|
69
69
|
def detect_missing_properties(opcode, intent)
|
@@ -180,21 +180,127 @@ module Paymentsds
|
|
180
180
|
end
|
181
181
|
|
182
182
|
def build_response(result)
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
183
|
+
|
184
|
+
case result.status
|
185
|
+
when 200
|
186
|
+
case result.body[:output_ResponseCode]
|
187
|
+
when Paymentsds::MPesa::INS0
|
188
|
+
response = Paymentsds::MPesa::Result.new(result.success?, nil, result.body)
|
189
|
+
else
|
190
|
+
raise UnknownError
|
191
|
+
end
|
192
|
+
|
193
|
+
when 201
|
194
|
+
case result.body[:output_ResponseCode]
|
195
|
+
when Paymentsds::MPesa::INS0
|
196
|
+
response = Paymentsds::MPesa::Result.new(result.success?, nil, result.body)
|
197
|
+
else
|
198
|
+
raise UnknownError
|
199
|
+
end
|
200
|
+
|
201
|
+
when 400
|
202
|
+
case result.body[:output_ResponseCode]
|
203
|
+
when Paymentsds::MPesa::INS13
|
204
|
+
raise InvalidShortcodeError
|
205
|
+
when Paymentsds::MPesa::INS14
|
206
|
+
raise InvalidReferenceError
|
207
|
+
when Paymentsds::MPesa::INS15
|
208
|
+
raise InvalidAmountError
|
209
|
+
when Paymentsds::MPesa::INS17
|
210
|
+
raise InvalidTransactionReferenceError
|
211
|
+
when Paymentsds::MPesa::INS18
|
212
|
+
raise InvalidTransactionIdError
|
213
|
+
when Paymentsds::MPesa::INS19
|
214
|
+
raise InvalidThirdPartyReferenceError
|
215
|
+
when Paymentsds::MPesa::INS20
|
216
|
+
raise InvalidMissingPropertiesError
|
217
|
+
when Paymentsds::MPesa::INS21
|
218
|
+
raise ValidationError
|
219
|
+
when Paymentsds::MPesa::INS22
|
220
|
+
raise InvalidOperationPartError
|
221
|
+
when Paymentsds::MPesa::INS23
|
222
|
+
raise UnknownStatusError
|
223
|
+
when Paymentsds::MPesa::INS24
|
224
|
+
raise InvalidInitiatorIdentifierError
|
225
|
+
when Paymentsds::MPesa::INS25
|
226
|
+
raise InvalidSecurityCredentialError
|
227
|
+
when Paymentsds::MPesa::INS993
|
228
|
+
raise DirectDebtMissingError
|
229
|
+
when Paymentsds::MPesa::INS994
|
230
|
+
raise DuplicatedDirectDebtError
|
231
|
+
when Paymentsds::MPesa::INS995
|
232
|
+
raise ProfileProblemsError
|
233
|
+
when Paymentsds::MPesa::INS996
|
234
|
+
raise InactiveAccountError
|
235
|
+
when Paymentsds::MPesa::INS997
|
236
|
+
raise InvalidLanguageCodeError
|
237
|
+
when Paymentsds::MPesa::INS998
|
238
|
+
raise InvalidMarketError
|
239
|
+
when Paymentsds::MPesa::INS2001
|
240
|
+
raise InitiatorAuthenticationError
|
241
|
+
when Paymentsds::MPesa::INS2002
|
242
|
+
raise InvalidReceiverError
|
243
|
+
when Paymentsds::MPesa::INS2051
|
244
|
+
raise InvalidMSISDNError
|
245
|
+
when Paymentsds::MPesa::INS2057
|
246
|
+
raise InvalidLanguageCodeError
|
247
|
+
else
|
248
|
+
raise UnknownError
|
249
|
+
end
|
250
|
+
|
251
|
+
when 401
|
252
|
+
case result.body[:output_ResponseCode]
|
253
|
+
when Paymentsds::MPesa::INS5
|
254
|
+
raise TransactionCancelledError
|
255
|
+
when Paymentsds::MPesa::INS6
|
256
|
+
raise TransactionFailedError
|
257
|
+
else
|
258
|
+
raise UnknownError
|
259
|
+
end
|
260
|
+
|
261
|
+
when 408
|
262
|
+
case result.body[:output_ResponseCode]
|
263
|
+
when Paymentsds::MPesa::INS9
|
264
|
+
raise RequestTimeoutError
|
265
|
+
else
|
266
|
+
raise UnknownError
|
267
|
+
end
|
268
|
+
|
269
|
+
when 409
|
270
|
+
case result.body[:output_ResponseCode]
|
271
|
+
when Paymentsds::MPesa::INS10
|
272
|
+
raise DuplicateTransactionError
|
273
|
+
else
|
274
|
+
raise UnknownError
|
275
|
+
end
|
276
|
+
|
277
|
+
when 422
|
278
|
+
case result.body[:output_ResponseCode]
|
279
|
+
when Paymentsds::MPesa::INS2006
|
280
|
+
raise InsufficientBalanceError
|
281
|
+
else
|
282
|
+
raise UnknownError
|
283
|
+
end
|
284
|
+
|
285
|
+
when 500
|
286
|
+
case result.body[:output_ResponseCode]
|
287
|
+
when Paymentsds::MPesa::INS1
|
288
|
+
raise InternalError
|
289
|
+
else
|
290
|
+
raise UnknownError
|
291
|
+
end
|
292
|
+
|
293
|
+
when 503
|
294
|
+
case result.body[:output_ResponseCode]
|
295
|
+
when Paymentsds::MPesa::INS16
|
296
|
+
raise UnavailableServerError
|
297
|
+
else
|
298
|
+
raise UnknownError
|
299
|
+
end
|
300
|
+
|
194
301
|
else
|
195
|
-
|
196
|
-
end
|
197
|
-
|
302
|
+
raise UnknownError
|
303
|
+
end
|
198
304
|
end
|
199
305
|
|
200
306
|
def generate_access_token
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paymentsds-mpesa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.alpha.
|
4
|
+
version: 0.1.0.pre.alpha.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edson Michaque
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|