pulumi-stripe
Version:
A Pulumi package for creating and managing Stripe resources.
415 lines (414 loc) • 17.8 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "./types/input";
import * as outputs from "./types/output";
/**
* 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 API.
*
* ## 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 <price_id>
* ```
*/
export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: PriceState, opts?: pulumi.CustomResourceOptions): 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.
*/
static isInstance(obj: any): obj is Price;
/**
* Bool. Whether the price can be used for new purchases. Defaults to `true`.
*/
readonly active: pulumi.Output<boolean | undefined>;
/**
* 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.
*/
readonly billingScheme: pulumi.Output<string>;
/**
* String. Three-letter ISO currency code, in lowercase - [supported currencies](https://stripe.com/docs/currencies).
*/
readonly currency: pulumi.Output<string>;
/**
* List(Resource). Prices defined in each available currency option. For details
* of individual arguments see Currency Options.
*/
readonly currencyOptions: pulumi.Output<outputs.PriceCurrencyOption[] | undefined>;
/**
* 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.
*/
readonly customUnitAmount: pulumi.Output<outputs.PriceCustomUnitAmount | undefined>;
/**
* String. A lookup key used to retrieve prices dynamically from a static string.
*/
readonly lookupKey: pulumi.Output<string | undefined>;
/**
* 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.
*/
readonly metadata: pulumi.Output<{
[key: string]: string;
} | undefined>;
/**
* String. A brief description of the price, hidden from customers.
*/
readonly nickname: pulumi.Output<string | undefined>;
/**
* String. The ID of the product that this price will belong to.
*/
readonly product: pulumi.Output<string>;
/**
* List(Resource). The recurring components of a price such as `interval` and `usageType`. For
* details of individual arguments see Recurring.
*/
readonly recurring: pulumi.Output<outputs.PriceRecurring | undefined>;
/**
* 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`.
*/
readonly taxBehavior: pulumi.Output<string | undefined>;
/**
* 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.
*/
readonly tiers: pulumi.Output<outputs.PriceTier[] | undefined>;
/**
* 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.
*/
readonly tiersMode: pulumi.Output<string | undefined>;
/**
* Bool. If set to `true`, will atomically remove the lookup key from the existing
* price, and assign it to this price.
*/
readonly transferLookupKey: pulumi.Output<boolean | undefined>;
/**
* 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.
*/
readonly transformQuantity: pulumi.Output<outputs.PriceTransformQuantity | undefined>;
/**
* String. One of `oneTime` or `recurring` depending on whether the price is for a one-time purchase or a
* recurring (subscription) purchase.
*/
readonly type: pulumi.Output<string>;
/**
* Int. A positive integer in cents (or `-1` for a free
* price) representing how much to charge.
*/
readonly unitAmount: pulumi.Output<number>;
/**
* 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.
*/
readonly unitAmountDecimal: pulumi.Output<number>;
/**
* 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);
}
/**
* 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<boolean>;
/**
* 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>;
/**
* String. Three-letter ISO currency code, in lowercase - [supported currencies](https://stripe.com/docs/currencies).
*/
currency?: pulumi.Input<string>;
/**
* List(Resource). Prices defined in each available currency option. For details
* of individual arguments see Currency Options.
*/
currencyOptions?: pulumi.Input<pulumi.Input<inputs.PriceCurrencyOption>[]>;
/**
* 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<inputs.PriceCustomUnitAmount>;
/**
* String. A lookup key used to retrieve prices dynamically from a static string.
*/
lookupKey?: pulumi.Input<string>;
/**
* 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>;
}>;
/**
* String. A brief description of the price, hidden from customers.
*/
nickname?: pulumi.Input<string>;
/**
* String. The ID of the product that this price will belong to.
*/
product?: pulumi.Input<string>;
/**
* List(Resource). The recurring components of a price such as `interval` and `usageType`. For
* details of individual arguments see Recurring.
*/
recurring?: pulumi.Input<inputs.PriceRecurring>;
/**
* 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<string>;
/**
* 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<pulumi.Input<inputs.PriceTier>[]>;
/**
* 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<string>;
/**
* Bool. If set to `true`, will atomically remove the lookup key from the existing
* price, and assign it to this price.
*/
transferLookupKey?: pulumi.Input<boolean>;
/**
* 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<inputs.PriceTransformQuantity>;
/**
* 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<string>;
/**
* Int. A positive integer in cents (or `-1` for a free
* price) representing how much to charge.
*/
unitAmount?: pulumi.Input<number>;
/**
* 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<number>;
}
/**
* 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<boolean>;
/**
* 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>;
/**
* String. Three-letter ISO currency code, in lowercase - [supported currencies](https://stripe.com/docs/currencies).
*/
currency: pulumi.Input<string>;
/**
* List(Resource). Prices defined in each available currency option. For details
* of individual arguments see Currency Options.
*/
currencyOptions?: pulumi.Input<pulumi.Input<inputs.PriceCurrencyOption>[]>;
/**
* 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<inputs.PriceCustomUnitAmount>;
/**
* String. A lookup key used to retrieve prices dynamically from a static string.
*/
lookupKey?: pulumi.Input<string>;
/**
* 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>;
}>;
/**
* String. A brief description of the price, hidden from customers.
*/
nickname?: pulumi.Input<string>;
/**
* String. The ID of the product that this price will belong to.
*/
product: pulumi.Input<string>;
/**
* List(Resource). The recurring components of a price such as `interval` and `usageType`. For
* details of individual arguments see Recurring.
*/
recurring?: pulumi.Input<inputs.PriceRecurring>;
/**
* 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<string>;
/**
* 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<pulumi.Input<inputs.PriceTier>[]>;
/**
* 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<string>;
/**
* Bool. If set to `true`, will atomically remove the lookup key from the existing
* price, and assign it to this price.
*/
transferLookupKey?: pulumi.Input<boolean>;
/**
* 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<inputs.PriceTransformQuantity>;
/**
* Int. A positive integer in cents (or `-1` for a free
* price) representing how much to charge.
*/
unitAmount?: pulumi.Input<number>;
/**
* 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<number>;
}