Developer Documentation

Checkout and renewals — HTTP and MCP

For one checkout URL that also schedules renewals, use mode=recurring in /docs/quickstart/checkout. The explicit payment-link and scheduler integration below remains available to existing clients. Base: https://chronosfy.com/api. Configure a verified Stripe account and tenant webhook first. Identity verification checks Accounts: Read (Connect) and Balance: Read only; it does not prove every feature permission. Restricted keys also need Customers: Write, Checkout Sessions: Write, PaymentIntents: Write, PaymentMethods: Read and Events: Read for this flow; SetupIntents: Write for separate setup. Keep test/live credentials and publishable keys in the same mode/account. See https://docs.stripe.com/keys. Use payments:links + payments:setup for Checkout that saves a card, payments:read to inspect it, and the payment action/financial recurrence scopes plus payments:charge to schedule charges. Create a person and payment action with stable creation keys before this flow. 1. POST /payment/links with Idempotency-Key: checkout:order-42:v1:
{
  "person_id": "PERSON_UUID", "amount": 2990, "currency": "BRL", "description": "First month",
  "success_url": "https://your-app.example/paid", "cancel_url": "https://your-app.example/cancel",
  "save_payment_method": true, "set_as_default": true,
  "client_reference_id": "order-42", "metadata": { "plan": "plus" }
}
MCP: create_payment_link with the same body plus request_key: "checkout:order-42:v1". Save the returned link ID and direct the customer to its hosted URL. Obtain consent for future charges. set_as_default changes the person's default used by all future unfrozen renewals. Omit it to preserve an existing valid default; the first valid card becomes default automatically. Existing frozen charges keep their card. 2. Confirm server state with GET /payment/links/LINK_UUID or get_payment_link({link_id}). Redirect to success_url alone is not proof. status=completed means paid; payment_method_status is independent: not_requested = no save requested; pending = association is being recovered; saved = local card ID available; needs_review = operator must inspect payment_method_error. Never charge again to repair a saved-card problem. payment.link.completed contains both states. Delayed association emits payment.link.payment_method.saved; review transitions emit payment.link.requires_attention. Deduplicate event_id and honor state_version. The reconciler retries pending card reads, at most 20 attempts with bounded backoff, then requires review. 3. Only after completed + saved, POST /recurrences with Idempotency-Key: renewal:subscription-42:v1:
{
  "name": "Plan renewal", "action_id": "PAYMENT_ACTION_UUID", "subject_id": "PERSON_UUID", "subject_type": "person",
  "amount": 2990, "currency": "BRL", "client_reference": "subscription-42",
  "frequency_config": { "type": "monthly", "day": 12, "time": "09:00", "timezone": "Europe/London" },
  "first_run_at": "FUTURE_ISO_8601_WITH_TIMEZONE"
}
MCP: create_recurrence with the same body plus request_key: "renewal:subscription-42:v1". Choose first_run_at once from the already-paid period's end, strictly future and at most 400 days away. Keep it unchanged on every retry, including after its date has passed. Calendar schedules choose the first matching slot ON OR AFTER that bound: monthly day 1 with a December 12 bound starts January 1, not December 12. Interval schedules start exactly at the bound. Pause/resume and frequency edits preserve the bound. Inspect next_run_at in the response. Manual trigger-now remains an explicit independent charge. Recovery: reuse identical keys/body across HTTP and MCP. A changed payload with the same key returns 409. PAYMENT_CUSTOMER_PENDING (409 busy or 502 uncertain) means retry the same request after a delay. PAYMENT_CUSTOMER_REVIEW_REQUIRED means inspect the account/mode/customer binding; never reset it blindly. An unresolved Customer is not recreated beyond 23 hours. Legacy conflicting Customers require review. A definitive Customer prerequisite refusal (422) can be corrected and retried with the same logical request; a link with failed + provider_failure is a final Checkout refusal. Correct that and create a new logical link. Payment card status errors are resource state, not evidence that the initial payment failed. MCP HTTP 200 may contain isError=true: inspect structuredContent.status_code/error/fields/details. Cancellation at period end, proration and a hosted card-change portal are not implemented by this flow. ## Card for this recurrence Select a saved card for future charges on this schedule. Charges already started keep their card. Direct card registration uses Stripe without Link.
GET /api/recurrences/{recurrence_id}/payment-method
PUT /api/recurrences/{recurrence_id}/payment-method
Content-Type: application/json

