mpesa_stk 1.0.2 → 1.1.0
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 +5 -5
- data/.sample.env +5 -5
- data/Gemfile.lock +3 -3
- data/README.md +47 -28
- data/lib/mpesa_stk/push_payment.rb +2 -2
- data/lib/mpesa_stk/version.rb +1 -1
- data/mpesa_stk.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a1448032d6f42e8d0ae52779d2aa3e564fc2fc7c3f612f5d1a7ab38dc6c63172
|
4
|
+
data.tar.gz: a1a7f8569dab22b228de03928b48e02b1994ddfa6f8dd7f9ebbf0519d05c86c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f0d19bd38006f073b5be5e78ed49bc3fbf4a40fcee04eaa0b34f0fa2c63a604799a298a11cb52ba11d55ba8a9de0ccf4193d0f5b72aefc89be7a4b067143f21
|
7
|
+
data.tar.gz: e01e9e3964f4828f91acca1cb671c8278b1b0ad3ff0294e6d950b27a2a6d9b014be7e46051cd6a3c93bdfbe36be5b00dc3767c3d7afaba0e921527863cdafef5
|
data/.sample.env
CHANGED
@@ -2,8 +2,8 @@ base_url="https://sandbox.safaricom.co.ke"
|
|
2
2
|
token_generator_url="/oauth/v1/generate?grant_type=client_credentials"
|
3
3
|
process_request_url="/mpesa/stkpush/v1/processrequest"
|
4
4
|
|
5
|
-
key=""
|
6
|
-
secret=""
|
7
|
-
business_short_code=""
|
8
|
-
business_passkey="
|
9
|
-
callback_url="
|
5
|
+
key="Abcr7aDsOzaPlf5Cd6FWBJqxh6zRJ2dy"
|
6
|
+
secret="9UVzOHhDq44nkZWP"
|
7
|
+
business_short_code="174379"
|
8
|
+
business_passkey="bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919"
|
9
|
+
callback_url="https://c90593e0.ngrok.io"
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mpesa_stk (1.
|
4
|
+
mpesa_stk (1.1.0)
|
5
5
|
httparty (~> 0.15.6)
|
6
6
|
redis-namespace (~> 1.5, >= 1.5.3)
|
7
7
|
redis-rack (~> 2.0, >= 2.0.2)
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
pry-nav (0.2.4)
|
29
29
|
pry (>= 0.9.10, < 0.11.0)
|
30
30
|
public_suffix (3.0.2)
|
31
|
-
rack (2.0.
|
31
|
+
rack (2.0.5)
|
32
32
|
rake (10.5.0)
|
33
33
|
redis (4.0.1)
|
34
34
|
redis-namespace (1.6.0)
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
redis-rack (2.0.4)
|
37
37
|
rack (>= 1.5, < 3)
|
38
38
|
redis-store (>= 1.2, < 2)
|
39
|
-
redis-store (1.
|
39
|
+
redis-store (1.5.0)
|
40
40
|
redis (>= 2.2, < 5)
|
41
41
|
safe_yaml (1.0.4)
|
42
42
|
slop (3.6.0)
|
data/README.md
CHANGED
@@ -8,54 +8,73 @@ Add this line to your application's Gemfile:
|
|
8
8
|
```ruby
|
9
9
|
gem 'mpesa_stk'
|
10
10
|
```
|
11
|
-
|
12
|
-
And then execute:
|
13
|
-
|
14
|
-
$ bundle or $ bundle install
|
11
|
+
and run the `bundle install` command
|
15
12
|
|
16
13
|
Or install it yourself as:
|
14
|
+
```ruby
|
15
|
+
gem install mpesa_stk
|
16
|
+
```
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
one needs to setup there environment variables, checkout `.sample.env`
|
18
|
+
# Getting Started
|
19
|
+
This gem has a `[redis](https://redis.io/)` dependency, so make sure it running
|
20
|
+
```ruby
|
21
|
+
$ redis-server
|
26
22
|
```
|
27
|
-
base_url="https://sandbox.safaricom.co.ke"
|
28
|
-
token_generator_url="/oauth/v1/generate?grant_type=client_credentials"
|
29
|
-
process_request_url="/mpesa/stkpush/v1/processrequest"
|
30
23
|
|
24
|
+
you need to setup your environment variables, checkout `.sample.env` for the values you need.
|
25
|
+
or run
|
26
|
+
```ruby
|
27
|
+
$ cp .sample.env .env
|
28
|
+
```
|
29
|
+
open `.env` on youe editor and add the missing variable
|
30
|
+
```
|
31
31
|
key=""
|
32
32
|
secret=""
|
33
33
|
business_short_code=""
|
34
|
-
business_passkey="
|
35
|
-
callback_url="
|
34
|
+
business_passkey=""
|
35
|
+
callback_url=""
|
36
36
|
```
|
37
|
+
|
38
|
+
* `key` and `secret` of the app created on your [developer account](https://developer.safaricom.co.ke/user/me/apps).
|
37
39
|
this can be found in [Test Credentials](https://developer.safaricom.co.ke/test_credentials)
|
38
|
-
* `key` and `secret` of your application key.
|
39
40
|
* `business_short_code` and `business_pass_key` from safaricom.
|
40
|
-
|
41
|
-
|
41
|
+
this is the url where response will be sent
|
42
|
+
* `callback_url` the url of your application. `make sure its a reachable/active url`
|
42
43
|
|
43
|
-
|
44
|
+
## Testing
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
```ruby
|
47
|
+
$ irb
|
47
48
|
```
|
48
|
-
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
2.5.0 :001 > require 'mpesa_stk'
|
49
52
|
```
|
50
53
|
|
54
|
+
```ruby
|
55
|
+
2.5.0 :002 > MpesaStk::PushPayment.call("500", "<YOUR PHONE NUMBER: 254711222333>")
|
51
56
|
```
|
52
|
-
|
57
|
+
|
58
|
+
expected irb output after the command
|
59
|
+
```hash
|
60
|
+
=> {
|
61
|
+
"MerchantRequestID"=>"7909-1302368-1",
|
62
|
+
"CheckoutRequestID"=>"ws_CO_DMZ_40472724_16062018092359957",
|
63
|
+
"ResponseCode"=>"0",
|
64
|
+
"ResponseDescription"=>"Success. Request accepted for processing",
|
65
|
+
"CustomerMessage"=>"Success. Request accepted for processing"
|
66
|
+
}
|
53
67
|
```
|
54
68
|
|
55
|
-
|
56
|
-
|
57
|
-
|
69
|
+
the above response means the response has been successfully sent to Safaricom for processing and you should be able to see the checkout/express prompt on the sender number.
|
70
|
+
|
71
|
+
### Mpesa Checkout/Express
|
72
|
+
This is the expected output on the mobile phone
|
73
|
+

|
74
|
+
|
75
|
+
### Callback url
|
58
76
|
|
77
|
+
After the pin code is entered on the checkout/express prompt. you will receive a request on the provided `callback_url` with the status of the action
|
59
78
|
|
60
79
|
|
61
80
|
## Development
|
@@ -44,8 +44,8 @@ module MpesaStk
|
|
44
44
|
PartyB: "#{ENV['business_short_code']}",
|
45
45
|
PhoneNumber: "#{phone_number}",
|
46
46
|
CallBackURL: "#{ENV['callback_url']}",
|
47
|
-
AccountReference: generate_bill_reference_number(
|
48
|
-
TransactionDesc: generate_bill_reference_number(
|
47
|
+
AccountReference: generate_bill_reference_number(5),
|
48
|
+
TransactionDesc: generate_bill_reference_number(5)
|
49
49
|
}.to_json
|
50
50
|
end
|
51
51
|
|
data/lib/mpesa_stk/version.rb
CHANGED
data/mpesa_stk.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{Lipa na M-Pesa Online Payment.}
|
13
13
|
spec.description = %q{initiate a M-Pesa transaction on behalf of a customer using STK Push.}
|
14
|
-
spec.homepage = "https://github.
|
14
|
+
spec.homepage = "https://mboya.github.io/mpesa_stk/"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mpesa_stk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mboya
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-06-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -194,7 +194,7 @@ files:
|
|
194
194
|
- lib/mpesa_stk/push_payment.rb
|
195
195
|
- lib/mpesa_stk/version.rb
|
196
196
|
- mpesa_stk.gemspec
|
197
|
-
homepage: https://github.
|
197
|
+
homepage: https://mboya.github.io/mpesa_stk/
|
198
198
|
licenses:
|
199
199
|
- MIT
|
200
200
|
metadata: {}
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
216
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.7.3
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Lipa na M-Pesa Online Payment.
|