railyard/apps/rago/.env.example
caelum0x 8695030576 feat(rago): scheduled downgrades, confirmed portal cancel, Mint void reversals, customer address
- Portal: "Change or cancel" confirmation page; cancel requires confirm=yes;
  cheaper same-currency/interval plans offered as downgrades at next billing
  date; "Keep my current plan" undoes a scheduled change.
- Downgrades: plan_change module + GET/POST/DELETE
  /api/v1/subscriptions/:external_id/plan_change, console card and actions.
  Clock applies scheduled downgrades (closing period billed once, old sub
  ended and new one started in one transaction, webhooks sent).
  Subscription lookup prefers the active subscription; billing run and queue
  skip arrears subs started on/after the billing date.
- Mint wallets: settle_void reverses captured holds payee -> customer with
  idempotency key rago:reverse:<hold id>; new 'reversed' hold status;
  retry via POST /wallets/:id/realtime/reversals. Console screen
  #/wallets/:id/mint with balance, holds, top-ups, 30-day ledger, hosted
  top-up link (Mint /v1/checkouts) and real-time settings.
- Creem: partial refunds refused up front (422 partial_refund_unsupported),
  since Creem's refund API only refunds whole payments.
- Iyzico: buyer built from customer record only (no placeholder identity or
  merchant default address); missing fields fail with customer_details_missing.
- Migration 0046: customer address/phone/identity columns, reversed hold
  status and columns, indexes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 17:22:14 +03:00

140 lines
5.3 KiB
Plaintext

