Skip to content

feat: implement DPO Group Gateway (Africa - 19+ countries)#32

Merged
teesofttech merged 8 commits into
masterfrom
feature/issue-14-dpo-gateway
Jun 10, 2026
Merged

feat: implement DPO Group Gateway (Africa - 19+ countries)#32
teesofttech merged 8 commits into
masterfrom
feature/issue-14-dpo-gateway

Conversation

@teesofttech

@teesofttech teesofttech commented Jun 10, 2026

Copy link
Copy Markdown
Owner

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

  • Enum value: DpoGroup = 13
  • Tx ref prefix: DPO_
  • API: XML-based API v6 (https://secure.3gdirectpay.com/API/v6/)
  • Auth: CompanyToken in XML request body
  • Sandbox: Configurable via IsSandbox flag

Files Changed

  • PaymentGatewayType.cs — Added DpoGroup = 13
  • PaymentGatewayConfig.cs — Added DpoGroupConfig with CompanyToken, PaymentCurrency, IsSandbox
  • DpoGroupGateway.cs — New gateway (create/verify/refund via XML API)
  • PaymentGatewayFactory.cs — Registered DpoGroup
  • IServiceCollectionExtensions.cs — DI registration in both enable-all and switch blocks
  • PaymentService.cs — Added KES/GHS/UGX/TZS/ZAR/RWF routing to DPO; DPO_ prefix detection

Summary by CodeRabbit

  • New Features
    • Added DPO Group as a new payment gateway provider with support for payment creation, transaction verification, and refunds
    • Introduced sandbox mode configuration for testing and evaluation
    • Extended currency support to include RWF
    • Enhanced automatic gateway selection logic to optimize transaction routing

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

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@teesofttech, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2d4a4207-ae65-44b1-a721-821c44c02cd9

📥 Commits

Reviewing files that changed from the base of the PR and between 3ac13ca and fb8f449.

📒 Files selected for processing (2)
  • PayBridge.SDK/Externsions/IServiceCollectionExtensions.cs
  • PayBridge.SDK/Gateways/DpoGroupGateway.cs
📝 Walkthrough

Walkthrough

This 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.

Changes

DPO Group Gateway Integration

Layer / File(s) Summary
Configuration schema and gateway type enum
PayBridge.SDK/Dtos/PaymentGatewayConfig.cs, PayBridge.SDK/Enums/PaymentGatewayType.cs
DpoGroupConfig DTO defines CompanyToken, PaymentCurrency (default "USD"), and IsSandbox (default false). PaymentGatewayType enum adds DpoGroup = 13 member and updates Opay = 12.
DPO Group gateway implementation
PayBridge.SDK/Gateways/DpoGroupGateway.cs
DpoGroupGateway implements IPaymentGateway with XML request/response handling for DPO API endpoints. CreatePaymentAsync generates token requests and parses checkout URLs. VerifyPaymentAsync queries transaction status and extracts customer/amount data. RefundPaymentAsync processes refunds via XML. Result codes map to internal PaymentStatus enum values; exceptions are wrapped in PaymentGatewayException with debug logging.
Dependency injection and factory registration
PayBridge.SDK/Externsions/IServiceCollectionExtensions.cs, PayBridge.SDK/Factories/PaymentGatewayFactory.cs
DpoGroupGateway is added to the default gateway list in RegisterGateways and gains explicit switch-case support. PaymentGatewayFactory.CreateGateways and TryAddGateway extend instantiation logic to resolve and register DpoGroupGateway alongside other payment gateways.
Payment service gateway selection and routing
PayBridge.SDK/Services/PaymentService.cs
SelectBestGateway adds RWF currency support and prioritizes DpoGroup in the multi-currency preferred gateway list ahead of Flutterwave and Paystack. DetermineGatewayFromReference recognizes transaction references starting with DPO_ prefix and routes them to PaymentGatewayType.DpoGroup.

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
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • teesofttech/PayBridge#27: Both PRs extend the same gateway-integration flow—updating PaymentGatewayType, DI registration, and PaymentService routing to add a new gateway type via transaction-reference prefixes and preferred-currency logic.
  • teesofttech/PayBridge#26: Both PRs wire a new gateway through the same plumbing points: PaymentGatewayConfig, IServiceCollectionExtensions.RegisterGateways, PaymentGatewayFactory.TryAddGateway, and PaymentService prefix/currency-based routing.
  • teesofttech/PayBridge#28: Both PRs extend the same gateway registration and selection pipeline by adding PaymentGatewayType enum members and updating DI/factory/service integration for new gateway providers.

Poem

🐰 A gateway hops across Africa's plains,
XML requests through DPO's domain,
From tokens to payments, refunds align,
Forty-five countries now in the line!
Mobile and cards dance in perfect time. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% 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 summarizes the main change: implementing DPO Group Gateway with geographic scope (Africa - 19+ countries).
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #14: DpoGroupGateway class, pan-African payment support, XML API integration, and multi-method payments.
Out of Scope Changes check ✅ Passed All code changes directly support DPO Group gateway implementation; no unrelated modifications detected in configuration, enums, factories, or routing.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/issue-14-dpo-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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 546368b and 3ac13ca.

📒 Files selected for processing (6)
  • PayBridge.SDK/Dtos/PaymentGatewayConfig.cs
  • PayBridge.SDK/Enums/PaymentGatewayType.cs
  • PayBridge.SDK/Externsions/IServiceCollectionExtensions.cs
  • PayBridge.SDK/Factories/PaymentGatewayFactory.cs
  • PayBridge.SDK/Gateways/DpoGroupGateway.cs
  • PayBridge.SDK/Services/PaymentService.cs

Comment thread PayBridge.SDK/Externsions/IServiceCollectionExtensions.cs Outdated
Comment thread PayBridge.SDK/Gateways/DpoGroupGateway.cs Outdated
Comment thread PayBridge.SDK/Gateways/DpoGroupGateway.cs

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

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 = 13 and a new DpoGroupConfig section (CompanyToken, PaymentCurrency, IsSandbox).
  • Implemented DpoGroupGateway with 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.

Comment thread PayBridge.SDK/Externsions/IServiceCollectionExtensions.cs Outdated
Comment thread PayBridge.SDK/Externsions/IServiceCollectionExtensions.cs
Comment thread PayBridge.SDK/Gateways/DpoGroupGateway.cs Outdated
Comment on lines +82 to +85
var response = await _httpClient.PostAsync(ApiUrl, content);
var responseBody = await response.Content.ReadAsStringAsync();
_logger.LogDebug("DPO createToken response: {Body}", responseBody);

Comment thread PayBridge.SDK/Gateways/DpoGroupGateway.cs Outdated
Comment thread PayBridge.SDK/Gateways/DpoGroupGateway.cs
Comment on lines +163 to +167
return new VerificationResponse
{
Success = result == "000",
TransactionReference = companyRef,
Amount = transactionAmount,
Comment thread PayBridge.SDK/Gateways/DpoGroupGateway.cs Outdated
Comment thread PayBridge.SDK/Gateways/DpoGroupGateway.cs Outdated
new XElement("CompanyToken", _config.DpoGroup.CompanyToken),
new XElement("Request", "refundToken"),
new XElement("TransactionToken", request.TransactionReference),
new XElement("refundAmount", request.Amount.ToString("F2")),
teesofttech and others added 7 commits June 10, 2026 19:45
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>
@teesofttech
teesofttech merged commit fbdc991 into master Jun 10, 2026
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 DPOGroupGateway (Pan-Africa - 45+ countries, cards + mobile money)

2 participants