|
| 1 | +# Payment Failed |
| 2 | + |
| 3 | +After the seller releases the sats, Mostro attempts to pay the buyer's Lightning invoice. If this payment fails, Mostro sends a `payment-failed` action to the buyer. |
| 4 | + |
| 5 | +> ⚠️ **Important:** `payment-failed` is an **Action** (notification), NOT an order **Status**. The order remains in `settled-hold-invoice` status while Mostro retries the payment. |
| 6 | +
|
| 7 | +## When Payment Fails |
| 8 | + |
| 9 | +When Mostro cannot pay the buyer's Lightning invoice, it sends this message to the buyer: |
| 10 | + |
| 11 | +```json |
| 12 | +[ |
| 13 | + { |
| 14 | + "order": { |
| 15 | + "version": 1, |
| 16 | + "id": "<Order Id>", |
| 17 | + "action": "payment-failed", |
| 18 | + "payload": { |
| 19 | + "payment_failed": { |
| 20 | + "payment_attempts": 3, |
| 21 | + "payment_retries_interval": 5 |
| 22 | + } |
| 23 | + } |
| 24 | + } |
| 25 | + }, |
| 26 | + null |
| 27 | +] |
| 28 | +``` |
| 29 | + |
| 30 | +### Payload Fields |
| 31 | + |
| 32 | +| Field | Type | Description | |
| 33 | +|-------|------|-------------| |
| 34 | +| `payment_attempts` | integer | Number of retry attempts remaining | |
| 35 | +| `payment_retries_interval` | integer | Minutes between retry attempts | |
| 36 | + |
| 37 | +## What Happens Next |
| 38 | + |
| 39 | +1. **Automatic retries**: Mostro will automatically retry the payment according to `payment_attempts` and `payment_retries_interval` |
| 40 | + |
| 41 | +2. **Order status unchanged**: The order remains in `settled-hold-invoice` status during retries |
| 42 | + |
| 43 | +3. **All retries failed**: If all payment attempts fail, Mostro sends `add-invoice` action requesting the buyer to provide a new Lightning invoice: |
| 44 | + |
| 45 | +```json |
| 46 | +[ |
| 47 | + { |
| 48 | + "order": { |
| 49 | + "version": 1, |
| 50 | + "id": "<Order Id>", |
| 51 | + "action": "add-invoice", |
| 52 | + "payload": { |
| 53 | + "order": { |
| 54 | + "id": "<Order Id>", |
| 55 | + "amount": 50000, |
| 56 | + ... |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + }, |
| 61 | + null |
| 62 | +] |
| 63 | +``` |
| 64 | + |
| 65 | +4. **Buyer provides new invoice**: The buyer must submit a new Lightning invoice for the sats to be delivered |
| 66 | + |
| 67 | +## Client Implementation Notes |
| 68 | + |
| 69 | +- **Do NOT create a "PaymentFailed" order status** — this action is a notification only |
| 70 | +- Display a message to the buyer explaining the payment failed and retries are in progress |
| 71 | +- When `add-invoice` is received after failed retries, prompt the buyer to provide a new invoice |
| 72 | +- The sats remain safely locked in escrow (`settled-hold-invoice`) throughout this process |
| 73 | + |
| 74 | +## Flow Diagram |
| 75 | + |
| 76 | +```text |
| 77 | +Seller releases sats |
| 78 | + │ |
| 79 | + ▼ |
| 80 | +Order status: settled-hold-invoice |
| 81 | + │ |
| 82 | + ▼ |
| 83 | +Mostro attempts Lightning payment |
| 84 | + │ |
| 85 | + ├─── Success ──────────────► Order status: success |
| 86 | + │ (buyer receives purchase-completed) |
| 87 | + │ |
| 88 | + └─── Failure |
| 89 | + │ |
| 90 | + ▼ |
| 91 | + Action: payment-failed (to buyer) |
| 92 | + Order status: still settled-hold-invoice |
| 93 | + │ |
| 94 | + ▼ |
| 95 | + Mostro retries (up to payment_attempts times) |
| 96 | + │ |
| 97 | + ├─── Retry succeeds ──► Order status: success |
| 98 | + │ |
| 99 | + └─── All retries fail |
| 100 | + │ |
| 101 | + ▼ |
| 102 | + Action: add-invoice (to buyer) |
| 103 | + Buyer provides new invoice |
| 104 | + │ |
| 105 | + ▼ |
| 106 | + Mostro pays new invoice ──► Order status: success |
| 107 | +``` |
| 108 | + |
| 109 | +## Related Actions |
| 110 | + |
| 111 | +- [release](./release.md) - Seller releases sats |
| 112 | +- [add-invoice](./take_sell.md) - Buyer provides Lightning invoice |
0 commit comments