The Payment service provides a mock payment processing implementation for testing and development. It simulates payment intent round-trips with realistic latency and random failure scenarios.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Diego31-10/TableOrderApp/llms.txt
Use this file to discover all available pages before exploring further.
Types
PaymentResult
Discriminated union representing the outcome of a payment transaction.Payment transaction result
Functions
processMockPayment
Simulates a payment intent with realistic latency (2 seconds) and a 15% random failure rate.Payment amount in currency units (currently not validated, reserved for future use)
Payment outcome after 2-second delay
Example
Type guard usage
Behavior
Latency simulation
All payment requests include a 2-second delay (setTimeout) to simulate network round-trip and payment processor latency.
Failure simulation
The service has a 15% random failure rate (Math.random() > 0.15). Failed payments return the following Spanish error message:
This mock service is intended for development and testing only. Replace with a real payment processor (Stripe, PayPal, etc.) in production.
Production considerations
When replacing this service with a real payment processor:- Maintain the same
PaymentResulttype signature for minimal refactoring - Handle additional error cases (network failures, declined cards, etc.)
- Implement proper error logging and monitoring
- Add PCI compliance requirements
- Implement idempotency for retry scenarios