pulumi-stripe
Version:
A Pulumi package for creating and managing Stripe resources.
115 lines • 5.02 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** 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
*
* ```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 <coupon_id>
* ```
*/
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, { ...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?.amountOff;
resourceInputs["appliesTos"] = state?.appliesTos;
resourceInputs["couponId"] = state?.couponId;
resourceInputs["currency"] = state?.currency;
resourceInputs["duration"] = state?.duration;
resourceInputs["durationInMonths"] = state?.durationInMonths;
resourceInputs["maxRedemptions"] = state?.maxRedemptions;
resourceInputs["metadata"] = state?.metadata;
resourceInputs["name"] = state?.name;
resourceInputs["percentOff"] = state?.percentOff;
resourceInputs["redeemBy"] = state?.redeemBy;
resourceInputs["timesRedeemed"] = state?.timesRedeemed;
resourceInputs["valid"] = state?.valid;
}
else {
const args = argsOrState;
resourceInputs["amountOff"] = args?.amountOff;
resourceInputs["appliesTos"] = args?.appliesTos;
resourceInputs["couponId"] = args?.couponId;
resourceInputs["currency"] = args?.currency;
resourceInputs["duration"] = args?.duration;
resourceInputs["durationInMonths"] = args?.durationInMonths;
resourceInputs["maxRedemptions"] = args?.maxRedemptions;
resourceInputs["metadata"] = args?.metadata;
resourceInputs["name"] = args?.name;
resourceInputs["percentOff"] = args?.percentOff;
resourceInputs["redeemBy"] = args?.redeemBy;
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