mpesa_stk 1.3 → 2.0.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 +4 -4
- data/.github/workflows/codeql-analysis.yml +70 -0
- data/.github/workflows/cop.yml +18 -14
- data/.rubocop.yml +62 -0
- data/.sample.env +22 -1
- data/CHANGELOG.md +244 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +81 -42
- data/README.md +986 -63
- data/Rakefile +8 -6
- data/SECURITY.md +21 -0
- data/bin/console +4 -3
- data/lib/mpesa_stk/access_token.rb +53 -21
- data/lib/mpesa_stk/account_balance.rb +142 -0
- data/lib/mpesa_stk/b2b.rb +153 -0
- data/lib/mpesa_stk/b2c.rb +151 -0
- data/lib/mpesa_stk/c2b.rb +127 -0
- data/lib/mpesa_stk/imsi.rb +70 -0
- data/lib/mpesa_stk/iot.rb +206 -0
- data/lib/mpesa_stk/pull_transactions.rb +126 -0
- data/lib/mpesa_stk/push.rb +70 -41
- data/lib/mpesa_stk/push_payment.rb +44 -16
- data/lib/mpesa_stk/ratiba.rb +118 -0
- data/lib/mpesa_stk/reversal.rb +147 -0
- data/lib/mpesa_stk/stk_push_query.rb +109 -0
- data/lib/mpesa_stk/transaction_status.rb +145 -0
- data/lib/mpesa_stk/version.rb +25 -1
- data/lib/mpesa_stk.rb +37 -1
- data/mpesa_stk.gemspec +33 -21
- metadata +110 -44
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '082084ffdcc3290058eadfdc3e63e59bbd257bfe29a8d346c42a29013abe8116'
|
|
4
|
+
data.tar.gz: 152156f9e4df7894afd4fe9ab9836df4ed2b4c5e17355dc33bee978b73e7a84a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a096f3653a3018fe7d2cde6e5764ba2c04f1116b055fcbe390e150e1a946b637b01e4bdcd4e3fd53bac1eb0e9d974c1e4efed733bc3f9475c7c8617eeb2411f1
|
|
7
|
+
data.tar.gz: d4b2019ef1f775f14e6180b643593a92a140530aade71d020cf5dd12cd81edb315c090b31fa10d3db0dd33419fa9dfdf489ec877a96bdd177e85802b2a57edc0
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
+
# to commit it to your repository.
|
|
3
|
+
#
|
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
+
# or to provide custom queries or build logic.
|
|
6
|
+
#
|
|
7
|
+
# ******** NOTE ********
|
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
+
# supported CodeQL languages.
|
|
11
|
+
#
|
|
12
|
+
name: "CodeQL"
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
push:
|
|
16
|
+
branches: [ master ]
|
|
17
|
+
pull_request:
|
|
18
|
+
# The branches below must be a subset of the branches above
|
|
19
|
+
branches: [ master ]
|
|
20
|
+
schedule:
|
|
21
|
+
- cron: '41 13 * * 1'
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
analyze:
|
|
25
|
+
name: Analyze
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
permissions:
|
|
28
|
+
actions: read
|
|
29
|
+
contents: read
|
|
30
|
+
security-events: write
|
|
31
|
+
|
|
32
|
+
strategy:
|
|
33
|
+
fail-fast: false
|
|
34
|
+
matrix:
|
|
35
|
+
language: [ 'ruby' ]
|
|
36
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
|
37
|
+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- name: Checkout repository
|
|
41
|
+
uses: actions/checkout@v2
|
|
42
|
+
|
|
43
|
+
# Initializes the CodeQL tools for scanning.
|
|
44
|
+
- name: Initialize CodeQL
|
|
45
|
+
uses: github/codeql-action/init@v1
|
|
46
|
+
with:
|
|
47
|
+
languages: ${{ matrix.language }}
|
|
48
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
49
|
+
# By default, queries listed here will override any specified in a config file.
|
|
50
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
51
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
|
52
|
+
|
|
53
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
54
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
|
55
|
+
- name: Autobuild
|
|
56
|
+
uses: github/codeql-action/autobuild@v1
|
|
57
|
+
|
|
58
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
59
|
+
# 📚 https://git.io/JvXDl
|
|
60
|
+
|
|
61
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
|
62
|
+
# and modify them (or add more) to build your code if your project
|
|
63
|
+
# uses a compiled language
|
|
64
|
+
|
|
65
|
+
#- run: |
|
|
66
|
+
# make bootstrap
|
|
67
|
+
# make release
|
|
68
|
+
|
|
69
|
+
- name: Perform CodeQL Analysis
|
|
70
|
+
uses: github/codeql-action/analyze@v1
|
data/.github/workflows/cop.yml
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
name: Cop
|
|
2
|
-
on: [push]
|
|
2
|
+
on: [push, pull_request]
|
|
3
3
|
|
|
4
4
|
jobs:
|
|
5
5
|
build:
|
|
6
6
|
runs-on: ubuntu-latest
|
|
7
7
|
steps:
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- uses: actions/checkout@v2
|
|
14
|
-
- name: Set up Ruby 2.6
|
|
15
|
-
uses: actions/setup-ruby@v1
|
|
8
|
+
- uses: actions/checkout@v4
|
|
9
|
+
|
|
10
|
+
- name: Set up Ruby
|
|
11
|
+
uses: ruby/setup-ruby@v1
|
|
16
12
|
with:
|
|
17
|
-
ruby-version: 2
|
|
18
|
-
|
|
13
|
+
ruby-version: "3.2"
|
|
14
|
+
bundler-cache: true
|
|
15
|
+
|
|
16
|
+
- name: Verify bundle installation
|
|
19
17
|
run: |
|
|
20
|
-
|
|
21
|
-
bundle install
|
|
22
|
-
|
|
18
|
+
bundle --version
|
|
19
|
+
bundle check || bundle install
|
|
20
|
+
|
|
21
|
+
- name: Rubocop checks
|
|
22
|
+
run: bundle exec rubocop
|
|
23
|
+
continue-on-error: false
|
|
24
|
+
|
|
25
|
+
- name: Run tests
|
|
26
|
+
run: bundle exec rake test
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
|
2
|
+
# configuration file. It makes it possible to enable/disable
|
|
3
|
+
# certain cops (checks) and to alter their behavior if they accept
|
|
4
|
+
# any parameters. The file can be placed either in your home
|
|
5
|
+
# directory or in some project directory.
|
|
6
|
+
#
|
|
7
|
+
# RuboCop will start looking for the configuration file in the directory
|
|
8
|
+
# where the inspected file is and continue its way up to the root directory.
|
|
9
|
+
#
|
|
10
|
+
# See https://docs.rubocop.org/rubocop/configuration
|
|
11
|
+
|
|
12
|
+
AllCops:
|
|
13
|
+
NewCops: enable
|
|
14
|
+
SuggestExtensions: false
|
|
15
|
+
TargetRubyVersion: 2.6
|
|
16
|
+
Exclude:
|
|
17
|
+
- 'vendor/**/*'
|
|
18
|
+
- 'test/**/*'
|
|
19
|
+
- 'spec/**/*'
|
|
20
|
+
|
|
21
|
+
# Disable Gemspec/DevelopmentDependencies - it's standard practice for gems
|
|
22
|
+
# to specify dev dependencies in gemspec
|
|
23
|
+
Gemspec/DevelopmentDependencies:
|
|
24
|
+
Enabled: false
|
|
25
|
+
|
|
26
|
+
# Allow longer lines for method signatures and complex API calls
|
|
27
|
+
Layout/LineLength:
|
|
28
|
+
Max: 130
|
|
29
|
+
Exclude:
|
|
30
|
+
- '**/*.gemspec'
|
|
31
|
+
|
|
32
|
+
# Allow longer methods for API classes that need to handle many parameters
|
|
33
|
+
Metrics/MethodLength:
|
|
34
|
+
Max: 15
|
|
35
|
+
|
|
36
|
+
# Allow longer classes for comprehensive API implementations
|
|
37
|
+
Metrics/ClassLength:
|
|
38
|
+
Max: 150
|
|
39
|
+
|
|
40
|
+
# Allow more complex methods for initialization with many parameters
|
|
41
|
+
# API classes need to handle many configuration options
|
|
42
|
+
Metrics/AbcSize:
|
|
43
|
+
Max: 25
|
|
44
|
+
|
|
45
|
+
Metrics/CyclomaticComplexity:
|
|
46
|
+
Max: 10
|
|
47
|
+
|
|
48
|
+
Metrics/PerceivedComplexity:
|
|
49
|
+
Max: 10
|
|
50
|
+
|
|
51
|
+
# Allow more parameters for API classes that need flexibility
|
|
52
|
+
# Some classes like Push need many optional parameters for different use cases
|
|
53
|
+
Metrics/ParameterLists:
|
|
54
|
+
Max: 10
|
|
55
|
+
CountKeywordArgs: true
|
|
56
|
+
MaxOptionalParameters: 6
|
|
57
|
+
|
|
58
|
+
# Allow get_ prefix for private validation/accessor methods
|
|
59
|
+
Naming/AccessorMethodName:
|
|
60
|
+
Enabled: true
|
|
61
|
+
Exclude:
|
|
62
|
+
- 'lib/mpesa_stk/**/*'
|
data/.sample.env
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
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
|
+
transaction_status_url="/mpesa/transactionstatus/v1/query"
|
|
5
|
+
stk_push_query_url="/mpesa/stkpushquery/v1/query"
|
|
6
|
+
b2c_url="/mpesa/b2c/v1/paymentrequest"
|
|
7
|
+
b2b_url="/mpesa/b2b/v1/paymentrequest"
|
|
8
|
+
c2b_register_url="/mpesa/c2b/v1/registerurl"
|
|
9
|
+
c2b_simulate_url="/mpesa/c2b/v1/simulate"
|
|
10
|
+
account_balance_url="/mpesa/accountbalance/v1/query"
|
|
11
|
+
reversal_url="/mpesa/reversal/v1/request"
|
|
12
|
+
ratiba_url="/standingorder/v1/createStandingOrderExternal"
|
|
13
|
+
iot_base_url="/simportal/v1"
|
|
14
|
+
pull_transactions_register_url="/pulltransactions/v1/register"
|
|
15
|
+
pull_transactions_query_url="/pulltransactions/v1/query"
|
|
4
16
|
|
|
5
17
|
key=""
|
|
6
18
|
secret=""
|
|
7
19
|
business_short_code=""
|
|
8
20
|
business_passkey=""
|
|
9
21
|
callback_url="https://api.endpoint/callback"
|
|
10
|
-
|
|
22
|
+
confirmation_url="https://api.endpoint/confirmation"
|
|
23
|
+
till_number=""
|
|
24
|
+
initiator=""
|
|
25
|
+
initiator_name=""
|
|
26
|
+
security_credential=""
|
|
27
|
+
result_url="https://api.endpoint/result"
|
|
28
|
+
queue_timeout_url="https://api.endpoint/queue_timeout"
|
|
29
|
+
iot_api_key="Yl4S3KEcr173mbeUdYdjf147IuG3rJ824ArMkP6Z"
|
|
30
|
+
vpn_group=""
|
|
31
|
+
username=""
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2025-01-XX
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
#### New API Endpoints
|
|
13
|
+
|
|
14
|
+
- **Transaction Status Query** (`MpesaStk::TransactionStatus`)
|
|
15
|
+
- Query the status of any M-Pesa transaction
|
|
16
|
+
- Supports querying by transaction ID
|
|
17
|
+
- Full error handling and response parsing
|
|
18
|
+
|
|
19
|
+
- **STK Push Query** (`MpesaStk::StkPushQuery`)
|
|
20
|
+
- Query the status of STK Push transactions
|
|
21
|
+
- Check payment request status using CheckoutRequestID
|
|
22
|
+
|
|
23
|
+
- **Business to Customer (B2C)** (`MpesaStk::B2C`)
|
|
24
|
+
- Send money from business to customer
|
|
25
|
+
- Supports salary payments, promotions, and other B2C transactions
|
|
26
|
+
- Configurable command IDs and remarks
|
|
27
|
+
|
|
28
|
+
- **Business to Business (B2B)** (`MpesaStk::B2B`)
|
|
29
|
+
- Send money from business to business
|
|
30
|
+
- Supports PayBill to PayBill and PayBill to Buy Goods transactions
|
|
31
|
+
- Full support for sender and receiver account references
|
|
32
|
+
|
|
33
|
+
- **Customer to Business (C2B)** (`MpesaStk::C2B`)
|
|
34
|
+
- Register C2B validation and confirmation URLs
|
|
35
|
+
- Simulate C2B payments for testing
|
|
36
|
+
- Complete C2B payment flow support
|
|
37
|
+
|
|
38
|
+
- **Account Balance Query** (`MpesaStk::AccountBalance`)
|
|
39
|
+
- Query account balance for PayBill or Till Number
|
|
40
|
+
- Supports both Initiator and PartyA queries
|
|
41
|
+
|
|
42
|
+
- **Transaction Reversal** (`MpesaStk::Reversal`)
|
|
43
|
+
- Reverse M-Pesa transactions
|
|
44
|
+
- Supports full and partial reversals
|
|
45
|
+
- Configurable timeout and result URLs
|
|
46
|
+
|
|
47
|
+
- **M-Pesa Ratiba (Standing Orders)** (`MpesaStk::Ratiba`)
|
|
48
|
+
- Create recurring payment standing orders
|
|
49
|
+
- Schedule automatic payments
|
|
50
|
+
- Manage subscription-based payments
|
|
51
|
+
|
|
52
|
+
- **IoT SIM Management & Messaging** (`MpesaStk::IoT`)
|
|
53
|
+
- **SIM Operations:**
|
|
54
|
+
- Get all SIMs with pagination
|
|
55
|
+
- Query lifecycle status
|
|
56
|
+
- Query customer information
|
|
57
|
+
- SIM activation
|
|
58
|
+
- Get activation trends
|
|
59
|
+
- Rename assets
|
|
60
|
+
- Get location information
|
|
61
|
+
- Suspend/unsuspend subscriptions
|
|
62
|
+
- **Messaging Operations:**
|
|
63
|
+
- Get all messages with pagination
|
|
64
|
+
- Search messages
|
|
65
|
+
- Filter messages by date/status
|
|
66
|
+
- Send single messages to IoT devices
|
|
67
|
+
- Delete messages and message threads
|
|
68
|
+
|
|
69
|
+
- **IMSI/SWAP Operations** (`MpesaStk::IMSI`)
|
|
70
|
+
- Check ATI (Access Transaction Information)
|
|
71
|
+
- Query IMSI and SIM swap information
|
|
72
|
+
- Supports both v1 and v2 API versions
|
|
73
|
+
- Useful for fraud prevention and SIM verification
|
|
74
|
+
|
|
75
|
+
- **Pull Transactions** (`MpesaStk::PullTransactions`)
|
|
76
|
+
- Register pull transaction callback URLs
|
|
77
|
+
- Query historical transactions
|
|
78
|
+
- Retrieve transaction data for reconciliation
|
|
79
|
+
|
|
80
|
+
#### Testing Infrastructure
|
|
81
|
+
|
|
82
|
+
- Comprehensive test suite with 148 tests covering all features
|
|
83
|
+
- Test files for all new API endpoints:
|
|
84
|
+
- `test/transaction_status_test.rb`
|
|
85
|
+
- `test/stk_push_query_test.rb`
|
|
86
|
+
- `test/b2c_test.rb`
|
|
87
|
+
- `test/b2b_test.rb`
|
|
88
|
+
- `test/c2b_test.rb`
|
|
89
|
+
- `test/account_balance_test.rb`
|
|
90
|
+
- `test/reversal_test.rb`
|
|
91
|
+
- `test/ratiba_test.rb`
|
|
92
|
+
- `test/iot_test.rb`
|
|
93
|
+
- `test/imsi_test.rb`
|
|
94
|
+
- `test/pull_transactions_test.rb`
|
|
95
|
+
- Enhanced `MockRedis` class for isolated testing without external Redis dependency
|
|
96
|
+
- Improved test helper with comprehensive environment variable setup
|
|
97
|
+
- All tests use WebMock for HTTP request stubbing
|
|
98
|
+
|
|
99
|
+
#### Documentation
|
|
100
|
+
|
|
101
|
+
- Comprehensive README.md update with:
|
|
102
|
+
- Detailed API reference for all endpoints
|
|
103
|
+
- Usage examples using both ENV variables and hash parameters
|
|
104
|
+
- Descriptions for each API endpoint explaining their purpose
|
|
105
|
+
- Consolidated response format and error handling sections
|
|
106
|
+
- Quick start examples
|
|
107
|
+
- Complete configuration guide
|
|
108
|
+
- Updated `.sample.env` with all new environment variables
|
|
109
|
+
- Clear documentation of required vs optional parameters
|
|
110
|
+
|
|
111
|
+
#### Configuration
|
|
112
|
+
|
|
113
|
+
- Added support for hash-based parameter passing for all APIs
|
|
114
|
+
- Enhanced ENV variable support for all new endpoints
|
|
115
|
+
- Improved error messages for missing configuration
|
|
116
|
+
- Standardized configuration access across all classes
|
|
117
|
+
|
|
118
|
+
### Changed
|
|
119
|
+
|
|
120
|
+
#### Dependencies
|
|
121
|
+
|
|
122
|
+
- Added explicit `base64` dependency (>= 0.1.0) for Ruby 3.4+ compatibility
|
|
123
|
+
- Added explicit `csv` dependency (>= 3.0.0) for Ruby 3.4+ compatibility
|
|
124
|
+
- Updated `minitest` to ~> 5.20 for Ruby 3.3+ compatibility
|
|
125
|
+
- Updated `pry` to ~> 0.12 for compatibility
|
|
126
|
+
- Updated `pry-nav` to ~> 0.3 for compatibility
|
|
127
|
+
- Updated `httparty` constraint to < 0.22.0
|
|
128
|
+
- All dependencies now compatible with Ruby 3.3+
|
|
129
|
+
|
|
130
|
+
#### Code Quality
|
|
131
|
+
|
|
132
|
+
- Improved error handling across all API classes
|
|
133
|
+
- Standardized error messages and exception types
|
|
134
|
+
- Enhanced HTTP response validation
|
|
135
|
+
- Better handling of missing configuration
|
|
136
|
+
- Improved code consistency across all classes
|
|
137
|
+
- Added `frozen_string_literal: true` to gemspec
|
|
138
|
+
|
|
139
|
+
#### Test Infrastructure
|
|
140
|
+
|
|
141
|
+
- Fixed circular require warnings in Ruby 3.3+
|
|
142
|
+
- Improved test isolation with better MockRedis implementation
|
|
143
|
+
- Enhanced test helper with proper warning suppression
|
|
144
|
+
- Better test organization and structure
|
|
145
|
+
|
|
146
|
+
#### CI/CD
|
|
147
|
+
|
|
148
|
+
- Updated GitHub Actions workflow:
|
|
149
|
+
- Updated `actions/checkout` to v4
|
|
150
|
+
- Updated Ruby setup action to `ruby/setup-ruby@v1`
|
|
151
|
+
- Updated Ruby version to 3.1
|
|
152
|
+
- Added `bundler-cache: true` for faster builds
|
|
153
|
+
- Added `pull_request` trigger
|
|
154
|
+
|
|
155
|
+
### Fixed
|
|
156
|
+
|
|
157
|
+
- Fixed Ruby 3.4+ compatibility warnings for `base64` and `csv` gems
|
|
158
|
+
- Fixed circular require warnings in test suite (Ruby 3.3+)
|
|
159
|
+
- Fixed `MockRedis` shared storage issue in tests
|
|
160
|
+
- Fixed assertion method names in tests (`assert_not_equal` → `refute_equal`)
|
|
161
|
+
- Fixed syntax error in `MpesaStk::IMSI` class
|
|
162
|
+
- Improved error handling for Redis connection failures
|
|
163
|
+
- Fixed generic exception handling (changed to `ArgumentError` where appropriate)
|
|
164
|
+
|
|
165
|
+
### Improved
|
|
166
|
+
|
|
167
|
+
- Better separation of concerns across API classes
|
|
168
|
+
- More consistent API design patterns
|
|
169
|
+
- Enhanced documentation and examples
|
|
170
|
+
- Improved code maintainability
|
|
171
|
+
- Better error messages for debugging
|
|
172
|
+
|
|
173
|
+
## [1.3.0] - Previous Version
|
|
174
|
+
|
|
175
|
+
### Features
|
|
176
|
+
|
|
177
|
+
- STK Push payment initiation
|
|
178
|
+
- Access token management with Redis caching
|
|
179
|
+
- Support for multiple applications with custom credentials
|
|
180
|
+
- Basic error handling and response parsing
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Version History
|
|
185
|
+
|
|
186
|
+
- **2.0.0** - Major release with comprehensive API coverage, full test suite, and Ruby 3.3+ compatibility
|
|
187
|
+
- **1.3.0** - Initial stable release with STK Push functionality
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Migration Guide
|
|
192
|
+
|
|
193
|
+
### Upgrading from 1.3.x to 2.0.0
|
|
194
|
+
|
|
195
|
+
1. **Update Dependencies:**
|
|
196
|
+
```bash
|
|
197
|
+
bundle update mpesa_stk
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
2. **New Environment Variables:**
|
|
201
|
+
Add the following to your `.env` file (see `.sample.env` for complete list):
|
|
202
|
+
- `transaction_status_url`
|
|
203
|
+
- `stk_push_query_url`
|
|
204
|
+
- `b2c_url`, `b2b_url`
|
|
205
|
+
- `c2b_register_url`, `c2b_simulate_url`
|
|
206
|
+
- `account_balance_url`
|
|
207
|
+
- `reversal_url`
|
|
208
|
+
- `ratiba_url`
|
|
209
|
+
- `iot_base_url`, `iot_api_key`, `vpn_group`, `username`
|
|
210
|
+
- `imsi_v1_url`, `imsi_v2_url`
|
|
211
|
+
- `pull_transactions_register_url`, `pull_transactions_query_url`
|
|
212
|
+
- `initiator`, `initiator_name`, `security_credential`
|
|
213
|
+
- `result_url`, `queue_timeout_url`, `confirmation_url`
|
|
214
|
+
|
|
215
|
+
3. **Ruby Version:**
|
|
216
|
+
Ensure you're using Ruby 2.6.0 or higher (Ruby 3.3+ recommended)
|
|
217
|
+
|
|
218
|
+
4. **Redis:**
|
|
219
|
+
Redis 4.0+ is now required
|
|
220
|
+
|
|
221
|
+
5. **API Changes:**
|
|
222
|
+
- All existing STK Push APIs remain backward compatible
|
|
223
|
+
- New APIs follow consistent patterns with both ENV and hash parameter support
|
|
224
|
+
- Error handling has been improved but maintains backward compatibility
|
|
225
|
+
|
|
226
|
+
### Breaking Changes
|
|
227
|
+
|
|
228
|
+
None - This release maintains full backward compatibility with version 1.3.x.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Contributors
|
|
233
|
+
|
|
234
|
+
- mboya
|
|
235
|
+
- cess
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Links
|
|
240
|
+
|
|
241
|
+
- [GitHub Repository](https://github.com/mboya/mpesa_stk)
|
|
242
|
+
- [RubyGems](https://rubygems.org/gems/mpesa_stk)
|
|
243
|
+
- [Safaricom Developer Portal](https://developer.safaricom.co.ke/)
|
|
244
|
+
|
data/Gemfile
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
source 'https://rubygems.org'
|
|
4
|
+
|
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
4
6
|
|
|
5
7
|
# Specify your gem's dependencies in mpesa_stk.gemspec
|
|
6
8
|
gemspec
|
data/Gemfile.lock
CHANGED
|
@@ -1,51 +1,89 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
mpesa_stk (
|
|
5
|
-
|
|
4
|
+
mpesa_stk (2.0.0)
|
|
5
|
+
base64 (>= 0.1.0)
|
|
6
|
+
csv (>= 3.0.0)
|
|
7
|
+
httparty (>= 0.15.6, < 0.22.0)
|
|
8
|
+
redis (>= 4.0)
|
|
6
9
|
redis-namespace (~> 1.5, >= 1.5.3)
|
|
7
10
|
redis-rack (~> 2.0, >= 2.0.2)
|
|
8
11
|
|
|
9
12
|
GEM
|
|
10
13
|
remote: https://rubygems.org/
|
|
11
14
|
specs:
|
|
12
|
-
addressable (2.
|
|
13
|
-
public_suffix (>= 2.0.2, <
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
addressable (2.8.8)
|
|
16
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
17
|
+
ast (2.4.3)
|
|
18
|
+
base64 (0.3.0)
|
|
19
|
+
bigdecimal (3.3.1)
|
|
20
|
+
coderay (1.1.3)
|
|
21
|
+
connection_pool (3.0.2)
|
|
22
|
+
crack (1.0.1)
|
|
23
|
+
bigdecimal
|
|
24
|
+
rexml
|
|
25
|
+
csv (3.3.5)
|
|
26
|
+
dotenv (2.8.1)
|
|
27
|
+
hashdiff (1.2.1)
|
|
28
|
+
httparty (0.21.0)
|
|
29
|
+
mini_mime (>= 1.0.0)
|
|
21
30
|
multi_xml (>= 0.5.2)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
json (2.17.1)
|
|
32
|
+
language_server-protocol (3.17.0.5)
|
|
33
|
+
lint_roller (1.1.0)
|
|
34
|
+
method_source (0.9.2)
|
|
35
|
+
mini_mime (1.1.5)
|
|
36
|
+
minitest (5.26.2)
|
|
37
|
+
multi_xml (0.7.2)
|
|
38
|
+
bigdecimal (~> 3.1)
|
|
39
|
+
parallel (1.27.0)
|
|
40
|
+
parser (3.3.10.0)
|
|
41
|
+
ast (~> 2.4.1)
|
|
42
|
+
racc
|
|
43
|
+
prism (1.6.0)
|
|
44
|
+
pry (0.12.2)
|
|
29
45
|
coderay (~> 1.1.0)
|
|
30
|
-
method_source (~> 0.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
rack (2.2.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
redis
|
|
39
|
-
redis (>=
|
|
40
|
-
redis-
|
|
46
|
+
method_source (~> 0.9.0)
|
|
47
|
+
pry-nav (0.3.0)
|
|
48
|
+
pry (>= 0.9.10, < 0.13.0)
|
|
49
|
+
public_suffix (7.0.0)
|
|
50
|
+
racc (1.8.1)
|
|
51
|
+
rack (2.2.21)
|
|
52
|
+
rainbow (3.1.1)
|
|
53
|
+
rake (13.3.1)
|
|
54
|
+
redis (5.4.1)
|
|
55
|
+
redis-client (>= 0.22.0)
|
|
56
|
+
redis-client (0.26.2)
|
|
57
|
+
connection_pool
|
|
58
|
+
redis-namespace (1.11.0)
|
|
59
|
+
redis (>= 4)
|
|
60
|
+
redis-rack (2.1.4)
|
|
41
61
|
rack (>= 2.0.8, < 3)
|
|
42
62
|
redis-store (>= 1.2, < 2)
|
|
43
|
-
redis-store (1.
|
|
44
|
-
redis (>= 4, <
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
redis-store (1.11.0)
|
|
64
|
+
redis (>= 4, < 6)
|
|
65
|
+
regexp_parser (2.11.3)
|
|
66
|
+
rexml (3.4.4)
|
|
67
|
+
rubocop (1.81.7)
|
|
68
|
+
json (~> 2.3)
|
|
69
|
+
language_server-protocol (~> 3.17.0.2)
|
|
70
|
+
lint_roller (~> 1.1.0)
|
|
71
|
+
parallel (~> 1.10)
|
|
72
|
+
parser (>= 3.3.0.2)
|
|
73
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
74
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
75
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
76
|
+
ruby-progressbar (~> 1.7)
|
|
77
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
78
|
+
rubocop-ast (1.48.0)
|
|
79
|
+
parser (>= 3.3.7.2)
|
|
80
|
+
prism (~> 1.4)
|
|
81
|
+
ruby-progressbar (1.13.0)
|
|
82
|
+
unicode-display_width (3.2.0)
|
|
83
|
+
unicode-emoji (~> 4.1)
|
|
84
|
+
unicode-emoji (4.1.0)
|
|
85
|
+
webmock (3.26.1)
|
|
86
|
+
addressable (>= 2.8.0)
|
|
49
87
|
crack (>= 0.3.2)
|
|
50
88
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
51
89
|
|
|
@@ -53,14 +91,15 @@ PLATFORMS
|
|
|
53
91
|
ruby
|
|
54
92
|
|
|
55
93
|
DEPENDENCIES
|
|
56
|
-
bundler
|
|
57
|
-
dotenv (
|
|
58
|
-
minitest (~> 5.
|
|
94
|
+
bundler (~> 2.0)
|
|
95
|
+
dotenv (~> 2.8)
|
|
96
|
+
minitest (~> 5.20)
|
|
59
97
|
mpesa_stk!
|
|
60
|
-
pry (~> 0.
|
|
61
|
-
pry-nav (~> 0.
|
|
98
|
+
pry (~> 0.12)
|
|
99
|
+
pry-nav (~> 0.3)
|
|
62
100
|
rake (>= 12.3.3)
|
|
63
|
-
|
|
101
|
+
rubocop (~> 1.0)
|
|
102
|
+
webmock (~> 3.18)
|
|
64
103
|
|
|
65
104
|
BUNDLED WITH
|
|
66
|
-
2.
|
|
105
|
+
2.7.2
|