feat: implement PawaPay Gateway (Africa - mobile money)#33
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis 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. ChangesPawaPay Gateway Integration
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
PawaPayGatewayimplementing deposit/verify/refund via PawaPay REST API. - Adds
PawaPayto gateway enums/config and registers it in the factory + DI extensions. - Updates
PaymentServiceto route additional currencies to PawaPay and detectPP_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.
| 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); | ||
|
|
| // 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; |
| 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"; |
| // 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; | ||
|
|
| services.AddScoped<InterswitchGateway>(); | ||
| services.AddScoped<RemitaGateway>(); | ||
| services.AddScoped<OpayGateway>(); | ||
| services.AddScoped<PawaPayGateway>(); | ||
| return; |
| case PaymentGatewayType.PawaPay: | ||
| services.AddScoped<PawaPayGateway>(); | ||
| break; |
29ce591 to
3054d53
Compare
Closes #15
Summary
Implements PawaPay payment gateway — Africa's leading mobile money aggregator.
Supported Currencies / Networks
Gateway Details
PawaPay = 13PP_ApiToken)https://api.pawapay.io)pawapay_correspondentFiles Changed
PaymentGatewayType.cs— AddedPawaPay = 13PaymentGatewayConfig.cs— AddedPawaPayConfig(ApiToken,IsSandbox)PawaPayGateway.cs— New gateway (deposit/verify/refund via REST API)PaymentGatewayFactory.cs— Registered PawaPayIServiceCollectionExtensions.cs— DI registration in both enable-all and switch blocksPaymentService.cs— Added GHS/TZS/UGX/RWF/ZMW/CDF/XOF/XAF/MWK routing to PawaPay;PP_prefix detectionSummary by CodeRabbit