Skip to content

fix(sdk): critical bug fixes, adapter standardisation, test revival & full documentation rewrite#61

Merged
Wgoeh merged 27 commits into
masterfrom
dev.fixes
Jul 4, 2026
Merged

fix(sdk): critical bug fixes, adapter standardisation, test revival & full documentation rewrite#61
Wgoeh merged 27 commits into
masterfrom
dev.fixes

Conversation

@Einswilli

Copy link
Copy Markdown
Collaborator

Description

This PR addresses the major gaps identified in the EasySwitch SDK codebase — from critical runtime bugs to incomplete provider implementations and outdated documentation. 38 commits, 46 tests passing.


Critical Fixes (Phase 1)

  • Provider enum: Added missing providers (Paystack, MTN, Airtel Money, QosPay, PayPlus, KkiaPay, PayDunya) and 10 missing currencies (UGX, TZS, KES, etc.)
  • Semoa adapter: Complete rewrite — was broken due to all() misuse (passed multiple args instead of iterable), private _validate_credentials (abstract method not implemented), sync/async mismatch, missing @register() decorator, cancel_transaction returning super().send_payment() nonsense
  • MTN adapter: Complete rewrite — was using legacy Config class, incompatible send_payment signature (kwargs instead of TransactionDetail), treating HTTPResponse objects as raw dicts, no registry registration
  • Paystack validate_webhook: Signature was incompatible with BaseAdapter (accepted raw_body: bytes instead of payload: Dict)
  • Bizao webhooks: validate_webhook/parse_webhook were delegating to abstract super() — guaranteed TypeError at runtime
  • Empty stubs: QosPay, PayPlus, KkiaPay, PayDunya, adapters/interfaces.py — all 0-byte files replaced with proper implementations or removed

Standardisation (Phase 2)

  • All adapters now use async with self.get_client() as client: consistently
  • response.status_coderesponse.status throughout (PayGate, Semoa)
  • All validate_webhook implementations return bool (not raise AuthenticationError)
  • Added **kwargs to EasySwitchError base so UnsupportedOperationError(provider=...) works everywhere
  • Normalised HTTPResponse.data access (removed dead hasattr(response, "json") branches)

Core Infrastructure (Phase 3)

  • Removed legacy Config dataclass (was unused, replaced by Pydantic RootConfig)
  • Fixed EnvConfigSource — lowercase provider keys and double-underscore _X_ prefix causing config validation failures
  • Activated MAX_AMOUNT validation in BaseAdapter.validate_transaction
  • Fixed validate_webhook_signature in validators (used repr() instead of json.dumps() — non-deterministic)
  • Fixed phone number validation (double-zero prefix case like 00228...)
  • Fixed RateLimitError passing unsupported headers= kwarg
  • Added environment/timeout back to RootConfig as top-level globals

Tests (Phase 4)

  • Zero → 46 passing tests across all 4 test files
  • Fixed all mock patterns to properly patch get_client() with async context managers
  • Fixed all assertions to use Provider/TransactionStatus enums instead of raw strings
  • Fixed config fixtures to match RootConfig schema (uppercase provider keys, no extra fields)
  • Fixed asyncio.run() conflict in async test context

Documentation (Phase 5)

  • Full guides for CinetPay, Semoa, Bizao (were just # Under development)
  • New guides for Paystack, MTN MoMo, Airtel Money
  • Provider Feature Matrix — operations, currencies, flows, rate limits across all 8 providers
  • Rewritten home page with provider ecosystem grid
  • Updated all API reference pages to match current code signatures and enums
  • Fixed FedaPay examples (was using asyncio.run() inline — bad practice)
  • Fixed PayGate guide (wrong env var names, missing webhooks section)
  • Updated mkdocs.yml navigation with all providers
  • Normalised .env.sample with all providers and fixed EVIRONMENT typos

Einswilli added 27 commits July 4, 2026 12:47
…osPay, PayPlus, PayDunya) and currencies (UGX, TZS, KES, RWF, ZMW, MWK, BIF, ETB, BWP, ZWL)
…ials signature with all implementations, add TransactionStatusResponse import
… TransactionStatus.PENDING enum instead of raw string
…ting to abstract super, causing crash); remove debug print
…lidate_credentials private, all() misuse, sync/async mix, response.status_code, cancel_transaction nonsense return, missing abstract methods
… ProviderConfig, TransactionDetail signature, HTTPResponse.data, all abstract methods implemented
…h self.get_client), replace status_code -> status, fix validate_webhook raises -> return False, fix transaction_type class -> enum instance
…erationError; accept **kwargs in base EasySwitchError and add provider param to UnsupportedOperationError
… hasattr/json branch), fix status .value -> enum in airtel
… AuthenticationError (consistent with BaseAdapter contract)
… repr (deterministic), fix phone number double-zero prefix handling
…timize sanitize_logs precompute; exceptions.py - ValidationError code not hardcoded; base.py - activate MAX_AMOUNT validation
…a (uppercase provider keys, default_currency, _X_ prefix fix), fix client.py add_source kwargs, fix test_client.py assertions and remove await on sync methods
…ontext=None, fix paystack tests for new validate_webhook signature and response.data
…ttern, webhook payload fields; fix cinetpay parse_webhook missing status; fix phone cleanup
…ent, fix webhook/status fields, ValidationError instead of ValueError)
…add provider feature matrix; rewrite home page with provider ecosystem grid; update mkdocs.yml navigation
…y/semoa/bizao guides, fix paygate guide, update api-reference with correct enums/signatures, fix fedapay asyncio example, update contributing guide

@Wgoeh Wgoeh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great thanks!

@Wgoeh Wgoeh merged commit 39173f0 into master Jul 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants