Skip to content
SDKProductWhat you sellOffer

Offer methods: trial, withdraw

The Offer Verbs trial, withdraw as typed SDK methods, with inputs, result, refusals and an example.

Reference for Offer, one group of Offer methods.

Offer.trial

Trial starts a Customer on an Offer free for a set number of days, with or without a card, converting or ending by its terms. Verb page.

TypeScript
interface OfferVerbs {
  trial(input: OfferTrialInput, options?: SB.CallOptions): SB.Call<OfferTrialOutput>
}

Emits Offer.trialed.

Inputs

InputTypeRequiredDescription
offerOfferrequiredThe Offer to try.
customerCustomerrequiredThe Customer who tries it.
daysintegerrequiredHow long the trial runs. Never randomized.
cardbooleanTrue to take a card up front and charge it when the trial ends.

Returns

OutputTypeRequiredDescription
subscriptionSubscriptionrequiredThe Subscription, free until the trial ends.
offerOfferrequiredThe Offer the trial is on.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

TypeScript
import { $ } from 'startup-builder'

const { subscription, offer } = await $.Offer.trial({ offer: 'offer_2hzYe1ERo0', customer: 'cus_K1BROJhqzZ', days: 1 })

Offer.withdraw

Withdraw closes a published Offer to new Customers and leaves every existing Order and Subscription in force. Verb page.

TypeScript
interface OfferVerbs {
  withdraw(input: OfferWithdrawInput, options?: SB.CallOptions): SB.Call<Offer>
}

Emits Offer.withdrawn.

Inputs

InputTypeRequiredDescription
offerOfferrequiredThe Offer to withdraw.

Returns

OutputTypeRequiredDescription
offerOfferrequiredThe Offer, closed to new acceptance.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
The record is not in a state that allows this Verb, so the call is refused.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.

Example

TypeScript
import { $ } from 'startup-builder'

const offer = await $.Offer.withdraw({ offer: 'offer_2hzYe1ERo0' })