Recur Docs

Plans

Create and manage subscription plans, list subscriptions, and query payment history.

Plans

Plan management and subscription queries are handled via the Recur REST API through RecurClient.

getPlans(appId)

List all plans for an app. No authentication required.

const plans: PlanInfo[] = await recur.getPlans("app_xxx");

getPlan(appId, planId)

Fetch a single plan by ID.

const plan: PlanInfo = await recur.getPlan("app_xxx", "plan_abc123");
 
console.log(plan.amountBaseUnits); // "5000000"
console.log(plan.intervalSeconds); // 2592000
console.log(plan.planSeed);        // "0100000000000000"

listPlans(appId)

Alias for getPlans. Returns the same PlanInfo[].

const plans = await recur.listPlans("app_xxx");

createPlan(options)

Create a new plan. Requires an API key or merchant authentication.

const plan = await recur.createPlan({
  appId: "app_xxx",
  name: "Pro Monthly",
  amount: 9_990_000, // $9.99 USDC
  intervalSeconds: 2_592_000, // 30 days
});

listSubscriptions(appId, options?)

List subscriptions for an app. Requires API key (merchant scope).

const subscriptions: SubscriptionInfo[] = await recur.listSubscriptions("app_xxx", {
  status: "active", // optional filter
});

getPaymentHistory(appId, options?)

Fetch payment transaction history for an app.

const payments: TransactionInfo[] = await recur.getPaymentHistory("app_xxx", {
  limit: 50,
  offset: 0,
});

getMySubscriptions(authToken, options?)

Fetch the authenticated subscriber's own subscriptions across all apps.

const token = await recur.authenticate(wallet);
const mySubs = await recur.getMySubscriptions(token);

registerSubscription(options, authToken)

Manually register a subscription with the API after on-chain creation. The high-level subscribe() calls this automatically — use this only if you built and sent the transaction yourself.

await recur.registerSubscription(
  {
    subscriptionPda: pda.toBase58(),
    planId: "plan_abc123",
    transactionSignature: sig,
  },
  token,
);

On-chain account data

getSubscriptionAccount(subscriptionPda)

Deserializes the on-chain subscription PDA data.

import { PublicKey } from "@solana/web3.js";
 
const data: OnChainSubscription = await recur.getSubscriptionAccount(
  new PublicKey("SUBSCRIPTIONPDAxxx..."),
);
 
console.log(data.subscriber);         // PublicKey
console.log(data.merchant);           // PublicKey
console.log(data.amount);             // BN (base units)
console.log(data.intervalSeconds);    // number
console.log(data.lastPaymentTimestamp); // number (unix)
console.log(data.cancelPending);      // boolean

deriveSubscriptionPda(subscriber, merchant, planSeedHex)

Derive the PDA address without building a transaction.

const { pda, bump } = recur.deriveSubscriptionPda(
  "SUBSCRIBERxxx...",
  "MERCHANTxxx...",
  "0100000000000000",
);