// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; /** * With this resource, you can create a coupon - [Stripe API coupon documentation](https://stripe.com/docs/api/coupons). * * A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer. * * A coupon has either a `percentOff` or an `amountOff` and `currency`. If you set an `amountOff`, that amount will be subtracted from any invoice’s subtotal. * * For example, an invoice with a subtotal of $100 will have a final total of $0 if a coupon with an amountOff of 20000 is applied to it and an invoice with a subtotal of $300 will have a final total of $100 if a coupon with an amountOff of 20000 is applied to it. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as stripe from "pulumi-stripe"; * * // coupon for the amount off discount * const couponCoupon = new stripe.Coupon("couponCoupon", { * amountOff: 1000, * currency: "aud", * duration: "once", * maxRedemptions: 10, * }); * // coupon for the percentage off discount * const couponIndex_couponCoupon = new stripe.Coupon("couponIndex/couponCoupon", { * percentOff: 33.3, * duration: "forever", * }); * // coupon with limitation to a date and the product only * const couponStripeIndex_couponCoupon = new stripe.Coupon("couponStripeIndex/couponCoupon", { * amountOff: 2000, * duration: "once", * redeemBy: "2025-07-23T03:27:06+00:00", * appliesTos: [stripe_product.product.id], * }); * ``` * * ## Import * * ```sh * $ pulumi import stripe:index/coupon:Coupon coupon * ``` */ export class Coupon extends pulumi.CustomResource { /** * Get an existing Coupon resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ public static get(name: string, id: pulumi.Input, state?: CouponState, opts?: pulumi.CustomResourceOptions): Coupon { return new Coupon(name, state, { ...opts, id: id }); } /** @internal */ public static readonly __pulumiType = 'stripe:index/coupon:Coupon'; /** * Returns true if the given object is an instance of Coupon. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ public static isInstance(obj: any): obj is Coupon { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Coupon.__pulumiType; } /** * Int. Amount (in the currency specified) that will be taken off the subtotal of any invoices for this customer. */ public readonly amountOff!: pulumi.Output; /** * List(String). A list of product IDs this coupon applies to. */ public readonly appliesTos!: pulumi.Output; /** * String. Unique string of your choice that will be used to identify this coupon when applying it to a customer. */ public readonly couponId!: pulumi.Output; /** * String. Required if `amountOff` has been set, the three-letter ISO code for the currency of the amount to take off. */ public readonly currency!: pulumi.Output; /** * String. Describes how long a customer who applies this coupon will get the discount. One of `forever`, `once`, and `repeating`. */ public readonly duration!: pulumi.Output; /** * If duration is repeating, the number of months the coupon applies. Null if coupon duration is forever or once. */ public readonly durationInMonths!: pulumi.Output; /** * Int. Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid. */ public readonly maxRedemptions!: pulumi.Output; /** * Map(String). Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. */ public readonly metadata!: pulumi.Output<{[key: string]: string} | undefined>; /** * String. Name of the coupon displayed to customers on for instance invoices or receipts. */ public readonly name!: pulumi.Output; /** * Float. Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percentOff of 50 will make a $100 invoice $50 instead. */ public readonly percentOff!: pulumi.Output; /** * String. Date after which the coupon can no longer be redeemed. Expected format is in the `RFC3339`. */ public readonly redeemBy!: pulumi.Output; /** * Int. Number of times this coupon has been applied to a customer. */ public /*out*/ readonly timesRedeemed!: pulumi.Output; /** * Bool. Taking account of the above properties, whether this coupon can still be applied to a customer. */ public /*out*/ readonly valid!: pulumi.Output; /** * Create a Coupon resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: CouponArgs, opts?: pulumi.CustomResourceOptions) constructor(name: string, argsOrState?: CouponArgs | CouponState, opts?: pulumi.CustomResourceOptions) { let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState as CouponState | undefined; resourceInputs["amountOff"] = state ? state.amountOff : undefined; resourceInputs["appliesTos"] = state ? state.appliesTos : undefined; resourceInputs["couponId"] = state ? state.couponId : undefined; resourceInputs["currency"] = state ? state.currency : undefined; resourceInputs["duration"] = state ? state.duration : undefined; resourceInputs["durationInMonths"] = state ? state.durationInMonths : undefined; resourceInputs["maxRedemptions"] = state ? state.maxRedemptions : undefined; resourceInputs["metadata"] = state ? state.metadata : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["percentOff"] = state ? state.percentOff : undefined; resourceInputs["redeemBy"] = state ? state.redeemBy : undefined; resourceInputs["timesRedeemed"] = state ? state.timesRedeemed : undefined; resourceInputs["valid"] = state ? state.valid : undefined; } else { const args = argsOrState as CouponArgs | undefined; resourceInputs["amountOff"] = args ? args.amountOff : undefined; resourceInputs["appliesTos"] = args ? args.appliesTos : undefined; resourceInputs["couponId"] = args ? args.couponId : undefined; resourceInputs["currency"] = args ? args.currency : undefined; resourceInputs["duration"] = args ? args.duration : undefined; resourceInputs["durationInMonths"] = args ? args.durationInMonths : undefined; resourceInputs["maxRedemptions"] = args ? args.maxRedemptions : undefined; resourceInputs["metadata"] = args ? args.metadata : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["percentOff"] = args ? args.percentOff : undefined; resourceInputs["redeemBy"] = args ? args.redeemBy : undefined; resourceInputs["timesRedeemed"] = undefined /*out*/; resourceInputs["valid"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Coupon.__pulumiType, name, resourceInputs, opts); } } /** * Input properties used for looking up and filtering Coupon resources. */ export interface CouponState { /** * Int. Amount (in the currency specified) that will be taken off the subtotal of any invoices for this customer. */ amountOff?: pulumi.Input; /** * List(String). A list of product IDs this coupon applies to. */ appliesTos?: pulumi.Input[]>; /** * String. Unique string of your choice that will be used to identify this coupon when applying it to a customer. */ couponId?: pulumi.Input; /** * String. Required if `amountOff` has been set, the three-letter ISO code for the currency of the amount to take off. */ currency?: pulumi.Input; /** * String. Describes how long a customer who applies this coupon will get the discount. One of `forever`, `once`, and `repeating`. */ duration?: pulumi.Input; /** * If duration is repeating, the number of months the coupon applies. Null if coupon duration is forever or once. */ durationInMonths?: pulumi.Input; /** * Int. Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid. */ maxRedemptions?: pulumi.Input; /** * Map(String). Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. */ metadata?: pulumi.Input<{[key: string]: pulumi.Input}>; /** * String. Name of the coupon displayed to customers on for instance invoices or receipts. */ name?: pulumi.Input; /** * Float. Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percentOff of 50 will make a $100 invoice $50 instead. */ percentOff?: pulumi.Input; /** * String. Date after which the coupon can no longer be redeemed. Expected format is in the `RFC3339`. */ redeemBy?: pulumi.Input; /** * Int. Number of times this coupon has been applied to a customer. */ timesRedeemed?: pulumi.Input; /** * Bool. Taking account of the above properties, whether this coupon can still be applied to a customer. */ valid?: pulumi.Input; } /** * The set of arguments for constructing a Coupon resource. */ export interface CouponArgs { /** * Int. Amount (in the currency specified) that will be taken off the subtotal of any invoices for this customer. */ amountOff?: pulumi.Input; /** * List(String). A list of product IDs this coupon applies to. */ appliesTos?: pulumi.Input[]>; /** * String. Unique string of your choice that will be used to identify this coupon when applying it to a customer. */ couponId?: pulumi.Input; /** * String. Required if `amountOff` has been set, the three-letter ISO code for the currency of the amount to take off. */ currency?: pulumi.Input; /** * String. Describes how long a customer who applies this coupon will get the discount. One of `forever`, `once`, and `repeating`. */ duration?: pulumi.Input; /** * If duration is repeating, the number of months the coupon applies. Null if coupon duration is forever or once. */ durationInMonths?: pulumi.Input; /** * Int. Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid. */ maxRedemptions?: pulumi.Input; /** * Map(String). Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. */ metadata?: pulumi.Input<{[key: string]: pulumi.Input}>; /** * String. Name of the coupon displayed to customers on for instance invoices or receipts. */ name?: pulumi.Input; /** * Float. Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percentOff of 50 will make a $100 invoice $50 instead. */ percentOff?: pulumi.Input; /** * String. Date after which the coupon can no longer be redeemed. Expected format is in the `RFC3339`. */ redeemBy?: pulumi.Input; }