Version

Coupons

A project's coupons as a connector's creator surface lists, creates, pauses and deletes them — one code any number of members redeem for money off, checked the way the dashboard checks it.

Subscriby\Connector\Core\Coupons. A coupon is one code any number of members may redeem for money off; an access code is one code for one person and lives on AccessCodes. Every call takes the CreatorRef of the account talking and runs as that creator with the dashboard's own rules, and every refusal reaches you as CouponRefused with a stable reason.

listForProject()

foreach ($this->coupons->listForProject($creator, $project) as $coupon) {
    // $coupon->code, ->discountType, ->discountValue, ->currency, ->active, ->redemptions, ->planIds
}

The project's coupons, newest first, each a CouponDetails: the code (upper-cased), the name, percentage or fixed with the value and, for a fixed amount, the currency's ISO code, whether members may redeem it now, how many may in all and how many have, when it starts and stops working, and the plans it is narrowed to (empty for every plan).

create()

$coupon = $this->coupons->create($creator, $project, new CouponDraft(
    code: 'save25',
    discountType: CouponDraft::PERCENTAGE,
    discountValue: '25',
    maxRedemptions: 10,
    planIds: [$planId],
));

The draft is checked the way create_coupon checks it before the core writes: the code is 3 to 64 letters, digits and dashes and not taken in the project, a percentage is 1 to 100, a fixed amount names the currency of the plans it applies to, and every plan named belongs to the project. A name left out is the code itself; startsAt and expiresAt are ISO 8601 with a zone.

setActive() and delete()

$paused = $this->coupons->setActive($creator, $coupon->id, false);
$this->coupons->delete($creator, $coupon->id);

Pausing keeps the code and its history and stops new redemptions; the delete is the dashboard's own.

Refusals

CouponRefused carries a stable reason: creator_unknown, project_unknown, coupon_unknown, invalid (with the core's translated sentence naming what was wrong), tier_required (coupons are not on the creator's plan) and not_permitted.

A fixed amount never mixes currencies: the core refuses a fixed coupon without a currency, and the currency must be the one the plans it applies to are priced in.

How is this guide?

Last updated on

Version

On this page

Subscriby is a product
designed by you — for you.
No boardroom full of executives deciding what we ships next. Our roadmap always shaped by you with your feedback.

Share feedback or a request

For AI agents: llms.txt · llms-full.txt