Skip to content

basalt / subscriptions/src / attestedPlanForPrice

Function: attestedPlanForPrice() ​

> attestedPlanForPrice(metadata, charged, priceFor): object

Defined in: subscriptions/src/gateway.ts:80

Like attestedPlan, but only attests a plan whose gateway price (or variant) is among the prices the event actually CHARGED. Signed metadata is stamped once, at checkout; the price of a gateway subscription can change afterwards (a swap, or a plan change in the gateway's own portal) while the metadata keeps naming the old plan. Binding the attestation to the charged price stops a renewal of a cheap subscription from "attesting" an expensive plan. No charged price, an unknown plan or a mismatch → nothing (fail closed).

Parameters ​

metadata ​

Record<string, unknown> | null | undefined

charged ​

readonly string[]

priceFor ​

(plan, period) => string

Returns ​

object

period? ​

> optional period?: BillingPeriod

plan? ​

> optional plan?: string

Released under the MIT License.