paymentsds-mpesa 0.1.0.pre.alpha.32 → 0.1.0.pre.alpha.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/paymentsds/mpesa/configuration.rb +1 -1
  3. data/lib/paymentsds/mpesa/errors/constants.rb +55 -46
  4. data/lib/paymentsds/mpesa/errors/{unavailabe_server.rb → unavailable_server.rb} +0 -0
  5. data/lib/paymentsds/mpesa/service.rb +10 -9
  6. data/lib/paymentsds/mpesa/version.rb +1 -1
  7. data/paymentsds-mpesa-0.1.0.pre.alpha.31/checksums.yaml.gz +0 -0
  8. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data.tar.gz +0 -0
  9. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/.gitignore +13 -0
  10. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/.overcommit.yml +0 -0
  11. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/.rspec +3 -0
  12. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/.rubocop.yml +0 -0
  13. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/.travis.yml +6 -0
  14. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/Gemfile +7 -0
  15. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/LICENSE +201 -0
  16. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/README.md +261 -0
  17. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/Rakefile +6 -0
  18. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/bin/console +14 -0
  19. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/bin/setup +8 -0
  20. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa.rb +17 -0
  21. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/client.rb +29 -0
  22. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/configuration.rb +59 -0
  23. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/constants.rb +164 -0
  24. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/environment.rb +17 -0
  25. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/error_type.rb +8 -0
  26. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/constants.rb +50 -0
  27. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/direct_debt_missing.rb +9 -0
  28. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/duplicate_direct_debt.rb +9 -0
  29. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/errors.rb +26 -0
  30. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/inactive_account.rb +9 -0
  31. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/initiator_authentication.rb +9 -0
  32. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/insuficient_balance.rb +9 -0
  33. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_amount.rb +9 -0
  34. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_initiator_identifier.rb +9 -0
  35. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_language_code.rb +9 -0
  36. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_market.rb +9 -0
  37. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_missing_properties.rb +9 -0
  38. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_msisdn.rb +9 -0
  39. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_receiver.rb +9 -0
  40. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_reference.rb +9 -0
  41. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_security_credential.rb +9 -0
  42. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_shortcode.rb +9 -0
  43. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_thirdparty_reference.rb +9 -0
  44. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_transaction_id.rb +9 -0
  45. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/invalid_transaction_reference.rb +9 -0
  46. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/profile_problems.rb +0 -0
  47. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/request_timeout.rb +9 -0
  48. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/transaction_cancelled.rb +9 -0
  49. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/transaction_failed.rb +9 -0
  50. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/unavailabe_server.rb +9 -0
  51. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/unknown.rb +9 -0
  52. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/unknown_status.rb +9 -0
  53. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/errors/validation.rb +9 -0
  54. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/operation.rb +28 -0
  55. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/patterns.rb +12 -0
  56. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/result.rb +18 -0
  57. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/service.rb +311 -0
  58. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/lib/paymentsds/mpesa/version.rb +7 -0
  59. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/paymentsds-mpesa.gemspec +32 -0
  60. data/paymentsds-mpesa-0.1.0.pre.alpha.31/data/publish.sh +6 -0
  61. data/paymentsds-mpesa-0.1.0.pre.alpha.31/metadata.gz +0 -0
  62. metadata +57 -2
