1. Coupons
Documentation
  • Back to home
  • StripeKit
  • Installation
  • Getting Started
  • Choosing a Mode
  • Type Reference
  • Setup
    • Configuration
    • Timezones
    • Storage Adapter
    • Money and Currency
    • Error Handling
  • Stripe
    • Elements
  • Modules
    • Overview
    • Customers
      • Overview
      • List
      • Retrieve
      • Find or Create by Email
      • Create
      • Update
      • Sync
      • Delete
    • Payment Methods
      • Overview
      • Create Setup Intent
      • List
      • Attach
      • Detach
      • Set Default
      • Sync
    • Payments
      • Overview
      • Pay With Saved Method
      • Create
      • Retrieve
      • Confirm
      • Cancel
      • Sync
    • Checkout
      • Overview
      • Get
      • Create
      • Submit Fields
      • Apply Coupon
      • Mark Complete
    • Subscriptions
      • Overview
      • Create
      • Retrieve
      • Cancel
      • Resume
      • Toggle Collection Method
      • Update Fields
      • Apply Promotion Code
      • List By Customer
      • Find By Metadata
      • Sync
    • Invoices
      • Overview
      • Retrieve
      • List By Customer
      • List By Subscription
      • Pay With Saved Method
      • Void
      • Finalize
      • Sync
    • Coupons
      • Overview
      • Create
      • Validate
      • Apply To Subscription
      • List
      • Deactivate
    • Webhooks
      • Overview
      • Process
      • Events Reference
    • Sync
      • Overview
  1. Coupons

Validate

$kit->coupons->validate()#

Checks whether a plain-text coupon code is currently valid, active, and not expired or exhausted. Returns null instead of throwing when the code is invalid, so it's safe to call directly from checkout-form validation.

Signature#

Example request#

Example response — valid code#

Same shape as create()'s response:

Example response — invalid, expired, or unknown code#

Errors#

This method never throws for an invalid code, it returns null. It can still throw StripeOperationError for a genuine Stripe-side failure while searching.

Notes#

validate() returns null for a code that: doesn't exist, has been manually deactivated, has expired (expiresAt in the past), or has hit maxRedemptions. It does not distinguish between these reasons in the return value; if you need to tell the customer why a code failed, use list() to look it up separately and inspect active / expiresAtUtc / timesRedeemed vs maxRedemptions yourself.
Use the returned stripePromotionCodeId with $kit->subscriptions->applyPromotionCode() or as promotionCode on $kit->subscriptions->create().
Previous
Create
Next
Apply To Subscription
Built with