Overview
The PaymentFailed event is emitted when a payment attempt fails for any reason. This event is consumed by various services to handle payment failures appropriately.
Consumers
This event is consumed by:
- BillingService (Subscriptions Domain) - To handle subscription payment failures
- OrdersService (Orders Domain) - To handle order payment failures
- NotificationService (Orders Domain) - To notify customers of payment failures
Failure Reasons
Common failure reasons include:
- insufficient_funds - Card has insufficient funds
- card_declined - Card was declined by issuer
- expired_card - Card has expired
- fraud_suspected - Payment flagged as potentially fraudulent
- network_error - Payment gateway network error
- invalid_payment_method - Payment method is invalid
Schema
Example Payload
{ "paymentId": "pay_123456", "amount": 49.99, "currency": "USD", "failureReason": "insufficient_funds", "failureMessage": "Your card has insufficient funds", "metadata": { "subscriptionId": "sub_ABC123", "invoiceId": "inv_123456", "customerId": "cust_XYZ789" }, "canRetry": true, "nextRetryAt": "2024-02-02T00:00:00Z", "timestamp": "2024-02-01T10:30:00Z"} Event-driven architecture documentation: FlowMart
PaymentFailed Schema
13 properties
paymentIdstring
requiredUnique identifier for the failed payment
amountnumber
requiredPayment amount that failed
currencystring
requiredCurrency code (ISO 4217)
failureReasonstring
requiredReason for payment failure
Allowed values:
insufficient_funds card_declined expired_card fraud_suspected network_error invalid_payment_method authentication_required otherfailureMessagestring
Human-readable failure message
metadataobject
canRetryboolean
Whether this payment can be retried
nextRetryAtstring<date-time>
Suggested time for next retry attempt
timestampstring<date-time>
requiredWhen the failure occurred