Mock Paystack DVA Repayment Flow for Driver Hire Purchase (#24)#40
Open
mimijuwonlo-commits wants to merge 1 commit into
Open
Conversation
Collaborator
|
@mimijuwonlo-commits great work, can you show the output of your changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mock Paystack DVA Repayment Flow for Driver Hire Purchase (#24)
Summary
This PR introduces a mock Paystack Dedicated Virtual Account (DVA) repayment flow to support local development and testing without requiring live Paystack credentials or API access.
When
ENABLE_MOCK_PAYMENTS=true, DVA provisioning bypasses Paystack entirely and returns deterministic, clearly identifiable test account details. The Driver Repayment Center also exposes a local-only simulator that allows developers and QA to create mock repayments using the existing repayment processing workflow.Changes
New Files
lib/services/paystack-mock.service.tsisMockPaymentsEnabled()isMockPaymentsRuntimeAllowed()createMockDriverDvaDetails()createMockDvaRepaymentReference()buildMockDedicatedNubanWebhookPayload()app/api/driver/payments/mock-repay/route.tsDevelopment/test-only endpoint for simulating incoming DVA transfers
Disabled in production
components/dashboard/driver-hire-purchase/mock-repayment-simulator.tsxUI component for triggering mock repayments from the Repayment Center
lib/services/__tests__/paystack-mock.service.test.tsUnit tests covering mock account generation, references, runtime guards, and webhook payload creation
Updated Files
lib/services/paystack-dva.service.tsShort-circuits to mock DVA provisioning when mock payments are enabled
Adds
isMockandmockReferencemetadata to account snapshotsapp/api/driver/virtual-account/route.tsReturns mock metadata in API responses
app/dashboard/driver/repayment/page.tsxDisplays mock account indicators and simulator UI
driver-virtual-account-card.tsxAdds mock account badges and test-only messaging
.env.exampleDocuments
ENABLE_MOCK_PAYMENTSCONTRIBUTING.mdAdds setup and usage instructions for mock payment testing
How It Works
Mock DVA Provisioning
When:
the application:
Skips all Paystack DVA provisioning requests
Does not require
PAYSTACK_SECRET_KEYReturns deterministic mock account details
Marks generated accounts as mock/test-only
Example:
Bank:
Mock Test BankProvider:
mock-paystackAccount Number:
0000xxxxxxMock Repayment Simulation
The Repayment Center displays:
Mock Test Account badge
Mock account details
Test-only alert messaging
Simulate Mock Transfer action
Submitting a simulated repayment processes the payment through the existing repayment workflow:
createAndConfirmDriverTransferPayment()confirmDriverPayment()This ensures repayment behavior remains consistent with production processing logic.
Security
Mock functionality is restricted through multiple safeguards:
Mock repayment endpoint requires:
ENABLE_MOCK_PAYMENTS=trueNODE_ENV !== "production"Mock account payloads are explicitly tagged:
Production Paystack behavior remains unchanged when the feature flag is disabled.
Testing
Unit Tests
Added 5 unit tests covering:
Mock enablement checks
Runtime restrictions
Deterministic account generation
Reference generation
Webhook payload creation
All new tests are passing.
Manual Testing
Add to
.env.local:Start the application.
Navigate to:
Verify:
Mock Test Account badge is displayed
Bank name is
Mock Test BankAccount number begins with
0000Simulate Mock Transfer button is visible
Submit a mock repayment and verify the repayment is recorded and applied to the contract balance.
Acceptance Criteria
Criterion | Status -- | -- Driver repayment account works in mock mode | ✅ No real Paystack API calls when mock mode is enabled | ✅ Mock account details are clearly identifiable | ✅ Existing Paystack flow unchanged when mock mode is disabled | ✅Notes
New files are lint-clean.
Unit tests pass.
Existing repository lint/typecheck/build issues are pre-existing and unrelated to this change.
close #24