UNPKG

pulumi-stripe

Version:

A Pulumi package for creating and managing Stripe resources.

115 lines 4.78 kB
"use strict"; // *** 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.PromotionCode = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * With this resource, you can create a promotion code - [Stripe API promotion code documentation](https://stripe.com/docs/api/promotion_codes). * * A Promotion Code represents a customer-redeemable code for a coupon. It can be used to create multiple codes for a single coupon. * * > Removal of the promotion code isn't supported through the Stripe API. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as stripe from "pulumi-stripe"; * * // promotion code for the coupon * const codePromotionCode = new stripe.PromotionCode("codePromotionCode", { * coupon: stripe_coupon.coupon.id, * code: "FREE", * }); * // promotion code for the coupon with limitations * const codeIndex_promotionCodePromotionCode = new stripe.PromotionCode("codeIndex/promotionCodePromotionCode", { * coupon: stripe_coupon.coupon.id, * code: "FREE", * maxRedemptions: 5, * expiresAt: "2025-08-03T08:37:18+00:00", * }); * // promotion code for the coupon to customer * const codeStripeIndex_promotionCodePromotionCode = new stripe.PromotionCode("codeStripeIndex/promotionCodePromotionCode", { * coupon: stripe_coupon.coupon.id, * code: "FREE", * customer: "cus...", * }); * // promotion code for the coupon with restrictions * const codeStripeIndex_promotionCodePromotionCode1 = new stripe.PromotionCode("codeStripeIndex/promotionCodePromotionCode1", { * coupon: stripe_coupon.coupon.id, * code: "FREE", * restrictions: { * firstTimeTransaction: true, * minimumAmount: 100, * minimumAmountCurrency: "aud", * }, * }); * ``` * * ## Import * * ```sh * $ pulumi import stripe:index/promotionCode:PromotionCode code <promotion_code_id> * ``` */ class PromotionCode extends pulumi.CustomResource { /** * Get an existing PromotionCode 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 PromotionCode(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of PromotionCode. 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'] === PromotionCode.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["active"] = state?.active; resourceInputs["code"] = state?.code; resourceInputs["coupon"] = state?.coupon; resourceInputs["customer"] = state?.customer; resourceInputs["expiresAt"] = state?.expiresAt; resourceInputs["maxRedemptions"] = state?.maxRedemptions; resourceInputs["metadata"] = state?.metadata; resourceInputs["restrictions"] = state?.restrictions; } else { const args = argsOrState; if (args?.coupon === undefined && !opts.urn) { throw new Error("Missing required property 'coupon'"); } resourceInputs["active"] = args?.active; resourceInputs["code"] = args?.code; resourceInputs["coupon"] = args?.coupon; resourceInputs["customer"] = args?.customer; resourceInputs["expiresAt"] = args?.expiresAt; resourceInputs["maxRedemptions"] = args?.maxRedemptions; resourceInputs["metadata"] = args?.metadata; resourceInputs["restrictions"] = args?.restrictions; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(PromotionCode.__pulumiType, name, resourceInputs, opts); } } exports.PromotionCode = PromotionCode; /** @internal */ PromotionCode.__pulumiType = 'stripe:index/promotionCode:PromotionCode'; //# sourceMappingURL=promotionCode.js.map