-
Notifications
You must be signed in to change notification settings - Fork 67
Coupons
A coupon contains information about a percent-off discount you might want to apply to a customer. Coupons only apply to invoices created for recurring subscriptions and invoice items; they do not apply to one-off charges.
Godoc:
http://go.pkgdoc.org/github.com/bradrydzewski/go.stripe#Coupon
Official Stripe Documentation:
https://stripe.com/docs/api#coupon_object
You can create coupons easily via the coupon management page of the Stripe dashboard. Coupon creation is also accessible via the API if you need to create coupons on the fly.
params := stripe.CouponParams{
Id: "test coupon 1",
PercentOff: 5,
Duration: DurationOnce,
}
coupon, err := stripe.Coupons.Create(¶ms)
Input Parameters:
http://go.pkgdoc.org/github.com/bradrydzewski/go.stripe#CouponParams
Official Stripe Documentation:
https://stripe.com/docs/api#create_coupon
Retrieves the coupon with the given ID.
coupon, err := stripe.Coupons.Retrieve("JAVA-COUPON-0013fe18-a231-461f-b681-1b882e225fd7")
Official Stripe Documentation:
https://stripe.com/docs/api#retrieve_coupon
You can delete coupons via the coupon management page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can't redeem the coupon. You can also delete coupons via the API.
_, err := stripe.Coupons.Delete("JAVA-COUPON-0013fe18-a231-461f-b681-1b882e225fd7")
Official Stripe Documentation:
https://stripe.com/docs/api#delete_coupon
Returns a list of your coupons.
coupons, err := stripe.Coupons.List()
By default, List()
will only return 10 results at a time. To cycle through all Coupons you can use ListN()
, which accepts a start and offset parameter:
// get a list of 10 coupons, starting at position 40 in the list of coupons
coupons, err := stripe.Coupons.ListN(10, 40)
Official Stripe Documentation:
https://stripe.com/docs/api#list_coupons