UNPKG

pulumi-stripe

Version:

A Pulumi package for creating and managing Stripe resources.

111 lines 5.48 kB
"use strict"; // *** 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! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Coupon = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./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 * * <!--Start PulumiCodeChooser --> * ```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], * }); * ``` * <!--End PulumiCodeChooser --> */ 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. */ static get(name, id, state, opts) { return new Coupon(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Coupon.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; 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; 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); } } exports.Coupon = Coupon; /** @internal */ Coupon.__pulumiType = 'stripe:index/coupon:Coupon'; //# sourceMappingURL=coupon.js.map