UNPKG

pulumi-stripe

Version:

A Pulumi package for creating and managing Stripe resources.

169 lines 7.81 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.Price = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * With this resource, you can create a price - [Stripe API price documentation](https://stripe.com/docs/api/prices). * * Prices define the unit cost, currency, and (optional) billing cycle for both recurring and one-time purchases of * products. Products help you track inventory or provisioning, and prices help you track payment terms. * * Different physical goods or levels of service should be represented by products, and pricing options should be * represented by prices. This approach lets you change prices without having to change your provisioning scheme. * * For example, you might have a single "gold" product that has prices for $10/month, $100/year, and €9 once. * * > Removal of the price isn't supported through the Stripe SDK. The best practice, which this provider follows, * is to archive the price by marking it as inactive on destroy, which indicates that the price is no longer * available for purchase. * * ## Example Usage * * <!--Start PulumiCodeChooser --> * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as stripe from "pulumi-stripe"; * * // basic price for the product * const pricePrice = new stripe.Price("pricePrice", { * product: stripe_product.product.id, * currency: "aud", * unitAmount: 100, * }); * // basic free price for the product * const priceIndex_pricePrice = new stripe.Price("priceIndex/pricePrice", { * product: stripe_product.product.id, * currency: "aud", * unitAmount: -1, * }); * // recurring price for the product * const priceStripeIndex_pricePrice = new stripe.Price("priceStripeIndex/pricePrice", { * product: stripe_product.product.id, * currency: "aud", * billingScheme: "per_unit", * unitAmount: 100, * recurring: { * interval: "week", * intervalCount: 1, * }, * }); * // tiered price for the product * const priceStripeIndex_pricePrice1 = new stripe.Price("priceStripeIndex/pricePrice1", { * product: stripe_product.product.id, * currency: "aud", * billingScheme: "tiered", * tiersMode: "graduated", * tiers: [ * { * upTo: 10, * unitAmount: 0, * }, * { * upTo: 100, * unitAmount: 300, * }, * { * upTo: -1, * unitAmountDecimal: 100.5, * }, * ], * recurring: { * interval: "week", * aggregateUsage: "sum", * intervalCount: 2, * usageType: "metered", * }, * }); * ``` * <!--End PulumiCodeChooser --> * * ## Note on updating prices * * Once created, you can update the `active`, `metadata`, `nickname`, `lookupKey`, `taxBehaviour` (only if unspecified) * and `transferLookupKey` attributes. * * Other attribute edits will trigger a destroy action (archival) and creation of a new price entry. */ class Price extends pulumi.CustomResource { /** * Get an existing Price 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 Price(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Price. 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'] === Price.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["active"] = state ? state.active : undefined; resourceInputs["billingScheme"] = state ? state.billingScheme : undefined; resourceInputs["currency"] = state ? state.currency : undefined; resourceInputs["currencyOptions"] = state ? state.currencyOptions : undefined; resourceInputs["lookupKey"] = state ? state.lookupKey : undefined; resourceInputs["metadata"] = state ? state.metadata : undefined; resourceInputs["nickname"] = state ? state.nickname : undefined; resourceInputs["product"] = state ? state.product : undefined; resourceInputs["recurring"] = state ? state.recurring : undefined; resourceInputs["taxBehaviour"] = state ? state.taxBehaviour : undefined; resourceInputs["tiers"] = state ? state.tiers : undefined; resourceInputs["tiersMode"] = state ? state.tiersMode : undefined; resourceInputs["transferLookupKey"] = state ? state.transferLookupKey : undefined; resourceInputs["transformQuantity"] = state ? state.transformQuantity : undefined; resourceInputs["type"] = state ? state.type : undefined; resourceInputs["unitAmount"] = state ? state.unitAmount : undefined; resourceInputs["unitAmountDecimal"] = state ? state.unitAmountDecimal : undefined; } else { const args = argsOrState; if ((!args || args.currency === undefined) && !opts.urn) { throw new Error("Missing required property 'currency'"); } if ((!args || args.product === undefined) && !opts.urn) { throw new Error("Missing required property 'product'"); } resourceInputs["active"] = args ? args.active : undefined; resourceInputs["billingScheme"] = args ? args.billingScheme : undefined; resourceInputs["currency"] = args ? args.currency : undefined; resourceInputs["currencyOptions"] = args ? args.currencyOptions : undefined; resourceInputs["lookupKey"] = args ? args.lookupKey : undefined; resourceInputs["metadata"] = args ? args.metadata : undefined; resourceInputs["nickname"] = args ? args.nickname : undefined; resourceInputs["product"] = args ? args.product : undefined; resourceInputs["recurring"] = args ? args.recurring : undefined; resourceInputs["taxBehaviour"] = args ? args.taxBehaviour : undefined; resourceInputs["tiers"] = args ? args.tiers : undefined; resourceInputs["tiersMode"] = args ? args.tiersMode : undefined; resourceInputs["transferLookupKey"] = args ? args.transferLookupKey : undefined; resourceInputs["transformQuantity"] = args ? args.transformQuantity : undefined; resourceInputs["unitAmount"] = args ? args.unitAmount : undefined; resourceInputs["unitAmountDecimal"] = args ? args.unitAmountDecimal : undefined; resourceInputs["type"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Price.__pulumiType, name, resourceInputs, opts); } } exports.Price = Price; /** @internal */ Price.__pulumiType = 'stripe:index/price:Price'; //# sourceMappingURL=price.js.map