Fetches a promo code based on the provided code and plan
import { whopSdk } from "@/lib/whop-sdk";
const result = await whopSdk.promoCodes.getPromoCode({
// The code of the promo code
code: "some string" /* Required! */,
// The ID of the plan to fetch the promo code for
planId: "xxxxxxxxxxx" /* Required! */,
});
const response = {
// The ID of the promo.
id: "xxxxxxxxxxx",
// The specific code used to apply the promo at checkout.
code: "some string",
// The timestamp of when the promo was created.
createdAt: 1716931200,
// The type (% or flat amount) of the promo.
promoType: "flat_amount" /* Valid values: flat_amount | percentage */,
// The monetary currency of the promo code.
baseCurrency:
"aed" /* Valid values: aed | all | amd | ape | ars | aud | bam | bgn | bhd | bob | brl | bsd | btc | cad | chf | clp | cop | crc | czk | dkk | dop | dzd | egp | etb | eth | eur | gbp | ghs | gmd | gtq | gyd | hkd | huf | idr | ils | inr | jmd | jod | jpy | kes | khr | krw | kwd | lkr | mad | mdl | mga | mkd | mnt | mop | mur | mxn | myr | nad | ngn | nok | nzd | omr | pen | php | pkr | pln | pyg | qar | ron | rsd | rub | rwf | sar | sek | sgd | thb | tnd | try | ttd | twd | tzs | usd | uyu | uzs | vnd | xcd | xof | zar */,
// The duration of the promo.
duration: "forever" /* Valid values: forever | once | repeating */,
// The amount off (% or flat amount) for the promo.
amountOff: 10,
// The amount off formatted for display.
discountOff: "some string",
// Restricts promo use to only be applied to already purchased memberships.
existingMembershipsOnly: true,
// The number of billing cycles the promo is applied for.
numberOfIntervals: 10,
// Whether or not the promo is a popup promo.
isPopupPromo: true,
};
Was this page helpful?