mtn_cm_momo_sdk 0.1.4 → 0.1.5
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/mtn_cm_momo_sdk/api.rb +67 -37
- data/lib/mtn_cm_momo_sdk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fba4e6a346f33d87fbf6ee1c2fb1785ffe77e60a
|
4
|
+
data.tar.gz: 6f0b830b9e85bd32ddb32b8c4372197723896015
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45dd0f6a08bdb8f582fde8770a30d97bb40abd03b0360595c281d882058b98fd4db25456ce0e15b3d6700caa39bfbc4fb79464bf6942810a0de13e3e3f16ae59
|
7
|
+
data.tar.gz: 3613dea904511cca544388cc1ff6a36fd60c8c8abf180b6010db3634a245b17d2fc9dced8763016a245c7b6e406f2c6439ab8aebfbd82b80467d7ed00c790191
|
data/lib/mtn_cm_momo_sdk/api.rb
CHANGED
@@ -19,74 +19,104 @@ module MtnCmMomoSdk
|
|
19
19
|
|
20
20
|
# @param [Object] amount
|
21
21
|
def buy_now!(tel, amount)
|
22
|
-
|
23
|
-
|
24
|
-
.merge!(_tel: tel)
|
22
|
+
da = body.merge!(_amount: amount)
|
23
|
+
.merge!(_tel: tel)
|
25
24
|
# da = payload(da)
|
26
|
-
|
27
|
-
self.class.get('/transactionRequest.xhtml', query: da)
|
28
|
-
rescue Net::ReadTimeout
|
29
|
-
{
|
30
|
-
:msg => "User does not authorize the request",
|
31
|
-
:request_status => false
|
32
|
-
}
|
33
|
-
end
|
25
|
+
call_server '/transactionRequest.xhtml', da
|
34
26
|
end
|
35
27
|
|
36
28
|
def refund!(tel, amount)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
self.class.get('/transaction.xhtml', query: da)
|
29
|
+
da = body.merge!(_amount: amount)
|
30
|
+
.merge!(_tel: tel)
|
31
|
+
# da = payload(da)
|
32
|
+
call_server '/transaction.xhtml', da
|
42
33
|
end
|
43
34
|
|
44
35
|
def donate!(tel, amount)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
self.class.get('/transaction.xhtml', query: da)
|
36
|
+
da = body.merge!(_amount: amount)
|
37
|
+
.merge!(_tel: tel)
|
38
|
+
# da = payload(da)
|
39
|
+
call_server '/transaction.xhtml', da
|
50
40
|
end
|
51
41
|
|
52
42
|
def checkout!(tel, amount)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
begin
|
58
|
-
self.class.get('/transactionRequest.xhtml', query: da)
|
59
|
-
rescue Net::ReadTimeout
|
60
|
-
{
|
61
|
-
:msg => "User does not authorize the request",
|
62
|
-
:request_status => false
|
63
|
-
}
|
64
|
-
end
|
43
|
+
da = body.merge!(_amount: amount)
|
44
|
+
.merge!(_tel: tel)
|
45
|
+
# da = payload(da)
|
46
|
+
call_server '/transactionRequest.xhtml', da
|
65
47
|
end
|
66
48
|
|
67
|
-
|
68
49
|
private
|
69
50
|
|
70
51
|
def payload(body)
|
71
52
|
options = {}
|
72
53
|
options.merge!(body: body)
|
73
54
|
.merge!(headers: headers)
|
74
|
-
|
75
55
|
end
|
76
56
|
|
77
57
|
def body
|
78
|
-
|
79
58
|
body = {
|
80
59
|
idbouton: @transaction[:idbouton],
|
81
60
|
typebouton: @transaction[:typebouton],
|
82
61
|
_clP: MtnCmMomoSdk.developer_clP,
|
83
62
|
_email: MtnCmMomoSdk.developer_email
|
84
63
|
}
|
85
|
-
|
86
64
|
end
|
87
65
|
|
88
66
|
def headers
|
89
67
|
{'Content-Type' => 'application/json'}
|
90
68
|
end
|
69
|
+
|
70
|
+
def call_server(url, data)
|
71
|
+
resp = self.class.get(url, query: data)
|
72
|
+
resp = JSON.parse resp.parsed_response
|
73
|
+
if resp == -1
|
74
|
+
{
|
75
|
+
:request_status => false,
|
76
|
+
:msg => 'the whole transaction failed',
|
77
|
+
:server_respond => resp
|
78
|
+
}
|
79
|
+
elsif resp["StatusCode"] == "01"
|
80
|
+
{
|
81
|
+
:request_status => true,
|
82
|
+
:msg => 'Successfully processed transaction',
|
83
|
+
:server_respond => resp
|
84
|
+
}
|
85
|
+
else
|
86
|
+
{
|
87
|
+
:request_status => false,
|
88
|
+
:msg => 'General failure',
|
89
|
+
:server_respond => resp
|
90
|
+
}
|
91
|
+
end
|
92
|
+
rescue Net::ReadTimeout
|
93
|
+
{
|
94
|
+
msg: 'User does not authorize the request',
|
95
|
+
request_status: false,
|
96
|
+
server_respond: nil
|
97
|
+
|
98
|
+
}
|
99
|
+
rescue Net::OpenTimeout
|
100
|
+
{
|
101
|
+
msg: 'could not connect to mtn server, please check your internet connection',
|
102
|
+
request_status: false,
|
103
|
+
server_respond: nil
|
104
|
+
|
105
|
+
}
|
106
|
+
rescue SocketError
|
107
|
+
{
|
108
|
+
msg: 'could not connect to mtn server, please check your internet connection',
|
109
|
+
request_status: false,
|
110
|
+
server_respond: nil
|
111
|
+
|
112
|
+
}
|
113
|
+
rescue => ex
|
114
|
+
{
|
115
|
+
msg: ex.message,
|
116
|
+
request_status: false,
|
117
|
+
server_respond: nil
|
118
|
+
|
119
|
+
}
|
120
|
+
end
|
91
121
|
end
|
92
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mtn_cm_momo_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fomekong Tekatsop Evaris
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|