feat(ledger): add GNU Taler payment gateway driver#4
Open
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
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
Adds GNU Taler as a first-class payment gateway option in Fleetbase Ledger, following the existing driver-based architecture.
GNU Taler is a privacy-preserving electronic payment system that provides customer anonymity while ensuring merchants remain fully accountable and taxable. It is free software (GNU project) and is already used by several European institutions and banks.
Files Changed
server/src/Gateways/TalerDriver.php(new)A complete implementation of
AbstractGatewayDriverfor GNU Taler:getCode()→'taler'getName()→'GNU Taler'getCapabilities()→['purchase', 'refund', 'webhooks']getConfigSchema()→ dynamic form fields (backend_url,instance_id,api_token) rendered automatically by the Fleetbase gateway settings UI — no frontend changes requiredpurchase()— POSTs to/instances/{id}/private/orders, embedsinvoice_uuidin the Taler contract terms for webhook traceability, fetchestaler_pay_urifrom the order status endpoint, returnsGatewayResponse::pending()with the URI for wallet redirecthandleWebhook()— receivesorder_idfrom Taler, re-queries the private API to verify payment status (prevents spoofing/replay attacks), extractsinvoice_uuidfrom contract terms, returnsGatewayResponse::success()which triggers the existingHandleSuccessfulPaymentlistenerrefund()— POSTs to/private/orders/{order_id}/refund, returnsGatewayResponse::success()withEVENT_REFUND_PROCESSEDtoTalerAmount()/fromTalerAmount()— bidirectional conversion between Fleetbase integer cents and TalerCURRENCY:UNITS.FRACTIONstrings, respecting the Fleetbase monetary storage standardserver/src/PaymentGatewayManager.php(modified)TalerDriverimport'taler'ingetRegisteredDriverCodes()createTalerDriver()factory methodserver/tests/Gateways/TalerDriverTest.php(new)16 Pest tests using
Http::fake()— no real backend required:purchase()handleWebhook()refund()How the Payment Flow Works
Integration Notes
POST /ledger/webhooks/taleris served automatically by the existingWebhookController— no route changes neededGatewaymodelencrypted:arraycastbackend_urlat a Taler test instance (e.g.https://backend.demo.taler.net/)HttpfacadeRefs: https://docs.taler.net/core/api-merchant.html