Repository navigation
Commit 9d4672f
authored
MOB-875 Adding Mpesa as a Payment Method (#119)
* MOB-875 Adding MobileMoney Charge endpoint
- Added Mobile Money as a supported channel
- Added endpoint for Mobile Money charge
- Added listener for mobile money events
- Added unit tests for endpoint and listener for mobile money charge
- Added Mock responses
- Updated tests to support mobile money as a channel
* MOB-875 Adding MobileMoney Charge endpoint
- Added Mobile Money as a supported channel
- Added endpoint for Mobile Money charge
- Added listener for mobile money events
- Added unit tests for endpoint and listener for mobile money charge
- Added Mock responses
- Updated tests to support mobile money as a channel
* MOB-875 Adding MobileMoney Charge endpoint
- Added Mobile Money as a supported channel
- Added endpoint for Mobile Money charge
- Added listener for mobile money events
- Added unit tests for endpoint and listener for mobile money charge
- Added Mock responses
- Updated tests to support mobile money as a channel
* MOB-875 Adding MobileMoney Charge endpoint
- Added Mobile Money as a supported channel
- Added endpoint for Mobile Money charge
- Added listener for mobile money events
- Added unit tests for endpoint and listener for mobile money charge
- Added Mock responses
- Updated tests to support mobile money as a channel
* MOB-875 Adding MobileMoney Charge endpoint
- Added Mobile Money as a supported channel
- Added endpoint for Mobile Money charge
- Added listener for mobile money events
- Added unit tests for endpoint and listener for mobile money charge
- Added Mock responses
- Updated tests to support mobile money as a channel
* Mpesa
* correct mapping of transaction data
* Complete M-Pesa error handling to mirror card flow
MPesaProcessingViewModel previously caught network errors and then
discarded them (commented-out display call), and routed non-success
transaction statuses to print(). Errors surfaced to the user only if
they originated in MPesaChrageViewModel.submitPhoneNumber, and even
then both .error and .fatalError auto-dismissed the flow — so the
customer was kicked out of the payment on recoverable failures
instead of being given a retry.
Introduce an MPesaContainer protocol on MPesaChrageViewModel mirroring
ChargeCardContainer. MPesaProcessingViewModel now routes both
listenForMPesa and checkPendingCharge through the container — success
and non-success statuses go to processTransactionResponse, thrown
errors go to displayTransactionError. The container maps .failed to
.error (retry) and .timeout / unexpected statuses to .fatalError
(auto-dismiss), matching ChargeCardViewModel.
MPesaChargeView now splits .error (shows "Try again" retry button
wired to restartMPesaPayment) from .fatalError (auto-dismiss with
ChargeErrorDetails), so recoverable errors no longer terminate the
payment.
TweetNacl/CTweetNacl Podfile fix:
Fix CTweetNacl module resolution in Example Pods build
Xcode 16+ / Swift 6 explicit-module builds fail to build PusherSwift
with "Unable to resolve module dependency: 'CTweetNacl'" because
TweetNacl's C submodule is declared in Pods/TweetNacl/Sources/module.map
but only TweetNacl's own target xcconfig gets that path on
SWIFT_INCLUDE_PATHS — consumers importing TweetNacl cannot find
CTweetNacl.
Extend the Podfile post_install hook to append
"${PODS_ROOT}/TweetNacl/Sources" to SWIFT_INCLUDE_PATHS on every
generated pod target so PusherSwift (and anything transitively
importing TweetNacl) can resolve the C submodule.
* Pin CI actions to SHAs and bump Xcode/iOS toolchain
Pin every third-party action to a full commit SHA (with a version
comment) so workflow supply-chain changes are explicit:
- actions/checkout v4 -> v6.0.2
- maxim-lobanov/setup-xcode v1 -> v1.7.0
- maxim-lobanov/setup-cocoapods v1 -> v1.4.0
- peter-evans/create-pull-request v4 -> v8.1.1
- ruby/setup-ruby v1 -> v1.302.0
- danger-swift-with-swiftlint 3.15.0 -> 3.22.1
Replace the archived actions/create-release@v1 with
softprops/action-gh-release@v3.0.0 (release_name -> name).
Bump the build toolchain off the retired macos-12 / macos-14
runners and the Xcode 15.3 / iOS 17.4 simulator:
- runners: macos-12 / macos-14 / macos-latest -> macos-15
- Xcode: 15.3.0 -> 26.3
- simulator: iPhone 15 Pro / iOS 17.4 -> iPhone 17 Pro / iOS 26.2
macos-26 is GA but currently ships without all iOS 26 simulator
runtimes on arm64, so macos-15 is the safer landing point.
* Add unit tests for Mobile Money flow
Cover the M-Pesa feature at the three layers the rest of the SDK
tests use (repository, ViewModel, charge-API):
* ChargeMobileMoneyRepositoryImplementationTests — chargeMobileMoney
(POST /charge/mobile_money), listenForMPesa (Pusher MOBILE_MONEY_<id>
channel, success and failed payloads), checkPendingCharge.
* MPesaChrageViewModelTests — phone validation, submitPhoneNumber
success/error paths, every processTransactionResponse branch
(success/failed/timeout/pending/unexpected), displayTransactionError,
restart, cancel.
* MPesaProcessingViewModelTests — initializeMPesaAuthorization
success/error, fire-and-forget checkTransactionStatus driven through
a closure hook + fulfillment, cancelTransaction, transactionDetails
proxy.
* MockChargeMobileMoneyRepository and MockMPesaContainer follow the
shape of the existing MockChargeCardRepository / MockChargeContainer.
Also picks up a few small drive-by fixes on the production side:
* MPesaChrageViewModel.cancelTransaction now calls restartMPesaPayment
instead of a TODO.
* ChargeCardViewModel marks its ChargeCardContainer conformance
@mainactor, matching MPesaChrageViewModel.
* Drop leftover print() calls in PusherSubscriptionListener.
* Drop the staging-URL comment in PaystackService.endpoint.
* Reformat ChargeTests.swift (whitespace only).
* Updated the unit tests
* Normalize Kenyan M-Pesa phone numbers before charge submission
Adds a `formattedKenyanPhoneNumber` String extension that accepts the
three common user-entered formats (leading 0, 254, or +254) and
normalizes them to a consistent +254 E.164 form. Applied in
`MPesaChrageViewModel.submitPhoneNumber` so the repository always
receives a uniformly formatted number. Covered by new
`StringExtensionsTests` and additional `MPesaChrageViewModelTests`
cases for each accepted prefix.
* cleaning up deployment yaml
* Removed unused environment variable1 parent f1311e5 commit 9d4672f
61 files changed
Lines changed: 1893 additions & 102 deletions
File tree
- .github/workflows
- Example
- paystack-sdk-ios.xcodeproj
- Sources
- PaystackSDK
- API/Charge
- Core
- Models
- Models
- Charge
- VerifyAccessCode
- Service
- Subscription
- URLRequest/Extensions
- PaystackUI
- Charge
- ChargeCard/Container
- MobileMoney
- Models
- Repository
- Viewmodels
- Views
- Models
- Components/Styles
- Images
- Images.xcassets
- cardLogo.imageset
- kenyaFlagLogo.imageset
- kenyaSHLogo.imageset
- messageBubbleLogo.imageset
- Utils
- Tests/PaystackSDKTests
- API
- Charge
- Resources
- Transactions/Resources
- UI
- Charge
- ChargeCard
- MPesaCharge
- MPesaProcessing
- MobileMoneyRepository
- Mocks
- Utils
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
| 41 | + | |
| 42 | + | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | | - | |
33 | | - | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
| 54 | + | |
| 55 | + | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
0 commit comments