feat: implement MonnifyGateway (Nigeria - bank transfer + card)#26
Conversation
|
Warning Review limit reached
More reviews will be available in 11 minutes and 16 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 pull request implements the Monnify payment gateway for Nigeria, adding configuration schemas, provider type enumeration, dependency injection wiring, a complete gateway implementation with payment creation/verification/refund operations, and updates to payment service routing for NGN currency and transaction reference detection. ChangesMonnify Payment Gateway
Sequence DiagramsequenceDiagram
participant Client
participant MonnifyGateway
participant MonnifyAPI as Monnify Auth/API
participant GatewayResponse as Response Handler
Client->>MonnifyGateway: CreatePaymentAsync(request)
MonnifyGateway->>MonnifyAPI: GetAccessTokenAsync via Basic-auth
MonnifyAPI-->>MonnifyGateway: accessToken
MonnifyGateway->>MonnifyAPI: POST /api/v1/transactions/init with token
MonnifyAPI-->>MonnifyGateway: checkoutUrl or error
MonnifyGateway->>GatewayResponse: parse responseBody and map to PaymentResponse
GatewayResponse-->>Client: PaymentResponse (pending + checkoutUrl)
Client->>MonnifyGateway: VerifyPaymentAsync(reference)
MonnifyGateway->>MonnifyAPI: GetAccessTokenAsync
MonnifyAPI-->>MonnifyGateway: accessToken
MonnifyGateway->>MonnifyAPI: GET /api/v1/transactions/query?reference
MonnifyAPI-->>MonnifyGateway: paymentStatus, amountPaid, completedOn, fee
GatewayResponse->>GatewayResponse: map Monnify status to internal PaymentStatus
GatewayResponse-->>Client: VerificationResponse with payment details
Client->>MonnifyGateway: RefundPaymentAsync(request)
MonnifyGateway->>MonnifyAPI: GetAccessTokenAsync
MonnifyAPI-->>MonnifyGateway: accessToken
MonnifyGateway->>MonnifyAPI: POST /api/v1/transactions/refunds with token
MonnifyAPI-->>MonnifyGateway: refundReference or error
GatewayResponse->>GatewayResponse: parse response and map to RefundResponse
GatewayResponse-->>Client: RefundResponse (refunded + RefundDate)
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly Related Issues
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.
Pull request overview
Implements a new Nigeria (NGN) payment option by adding a Monnify gateway and wiring it into gateway selection and registration so the SDK can initiate, verify, and refund Monnify transactions.
Changes:
- Added
Monnifyto the gateway enum/config and introduced a fullMonnifyGatewayimplementation (create/verify/refund). - Updated DI + factory wiring to include Monnify and updated NGN routing / reference-prefix detection to recognize Monnify and Flutterwave prefixes.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| PayBridge.SDK/Services/PaymentService.cs | Prefer Monnify for NGN and detect MNF_ / FLW_ prefixes. |
| PayBridge.SDK/Gateways/MonnifyGateway.cs | New Monnify gateway implementation (auth, create, verify, refund). |
| PayBridge.SDK/Factories/PaymentGatewayFactory.cs | Add Monnify to gateway initialization switch and allow null gateway resolution. |
| PayBridge.SDK/Externsions/IServiceCollectionExtensions.cs | Register Monnify in DI under enabled/all-gateways paths. |
| PayBridge.SDK/Enums/PaymentGatewayType.cs | Add Monnify = 7. |
| PayBridge.SDK/Dtos/PaymentGatewayConfig.cs | Add MonnifyConfig (ApiKey/SecretKey/ContractCode). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 135: Register MonnifyGateway under the IPaymentGateway service type so
PaymentService (which resolves IEnumerable<IPaymentGateway> into _gateways) will
include it; replace the concrete-only registration of MonnifyGateway
(services.AddScoped<MonnifyGateway>()) with a scoped registration that maps
IPaymentGateway to MonnifyGateway (or add an additional
AddScoped<IPaymentGateway, MonnifyGateway>() alongside the concrete
registration) for both places where MonnifyGateway is currently registered so it
appears in the resolved _gateways collection.
In `@PayBridge.SDK/Gateways/MonnifyGateway.cs`:
- Around line 29-31: The MonnifyGateway constructor is using
IOptions<PaymentGatewayConfig> which doesn't match how AddPayBridge registers a
singleton PaymentGatewayConfig; change the constructor signature to accept a
concrete PaymentGatewayConfig (replace IOptions<PaymentGatewayConfig> config
with PaymentGatewayConfig config) and assign _config = config so the runtime
config from AddPayBridge (and credentials set via configAction) are used; update
any references to config.Value accordingly and keep ILogger<MonnifyGateway>
logger and IHttpClientFactory unchanged.
- Line 65: The MonnifyGateway is currently logging the raw auth response via the
_logger.LogDebug("Monnify auth response: {Body}", body) call which can expose
sensitive tokens; update the MonnifyGateway to stop emitting the full response
body — either remove the LogDebug call or replace it with a safe, redacted log
that parses the response and omits or masks sensitive fields like
accessToken/refreshToken (e.g., log only status, expiry, or a boolean indicating
token presence) so the raw credentials are never 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: 79969f6e-217f-40f7-8840-006caa84c781
📒 Files selected for processing (6)
PayBridge.SDK/Dtos/PaymentGatewayConfig.csPayBridge.SDK/Enums/PaymentGatewayType.csPayBridge.SDK/Externsions/IServiceCollectionExtensions.csPayBridge.SDK/Factories/PaymentGatewayFactory.csPayBridge.SDK/Gateways/MonnifyGateway.csPayBridge.SDK/Services/PaymentService.cs
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>
Summary
Implements the Monnify payment gateway (by Moniepoint) for Nigeria NGN payments.
Changes
PaymentGatewayType.cs— addedMonnify = 7PaymentGatewayConfig.cs— addedMonnifyConfigwithApiKey,SecretKey,ContractCodeGateways/MonnifyGateway.cs— full implementation: create, verify, refundIServiceCollectionExtensions.cs— registeredMonnifyGatewayin DIPaymentGatewayFactory.cs— added Monnify to factory switch + nullable fixPaymentService.cs— NGN currency now prefers Monnify; addedMNF_prefix detectionHow it works
/api/v1/merchant/transactions/init-transaction/api/v2/merchant/transactions/query?paymentReference={ref}/api/v1/merchant/refunds/initiate-refundConfig (appsettings.json)
Closes #9
Summary by CodeRabbit