# ---- Rago configuration (copy to .env and edit) ----------------------------
# Postgres connection (required).
DATABASE_URL=postgres://postgres:postgres@localhost:5432/rago
# API bind address.
RAGO_API_ADDR=0.0.0.0:3000
# Background daemon (rago-server): seconds between ticks, and the hour (UTC)
# at which the daily billing cycle runs.
RAGO_TICK_SECS=15
RAGO_BILLING_HOUR=0
# Fixed-window API rate limit (requests per minute; default 6000).
RAGO_RATE_LIMIT=6000
# Reel-generation per-unit pricing for the `menivor_reels` catalog
# (GET /reels/catalog). JSON object mapping a reel metric code to an integer
# price in CENTS per billed unit; any metric omitted falls back to the built-in
# default ($0.20/reel, $0.01/render-second, $0.01/AI credit). Unset or malformed
# uses the full default set. Example:
# RAGO_REEL_PRICING={"reel_generated":25,"reel_render_seconds":1,"reel_ai_credits":2}
RAGO_REEL_PRICING=
# Dashboard admin JWT signing secret (required in release builds — the server
# refuses to boot without it). Generate one with: openssl rand -hex 32
RAGO_JWT_SECRET=
# Log filter (tracing EnvFilter syntax).
RUST_LOG=info
# ---- ClickHouse event store (optional) -------------------------------------
CLICKHOUSE_URL=http://localhost:8123
CLICKHOUSE_DATABASE=rago
# ---- Live transports (only used when built with `--features live`) ---------
# Tax / accounting / CRM aggregator + payment providers (reqwest HTTP transport).
RAGO_TAX_BASE_URL=
RAGO_TAX_API_KEY=
# Optional: route accounting / CRM calls through an aggregator instead of the
# providers' own APIs (Xero Accounting API, NetSuite RESTlet + SuiteQL,
# Salesforce REST, HubSpot CRM v3 are called directly when these are empty).
RAGO_ACCOUNTING_BASE_URL=
RAGO_CRM_BASE_URL=
# Public origin of this server. Builds the OAuth redirect URIs to register with
# providers: <origin>/integrations/oauth/callback (Xero, Salesforce, HubSpot)
# and <origin>/admin/sso/callback (Google, Okta, Entra ID sign-in).
RAGO_PUBLIC_URL=
# Integration OAuth apps (Xero / Salesforce / HubSpot). Per-organization app
# credentials saved on an integration take precedence; these are the
# deployment-wide fallback. Legacy RAGO_OAUTH_CLIENT_ID/SECRET apply to all.
RAGO_XERO_OAUTH_CLIENT_ID=
RAGO_XERO_OAUTH_CLIENT_SECRET=
RAGO_SALESFORCE_OAUTH_CLIENT_ID=
RAGO_SALESFORCE_OAUTH_CLIENT_SECRET=
RAGO_HUBSPOT_OAUTH_CLIENT_ID=
RAGO_HUBSPOT_OAUTH_CLIENT_SECRET=
# Override the callback URL (default: RAGO_PUBLIC_URL/integrations/oauth/callback).
RAGO_INTEGRATION_OAUTH_REDIRECT_URI=
# SSO IdP apps. Each organization enables SSO with an auth integration for its
# email domain (its own client id/secret, Okta org, Entra tenant). These are the
# fallback shared app, e.g. one "Sign in with Google" app for every tenant.
RAGO_GOOGLE_CLIENT_ID=
RAGO_GOOGLE_CLIENT_SECRET=
RAGO_OKTA_CLIENT_ID=
RAGO_OKTA_CLIENT_SECRET=
RAGO_OKTA_DOMAIN=
RAGO_ENTRA_ID_CLIENT_ID=
RAGO_ENTRA_ID_CLIENT_SECRET=
RAGO_ENTRA_ID_TENANT_ID=
# Override the SSO callback URL (default: RAGO_PUBLIC_URL/admin/sso/callback).
RAGO_SSO_REDIRECT_URI=
# SMTP email transport (live EmailTransport).
RAGO_SMTP_HOST=
RAGO_SMTP_PORT=587
RAGO_SMTP_USERNAME=
RAGO_SMTP_PASSWORD=
# ---- Payments (per-organization providers) ---------------------------------
# Provider secrets saved from the dashboard/GraphQL are sealed (AES-256-GCM)
# with this key before they are stored. REQUIRED to configure providers from
# the dashboard. Generate with: openssl rand -hex 32. Never rotate without
# re-entering provider secrets.
RAGO_ENCRYPTION_KEY=
# Single-tenant fallback when an organization has no provider configured in
# the dashboard: provider type (stripe | gocardless | adyen) and its secret.
RAGO_PAYMENT_PROVIDER=stripe
RAGO_STRIPE_SECRET_KEY=
RAGO_GOCARDLESS_ACCESS_TOKEN=
RAGO_ADYEN_API_KEY=
RAGO_ADYEN_MERCHANT_ACCOUNT=
# Creem (merchant of record): API key + one-time product sold at the invoice
# amount (custom_price) + that product's currency.
RAGO_CREEM_API_KEY=
RAGO_CREEM_PRODUCT_ID=
RAGO_CREEM_PRODUCT_CURRENCY=USD
# Dodo Payments (merchant of record): API key + pay-what-you-want product.
RAGO_DODO_API_KEY=
RAGO_DODO_PRODUCT_ID=
# Iyzico: API key + secret key. The buyer's address, city and identity number
# come from each customer record (address_line1, city, identity_number).
RAGO_IYZICO_API_KEY=
RAGO_IYZICO_SECRET_KEY=
# live | test (Creem, Dodo) / sandbox (Iyzico) for the env-configured provider.
RAGO_PAYMENT_PROVIDER_MODE=live
# Where Stripe Checkout / Billing Portal return the customer (used when the
# provider has no success_redirect_url configured).
RAGO_CHECKOUT_SUCCESS_URL=
# Incoming provider webhook signing secrets
# (POST /webhooks/{stripe,gocardless,adyen}/:organization_id).
RAGO_STRIPE_WEBHOOK_SECRET=
RAGO_GOCARDLESS_WEBHOOK_SECRET=
RAGO_ADYEN_HMAC_KEY=
RAGO_CREEM_WEBHOOK_SECRET=
RAGO_DODO_WEBHOOK_SECRET=
# ---- Real-time wallets (Mint holds) -----------------------------------------
# The Mint server real-time wallets settle on, and the seller's Mint account
# that captured holds are paid to.
RAGO_MINT_URL=
RAGO_MINT_API_KEY=
RAGO_MINT_PAYEE_ACCOUNT=
# Set to false to have dunning record payment requests without charging.
RAGO_DUNNING_CHARGE=true
# Avalara company code (tax provider `avalara`).
RAGO_AVALARA_COMPANY_CODE=
# Expose GET /api/v1/emails (process-wide captured emails of non-live builds).
# Only for single-tenant development deployments.
RAGO_EXPOSE_CAPTURED_EMAILS=false