Add swap service - #173
Open
watersRand wants to merge 5 commits into
Open
Conversation
RafaelJohn9
requested changes
Aug 18, 2026
RafaelJohn9
left a comment
Member
There was a problem hiding this comment.
Hello @watersRand , thanks for the awesome PR, a few changes to consider 🤝
RafaelJohn9
requested changes
Aug 31, 2026
Member
There was a problem hiding this comment.
Apologies for the late review. you can always tag me for a review, no worries 🤝 ,
Thanks for the changes and we have a few things to do before we become ready to merge.
- Remove the
environmentparameter across the Swap module since this is only used insidehttp_clientmodule. - We then update the stubs correctly.
- Then we wire in this service to client and async client see (https://github.com/Byte-Barn/mpesakit/blob/master/mpesakit/mpesa_client.py)
Then we will be good to go 👍
|
|
||
| http_client: HttpClient | ||
| token_manager: TokenManager | ||
| environment: Literal["sandbox", "production"] = "sandbox" |
Member
There was a problem hiding this comment.
We can deprecate the environment parameter that we have across the different swap files, since this is handled by our http client file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces the SIM Swap Detection Service (
/imsi/v2/checkATI) to support checking when a subscriber's SIM card was last swapped. This helps detect and mitigate account takeover and fraud risks prior to completing high-value transactions.Key changes included:
SwapServiceandAsyncSwapServicewithswap_query(customer_number)andswap_request(request)methods.SwapRequest(with MSISDN auto-normalization) andSwapResponsePydantic models.is_successfulandis_recently_swappedproperties toSwapResponseto handle Safaricom's sentinel non-swapped date (01-01-1900)..pyitype stubs, updateddocs/swap.md, and updated landing page status/feature data.Fixes #160
Type of Change
How Has This Been Tested?
SwapRequestphone number auto-normalization,SwapResponse.is_recently_swappedsentinel date evaluation (01-01-1900vs active timestamp), and sync/async service call execution.ruff checkand type assertions with.pyistub files to verify clean linting across the package.Checklist
Screenshots (if applicable)
N/A (Backend API addition & documentation update)
Additional Context
checkATI) is a paid API product on Safaricom Daraja. Documentation and docstrings reflect onboarding guidance for sandbox and production.