ipay-rest 0.1.1 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3719474558131f6d1f0ca3cd1cfa71327010e6659fa796442a52d3667ea300f0
4
- data.tar.gz: 7ede8399bb0483b165cb49faa96cd1ba7b4ee37a9820b3bfa194305057adb6aa
3
+ metadata.gz: 21b3bd6148d40350b70bf844eb02642580a224ab64dd6b2fa3534a60a4837f79
4
+ data.tar.gz: a2de27dd1bce5c4c41ad6838c5d2d782f7624984bac436ae540db63085c25c10
5
5
  SHA512:
6
- metadata.gz: 72786c1d980c6801fef43204a380040b58a2ebaecf275c31455e3b5e6730b91435782a9ca1685e255afb293aa0f8ae7504a6ae3b839df81a5578091ccf46e4fc
7
- data.tar.gz: d8bb45b5a2c30870b78bb1774266891eb94fdb3eb8eb77b66a0c7e1aca38b76bcbc57548a585628e15f860352499ab6c023fec1fbac30cff832bca84bffc1d68
6
+ metadata.gz: 564922754cfea3b02157c1985b067dbd99b1860a72f041908b48ec4e920d1d23bf251b2be9c8c638b5255db6d9147f7ee1090f50301a783536463b473b877c5e
7
+ data.tar.gz: 3b81cccfd0fdfa854ab5cc2265a2c57aabd5b179b762ddae4b70f29564c2092f9dd329866e1aa61f95234273b2b436976edacd42efcd30eb1ffc2cbd36ec4625
@@ -1,35 +1,5 @@
1
1
  module Ipay
2
2
  module Rest
3
- class Error < StandardError; end
4
-
5
- class FailedTransactionError < StandardError
6
- def to_s
7
- 'Failed transaction. Not all parameters fulfilled. A notification of this transaction sent to the merchant.'
8
- end
9
- end
10
-
11
- class PendingTransactionError < StandardError
12
- def to_s
13
- 'Pending: Incoming Mobile Money Transaction Not found. Please try again in 5 minutes.'
14
- end
15
- end
16
-
17
- class UsedCodeError < StandardError
18
- def to_s
19
- 'Used: This code has been used already. A notification of this transaction sent to the merchant.'
20
- end
21
- end
22
-
23
- class PaymentDeficitError < StandardError
24
- def to_s
25
- 'Less: The amount that you have sent via mobile money is LESS than what was required to validate this transaction.'
26
- end
27
- end
28
-
29
- class OverPaymentError < StandardError
30
- def to_s
31
- 'More: The amount that you have sent via mobile money is MORE than what was required to validate this transaction.'
32
- end
33
- end
3
+ class IpayError < StandardError; end
34
4
  end
35
5
  end
@@ -0,0 +1,9 @@
1
+ module Ipay
2
+ module Rest
3
+ class FailedTransactionError < IpayError
4
+ def to_s
5
+ 'Failed transaction. Not all parameters fulfilled. A notification of this transaction sent to the merchant.'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Ipay
2
+ module Rest
3
+ class OverPaymentError < IpayError
4
+ def to_s
5
+ 'More: The amount that you have sent via mobile money is MORE than what was required to validate this transaction.'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Ipay
2
+ module Rest
3
+ class PaymentDeficitError < IpayError
4
+ def to_s
5
+ 'Less: The amount that you have sent via mobile money is LESS than what was required to validate this transaction.'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Ipay
2
+ module Rest
3
+ class PendingTransactionError < IpayError
4
+ def to_s
5
+ 'Pending: Incoming Mobile Money Transaction Not found. Please try again in 5 minutes.'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Ipay
2
+ module Rest
3
+ class UsedCodeError < IpayError
4
+ def to_s
5
+ 'Used: This code has been used already. A notification of this transaction sent to the merchant.'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -22,10 +22,15 @@ module Ipay
22
22
 
23
23
  def handle_response(response)
24
24
  status = response.body['status'] || response.body['header_status']
25
+ message = response.body['text'] || response.body['error']
25
26
 
26
27
  case status
27
28
  when 0
28
- raise Error, response.body['text']
29
+ raise IpayError, message
30
+ when 2
31
+ raise IpayError, message
32
+ when 400..599
33
+ raise Error, message
29
34
  when "fe2707etr5s4wq"
30
35
  raise FailedTransactionError
31
36
  when "bdi6p2yy76etrs"
@@ -1,5 +1,5 @@
1
1
  module Ipay
2
2
  module Rest
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
data/lib/ipay/rest.rb CHANGED
@@ -4,7 +4,7 @@ require "ipay/rest/constants"
4
4
  module Ipay
5
5
  module Rest
6
6
  autoload :Client, "ipay/rest/client"
7
- autoload :Error, "ipay/rest/error"
7
+ autoload :IpayError, "ipay/rest/error"
8
8
  autoload :Object, "ipay/rest/object"
9
9
  autoload :Resource, "ipay/rest/resource"
10
10
 
@@ -14,5 +14,11 @@ module Ipay
14
14
  autoload :UssdPush, 'ipay/rest/objects/ussd_push'
15
15
 
16
16
  autoload :TransactionResource, 'ipay/rest/resources/transaction'
17
+
18
+ autoload :FailedTransactionError, 'ipay/rest/errors/failed_transaction'
19
+ autoload :OverPaymentError, 'ipay/rest/errors/over_payment'
20
+ autoload :PaymentDeficitError, 'ipay/rest/errors/payment_deficit'
21
+ autoload :PendingTransactionError, 'ipay/rest/errors/pending_transaction'
22
+ autoload :UsedCodeError, 'ipay/rest/errors/used_code'
17
23
  end
18
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipay-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Ralak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-12 00:00:00.000000000 Z
11
+ date: 2022-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -49,6 +49,11 @@ files:
49
49
  - lib/ipay/rest/client.rb
50
50
  - lib/ipay/rest/constants.rb
51
51
  - lib/ipay/rest/error.rb
52
+ - lib/ipay/rest/errors/failed_transaction.rb
53
+ - lib/ipay/rest/errors/over_payment.rb
54
+ - lib/ipay/rest/errors/payment_deficit.rb
55
+ - lib/ipay/rest/errors/pending_transaction.rb
56
+ - lib/ipay/rest/errors/used_code.rb
52
57
  - lib/ipay/rest/object.rb
53
58
  - lib/ipay/rest/objects/initiator.rb
54
59
  - lib/ipay/rest/objects/transaction.rb