Skip to content
Terra WalletDevelopers

Early access. The Terra API and SDKs may change before launch, and the SDK packages are not published yet.

View as Markdown

Terra Pay

Early access

Subscriptions and plans

A plan is a price and an interval. A subscription puts a customer on a plan. In v1, every subscription is pay each period: Terra creates a renewal invoice each period and the customer pays it from their own wallet. Nothing is ever taken from a customer's wallet without their action.

Create a plan#

POST /v1/plans:

FieldTypeRequiredNotes
namestringyesFor example Pro
amountdecimal stringyesThe price per period, for example "10.00"
currencystringyesA fiat ISO code
intervalstringyesweek, month or year
interval_countintegeryesPeriods between renewals: 1 with month is monthly, 3 with month is quarterly
trial_daysintegernoA free trial before the first payment

JavaScript

// Preview: create a monthly plan (Node 18 or later).const plan = await fetch("https://terrawallet.us/api/v1/plans", {  method: "POST",  headers: {    Authorization: `Bearer ${process.env.TERRA_SECRET_KEY}`,    "Content-Type": "application/json",    "Idempotency-Key": "plan-pro-monthly",  },  body: JSON.stringify({ name: "Pro", amount: "10.00", currency: "USD", interval: "month", interval_count: 1, trial_days: 14 }),}).then((r) => r.json());

Every plan has a subscription link: https://pay.terrawallet.us/s/plan_.... Customers open it, enter their email and subscribe. No code is needed on your side.

Subscribe a customer from your server#

POST /v1/subscriptions with plan (a plan_... id) and customer_email. The response is the subscription with its first invoice.

JavaScript

const subscription = await fetch("https://terrawallet.us/api/v1/subscriptions", {  method: "POST",  headers: {    Authorization: `Bearer ${process.env.TERRA_SECRET_KEY}`,    "Content-Type": "application/json",    "Idempotency-Key": `subscribe-${user.id}-${plan.id}`,  },  body: JSON.stringify({ plan: plan.id, customer_email: user.email }),}).then((r) => r.json());

Renewals#

  • Renewal invoices are created automatically each period.
  • The customer gets reminders 7, 3 and 1 days before each renewal, by email (and by Terra Wallet notification and webhook, per the design).
  • After a missed renewal the subscription becomes past_due; the design adds a grace period and then an automatic pause.

Statuses#

StatusMeaning
trialingIn the free trial
activePaid up for the current period
past_dueA renewal was not paid in time
pausedPaused: no renewals are issued
canceledEnded

Webhooks#

subscription.created, subscription.renewed, subscription.payment_failed, subscription.past_due and subscription.canceled. Grant or remove access from these events, after verifying each signature (see Webhooks).

Auto-pay with a capped on-chain permission (later, gated)#

The Terra Pay design also has an auto-pay mode for EVM chains first, then Tron: the customer signs one capped permission, for example "Allow up to 10 USDC every 30 days to Merchant X until 23 Nov 2027". The Terra Subscriptions contract would allow exactly one charge per period, never above the cap and only to the merchant's registered wallet, and the customer could cancel at any time with immediate on-chain effect.

It is not available. Before it touches mainnet it needs an independent contract audit, fuzzing and formal tests, a testnet beta and a legal review. Solana auto-pay needs its own audited program and comes after that. Checkout always tells the customer which mode they are agreeing to before they agree.