Skip to content

Commit 9d4672f

Browse files
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 variable
1 parent f1311e5 commit 9d4672f

61 files changed

Lines changed: 1893 additions & 102 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build.yml‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,55 +8,55 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: macos-14
11+
runs-on: macos-15
1212
name: Build and Test Swift Package
1313

1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1616
- name: Select Xcode Version
17-
uses: maxim-lobanov/setup-xcode@v1
17+
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0
1818
with:
19-
xcode-version: '15.3.0'
20-
19+
xcode-version: '26.3'
20+
2121
- name: Setup environment
2222
run: |
2323
bundle install
2424
2525
- name: Build and Run tests
2626
run: |
27-
xcodebuild clean build test -scheme PaystackSDK-Package -sdk iphonesimulator17.4 -destination "OS=17.4,name=iPhone 15 Pro" -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO
27+
xcodebuild clean build test -scheme PaystackSDK-Package -sdk iphonesimulator26.2 -destination "OS=26.2,name=iPhone 17 Pro" -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO
2828
brew install sonar-scanner
2929
bundle exec fastlane sonar_scan
3030
env:
3131
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3232
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
33-
33+
3434

3535
PodLinting:
36-
runs-on: macos-12
36+
runs-on: macos-15
3737
name: Lint Podspec
38-
38+
3939
steps:
4040
- name: Checkout
41-
uses: actions/checkout@v4
42-
41+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
42+
4343
- name: setup-cocoapods
44-
uses: maxim-lobanov/setup-cocoapods@v1
44+
uses: maxim-lobanov/setup-cocoapods@8e97e1e98e6ccf42564fdf5622c8feec74199377 # v1.4.0
4545
with:
4646
version: 1.15.2
47-
47+
4848
- name: Run pod lint for Paystack Core
4949
run: pod lib lint PaystackCore.podspec --allow-warnings
5050

5151
# TODO: Add sonar here once the project is added
5252

5353
release:
5454
if: ${{ github.event.pull_request.merged == true && github.head_ref == 'release/update-versions' }}
55-
runs-on: macos-12
55+
runs-on: macos-15
5656
needs: [build, PodLinting]
5757

5858
steps:
59-
- uses: actions/checkout@v4
59+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6060

6161
- name: Get version information
6262
run: |
@@ -67,12 +67,12 @@ jobs:
6767
6868
- name: Create Release
6969
id: create_release
70-
uses: actions/create-release@v1
70+
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
7171
env:
7272
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7373
with:
7474
tag_name: ${{ env.version }}
75-
release_name: ${{ env.version }}
75+
name: ${{ env.version }}
7676
body: ${{ env.body }}
7777

7878
- name: Install Cocoapods

‎.github/workflows/deploy.yml‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ on:
55

66
jobs:
77
deploy:
8-
runs-on: macos-14
8+
runs-on: macos-15
99
name: Deploy to Cocoapods Trunk
1010

1111
steps:
12-
- uses: actions/checkout@v4
13-
12+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
13+
1414
- name: Select Xcode Version
15-
uses: maxim-lobanov/setup-xcode@v1
15+
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0
1616
with:
17-
xcode-version: '15.3.0'
18-
17+
xcode-version: '26.3'
18+
1919
- name: Setup environment
2020
run: |
2121
bundle install
2222
2323
- name: Build and Run tests
2424
run: |
25-
xcodebuild clean build test -scheme PaystackSDK-Package -sdk iphonesimulator17.4 -destination "OS=17.4,name=iPhone 15 Pro" -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO
26-
25+
xcodebuild clean build test -scheme PaystackSDK-Package -sdk iphonesimulator26.2 -destination "OS=26.2,name=iPhone 17 Pro" -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO
26+
2727
- name: setup-cocoapods
28-
uses: maxim-lobanov/setup-cocoapods@v1
28+
uses: maxim-lobanov/setup-cocoapods@8e97e1e98e6ccf42564fdf5622c8feec74199377 # v1.4.0
2929
with:
3030
version: 1.15.2
3131

@@ -38,22 +38,22 @@ jobs:
3838
3939
- name: Create Release
4040
id: create_release
41-
uses: actions/create-release@v1
41+
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
4242
env:
4343
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4444
with:
4545
tag_name: ${{ env.version }}
46-
release_name: ${{ env.version }}
46+
name: ${{ env.version }}
4747
body: ${{ env.body }}
4848

4949
Publish_Cocoapods:
5050
runs-on: ubuntu-latest
5151
needs: deploy
5252
steps:
5353
- name: Checkout
54-
uses: actions/checkout@v4
54+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5555

