Skip to main content

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

ParameterTypeDescription
idstringFilter by AccruPay template ID.
transactionProviderTRANSACTION_PROVIDERFilter by provider enum value.
transactionProviderIdstringFilter by provider record ID.
namestringFilter by template name.
currencyCURRENCYFilter by currency.
providerCodestringProvider's template identifier.
providerParentTemplateCodestringProvider's parent template code.
providerStatusPAYMENT_PLAN_TEMPLATE_STATUSProvider-reported status.
skipnumberOffset-based pagination offset.
takenumberOffset-based page size.
afterstringCursor for forward pagination.
firstnumberPage size for forward cursor pagination.
beforestringCursor for backward pagination.
lastnumberPage size for backward cursor pagination.
sortingobjectSort field and direction.

getOne()

Fetch a single template by ID.

const template = await accrupay.paymentPlanTemplates.getOne({
merchantPaymentPlanTemplateId: 'template-id', // required
});
ParameterTypeRequiredDescription
merchantPaymentPlanTemplateIdstringYesAccruPay 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,
},
});
ParameterTypeRequiredDescription
merchantTransactionProviderIdstringYesAccruPay transaction provider ID.
dataMerchantPaymentPlanTemplateCreateSchemaYesTemplate 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,
},
});
ParameterTypeRequiredDescription
merchantTransactionProviderIdstringYesAccruPay transaction provider ID.
merchantPaymentPlanTemplateIdstringYesAccruPay template ID to update.
dataMerchantPaymentPlanTemplateUpdateSchemaYesFields 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
});
ParameterTypeRequiredDescription
merchantTransactionProviderIdstringYesAccruPay transaction provider ID.
providerCodestringYesThe provider's own template identifier.

Return shape

All methods return a PaymentPlanTemplate object (or a paginated list for getMany).

FieldTypeDescription
idstringAccruPay template ID.
namestringTemplate display name.
descriptionstring | nullOptional description.
amountbigintRecurring charge amount in smallest currency unit.
initialAmountbigintFirst-charge amount.
currencyCURRENCYISO 4217 currency.
providerCodestringProvider's template identifier.
providerErrorstring | nullLast provider error, if any.
providerLastSyncedAtstringISO timestamp of last sync.
providerLastVerifiedAtstringISO timestamp of last verification.
providerParentTemplateCodestring | nullProvider's parent template code.
providerStatusstringRaw status from provider.
transactionProviderIdstringAssociated transaction provider.
renewalIntervalDaysnumberDays between renewals.
renewalIntervalMonthsnumberMonths between renewals.
renewalIntervalYearsnumberYears between renewals.
endsAfterDaysnumberTemplate lifetime in days.
endsAfterMonthsnumberTemplate lifetime in months.
endsAfterYearsnumberTemplate lifetime in years.
trialPeriodDaysnumberTrial length in days.
trialPeriodMonthsnumberTrial length in months.
trialPeriodYearsnumberTrial length in years.
payloadobject | nullArbitrary metadata.
createdAtstringISO creation timestamp.
updatedAtstringISO last-update timestamp.