// *** 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 inputs from "./types/input"; import * as outputs from "./types/output"; import * as utilities from "./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 * * ```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, * }); * // price with custom unit amount * const priceStripeIndex_pricePrice = new stripe.Price("priceStripeIndex/pricePrice", { * product: stripe_product.product.id, * currency: "aud", * customUnitAmount: { * enabled: true, * minimum: 500, * maximum: 50000, * preset: 1000, * }, * }); * // recurring price for the product * const priceStripeIndex_pricePrice1 = new stripe.Price("priceStripeIndex/pricePrice1", { * product: stripe_product.product.id, * currency: "aud", * billingScheme: "per_unit", * unitAmount: 100, * recurring: { * interval: "week", * intervalCount: 1, * }, * }); * // tiered price for the product * const priceStripeIndex_pricePrice2 = new stripe.Price("priceStripeIndex/pricePrice2", { * 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", * meter: "mtr_1234567890", * }, * }); * ``` * * ## Note on updating prices * * Once created, you can update the `active`, `metadata`, `nickname`, `lookupKey`, `taxBehavior` (only if unspecified) * and `transferLookupKey` attributes. * * Other attribute edits will trigger a destroy action (archival) and creation of a new price entry. * * ## Import * * ```sh * $ pulumi import stripe:index/price:Price price * ``` */ export 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. */ public static get(name: string, id: pulumi.Input, state?: PriceState, opts?: pulumi.CustomResourceOptions): Price { return new Price(name, state, { ...opts, id: id }); } /** @internal */ public static readonly __pulumiType = 'stripe:index/price:Price'; /** * 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. */ public static isInstance(obj: any): obj is Price { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Price.__pulumiType; } /** * Bool. Whether the price can be used for new purchases. Defaults to `true`. */ public readonly active!: pulumi.Output; /** * String. Describes how to compute the price per period. Either `perUnit` or `tiered` * . `perUnit` indicates that the fixed amount (specified in `unitAmount` or `unitAmountDecimal`) will be charged per * unit in quantity (for prices with `usage_type=licensed`), or per unit of total usage (for prices * with `usage_type=metered`). `tiered` indicates that the unit pricing will be computed using a tiering strategy as * defined using the `tiers` and `tiersMode` attributes. */ public readonly billingScheme!: pulumi.Output; /** * String. Three-letter ISO currency code, in lowercase - [supported currencies](https://stripe.com/docs/currencies). */ public readonly currency!: pulumi.Output; /** * List(Resource). Prices defined in each available currency option. For details * of individual arguments see Currency Options. */ public readonly currencyOptions!: pulumi.Output; /** * List(Resource). When set, provides configuration for the amount to be adjusted by * the customer during Checkout Sessions and Payment Links. * For individual fields see Custom Unit Amount. */ public readonly customUnitAmount!: pulumi.Output; /** * String. A lookup key used to retrieve prices dynamically from a static string. */ public readonly lookupKey!: 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. A brief description of the price, hidden from customers. */ public readonly nickname!: pulumi.Output; /** * String. The ID of the product that this price will belong to. */ public readonly product!: pulumi.Output; /** * List(Resource). The recurring components of a price such as `interval` and `usageType`. For * details of individual arguments see Recurring. */ public readonly recurring!: pulumi.Output; /** * String. Specifies whether the price is considered inclusive of taxes or exclusive of * taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it * cannot be changed, default is `unspecified`. */ public readonly taxBehavior!: pulumi.Output; /** * List(Resource). Each element represents a pricing tier. This parameter requires `billingScheme` * to be set to `tiered`. See also the documentation for `billingScheme`. For details of individual arguments * see Tiers. */ public readonly tiers!: pulumi.Output; /** * String. Defines if the tiering price should be `graduated` * or `volume` based. In `volume`-based tiering, the maximum quantity within a period determines the per-unit price, * in `graduated` tiering pricing can successively change as the quantity grows. */ public readonly tiersMode!: pulumi.Output; /** * Bool. If set to `true`, will atomically remove the lookup key from the existing * price, and assign it to this price. */ public readonly transferLookupKey!: pulumi.Output; /** * List(Resource). Apply a transformation to the reported usage or set quantity before * computing the billed price. Cannot be combined with `tiers`. For details of individual arguments * see Transform Quantity. */ public readonly transformQuantity!: pulumi.Output; /** * String. One of `oneTime` or `recurring` depending on whether the price is for a one-time purchase or a * recurring (subscription) purchase. */ public /*out*/ readonly type!: pulumi.Output; /** * Int. A positive integer in cents (or `-1` for a free * price) representing how much to charge. */ public readonly unitAmount!: pulumi.Output; /** * Float. Same as `unitAmount`, but accepts a decimal value in cents with at most 12 * decimal places. Only one of `unitAmount` and `unitAmountDecimal` can be set. */ public readonly unitAmountDecimal!: pulumi.Output; /** * Create a Price 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: PriceArgs, opts?: pulumi.CustomResourceOptions) constructor(name: string, argsOrState?: PriceArgs | PriceState, opts?: pulumi.CustomResourceOptions) { let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState as PriceState | undefined; 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["customUnitAmount"] = state ? state.customUnitAmount : 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["taxBehavior"] = state ? state.taxBehavior : 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 as PriceArgs | undefined; 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["customUnitAmount"] = args ? args.customUnitAmount : 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["taxBehavior"] = args ? args.taxBehavior : 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); } } /** * Input properties used for looking up and filtering Price resources. */ export interface PriceState { /** * Bool. Whether the price can be used for new purchases. Defaults to `true`. */ active?: pulumi.Input; /** * String. Describes how to compute the price per period. Either `perUnit` or `tiered` * . `perUnit` indicates that the fixed amount (specified in `unitAmount` or `unitAmountDecimal`) will be charged per * unit in quantity (for prices with `usage_type=licensed`), or per unit of total usage (for prices * with `usage_type=metered`). `tiered` indicates that the unit pricing will be computed using a tiering strategy as * defined using the `tiers` and `tiersMode` attributes. */ billingScheme?: pulumi.Input; /** * String. Three-letter ISO currency code, in lowercase - [supported currencies](https://stripe.com/docs/currencies). */ currency?: pulumi.Input; /** * List(Resource). Prices defined in each available currency option. For details * of individual arguments see Currency Options. */ currencyOptions?: pulumi.Input[]>; /** * List(Resource). When set, provides configuration for the amount to be adjusted by * the customer during Checkout Sessions and Payment Links. * For individual fields see Custom Unit Amount. */ customUnitAmount?: pulumi.Input; /** * String. A lookup key used to retrieve prices dynamically from a static string. */ lookupKey?: 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. A brief description of the price, hidden from customers. */ nickname?: pulumi.Input; /** * String. The ID of the product that this price will belong to. */ product?: pulumi.Input; /** * List(Resource). The recurring components of a price such as `interval` and `usageType`. For * details of individual arguments see Recurring. */ recurring?: pulumi.Input; /** * String. Specifies whether the price is considered inclusive of taxes or exclusive of * taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it * cannot be changed, default is `unspecified`. */ taxBehavior?: pulumi.Input; /** * List(Resource). Each element represents a pricing tier. This parameter requires `billingScheme` * to be set to `tiered`. See also the documentation for `billingScheme`. For details of individual arguments * see Tiers. */ tiers?: pulumi.Input[]>; /** * String. Defines if the tiering price should be `graduated` * or `volume` based. In `volume`-based tiering, the maximum quantity within a period determines the per-unit price, * in `graduated` tiering pricing can successively change as the quantity grows. */ tiersMode?: pulumi.Input; /** * Bool. If set to `true`, will atomically remove the lookup key from the existing * price, and assign it to this price. */ transferLookupKey?: pulumi.Input; /** * List(Resource). Apply a transformation to the reported usage or set quantity before * computing the billed price. Cannot be combined with `tiers`. For details of individual arguments * see Transform Quantity. */ transformQuantity?: pulumi.Input; /** * String. One of `oneTime` or `recurring` depending on whether the price is for a one-time purchase or a * recurring (subscription) purchase. */ type?: pulumi.Input; /** * Int. A positive integer in cents (or `-1` for a free * price) representing how much to charge. */ unitAmount?: pulumi.Input; /** * Float. Same as `unitAmount`, but accepts a decimal value in cents with at most 12 * decimal places. Only one of `unitAmount` and `unitAmountDecimal` can be set. */ unitAmountDecimal?: pulumi.Input; } /** * The set of arguments for constructing a Price resource. */ export interface PriceArgs { /** * Bool. Whether the price can be used for new purchases. Defaults to `true`. */ active?: pulumi.Input; /** * String. Describes how to compute the price per period. Either `perUnit` or `tiered` * . `perUnit` indicates that the fixed amount (specified in `unitAmount` or `unitAmountDecimal`) will be charged per * unit in quantity (for prices with `usage_type=licensed`), or per unit of total usage (for prices * with `usage_type=metered`). `tiered` indicates that the unit pricing will be computed using a tiering strategy as * defined using the `tiers` and `tiersMode` attributes. */ billingScheme?: pulumi.Input; /** * String. Three-letter ISO currency code, in lowercase - [supported currencies](https://stripe.com/docs/currencies). */ currency: pulumi.Input; /** * List(Resource). Prices defined in each available currency option. For details * of individual arguments see Currency Options. */ currencyOptions?: pulumi.Input[]>; /** * List(Resource). When set, provides configuration for the amount to be adjusted by * the customer during Checkout Sessions and Payment Links. * For individual fields see Custom Unit Amount. */ customUnitAmount?: pulumi.Input; /** * String. A lookup key used to retrieve prices dynamically from a static string. */ lookupKey?: 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. A brief description of the price, hidden from customers. */ nickname?: pulumi.Input; /** * String. The ID of the product that this price will belong to. */ product: pulumi.Input; /** * List(Resource). The recurring components of a price such as `interval` and `usageType`. For * details of individual arguments see Recurring. */ recurring?: pulumi.Input; /** * String. Specifies whether the price is considered inclusive of taxes or exclusive of * taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it * cannot be changed, default is `unspecified`. */ taxBehavior?: pulumi.Input; /** * List(Resource). Each element represents a pricing tier. This parameter requires `billingScheme` * to be set to `tiered`. See also the documentation for `billingScheme`. For details of individual arguments * see Tiers. */ tiers?: pulumi.Input[]>; /** * String. Defines if the tiering price should be `graduated` * or `volume` based. In `volume`-based tiering, the maximum quantity within a period determines the per-unit price, * in `graduated` tiering pricing can successively change as the quantity grows. */ tiersMode?: pulumi.Input; /** * Bool. If set to `true`, will atomically remove the lookup key from the existing * price, and assign it to this price. */ transferLookupKey?: pulumi.Input; /** * List(Resource). Apply a transformation to the reported usage or set quantity before * computing the billed price. Cannot be combined with `tiers`. For details of individual arguments * see Transform Quantity. */ transformQuantity?: pulumi.Input; /** * Int. A positive integer in cents (or `-1` for a free * price) representing how much to charge. */ unitAmount?: pulumi.Input; /** * Float. Same as `unitAmount`, but accepts a decimal value in cents with at most 12 * decimal places. Only one of `unitAmount` and `unitAmountDecimal` can be set. */ unitAmountDecimal?: pulumi.Input; }