Skip to main content
Create a coupon once, then pass its id or name as coupon when you create a payment intent. Modem Pay checks the coupon’s rules and takes the discount off the amount.

Create a coupon

Use modempay.coupons.create() to create a coupon. Coupons can offer a fixed amount or percentage discount and support options like duration, redemption limits, and restrictions. Example: Creating a 15% Off Coupon for a Market Promotion
This creates a coupon offering 15% off for purchases of at least 100 GMD, valid until June 30, 2025, and redeemable once. Example: Creating a 50 GMD Off Coupon for Mobile Data
This coupon gives 50 GMD off for first-time data bundle purchases of 200 GMD or more, with no expiry or redemption limit. Key Parameters
  • name : Descriptive name (e.g., “MarketFest”).
  • percent_off : Percentage discount (e.g., 15 for 15%). Use amount_off for fixed amounts.
  • currency : Set to “GMD” for all amounts.
  • duration : “once”, “repeating”, or “forever”.
  • duration_in_months : Required if duration is “repeating”.
  • max_redemptions : Maximum uses of the coupon.
  • redeem_by : Expiry date.
  • restrictions : Conditions like minimum_amount or first_time_transaction.

Get a coupon

Fetch a specific coupon’s details using modempay.coupons.retrieve().

List coupons

View all coupons with modempay.coupons.list(), with options to paginate or filter.
This retrieves up to 5 coupons with “Fest” in their name.

Update a coupon

Modify a coupon’s properties (e.g., name, redemption limits) using modempay.coupons.update().
This extends the coupon’s validity to July 31, 2025, and increases the redemption limit to 75.

Delete a coupon

Permanently remove a coupon with modempay.coupons.delete().

Use a coupon on a payment

Apply a coupon to a PaymentIntent to discount the transaction. Include the coupon id or name in the coupon field when creating a PaymentIntent.
If the coupon offers 15% off and the original amount is 150 GMD, the discounted amount will be 127.50 GMD (assuming the coupon is valid and meets restrictions). How It Works
  • Modem Pay validates the coupon’s restrictions (e.g., minimum_amount, first_time_transaction).
  • If valid, the discount (percent_off or amount_off) is applied to the PaymentIntent’s amount.
  • The coupon’s times_redeemed increments upon successful application.

Tips

  • Validate Restrictions: Ensure the coupon’s minimum_amount aligns with your pricing.
  • Test Thoroughly: Use test API keys to simulate coupon scenarios.
  • Monitor Usage: Track active coupons and redemptions with modempay.coupons.list().

When a coupon doesn’t apply

  • Invalid Coupon: Verify the coupon ID and ensure valid: true.
  • Restrictions Not Met: Check if the PaymentIntent meets minimum_amount or first_time_transaction requirements.
  • API Errors: Confirm API key setup and network connectivity.