Skip to content

Error Handling

Handle payment failures gracefully in your integration.

Error Response Format

json
{
  "error": {
    "code": "INSUFFICIENT_BALANCE",
    "message": "Balance is insufficient for this payment",
    "details": {
      "available": 5000,
      "required": 10000
    }
  }
}

Common Error Codes

CodeDescriptionAction
INSUFFICIENT_BALANCENot enough funds in balanceFund balance
INVALID_RECIPIENTRecipient not found or inactiveVerify recipient ID
PAYMENT_METHOD_NOT_VERIFIEDBank account not verifiedWait for verification
RAIL_NOT_AVAILABLERequested rail not supportedUse different rail
COMPLIANCE_HOLDPayment flagged for reviewContact support
RAIL_UNAVAILABLERequested rail not availableUse different rail

Payment Failures

Payments can fail at different stages:

Validation Failure

Payment fails validation before processing:

json
{
  "status": "failed",
  "failureCode": "VALIDATION_ERROR",
  "failureReason": "Recipient has no verified payment methods"
}

Processing Failure

Payment fails during processing:

json
{
  "status": "failed",
  "failureCode": "BANK_REJECTED",
  "failureReason": "Account closed"
}

Retry Logic

Failed payments can be retried:

bash
curl -X POST https://api.paystream.fi/api/v1/payments/pay_123/retry \
  -H "Authorization: Bearer psk_test_xxx"

Retry rules:

  • Max 3 retries per payment
  • 24-hour cooldown between retries
  • Some failures (e.g., account closed) cannot be retried

Idempotency

Use idempotency keys to prevent duplicate payments:

bash
curl -X POST https://api.paystream.fi/api/v1/payments \
  -H "Authorization: Bearer psk_test_xxx" \
  -H "Idempotency-Key: unique-request-id" \
  -d '{...}'

Released under the MIT License.