> ## Documentation Index
> Fetch the complete documentation index at: https://docs.waffo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Payment Troubleshooting

> Fix common payment issues

## Overview

Payments fail sometimes. Here's how to diagnose and fix issues.

***

## Common Decline Reasons

### Card Declined

| Code | Meaning | Customer Action |
| - | - | - |
| `card_declined` | Generic decline | Try different card |
| `insufficient_funds` | Not enough money | Add funds or use different card |
| `lost_card` | Card reported lost | Use different card |
| `stolen_card` | Card reported stolen | Use different card |
| `expired_card` | Card past expiration | Update card |

### Processing Errors

| Code | Meaning | Action |
| - | - | - |
| `processing_error` | Temporary issue | Retry in a few minutes |
| `rate_limit` | Too many requests | Slow down, retry later |
| `network_error` | Connection failed | Retry |

### Validation Errors

| Code | Meaning | Fix |
| - | - | - |
| `invalid_number` | Card number wrong | Re-enter card |
| `invalid_expiry` | Expiration date wrong | Check MM/YY format |
| `invalid_cvc` | CVC wrong | Check 3-4 digit code |
| `incorrect_zip` | ZIP doesn't match | Verify billing address |

***

## Decline Rate Too High?

Normal decline rates: **5-10%**

If higher, check:

### 1. Card Quality

| Issue | Sign | Fix |
| - | - | - |
| Prepaid cards | High `card_declined` | Consider blocking |
| International cards | Geographic mismatches | Enable 3DS |
| Corporate cards | Spending limits | Contact customer |

### 2. Fraud Signals

| Issue | Sign | Fix |
| - | - | - |
| Card testing | Many small amounts | Block suspicious IPs |
| Stolen cards | High fraud rate | Tighten fraud rules |
| VPN users | IP/card mismatch | Additional verification |

### 3. Technical Issues

| Issue | Sign | Fix |
| - | - | - |
| Form errors | High `invalid_*` | Improve form validation |
| Integration bugs | Unexpected errors | Check logs |
| Timeout | `processing_error` | Increase timeouts |

***

## Subscription Payment Failures

Recurring payments need special handling.

### Why Subscriptions Fail

| Reason | Frequency | Solution |
| - | - | - |
| Card expired | Common | Card updater service |
| Insufficient funds | Common | Smart retry timing |
| Card replaced | Occasional | Ask customer to update |
| Account closed | Rare | Customer outreach |

### Our Retry Logic

We automatically retry failed subscription payments:

```
Day 0: Initial attempt
Day 1: First retry
Day 3: Second retry
Day 5: Third retry
Day 7: Final retry → Cancel or pause
```

### Dunning Emails

Automated emails to customers:

1. **Payment failed** - Immediate notification
2. **Retry scheduled** - Heads up before next attempt
3. **Update card** - Link to customer portal
4. **Final warning** - Before subscription cancels

***

## Chargebacks & Disputes

### Chargeback Process

```
Customer disputes → Bank contacts us → You respond → Decision
```

### Timeline

| Stage | Timeframe |
| - | - |
| Dispute opened | Day 0 |
| Response deadline | 7-21 days |
| Bank decision | 45-90 days |
| Final (if appealed) | Up to 120 days |

### Winning Disputes

Strong evidence includes:

> [card] For Digital Products
>
> * Customer IP address
> * Download/access logs
> * Account activity
> * Device fingerprint

> [card] For Subscriptions
>
> * Sign-up confirmation
> * Usage history
> * Previous successful payments
> * Cancellation policy (agreed to)

### Preventing Disputes

| Issue | Prevention |
| - | - |
| "I didn't authorize" | Use 3DS |
| "I don't recognize" | Clear billing descriptor |
| "I canceled" | Confirm cancellations |
| "Didn't receive" | Delivery confirmation |

***

## Testing Payments

Use test mode to simulate scenarios.

### Test Card Numbers

| Card | Behavior |
| - | - |
| `4576 7500 0000 0110` | Always succeeds (Visa) |
| `2226 9000 0000 0110` | Always succeeds (Mastercard) |
| `4576 7500 0000 0220` | Always declines |

### Test Mode Tips

* Use `X-Environment: test` header in API calls
* Use API keys created for the test environment
* No real money moves
* Test all scenarios before going live
* Verify webhooks work correctly

***

## Webhook Issues

### Not Receiving Webhooks?

| Check | Solution |
| - | - |
| Endpoint URL correct? | Verify in Dashboard |
| HTTPS enabled? | Webhooks require HTTPS |
| Firewall blocking? | Whitelist our IPs |
| Endpoint returning 200? | Must respond with 2xx |

### Webhook Signature Invalid?

```javascript theme={"system"}
// Common mistakes
❌ Using wrong webhook secret
❌ Parsing body before verification
❌ Using live secret with test events

// Correct approach
✅ Use raw request body for verification
✅ Match secret to environment (test/live)
```

### Debugging Webhooks

1. Check Dashboard → API & Development → Webhooks
2. View recent attempts
3. See request/response details
4. Resend failed webhooks

***

## Integration Checklist

Before going live:

### API Integration

* [ ] Using API keys created for production environment
* [ ] `X-Environment: prod` header set for live API calls
* [ ] Error handling for all API calls
* [ ] `X-Idempotency-Key` set on every write you must not duplicate — the SDKs no longer generate one, so pass `{ idempotencyKey }` on the call (or set the header when calling REST directly); without it a retried write executes twice
* [ ] Webhook endpoints configured and tested

### Checkout Flow

* [ ] Card form validates input
* [ ] Loading states during processing
* [ ] Clear error messages
* [ ] Success confirmation page

### Subscriptions

* [ ] Trial periods configured
* [ ] Proration settings correct
* [ ] Cancellation flow works
* [ ] Customer portal enabled

### Error Handling

* [ ] Graceful decline handling
* [ ] Retry logic for network errors
* [ ] Logging for debugging
* [ ] Customer-friendly messages

***

## Getting Help

### Self-Service

| Resource | Use For |
| - | - |
| Dashboard logs | Transaction details |
| API logs | Request/response data |
| Webhook logs | Delivery status |
| Test mode | Reproduce issues |

### Contact Support

When contacting us, include:

* Payment/customer ID
* Timestamp of issue
* Error message (exact)
* Steps to reproduce
* Expected vs actual behavior

**[support@waffo.ai](mailto:support@waffo.ai)**

***

## Quick Reference

### Decline Code Actions

| Code | Retry? | Customer Action |
| - | - | - |
| `card_declined` | Once | Different card |
| `insufficient_funds` | Yes (later) | Add funds |
| `expired_card` | No | Update card |
| `processing_error` | Yes | Wait and retry |
| `rate_limit` | Yes (slower) | - |
| `invalid_*` | No | Fix input |

### Response Codes

| HTTP Code | Meaning |
| - | - |
| 200 | Success |
| 400 | Bad request (invalid parameters) |
| 401 | Authentication failed |
| 403 | Forbidden (insufficient permissions) |
| 404 | Resource not found |
| 409 | Conflict (idempotent request in progress) |
| 429 | Rate limited |
| 500 | Server error (retry) |
| 501 | Not implemented |
| 502 | Gateway error |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.