feat: implement DPO Group Gateway (Africa - 19+ countries)#32
Conversation
|
Warning Review limit reached
More reviews will be available in 21 minutes and 20 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR implements DPO Group as a new payment gateway supporting card and mobile money transactions across 45+ African countries. The change adds configuration schema, a complete gateway implementation with XML-based API communication, dependency injection wiring, and payment routing logic. ChangesDPO Group Gateway Integration
Sequence Diagram(s)sequenceDiagram
participant Client
participant PaymentService
participant DpoGroupGateway
participant DpoAPI
Client->>PaymentService: CreatePaymentAsync(request)
PaymentService->>DpoGroupGateway: CreatePaymentAsync(request)
DpoGroupGateway->>DpoAPI: POST /createToken (XML)
DpoAPI-->>DpoGroupGateway: XML response with Result + TransToken
DpoGroupGateway->>DpoGroupGateway: Parse XML, map Result to PaymentStatus
DpoGroupGateway-->>PaymentService: PaymentResponse with checkoutUrl
PaymentService-->>Client: checkoutUrl
Client->>PaymentService: VerifyPaymentAsync(transactionReference)
PaymentService->>DpoGroupGateway: VerifyPaymentAsync(transactionReference)
DpoGroupGateway->>DpoAPI: POST /verifyToken (XML)
DpoAPI-->>DpoGroupGateway: XML response with customer + amount + status
DpoGroupGateway->>DpoGroupGateway: Parse XML, map result code to PaymentStatus
DpoGroupGateway-->>PaymentService: VerificationResponse
PaymentService-->>Client: PaymentStatus
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 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.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@PayBridge.SDK/Externsions/IServiceCollectionExtensions.cs`:
- Line 140: The DI registration currently only adds the concrete DpoGroupGateway
type, so it won’t be discovered by PaymentService which consumes
IEnumerable<IPaymentGateway>; update IServiceCollectionExtensions to register
DpoGroupGateway as an implementation of IPaymentGateway (e.g.,
AddScoped<IPaymentGateway, DpoGroupGateway> or add that alongside the existing
registration) and apply the same pattern for the other gateway registrations
around the 186-188 block so all gateway classes are registered as
IPaymentGateway implementations.
In `@PayBridge.SDK/Gateways/DpoGroupGateway.cs`:
- Around line 100-107: The gateway is returning txRef (DPO_...) but the
verification flow expects the token under <TransactionToken>, causing mismatched
identifiers; update the payment creation response in DpoGroupGateway so
PaymentResponse.TransactionReference is set to transToken (the TransToken value
used to build checkoutUrl) rather than txRef, and ensure any other returns or
logs in this class (references to txRef around the other return block)
consistently use transToken so the verification method that reads
<TransactionToken> will match the original TransactionReference.
- Around line 79-85: Current debug logs call _logger.LogDebug with raw xmlString
and responseBody around the DPO request/response (the PostAsync(ApiUrl, content)
flow), which can leak CompanyToken, customer email, and transaction tokens;
replace these direct logs with sanitized outputs by creating and using a masker
(e.g., a MaskSensitiveFields helper that strips or redacts CompanyToken, email,
transaction/token elements/attributes) and log the maskedXml and maskedResponse
instead, or log only non-sensitive metadata (status code, correlation id,
truncated length). Apply the same replacement wherever _logger.LogDebug("DPO
createToken request...") / LogDebug("DPO createToken response...") appear (and
the other occurrences noted) so no raw payload is written to logs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 01a5c94c-7c5c-4119-8a45-355114287d4c
📒 Files selected for processing (6)
PayBridge.SDK/Dtos/PaymentGatewayConfig.csPayBridge.SDK/Enums/PaymentGatewayType.csPayBridge.SDK/Externsions/IServiceCollectionExtensions.csPayBridge.SDK/Factories/PaymentGatewayFactory.csPayBridge.SDK/Gateways/DpoGroupGateway.csPayBridge.SDK/Services/PaymentService.cs
There was a problem hiding this comment.
Pull request overview
This PR adds a new DPO Group payment gateway implementation to the SDK and wires it into gateway selection, configuration, and DI so PayBridge can initiate/verify/refund payments via DPO’s XML API.
Changes:
- Added
PaymentGatewayType.DpoGroup = 13and a newDpoGroupConfigsection (CompanyToken,PaymentCurrency,IsSandbox). - Implemented
DpoGroupGatewaywith create/verify/refund flows against the XML API. - Updated factory/DI registration and currency-based routing + reference-prefix detection to route supported currencies to DPO.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| PayBridge.SDK/Services/PaymentService.cs | Routes select African currencies to DPO and detects DPO_ reference prefix. |
| PayBridge.SDK/Gateways/DpoGroupGateway.cs | Implements DPO create/verify/refund using XML API calls. |
| PayBridge.SDK/Factories/PaymentGatewayFactory.cs | Adds DPO gateway creation via the factory. |
| PayBridge.SDK/Externsions/IServiceCollectionExtensions.cs | Registers DpoGroupGateway in DI for enable-all and enabled-gateways paths. |
| PayBridge.SDK/Enums/PaymentGatewayType.cs | Adds the DpoGroup enum value. |
| PayBridge.SDK/Dtos/PaymentGatewayConfig.cs | Adds DpoGroupConfig into the main config model. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var response = await _httpClient.PostAsync(ApiUrl, content); | ||
| var responseBody = await response.Content.ReadAsStringAsync(); | ||
| _logger.LogDebug("DPO createToken response: {Body}", responseBody); | ||
|
|
| return new VerificationResponse | ||
| { | ||
| Success = result == "000", | ||
| TransactionReference = companyRef, | ||
| Amount = transactionAmount, |
| new XElement("CompanyToken", _config.DpoGroup.CompanyToken), | ||
| new XElement("Request", "refundToken"), | ||
| new XElement("TransactionToken", request.TransactionReference), | ||
| new XElement("refundAmount", request.Amount.ToString("F2")), |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Closes #14
Summary
Implements DPO Group payment gateway — a pan-African payment provider supporting 19+ countries.
Supported Currencies
KES, GHS, UGX, TZS, ZAR, RWF, USD, EUR and more
Gateway Details
DpoGroup = 13DPO_https://secure.3gdirectpay.com/API/v6/)IsSandboxflagFiles Changed
PaymentGatewayType.cs— AddedDpoGroup = 13PaymentGatewayConfig.cs— AddedDpoGroupConfigwithCompanyToken,PaymentCurrency,IsSandboxDpoGroupGateway.cs— New gateway (create/verify/refund via XML API)PaymentGatewayFactory.cs— Registered DpoGroupIServiceCollectionExtensions.cs— DI registration in both enable-all and switch blocksPaymentService.cs— Added KES/GHS/UGX/TZS/ZAR/RWF routing to DPO;DPO_prefix detectionSummary by CodeRabbit