Skip to content

feat: implement PawaPay Gateway (Africa - mobile money)#33

Merged
teesofttech merged 1 commit into
masterfrom
feature/issue-15-pawapay-gateway
Jun 11, 2026
Merged

feat: implement PawaPay Gateway (Africa - mobile money)#33
teesofttech merged 1 commit into
masterfrom
feature/issue-15-pawapay-gateway

Conversation

@teesofttech

@teesofttech teesofttech commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Closes #15

Summary

Implements PawaPay payment gateway — Africa's leading mobile money aggregator.

Supported Currencies / Networks

Currency Country Provider
GHS Ghana MTN MoMo
TZS Tanzania Vodacom M-Pesa
UGX Uganda MTN MoMo
RWF Rwanda MTN MoMo
ZMW Zambia MTN MoMo
CDF DRC Airtel Money
XOF Ivory Coast Orange Money
XAF Cameroon MTN MoMo
MWK Malawi Airtel Money

Gateway Details

  • Enum value: PawaPay = 13
  • Tx ref prefix: PP_
  • Auth: Bearer token (ApiToken)
  • API: REST JSON (https://api.pawapay.io)
  • Correspondent: Auto-derived from currency; overridable via request metadata key pawapay_correspondent

Files Changed

  • PaymentGatewayType.cs — Added PawaPay = 13
  • PaymentGatewayConfig.cs — Added PawaPayConfig (ApiToken, IsSandbox)
  • PawaPayGateway.cs — New gateway (deposit/verify/refund via REST API)
  • PaymentGatewayFactory.cs — Registered PawaPay
  • IServiceCollectionExtensions.cs — DI registration in both enable-all and switch blocks
  • PaymentService.cs — Added GHS/TZS/UGX/RWF/ZMW/CDF/XOF/XAF/MWK routing to PawaPay; PP_ prefix detection

Summary by CodeRabbit

  • New Features
    • Integrated PawaPay as a new payment gateway with support for payment creation, transaction verification, and refund processing
    • Added PawaPay configuration options including API token authentication and sandbox/live environment modes
    • Enhanced payment routing to intelligently prioritize PawaPay across supported currencies and transaction scenarios

Copilot AI review requested due to automatic review settings June 10, 2026 18:48
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds complete support for the PawaPay payment gateway, an Africa-wide mobile money aggregator covering 30+ countries. It introduces configuration DTOs, gateway implementation with deposit/refund/verification flows, DI wiring, factory integration, and payment service routing to detect and select the gateway.

Changes

PawaPay Gateway Integration

Layer / File(s) Summary
Configuration and enum setup
PayBridge.SDK/Dtos/PaymentGatewayConfig.cs, PayBridge.SDK/Enums/PaymentGatewayType.cs
PawaPayConfig DTO defines API token and sandbox mode flag; PaymentGatewayType enum adds PawaPay = 14 provider value.
PawaPayGateway core implementation
PayBridge.SDK/Gateways/PawaPayGateway.cs
Implements IPaymentGateway with CreatePaymentAsync (POST /deposits), VerifyPaymentAsync (GET /deposits/{id}), and RefundPaymentAsync (POST /refunds), handling bearer auth, status mapping (COMPLETED, FAILED, TIMED_OUT, REJECTED), correspondent code selection by currency, and exception wrapping.
Dependency injection and factory wiring
PayBridge.SDK/Externsions/IServiceCollectionExtensions.cs, PayBridge.SDK/Factories/PaymentGatewayFactory.cs
RegisterGateways adds PawaPayGateway to both auto-enable and explicit switch cases; PaymentGatewayFactory resolves PawaPayGateway from DI container in auto-enable and TryAddGateway paths.
Payment service routing and detection
PayBridge.SDK/Services/PaymentService.cs
SelectBestGateway includes PawaPay in preferred-gateway lists for targeted currency groups; DetermineGatewayFromReference recognizes PP_ transaction prefix to route to PawaPay.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • teesofttech/PayBridge#26: Both PRs wire up a new payment gateway by extending the same gateway infrastructure (updating PaymentGatewayType, DI registration in IServiceCollectionExtensions, factory resolution in PaymentGatewayFactory, and routing/inference logic in PaymentService), though for different gateways (PawaPay vs Monnify).
  • teesofttech/PayBridge#28: Both PRs modify the shared gateway plumbing (e.g., PaymentGatewayType, PaymentGatewayConfig, RegisterGateways, PaymentGatewayFactory switch, and PaymentService routing/detection) to wire in a new payment provider gateway type—main adds PawaPay, retrieved adds Interswitch.
  • teesofttech/PayBridge#30: Both PRs extend the shared gateway plumbing (PaymentGatewayConfig/PaymentGatewayType, DI registration in IServiceCollectionExtensions, resolution in PaymentGatewayFactory, and routing/prefix detection in PaymentService) to add a new gateway—main adds PawaPay while the retrieved PR adds Opay—so they touch the same integration paths.

Poem

🐰 A gateway named PawaPay now hops into the fold,
Africa's mobile money, precious as gold!
Deposits and refunds across thirty lands,
Correspondent codes mapped by currency's hands.
Bearer tokens and bearer threads weave the dance—
Another payment provider joins the finance trance!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: implementing a new PawaPay payment gateway for Africa mobile money.
Linked Issues check ✅ Passed All requirements from issue #15 are met: PawaPayGateway implementation added with deposit/verification/refund flows, PawaPay API integration with bearer token auth, configuration and registration completed.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing PawaPay gateway support; no unrelated modifications detected across DTO, enum, factory, DI, gateway, and service files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/issue-15-pawapay-gateway

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Pull request overview

Adds a new PawaPay payment gateway integration to the PayBridge SDK, wiring it into gateway selection, DI registration, and reference-prefix detection so mobile-money payments can be routed through PawaPay for supported African markets/currencies.

Changes:

  • Introduces PawaPayGateway implementing deposit/verify/refund via PawaPay REST API.
  • Adds PawaPay to gateway enums/config and registers it in the factory + DI extensions.
  • Updates PaymentService to route additional currencies to PawaPay and detect PP_ transaction references.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
PayBridge.SDK/Services/PaymentService.cs Routes a set of currencies to PawaPay and adds PP_ prefix detection.
PayBridge.SDK/Gateways/PawaPayGateway.cs New gateway implementation for create/verify/refund with correspondent derivation.
PayBridge.SDK/Factories/PaymentGatewayFactory.cs Registers PawaPay in gateway creation/lookup.
PayBridge.SDK/Externsions/IServiceCollectionExtensions.cs Adds DI registration for PawaPayGateway.
PayBridge.SDK/Enums/PaymentGatewayType.cs Adds PawaPay = 13.
PayBridge.SDK/Dtos/PaymentGatewayConfig.cs Adds PawaPayConfig (ApiToken/IsSandbox).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 254 to 266
case "KES":
case "GHS":
case "UGX":
case "TZS":
case "ZAR":
return ChooseAvailableGateway(PaymentGatewayType.Flutterwave, PaymentGatewayType.Paystack);
case "RWF":
case "ZMW":
case "CDF":
case "XOF":
case "XAF":
case "MWK":
return ChooseAvailableGateway(PaymentGatewayType.PawaPay, PaymentGatewayType.Flutterwave, PaymentGatewayType.Paystack);

Comment on lines +163 to +167
// Response is an array with one element
using var doc = JsonDocument.Parse(responseBody);
var root = doc.RootElement.ValueKind == JsonValueKind.Array
? doc.RootElement[0]
: doc.RootElement;
Comment on lines +220 to +227
var response = await _httpClient.PostAsync($"{BaseUrl}/refunds", content);
var responseBody = await response.Content.ReadAsStringAsync();
_logger.LogDebug("PawaPay refund response: {Body}", responseBody);

var doc = JsonDocument.Parse(responseBody);
var root = doc.RootElement;
var status = root.TryGetProperty("status", out var st) ? st.GetString() : null;
var isSuccess = response.IsSuccessStatusCode && status != "REJECTED";
Comment on lines +61 to +64
// PawaPay requires a correspondent (mobile money provider code) and phone number.
// Phone number is expected in request.CustomerPhone in international format (e.g. 233XXXXXXXXX)
var phone = request.CustomerPhone ?? string.Empty;

Comment on lines 137 to 141
services.AddScoped<InterswitchGateway>();
services.AddScoped<RemitaGateway>();
services.AddScoped<OpayGateway>();
services.AddScoped<PawaPayGateway>();
return;
Comment on lines +186 to +188
case PaymentGatewayType.PawaPay:
services.AddScoped<PawaPayGateway>();
break;
@teesofttech
teesofttech force-pushed the feature/issue-15-pawapay-gateway branch from 29ce591 to 3054d53 Compare June 11, 2026 12:45
@teesofttech
teesofttech merged commit bea483c into master Jun 11, 2026
1 of 2 checks 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.

feat: implement PawapayGateway (Africa - mobile money aggregator, 30+ countries)

2 participants