Add revenue lifecycle safeguards#11
Merged
Merged
Conversation
Implements TalerDriver as a first-class payment gateway option in the
Fleetbase Ledger module, following the existing driver-based architecture.
## What was added
### server/src/Gateways/TalerDriver.php
- Extends AbstractGatewayDriver and implements GatewayDriverInterface
- getCode(): 'taler'
- getName(): 'GNU Taler'
- getCapabilities(): ['purchase', 'refund', 'webhooks']
- getConfigSchema(): dynamic form fields for backend_url, instance_id,
api_token — rendered automatically by the Fleetbase gateway UI
- purchase(): POSTs to Taler Merchant Backend /private/orders, embeds
invoice_uuid in contract terms, returns GatewayResponse::pending()
with taler_pay_uri for wallet redirect
- handleWebhook(): receives order_id, re-queries private API to verify
payment status (prevents spoofing), returns GatewayResponse::success()
which triggers the existing HandleSuccessfulPayment listener
- refund(): POSTs to /private/orders/{order_id}/refund, returns
GatewayResponse::success() with EVENT_REFUND_PROCESSED
- toTalerAmount() / fromTalerAmount(): bidirectional conversion between
Fleetbase integer cents and Taler 'CURRENCY:UNITS.FRACTION' strings
### server/src/PaymentGatewayManager.php
- Added TalerDriver import
- Registered 'taler' in getRegisteredDriverCodes()
- Added createTalerDriver() factory method
### server/tests/Gateways/TalerDriverTest.php
- Full Pest test suite covering:
- Driver metadata (code, name, capabilities, config schema)
- purchase() happy path and failure paths
- handleWebhook() happy path, unpaid order, missing order_id
- refund() happy path and failure paths
- Amount conversion edge cases (zero, single-digit fraction)
## Integration notes
- Webhook route is automatically served at POST /ledger/webhooks/taler
by the existing WebhookController — no route changes needed
- All monetary values follow the Fleetbase standard: integers in the
smallest currency unit (cents), converted to/from Taler string format
- API token is stored encrypted via the existing Gateway model cast
- Sandbox mode is handled by pointing backend_url at a test instance
Refs: https://docs.taler.net/core/api-merchant.html
feat(ledger): add GNU Taler payment gateway driver
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.
Summary
Validation