kerne is your secret-key client and asUser is kerne.withToken(userAccessToken), a client that acts as one signed-in user.
List plans
Your public pricing, for a pricing page. No secret key needed.amount is in the currency’s smallest unit (2900 is 29.00). interval is a count and a unit, D, M or Y: 1M is monthly, 1Y yearly. A price’s label groups equivalent prices across plans, such as every plan’s annual price.
Find a price id
NotFoundError if the plan or the label doesn’t exist, and a ValidationError if the plan has several prices and you didn’t pass a label.
Start a checkout
PLAN_PRICE_NOT_FOUND.
Required when the customer has no email on file. Also creates the customer if it doesn’t exist.
Prepaid allowances the buyer chose. Stripe only.
steps is capped at the plan’s maximum.Embedded card checkout
Stripe only. For a card form you build with Stripe.js instead of the hosted checkout page:createSubscriptionHeadless() requires your secret key, and Kerne checks with Stripe that the payment method belongs to this customer. Pass email when the customer has no email on file.
In CI or a seed script, pass
testCardToken: 'tok_visa' instead of stripePaymentMethodId: it
creates a new payment method on each call. Stripe test mode only.Read subscriptions
list() also filters by productSlug. On a withToken() client it only returns that user’s subscriptions.
status is ACTIVE, TRIALING, PAST_DUE, CANCELED, UNPAID or PAUSED. PAST_DUE keeps access unless your payment failure policy ends it; UNPAID ends it.
Change plan
Cancel
canceled_at is set now, and status becomes CANCELED at the end of the period. Cancelling immediately sets both now. Either way the payment provider is told first, so no further invoice goes out, and the subscription is kept for history.
billing.cancel() throws a NotFoundError (NO_ACTIVE_SUBSCRIPTION) when the user has no subscription.

