Skip to content
Cipay
Esc
navigateopen⌘Jpreview
On this page

Discounts

Inspect merchant discounts and safely check whether a code applies to checkout.

Use authenticated discount methods for merchant tooling. Use checkApplicability when a buyer enters a code during public checkout.

List discounts

List results are ready to display. Do not retrieve the first item again just to prove the detail endpoint works.

const discounts = await cipay.discounts.list({
  status: "active",
  pageSize: 25,
});

for (const discount of discounts.items) {
  console.info({ id: discount.id, code: discount.code, status: discount.status });
}

Retrieve one discount

Use a known discount ID from a route, selection, or stored reference when you need its current full record.

const discount = await cipay.discounts.retrieve(discountId);

console.info({
  id: discount.id,
  type: discount.type,
  value: discount.value,
  status: discount.status,
});

The merchant response includes the discount type and configured value. See the generated list and detail response schemas.

Check a buyer’s code

Let Cipay evaluate eligibility against the current checkout context. Do not reproduce private discount rules in browser code.

const result = await cipay.discounts.checkApplicability({
  locator: process.env.CIPAY_STOREFRONT_LOCATOR!,
  origin: "https://shop.example.test",
  offerId,
  code: buyerEnteredCode,
});

if (result.accepted) {
  console.info({ discountHalalas: result.discountHalalas });
}

The locator selects the public storefront. origin identifies the requesting website so Cipay can compare it with the storefront’s approved origins. createCipayBuyerHandler derives and forwards the origin automatically.

Possible outcomes are accepted, invalid, ineligible, expired, and rate_limited. Show one neutral message for rejected codes so private discount rules are not exposed.