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.
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