Skip to content

Add revenue lifecycle safeguards#11

Merged
roncodes merged 11 commits into
mainfrom
dev-v0.0.6
Jun 23, 2026
Merged

Add revenue lifecycle safeguards#11
roncodes merged 11 commits into
mainfrom
dev-v0.0.6

Conversation

@roncodes

Copy link
Copy Markdown
Member

Summary

  • Add a Ledger revenue lifecycle service for order cancellation, order deletion, invoice deletion, restore handling, transaction voiding, paid-invoice review metadata, and reversal journal creation.
  • Keep order and invoice observers thin by delegating lifecycle behavior to the shared service.
  • Add a dry-run-first repair command for inactive orders, deleted or inactive invoices, and missing revenue recognition reversals.
  • Add source-contract coverage for the lifecycle delegation and repair command registration.

Validation

  • PHP syntax checks passed for the touched Ledger service, command, observer, provider, and test files.
  • Cached diff whitespace check passed.
  • Local Pest/PHPUnit execution was blocked by missing or mismatched server test dependencies.

roncodes and others added 9 commits March 30, 2026 04:17
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
@roncodes roncodes marked this pull request as ready for review June 23, 2026 11:40
@roncodes roncodes merged commit 3d9b769 into main Jun 23, 2026
7 checks passed
@roncodes roncodes deleted the dev-v0.0.6 branch June 23, 2026 15:42
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.

1 participant