mpesa_stk 1.3 → 3.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/.gitignore +2 -0
- data/.rubocop.yml +63 -0
- data/.sample.env +22 -1
- data/CHANGELOG.md +259 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +6 -2
- data/Gemfile.lock +91 -43
- data/LICENSE.txt +0 -0
- data/MIGRATION.md +77 -0
- data/README.md +536 -97
- data/Rakefile +8 -6
- data/SECURITY.md +21 -0
- data/bin/console +4 -3
- data/bin/index.jpeg +0 -0
- data/lib/mpesa_stk/access_token.rb +54 -21
- data/lib/mpesa_stk/account_balance.rb +30 -0
- data/lib/mpesa_stk/b2b.rb +44 -0
- data/lib/mpesa_stk/b2c.rb +39 -0
- data/lib/mpesa_stk/c2b.rb +44 -0
- data/lib/mpesa_stk/client.rb +67 -0
- data/lib/mpesa_stk/config.rb +36 -0
- data/lib/mpesa_stk/imsi.rb +28 -0
- data/lib/mpesa_stk/iot.rb +167 -0
- data/lib/mpesa_stk/pull_transactions.rb +44 -0
- data/lib/mpesa_stk/push.rb +43 -105
- data/lib/mpesa_stk/ratiba.rb +37 -0
- data/lib/mpesa_stk/reversal.rb +40 -0
- data/lib/mpesa_stk/stk_push_query.rb +38 -0
- data/lib/mpesa_stk/transaction_status.rb +38 -0
- data/lib/mpesa_stk/version.rb +3 -1
- data/lib/mpesa_stk.rb +27 -3
- data/mpesa_stk.gemspec +34 -21
- metadata +126 -44
- data/lib/mpesa_stk/push_payment.rb +0 -71
data/MIGRATION.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Migrating from 2.x to 3.0
|
|
2
|
+
|
|
3
|
+
Version 3.0 unifies the public API around `.call` (and `.register` where registration is not a payment). String-key option hashes are removed; use keyword arguments instead.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
ENV variables from `.sample.env` still work. Optional programmatic overrides:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
MpesaStk.configure do |c|
|
|
11
|
+
c[:business_short_code] = '174379'
|
|
12
|
+
c[:key] = 'your_key'
|
|
13
|
+
end
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Set `MPESA_STK_SKIP_DOTENV=true` in production if your host app loads environment variables itself.
|
|
17
|
+
|
|
18
|
+
## API changes
|
|
19
|
+
|
|
20
|
+
| 2.x | 3.0 |
|
|
21
|
+
|-----|-----|
|
|
22
|
+
| `MpesaStk::PushPayment.call(amount, phone)` | `MpesaStk::Push.call(amount, phone)` |
|
|
23
|
+
| `MpesaStk::Push.pay_bill(amount, phone, hash)` | `MpesaStk::Push.call(amount, phone, **opts)` |
|
|
24
|
+
| `MpesaStk::Push.buy_goods(amount, phone, hash)` | `MpesaStk::Push.call(amount, phone, type: :buy_goods, till_number: '...')` |
|
|
25
|
+
| `MpesaStk::B2C.pay(amount, phone, hash)` | `MpesaStk::B2C.call(amount, phone, remarks: '...')` |
|
|
26
|
+
| `MpesaStk::B2B.pay(amount, receiver, hash)` | `MpesaStk::B2B.call(amount, receiver, **opts)` |
|
|
27
|
+
| `MpesaStk::C2B.register_url(hash)` | `MpesaStk::C2B.register(**opts)` |
|
|
28
|
+
| `MpesaStk::C2B.simulate(amount, phone, hash)` | `MpesaStk::C2B.call(amount, phone, **opts)` |
|
|
29
|
+
| `MpesaStk::StkPushQuery.query(id, hash)` | `MpesaStk::StkPushQuery.call(id, **opts)` |
|
|
30
|
+
| `MpesaStk::TransactionStatus.query(id, hash)` | `MpesaStk::TransactionStatus.call(id, **opts)` |
|
|
31
|
+
| `MpesaStk::AccountBalance.query(hash)` | `MpesaStk::AccountBalance.call(**opts)` |
|
|
32
|
+
| `MpesaStk::Reversal.reverse(id, amount, hash)` | `MpesaStk::Reversal.call(id, amount, **opts)` |
|
|
33
|
+
| `MpesaStk::Ratiba.create_standing_order(hash)` | `MpesaStk::Ratiba.call(amount:, party_a:, start_date:, end_date:, **opts)` |
|
|
34
|
+
| `MpesaStk::PullTransactions.register(hash)` | `MpesaStk::PullTransactions.register(**opts)` |
|
|
35
|
+
| `MpesaStk::PullTransactions.query(start, end, hash)` | `MpesaStk::PullTransactions.call(start, end, **opts)` |
|
|
36
|
+
| `MpesaStk::IMSI.check_ati(phone, hash, version:)` | `MpesaStk::IMSI.call(phone, version: 'v1', **opts)` |
|
|
37
|
+
| `MpesaStk::IoT.sims({}).get_all_sims` | `MpesaStk::IoT.list_sims` or `MpesaStk::IoT.call(:get_all_sims, **opts)` |
|
|
38
|
+
| `MpesaStk::IoT.messaging({}).send_single_message(msisdn, msg)` | `MpesaStk::IoT.send_message(msisdn, msg)` |
|
|
39
|
+
|
|
40
|
+
## Hash to keyword examples
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
# 2.x
|
|
44
|
+
MpesaStk::B2C.pay(100, '254712345678', { 'command_id' => 'SalaryPayment', 'key' => 'k', 'secret' => 's' })
|
|
45
|
+
|
|
46
|
+
# 3.0
|
|
47
|
+
MpesaStk::B2C.call(100, '254712345678', command_id: 'SalaryPayment', key: 'k', secret: 's')
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
# 2.x
|
|
52
|
+
MpesaStk::Push.pay_bill(100, '254712345678', { 'business_short_code' => '174379', 'callback_url' => 'https://...' })
|
|
53
|
+
|
|
54
|
+
# 3.0
|
|
55
|
+
MpesaStk::Push.call(100, '254712345678', business_short_code: '174379', callback_url: 'https://...')
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## IoT
|
|
59
|
+
|
|
60
|
+
Prefer shortcuts:
|
|
61
|
+
|
|
62
|
+
```ruby
|
|
63
|
+
MpesaStk::IoT.list_sims(page_size: 20)
|
|
64
|
+
MpesaStk::IoT.send_message('0110100606', 'Hello device')
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Or dispatch any instance method:
|
|
68
|
+
|
|
69
|
+
```ruby
|
|
70
|
+
MpesaStk::IoT.call(:query_lifecycle_status, '0110100606')
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Internal changes
|
|
74
|
+
|
|
75
|
+
- Shared `MpesaStk::Client` base for HTTP and OAuth
|
|
76
|
+
- `MpesaStk::Config` for ENV / configure overrides
|
|
77
|
+
- Removed per-class `get_*` helpers and string-hash constructors
|