Plan Templates
Plan templates define the reusable billing configuration (interval, amount, trial) that payment plans are created from. Create a template once and stamp out as many plans as you need.
Methods
getMany()
List plan templates with optional filters and pagination.
import { CURRENCY } from '@accrupay/node';
const templates = await accrupay.paymentPlanTemplates.getMany({
currency: CURRENCY.USD,
take: 20,
skip: 0,
});
Filters
| Parameter | Type | Description |
|---|---|---|
id | string | Filter by AccruPay template ID. |
transactionProvider | TRANSACTION_PROVIDER | Filter by provider enum value. |
transactionProviderId | string | Filter by provider record ID. |
name | string | Filter by template name. |
currency | CURRENCY | Filter by currency. |
providerCode | string | Provider's template identifier. |
providerParentTemplateCode | string | Provider's parent template code. |
providerStatus | PAYMENT_PLAN_TEMPLATE_STATUS | Provider-reported status. |
skip | number | Offset-based pagination offset. |
take | number | Offset-based page size. |
after | string | Cursor for forward pagination. |
first | number | Page size for forward cursor pagination. |
before | string | Cursor for backward pagination. |
last | number | Page size for backward cursor pagination. |
sorting | object | Sort field and direction. |
getOne()
Fetch a single template by ID.
const template = await accrupay.paymentPlanTemplates.getOne({
merchantPaymentPlanTemplateId: 'template-id', // required
});
| Parameter | Type | Required | Description |
|---|---|---|---|
merchantPaymentPlanTemplateId | string | Yes | AccruPay template ID. |
createOne()
Create a new plan template.
import { CURRENCY } from '@accrupay/node';
const template = await accrupay.paymentPlanTemplates.createOne({
merchantTransactionProviderId: 'provider-id', // required
data: {
name: 'Monthly Pro',
description: 'Pro tier billed monthly',
amount: 4999n,
currency: CURRENCY.USD,
renewalIntervalMonths: 1,
renewalIntervalDays: 0,
renewalIntervalYears: 0,
endsAfterMonths: 0,
endsAfterDays: 0,
endsAfterYears: 0,
trialPeriodDays: 14,
trialPeriodMonths: 0,
trialPeriodYears: 0,
},
});
| Parameter | Type | Required | Description |
|---|---|---|---|
merchantTransactionProviderId | string | Yes | AccruPay transaction provider ID. |
data | MerchantPaymentPlanTemplateCreateSchema | Yes | Template creation payload. |
updateOne()
Update an existing template. Both IDs are required.
const updated = await accrupay.paymentPlanTemplates.updateOne({
merchantTransactionProviderId: 'provider-id', // required
merchantPaymentPlanTemplateId: 'template-id', // required
data: {
name: 'Monthly Pro — Updated',
trialPeriodDays: 7,
},
});
| Parameter | Type | Required | Description |
|---|---|---|---|
merchantTransactionProviderId | string | Yes | AccruPay transaction provider ID. |
merchantPaymentPlanTemplateId | string | Yes | AccruPay template ID to update. |
data | MerchantPaymentPlanTemplateUpdateSchema | Yes | Fields to update (partial). |
syncOne()
Pull the latest template state from the provider. Both parameters are required.
await accrupay.paymentPlanTemplates.syncOne({
merchantTransactionProviderId: 'provider-id', // required
providerCode: 'provider-template-code', // required
});
| Parameter | Type | Required | Description |
|---|---|---|---|
merchantTransactionProviderId | string | Yes | AccruPay transaction provider ID. |
providerCode | string | Yes | The provider's own template identifier. |
Return shape
All methods return a PaymentPlanTemplate object (or a paginated list for getMany).
| Field | Type | Description |
|---|---|---|
id | string | AccruPay template ID. |
name | string | Template display name. |
description | string | null | Optional description. |
amount | bigint | Recurring charge amount in smallest currency unit. |
initialAmount | bigint | First-charge amount. |
currency | CURRENCY | ISO 4217 currency. |
providerCode | string | Provider's template identifier. |
providerError | string | null | Last provider error, if any. |
providerLastSyncedAt | string | ISO timestamp of last sync. |
providerLastVerifiedAt | string | ISO timestamp of last verification. |
providerParentTemplateCode | string | null | Provider's parent template code. |
providerStatus | string | Raw status from provider. |
transactionProviderId | string | Associated transaction provider. |
renewalIntervalDays | number | Days between renewals. |
renewalIntervalMonths | number | Months between renewals. |
renewalIntervalYears | number | Years between renewals. |
endsAfterDays | number | Template lifetime in days. |
endsAfterMonths | number | Template lifetime in months. |
endsAfterYears | number | Template lifetime in years. |
trialPeriodDays | number | Trial length in days. |
trialPeriodMonths | number | Trial length in months. |
trialPeriodYears | number | Trial length in years. |
payload | object | null | Arbitrary metadata. |
createdAt | string | ISO creation timestamp. |
updatedAt | string | ISO last-update timestamp. |