paymentsds-mpesa 0.1.0.pre.alpha.16 → 0.1.0.pre.alpha.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paymentsds/mpesa/environment.rb +5 -1
- data/lib/paymentsds/mpesa/service.rb +17 -13
- data/lib/paymentsds/mpesa/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4d175e328213e45fddb5647da3a6e1d9168e1e92154aee542b98b7d514c070d
|
4
|
+
data.tar.gz: 75cd7d38ea3f2681022e7708f661a0dd0bad957606041f68dce41899d3eda22a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bde89ecd224ba63bb802cc44ceeaa1f43ea914753bb4e029d786654333306d1e3bbeda74ff56afe794c978c887670f71c41bcee07d7bd38162f4b0a515154465
|
7
|
+
data.tar.gz: c40699c7a4c74c2a4885ba3699b3965145de9462dcc67ca5bd60c926abbdfb201a6e13b7d31dbdb006d8c70214da34abe2798c0f605e2261000731e39d5c8eed
|
@@ -4,10 +4,14 @@ module Paymentsds
|
|
4
4
|
attr_accessor :scheme
|
5
5
|
attr_accessor :domain
|
6
6
|
|
7
|
-
def initialize(scheme,
|
7
|
+
def initialize(scheme, domain)
|
8
8
|
@scheme = scheme
|
9
9
|
@domain = domain
|
10
10
|
end
|
11
|
+
|
12
|
+
def to_url
|
13
|
+
"#{@scheme}://#{@domain}"
|
14
|
+
end
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'json'
|
2
3
|
require 'faraday'
|
3
4
|
|
4
5
|
module Paymentsds
|
@@ -137,7 +138,7 @@ module Paymentsds
|
|
137
138
|
generate_access_token
|
138
139
|
|
139
140
|
request_data = {
|
140
|
-
base_url: "#{@config.environment.
|
141
|
+
base_url: "#{@config.environment.to_url}:#{operation[:port]}",
|
141
142
|
url: operation[:path],
|
142
143
|
method: operation[:method],
|
143
144
|
path: operation[:path],
|
@@ -146,27 +147,30 @@ module Paymentsds
|
|
146
147
|
body: build_request_body(opcode, intent)
|
147
148
|
}
|
148
149
|
|
149
|
-
http_client = Faraday.new
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
end
|
150
|
+
http_client = Faraday.new(
|
151
|
+
url: request_data[:base_url],
|
152
|
+
headers: request_data[:headers],
|
153
|
+
)
|
154
154
|
|
155
|
-
|
155
|
+
puts request_data[:base_url]
|
156
156
|
|
157
|
+
case operation[:method]
|
157
158
|
when :get
|
158
|
-
response = http_client.get do |req|
|
159
|
-
req.params = request_data
|
159
|
+
response = http_client.get(request_data[:path]) do |req|
|
160
|
+
req.params = request_data[:body]
|
161
|
+
req.options.timeout = request_data[:timeout]
|
160
162
|
end
|
161
163
|
|
162
164
|
when :post
|
163
|
-
response = http_client.post do |req|
|
164
|
-
req.body = request_data.
|
165
|
+
response = http_client.post(request_data[:path]) do |req|
|
166
|
+
req.body = request_data[:body].to_json
|
167
|
+
req.options.timeout = request_data[:timeout]
|
165
168
|
end
|
166
169
|
|
167
170
|
when :put
|
168
|
-
response = http_client.put do |req|
|
169
|
-
req.body = request_data.
|
171
|
+
response = http_client.put(request_data[:path]) do |req|
|
172
|
+
req.body = request_data[:body].to_json
|
173
|
+
req.options.timeout = request_data[:timeout]
|
170
174
|
end
|
171
175
|
end
|
172
176
|
|