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
Usemodempay.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
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 usingmodempay.coupons.retrieve().
List coupons
View all coupons withmodempay.coupons.list(), with options to paginate or filter.
Update a coupon
Modify a coupon’s properties (e.g., name, redemption limits) usingmodempay.coupons.update().
Delete a coupon
Permanently remove a coupon withmodempay.coupons.delete().
Use a coupon on a payment
Apply a coupon to a PaymentIntent to discount the transaction. Include the couponid or name in the coupon field when creating a PaymentIntent.
- Modem Pay validates the coupon’s restrictions (e.g.,
minimum_amount,first_time_transaction). - If valid, the discount (
percent_offoramount_off) is applied to thePaymentIntent’s amount. - The coupon’s
times_redeemedincrements upon successful application.
Tips
- Validate Restrictions: Ensure the coupon’s
minimum_amountaligns 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
PaymentIntentmeetsminimum_amountorfirst_time_transactionrequirements. - API Errors: Confirm API key setup and network connectivity.
