LostChurn Docs
API Reference

Payments API

Query failed payments, retrieve payment details, and trigger manual retries via the LostChurn REST API.

The Payments API lets you list failed payments, retrieve details for a specific payment, and manually trigger retries.

Endpoints

MethodPathDescription
GET/v1/paymentsList payments
GET/v1/payments/:idGet a payment
POST/v1/payments/:id/retryRetry a payment

List Payments

Retrieve a paginated list of payments, optionally filtered by status, customer, date range, or decline category.

GET /v1/payments

Query Parameters

ParameterTypeDefaultDescription
statusstringallFilter by status: pending, retrying, recovered, terminal, communication_pending
customer_idstring--Filter by customer ID
decline_categorystring--Filter by category: soft_retry, hard_customer, terminal, unknown
pspstring--Filter by payment processor: stripe, braintree, etc.
currencystring--Filter by ISO currency code
amount_mininteger--Minimum amount in smallest currency unit
amount_maxinteger--Maximum amount in smallest currency unit
created_afterstring--ISO 8601 datetime. Return payments created after this time
created_beforestring--ISO 8601 datetime. Return payments created before this time
sortstringcreated_atSort field: created_at, amount, status
orderstringdescSort order: asc, desc
pageinteger1Page number
per_pageinteger20Results per page (max: 100)

Example Request

curl "https://api.lostchurn.com/v1/payments?status=pending&decline_category=soft_retry&per_page=5" \
  -H "Authorization: Bearer lc_live_your_api_key"

Example Response

{
  "data": [
    {
      "id": "pay_abc123",
      "customer_id": "cus_def456",
      "subscription_id": "sub_ghi789",
      "amount": 4999,
      "currency": "usd",
      "status": "pending",
      "decline_code": "insufficient_funds",
      "decline_category": "soft_retry",
      "decline_subcategory": "balance",
      "psp": "stripe",
      "psp_payment_id": "pi_3ABC123DEF456",
      "retry_count": 0,
      "max_retries": 4,
      "next_retry_at": "2025-03-10T06:00:00Z",
      "created_at": "2025-03-08T14:30:00Z",
      "updated_at": "2025-03-08T14:30:00Z"
    },
    {
      "id": "pay_jkl012",
      "customer_id": "cus_mno345",
      "subscription_id": "sub_pqr678",
      "amount": 9900,
      "currency": "usd",
      "status": "pending",
      "decline_code": "generic_decline",
      "decline_category": "soft_retry",
      "decline_subcategory": "generic",
      "psp": "stripe",
      "psp_payment_id": "pi_3XYZ789GHI012",
      "retry_count": 1,
      "max_retries": 3,
      "next_retry_at": "2025-03-10T12:00:00Z",
      "created_at": "2025-03-07T09:15:00Z",
      "updated_at": "2025-03-08T09:15:00Z"
    }
  ],
  "pagination": {
    "total": 47,
    "page": 1,
    "per_page": 5,
    "total_pages": 10
  }
}

Get a Payment

Retrieve details for a single payment, including its full retry history.

GET /v1/payments/:id

Example Request

curl https://api.lostchurn.com/v1/payments/pay_abc123 \
  -H "Authorization: Bearer lc_live_your_api_key"

Example Response

{
  "data": {
    "id": "pay_abc123",
    "customer_id": "cus_def456",
    "subscription_id": "sub_ghi789",
    "amount": 4999,
    "currency": "usd",
    "status": "recovered",
    "decline_code": "insufficient_funds",
    "decline_category": "soft_retry",
    "decline_subcategory": "balance",
    "psp": "stripe",
    "psp_payment_id": "pi_3ABC123DEF456",
    "retry_count": 2,
    "max_retries": 4,
    "created_at": "2025-03-08T14:30:00Z",
    "recovered_at": "2025-03-10T06:12:00Z",
    "updated_at": "2025-03-10T06:12:00Z",
    "customer": {
      "id": "cus_def456",
      "email": "customer@example.com",
      "name": "Jane Smith"
    },
    "retries": [
      {
        "attempt": 1,
        "status": "failed",
        "decline_code": "insufficient_funds",
        "attempted_at": "2025-03-09T06:00:00Z"
      },
      {
        "attempt": 2,
        "status": "succeeded",
        "decline_code": null,
        "attempted_at": "2025-03-10T06:12:00Z"
      }
    ]
  }
}

Retry a Payment

Manually trigger an immediate retry for a failed payment. The payment must be in pending or communication_pending status.

POST /v1/payments/:id/retry

Example Request

curl -X POST https://api.lostchurn.com/v1/payments/pay_abc123/retry \
  -H "Authorization: Bearer lc_live_your_api_key" \
  -H "Content-Type: application/json"

Example Response (Retry Initiated)

{
  "data": {
    "id": "pay_abc123",
    "status": "retrying",
    "retry_count": 3,
    "retry_initiated_at": "2025-03-08T15:00:00Z",
    "message": "Retry submitted to payment processor."
  }
}

Example Response (Cannot Retry)

{
  "error": {
    "code": "state_conflict",
    "message": "Payment pay_abc123 is in 'terminal' status and cannot be retried.",
    "request_id": "req_9876543210"
  }
}

Manual retries count toward your plan's monthly recovery attempt limit. Use them judiciously for specific cases rather than as a bulk recovery strategy.

Retry Rules

Current StatusCan Retry?
pendingYes
retryingNo (retry already in progress)
communication_pendingYes
recoveredNo (already recovered)
terminalNo (permanently failed)

Payment Object

FieldTypeDescription
idstringLostChurn payment ID
customer_idstringCustomer ID from your PSP
subscription_idstringSubscription ID from your PSP
amountintegerAmount in smallest currency unit
currencystringISO 4217 currency code
statusstringCurrent status (see table above)
decline_codestringRaw decline code from PSP
decline_categorystringLostChurn category
decline_subcategorystringLostChurn subcategory
pspstringPayment processor name
psp_payment_idstringPayment ID in your PSP
retry_countintegerNumber of retries attempted
max_retriesintegerMaximum retries allowed for this decline
next_retry_atstring | nullScheduled time for next retry
recovered_atstring | nullTimestamp of successful recovery
created_atstringWhen the payment failure was recorded
updated_atstringLast update timestamp

Next Steps

On this page