56-
- uses: ruby/setup-ruby@v1
56+
- uses: ruby/setup-ruby@7372622e62b60b3cb750dcd2b9e32c247ffec26a # v1.302.0
5757
with:
5858
ruby-version: '3.2.2'
5959

@@ -65,4 +65,3 @@ jobs:
6565
pod trunk push PaystackUI.podspec --allow-warnings
6666
env:
6767
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
68-

‎.github/workflows/primary.yml‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ jobs:
1212
name: Code quality Checks
1313

1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1616
- name: Danger
17-
uses: docker://ghcr.io/danger/danger-swift-with-swiftlint:3.15.0
17+
uses: docker://ghcr.io/danger/danger-swift-with-swiftlint:3.22.1
1818
with:
1919
args: --failOnErrors --no-publish-check
2020
env:
2121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2222

2323
SwiftPackage:
24-
runs-on: macos-14
24+
runs-on: macos-15
2525
name: Build and Test Swift Package
2626

2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2929
- name: Select Xcode Version
30-
uses: maxim-lobanov/setup-xcode@v1
30+
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0
3131
with:
32-
xcode-version: '15.3.0'
33-
32+
xcode-version: '26.3'
33+
3434
- name: Setup environment
3535
run: |
3636
bundle install
3737
3838
- name: Build and Run tests
3939
run: |
40-
xcodebuild clean build test -scheme PaystackSDK-Package -sdk iphonesimulator17.4 -destination "OS=17.4,name=iPhone 15 Pro" -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO
40+
xcodebuild clean build test -scheme PaystackSDK-Package -sdk iphonesimulator26.2 -destination "OS=26.2,name=iPhone 17 Pro" -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO
4141
brew install sonar-scanner
4242
bundle exec fastlane sonar_scan
4343
env:
@@ -46,15 +46,15 @@ jobs:
4646

4747
PodLinting:
4848
if: ${{ false }}
49-
runs-on: macos-12
49+
runs-on: macos-15
5050
name: Lint Podspec
51-
51+
5252
steps:
5353
- name: Checkout
54-
uses: actions/checkout@v4
55-
54+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
55+
5656
- name: setup-cocoapods
57-
uses: maxim-lobanov/setup-cocoapods@v1
57+
uses: maxim-lobanov/setup-cocoapods@8e97e1e98e6ccf42564fdf5622c8feec74199377 # v1.4.0
5858
with:
5959
version: 1.15.2
6060

‎.github/workflows/release.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ on:
1616

1717
jobs:
1818
release:
19-
runs-on: macos-14
19+
runs-on: macos-15
2020

2121
steps:
22-
- uses: actions/checkout@v4
22+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2323

2424
- name: Increment Latest Version
2525
run: |
2626
mode=${{ github.event.inputs.release }}
2727
cd Sources/PaystackSDK
2828
sh Versioning/update_version.sh $mode ${{ github.event.inputs.body }}
29-
29+
3030
- name: Open Pull Request
31-
uses: peter-evans/create-pull-request@v4
31+
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
3232
with:
3333
commit-message: Updated versions in podspec and plist for release
3434
title: Updating SDK Version
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1500"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "PaystackCore"
18+
BuildableName = "PaystackCore"
19+
BlueprintName = "PaystackCore"
20+
ReferencedContainer = "container:">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES"
30+
shouldAutocreateTestPlan = "YES">
31+
</TestAction>
32+
<LaunchAction
33+
buildConfiguration = "Debug"
34+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
35+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
36+
launchStyle = "0"
37+
useCustomWorkingDirectory = "NO"
38+
ignoresPersistentStateOnLaunch = "NO"
39+
debugDocumentVersioning = "YES"
40+
debugServiceExtension = "internal"
41+
allowLocationSimulation = "YES">
42+
</LaunchAction>
43+
<ProfileAction
44+
buildConfiguration = "Release"
45+
shouldUseLaunchSchemeArgsEnv = "YES"
46+
savedToolIdentifier = ""
47+
useCustomWorkingDirectory = "NO"
48+
debugDocumentVersioning = "YES">
49+
<MacroExpansion>
50+
<BuildableReference
51+
BuildableIdentifier = "primary"
52+
BlueprintIdentifier = "PaystackCore"
53+
BuildableName = "PaystackCore"
54+
BlueprintName = "PaystackCore"
55+
ReferencedContainer = "container:">
56+
</BuildableReference>
57+
</MacroExpansion>
58+
</ProfileAction>
59+
<AnalyzeAction
60+
buildConfiguration = "Debug">
61+
</AnalyzeAction>
62+
<ArchiveAction
63+
buildConfiguration = "Release"
64+
revealArchiveInOrganizer = "YES">
65+
</ArchiveAction>
66+
</Scheme>

0 commit comments

Comments
 (0)