@@ -0,0 +1,261 @@
1
+ # M-Pesa SDK for Ruby
2
+
3
+ M-Pesa SDK for Ruby is an unofficial library aiming to help businesses integrating every [M-Pesa](https://developer.mpesa.vm.co.mz) operations to their Ruby applications.
4
+
5
+ ## Contents
6
+
7
+ - [Features](#features)
8
+ - [Usage](#usage)
9
+ - [Quickstart](#usage/scenario-1)
10
+ - [Receive Money from a Mobile Account](#usage/scenario-1)
11
+ - [Send Money to a Mobile Account](#usage/scenario-2)
12
+ - [Send Money to a Business Account](#usage/scenario-3)
13
+ - [Revert a Transaction](#usage/scenario-4)
14
+ - [Query the Status of a Transaction](#usage/scenario-5)
15
+ - [Examples](#usage/scenario-6)
16
+ - [Prerequisites](#prerequisites)
17
+ - [Installation](#installation)
18
+ - [Using RubyGems](#installation/scenario-1)
19
+ - [Using Bundler](#installation/scenario-2)
20
+ - [Installation Scenario 3](#installation/scenario-3)
21
+ - [Installation Scenario 4](#installation/scenario-4)
22
+ - [Configuration](#configuration)
23
+ - [Configuration Scenario 1](#configuration/scenario-1)
24
+ - [Configuration Scenario 2](#configuration/scenario-2)
25
+ - [Configuration Scenario 3](#configuration/scenario-3)
26
+ - [Configuration Scenario 4](#configuration/scenario-4)
27
+ - [Related Projects](#related-projects)
28
+ - [Dependencies](#related-projects/dependencies)
29
+ - [Friends](#related-projects/friends)
30
+ - [Alternatives](#related-projects/alternatives)
31
+ - [Contributing](#contributing)
32
+ - [Changelog](#changelog)
33
+ - [Authors](#authors)
34
+ - [Credits](#credits)
35
+ - [License](#license)
36
+
37
+ ## Features <a name="features"></a>
38
+
39
+ - Receive money from a mobile account to a business account
40
+ - Send money from a business account to a mobile account
41
+ - Send money from a business account to a another business account
42
+ - Revert a transaction
43
+ - Query the status of a transaction
44
+
45
+ ## Usage <a name="usage"></a>
46
+
47
+ ### Quickstart <a name="#usage/scenario-1"></a>
48
+
49
+ ### Receive Money from a Mobile Account <a name="#usage/scenario-2"></a>
50
+
51
+ ```ruby
52
+ require 'paymentsds/mpesa'
53
+
54
+ client = Paymentsds::MPesa::Client.new do |config|
55
+ config.api_key = '<REPLACE>' # API Key
56
+ config.public_key = '<REPLACE>' # Public Key
57
+ config.service_provider_code = '<REPLACE>' # input_ServiceProviderCode
58
+ end
59
+
60
+ begin
61
+ payment_data = {
62
+ from: '841234567', # input_CustomerMSISDN
63
+ reference: '11114', # input_ThirdPartyReference
64
+ transaction: 'T12344CC', # input_TransactionReference
65
+ amount: '10' # input_Amount
66
+ }
67
+
68
+ result = client.receive(payment_data)
69
+
70
+ if result.success?
71
+ puts result.data
72
+ end
73
+ rescue
74
+ puts 'Operation failed'
75
+ end
76
+ ```
77
+ ### Send Money to a Mobile Account <a name="#usage/scenario-3"></a>
78
+
79
+ ```ruby
80
+ require 'paymentsds/mpesa'
81
+
82
+ client = Paymentsds::MPesa::Client.new do |config|
83
+ config.api_key = '<REPLACE>' # API Key
84
+ config.public_key = '<REPLACE>' # Public Key
85
+ config.service_provider_code = '<REPLACE>' # input_ServiceProviderCode
86
+ end
87
+
88
+ begin
89
+ payment_data = {
90
+ to: '841234567', # input_CustomerMSISDN
91
+ reference: '11114', # input_ThirdPartyReference
92
+ transaction: 'T12344CC', # input_TransactionReference
93
+ amount: '10' # input_Amount
94
+ }
95
+
96
+ result = client.send(payment_data)
97
+
98
+ if result.success?
99
+ puts result.data
100
+ end
101
+ rescue
102
+ puts 'Operation failed'
103
+ end
104
+ ```
105
+
106
+ ### Send Money to a Business Account <a name="#usage/scenario-4"></a>
107
+
108
+ ```ruby
109
+ require 'paymentsds/mpesa'
110
+
111
+ client = Paymentsds::MPesa::Client.new do |config|
112
+ config.api_key = '<REPLACE>' # API Key
113
+ config.public_key = '<REPLACE>' # Public Key
114
+ config.service_provider_code = '<REPLACE>' # input_ServiceProviderCode
115
+ end
116
+
117
+ begin
118
+ payment_data = {
119
+ to: '979797', # input_ReceiverPartyCode
120
+ reference: '11114', # input_ThirdPartyReference
121
+ transaction: 'T12344CC', # input_TransactionReference
122
+ amount: '10' # input_Amount
123
+ }
124
+
125
+ result = client.send(payment_data)
126
+
127
+ if result.success?
128
+ puts result.data
129
+ end
130
+ rescue
131
+ puts 'Operation failed'
132
+ end
133
+ ```
134
+
135
+ ### Revert a Transaction <a name="#usage/scenario-5"></a>
136
+
137
+ ```ruby
138
+ require 'paymentsds/mpesa'
139
+
140
+ client = Paymentsds::MPesa::Client.new do |config|
141
+ config.api_key = '<REPLACE>' # API Key
142
+ config.public_key = '<REPLACE>' # Public Key
143
+ config.service_provider_code = '<REPLACE>' # input_ServiceProviderCode
144
+ config.initiator_identifier = '<REPLACE>' # input_InitiatorIdentifier,
145
+ config.security_identifier = '<REPLACE>' # input_SecurityCredential
146
+ end
147
+
148
+ begin
149
+ reversion_data = {
150
+ reference: '11114', # input_ThirdPartyReference
151
+ transaction: 'T12344CC', # input_TransactionReference
152
+ amount: '10' # input_ReversalAmounts
153
+ }
154
+
155
+ result = client.reversion(payment_data)
156
+
157
+ if result.success?
158
+ # Handle success scenario
159
+ end
160
+ rescue
161
+ # Handle failure scenario
162
+ end
163
+ ```
164
+
165
+ ### Query the Status of a Transaction <a name="#usage/scenario-6"></a>
166
+
167
+ ### Examples <a name="usage/scenario-7"></a>
168
+
169
+ ## Prerequisites <a name="prerequisites"></a>
170
+
171
+ - [Ruby 2.5+](https://www.ruby-lang.org)
172
+ - [RubyGems](https://rubygems.org)
173
+ - [Bundler](https://bundler.io)
174
+
175
+ ## Installation <a name="installation"></a>
176
+
177
+ ### Using RubyGems <a name="installation/scenario-1"></a>
178
+
179
+ ```bash
180
+ gem install paymentsds-mpesa
181
+ ```
182
+
183
+ ### Using Bundler <a name="installation/scenario-2"></a>
184
+
185
+ ```ruby
186
+ #Gemfile
187
+ gem 'paymentsds-mpesa'
188
+ ```
189
+
190
+ ### Installation Scenario 3 <a name="installation/scenario-3"></a>
191
+
192
+ ## Configuration <a name="configuration"></a>
193
+
194
+ ### Configuration Scenario 1 <a name="configuration/scenario-1"></a>
195
+
196
+ ### Configuration Scenario 2 <a name="configuration/scenario-2"></a>
197
+
198
+ ### Configuration Scenario 3 <a name="configuration/scenario-3"></a>
199
+
200
+ ## Related Projects <a name="related-projects"></a>
201
+
202
+ ### Dependencies <a name="related-projects/dependencies"></a>
203
+
204
+ #### Production Dependencies
205
+
206
+ - [Faraday](https://github.com/lostisland/faraday)
207
+ - [OpenSSL](https://github.com/ruby/openssl)
208
+
209
+
210
+ #### Development Dependencies
211
+
212
+ - [RSpec](https://github.com/rspec/rspec)
213
+ - [Rake](https://github.com/ruby/rake)
214
+ - [RuboCop](https://github.com/rubocop-hq/rubocop)
215
+ - [Overcommit](https://github.com/sds/overcommit)
216
+
217
+ ### Friends <a name="related-projects/friends"></a>
218
+
219
+ - [M-Pesa SDK for Javascript](https://github.com/paymentsds/mpesa-js-sdk)
220
+ - [M-Pesa SDK for PHP](https://github.com/paymentsds/mpesa-php-sdk)
221
+ - [M-Pesa SDK for Ruby](https://github.com/paymentsds/mpesa-ruby-sdk)
222
+ - [M-Pesa SDK for Python](https://github.com/paymentsds/mpesa-python-sdk)
223
+
224
+ ### Alternatives <a name="related-projects/alternatives"></a>
225
+
226
+ - [Alternative 1](https://github.com/<username>/<project>)
227
+ - [Alternative 2](https://github.com/<username>/<project>)
228
+ - [Alternative 3](https://github.com/<username>/<project>)
229
+ - [Alternative 4](https://github.com/<username>/<project>)
230
+
231
+
232
+ ### Inspiration
233
+
234
+ - [rosariopfernandes/mpesa-node-api](https://github.com/abdulmueid/mpesa-php-api)
235
+ - [karson/mpesa-php-sdk](https://github.com/karson/mpesa-php-sdk)
236
+ - [codeonweekends/mpesa-php-sdk](https://github.com/codeonweekends/mpesa-php-sdk)
237
+ - [abdulmueid/mpesa-php-api](https://github.com/abdulmueid/mpesa-php-api)
238
+ - [realdm/mpesasdk](https://github.com/realdm/mpesasdk)
239
+
240
+
241
+ ## Contributing <a name="contributing"></a>
242
+
243
+ ## Changelog <a name="changelog"></a>
244
+
245
+ ## Authors <a name="authors"></a>
246
+
247
+ - [Edson Michaque](https://github.com/edsonmichaque)
248
+ - [Nélio Macombo](https://github.com/neliomacombo)
249
+
250
+ ## Credits <a name="credits"></a>
251
+
252
+ ## License <a name="license"></a>
253
+
254
+ Copyright 2020 Anísio Mandlate, Edson Michaque, Elton Laice and Nélio Macombo
255
+
256
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
257
+
258
+ http://www.apache.org/licenses/LICENSE-2.0
259
+
260
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
261
+
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'paysuite/mpesa'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'mpesa/version'
4
+ require_relative 'mpesa/operation'
5
+ require_relative 'mpesa/constants'
6
+ require_relative 'mpesa/environment'
7
+ require_relative 'mpesa/configuration'
8
+ require_relative 'mpesa/result'
9
+ require_relative 'mpesa/error_type'
10
+ require_relative 'mpesa/service'
11
+ require_relative 'mpesa/client'
12
+
13
+ module Paymentsds
14
+ module MPesa
15
+ class Error < StandardError; end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Paymentsds
4
+ module MPesa
5
+ class Client
6
+ def initialize
7
+ @service = Service.new
8
+ yield(@service.config) if block_given?
9
+ @service.apply
10
+ end
11
+
12
+ def send(intent)
13
+ @service.handle_send(intent)
14
+ end
15
+
16
+ def receive(intent)
17
+ @service.handle_receive(intent)
18
+ end
19
+
20
+ def query(intent)
21
+ @service.handle_query(intent)
22
+ end
23
+
24
+ def revert(intent)
25
+ @service.handle_revert(intent)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'base64'
4
+ require 'openssl'
5
+
6
+ module Paymentsds
7
+ module MPesa
8
+ class Configuration
9
+ attr_accessor :access_token
10
+ attr_accessor :api_key
11
+ attr_accessor :public_key
12
+ attr_accessor :user_agent
13
+ attr_accessor :verify_ssl
14
+ attr_accessor :timeout
15
+ attr_accessor :debugging
16
+ attr_accessor :environment
17
+ attr_accessor :initiator_identifier
18
+ attr_accessor :security_credential
19
+ attr_accessor :service_provider_code
20
+ attr_accessor :origin
21
+ attr_reader :auth
22
+
23
+ def initialize
24
+ @user_agent = 'Paymentsds Ruby'
25
+ @origin = "*"
26
+ @verify_ssl = false
27
+ @timeout = 10
28
+
29
+ yield(self) if block_given?
30
+ end
31
+
32
+ def apply
33
+ @environment = if @environment == :production
34
+ Paymentsds::MPesa::Environment.new('https', 'api.vm.co.mz').freeze
35
+ else
36
+ Paymentsds::MPesa::Environment.new('https', 'api.sandbox.vm.co.mz').freeze
37
+ end
38
+ end
39
+
40
+ def generate_access_token
41
+ has_keys = instance_variable_defined?('@api_key') && instance_variable_defined?('@public_key')
42
+ has_access_token = instance_variable_defined?('@access_token')
43
+
44
+ @auth = encrypt(@api_key, @public_key) if has_keys
45
+ @auth = @access_token if has_access_token
46
+ end
47
+
48
+ private
49
+
50
+ def encrypt(api_key, public_key)
51
+ plain_public_key = Base64.decode64 public_key
52
+ key = OpenSSL::PKey::RSA.new plain_public_key
53
+ encrypted_api_key = key.public_encrypt api_key
54
+
55
+ Base64.strict_encode64 encrypted_api_key
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,164 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Paymentsds
4
+ module MPesa
5
+ PATTERNS = {
6
+ PHONE_NUMBER: /^((00|\+)?(258))?8[45][0-9]{7}$/,
7
+ MONEY_AMOUNT: /^[1-9][0-9]*(\.[0-9]+)?$/,
8
+ WORD: /^\w+$/,
9
+ SERVICE_PROVIDER: /^[0-9]{5,6}$/
10
+ }.freeze
11
+
12
+ OPERATIONS = {
13
+ C2B_PAYMENT: {
14
+ method: :post,
15
+ port: '18352',
16
+ path: '/ipg/v1x/c2bPayment/singleStage/',
17
+ mapping: {
18
+ to: 'input_ServiceProviderCode',
19
+ from: 'input_CustomerMSISDN',
20
+ amount: 'input_Amount',
21
+ reference: 'input_ThirdPartyReference',
22
+ transaction: 'input_TransactionReference'
23
+ },
24
+ validation: {
25
+ to: PATTERNS[:SERVICE_PROVIDER],
26
+ from: PATTERNS[:PHONE_NUMBER],
27
+ amount: PATTERNS[:MONEY_AMOUNT],
28
+ reference: PATTERNS[:WORD],
29
+ transaction: PATTERNS[:WORD]
30
+ },
31
+ required: [
32
+ :to,
33
+ :from,
34
+ :amount,
35
+ :reference,
36
+ :transaction
37
+ ],
38
+ optional: [
39
+ :to
40
+ ]
41
+ },
42
+
43
+ B2C_PAYMENT: {
44
+ method: :post,
45
+ port: '18345',
46
+ path: '/ipg/v1x/b2cPayment/',
47
+ mapping: {
48
+ to: 'input_ServiceProviderCode',
49
+ from: 'input_CustomerMSISDN',
50
+ amount: 'input_Amount',
51
+ reference: 'input_ThirdPartyReference',
52
+ transaction: 'input_TransactionReference'
53
+ },
54
+ validation: {
55
+ to: PATTERNS[:SERVICE_PROVIDER],
56
+ from: PATTERNS[:PHONE_NUMBER],
57
+ amount: PATTERNS[:MONEY_AMOUNT],
58
+ reference: PATTERNS[:WORD],
59
+ transaction: PATTERNS[:WORD]
60
+ },
61
+ required: [
62
+ :to,
63
+ :from,
64
+ :amount,
65
+ :reference,
66
+ :transaction
67
+ ],
68
+ optional: [
69
+ :to
70
+ ]
71
+ },
72
+
73
+ B2B_PAYMENT: {
74
+ method: :post,
75
+ port: '18349',
76
+ path: '/ipg/v1x/b2bPayment/',
77
+ mapping: {
78
+ to: 'input_ServiceProviderCode',
79
+ from: 'input_CustomerMSISDN',
80
+ amount: 'input_Amount',
81
+ reference: 'input_ThirdPartyReference',
82
+ transaction: 'input_TransactionReference'
83
+ },
84
+ validation: {
85
+ to: PATTERNS[:SERVICE_PROVIDER],
86
+ from: PATTERNS[:PHONE_NUMBER],
87
+ amount: PATTERNS[:MONEY_AMOUNT],
88
+ reference: PATTERNS[:WORD],
89
+ transaction: PATTERNS[:WORD]
90
+ },
91
+ required: [
92
+ :to,
93
+ :from,
94
+ :amount,
95
+ :reference,
96
+ :transaction
97
+ ],
98
+ optional: [
99
+ :to
100
+ ]
101
+ },
102
+
103
+ REVERSAL: {
104
+ method: :put,
105
+ port: '18354',
106
+ path: '/ipg/v1x/reversal/',
107
+ mapping: {
108
+ to: 'input_ServiceProviderCode',
109
+ from: 'input_CustomerMSISDN',
110
+ amount: 'input_Amount',
111
+ reference: 'input_ThirdPartyReference',
112
+ transaction: 'input_TransactionReference'
113
+ },
114
+ validation: {
115
+ to: PATTERNS[:SERVICE_PROVIDER],
116
+ from: PATTERNS[:PHONE_NUMBER],
117
+ amount: PATTERNS[:MONEY_AMOUNT],
118
+ reference: PATTERNS[:WORD],
119
+ transaction: PATTERNS[:WORD]
120
+ },
121
+ required: [
122
+ :to,
123
+ :from,
124
+ :amount,
125
+ :reference,
126
+ :transaction
127
+ ],
128
+ optional: [
129
+ :to
130
+ ]
131
+ },
132
+
133
+ QUERY_TRANSACTION_STATUS: {
134
+ method: :get,
135
+ port: '18353',
136
+ path: '/ipg/v1x/queryTransactionStatus/',
137
+ mapping: {
138
+ to: 'input_ServiceProviderCode',
139
+ from: 'input_CustomerMSISDN',
140
+ amount: 'input_Amount',
141
+ reference: 'input_ThirdPartyReference',
142
+ transaction: 'input_TransactionReference'
143
+ },
144
+ validation: {
145
+ to: PATTERNS[:SERVICE_PROVIDER],
146
+ from: PATTERNS[:PHONE_NUMBER],
147
+ amount: PATTERNS[:MONEY_AMOUNT],
148
+ reference: PATTERNS[:WORD],
149
+ transaction: PATTERNS[:WORD]
150
+ },
151
+ required: [
152
+ :to,
153
+ :from,
154
+ :amount,
155
+ :reference,
156
+ :transaction
157
+ ],
158
+ optional: [
159
+ :to
160
+ ]
161
+ }
162
+ }.freeze
163
+ end
164
+ end