{"payment_method_id":"<cards[].id>"}
`get_recurrence_cards`, `set_recurrence_card` ## Refunds Stripe and Teya support full and partial refunds. Enter the amount in the smallest currency unit. Use a new key for each separate refund and reuse it when retrying. Only succeeded confirms the refund. Refunding a payment leaves future renewals scheduled. Already refunded by the provider `already_refunded_externally` Already refunded by another request `already_refunded_by_other_request`
curl -X POST "$API/checkout/sessions/$CHECKOUT_ID/refund" \
  -H "Authorization: ApiKey $API_KEY" -H "Idempotency-Key: refund:order-42:1" \
  -H "Content-Type: application/json" -d '{"amount":2500,"reason":"requested_by_customer"}'
curl "$API/payment/refunds/$REFUND_ID" -H "Authorization: ApiKey $API_KEY"
payments:refund   POST /checkout/sessions/{id}/refund
payments:refund   POST /payment/links/{id}/refund
payments:refund   POST /payment/charges/{charge_id}/refund
payments:read     GET  /payment/refunds/{id}
MCP               request_refund, get_refund
Teya              refunds/create
## Card processing responses gateway_response gives the Chronosfy operation, status and code. provider_response preserves the original provider fields allowed for merchants, including issuer codes when available. It is null for local storage, a missing reply or older records without a recorded response. Read the result on your server using the checkout ID after the browser returns.
{
  "provider_response": {
    "provider": "teya",
    "body": {
      "status": "FAILURE",
      "status_reason": "INSUFFICIENT_FUNDS",
      "issuer_result": { "response_code": "51" }
    }
  },
  "gateway_response": {
    "operation": "charge",
    "status": "failed",
    "code": "CHARGE_FAILED",
    "reason": "insufficient_funds"
  }
}
## Try other saved cards On a confirmed eligible decline, try the other saved cards one at a time, starting with the primary card each round. Stop on approval, a pending result, an authentication request or a fraud block. A temporary decline can trigger another round for the same installment after 24 hours, then 72 hours later. Teya retries the card linked to the mandate. Enabled by default. Disable it for the tenant, customer or recurrence. A restriction at any level takes precedence.
GET /settings/payment/card-retries
GET /payment/methods/{person_id}/card-retries
GET /recurrences/{recurrence_id}/card-retries
PUT /settings/payment/card-retries
PUT /payment/methods/{person_id}/card-retries
PUT /recurrences/{recurrence_id}/card-retries

{"enabled":false}

GET /recurrences/{recurrence_id}/card-attempts
`enabled` · `effective_enabled` · `disabled_by` MCP · `get_card_retry_settings` · `set_card_retry_settings` · `list_recurrence_card_attempts` Payment event version A card decline is an attempt. Final failure closes the installment after retries. Existing subscriptions keep version 2 until you select version 3. `payment.attempt.failed` · `payment.succeeded` · `payment.failed` `PUT /events/webhooks/{id}/payment-event-version` · `{"version":3}` · MCP `set_payment_event_version` ## Default payment provider Saving credentials keeps the default unchanged, even for the first provider. To choose the account for new payments, the tenant owner selects a saved account and confirms the change. An explicit provider can be used before choosing a default.
GET /api/settings/payment
Authorization: Bearer <owner_access_token>

POST /api/auth/reauth
Authorization: Bearer <owner_access_token>
Content-Type: application/json

{"password":"<password>","operation":"PUT /settings/payment/default"}

PUT /api/settings/payment/default
Authorization: Bearer <owner_access_token>
X-Reauth-Token: <reauth_token>
Content-Type: application/json

{"config_id":"<configurations[].config_id>"}
MCP: set_default_payment_provider({config_id, reauth_token})