pulumi-stripe
Version:
A Pulumi package for creating and managing Stripe resources.
185 lines • 7.49 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.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 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>
* ```
*/
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, { ...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?.active;
resourceInputs["billingScheme"] = state?.billingScheme;
resourceInputs["currency"] = state?.currency;
resourceInputs["currencyOptions"] = state?.currencyOptions;
resourceInputs["customUnitAmount"] = state?.customUnitAmount;
resourceInputs["lookupKey"] = state?.lookupKey;
resourceInputs["metadata"] = state?.metadata;
resourceInputs["nickname"] = state?.nickname;
resourceInputs["product"] = state?.product;
resourceInputs["recurring"] = state?.recurring;
resourceInputs["taxBehavior"] = state?.taxBehavior;
resourceInputs["tiers"] = state?.tiers;
resourceInputs["tiersMode"] = state?.tiersMode;
resourceInputs["transferLookupKey"] = state?.transferLookupKey;
resourceInputs["transformQuantity"] = state?.transformQuantity;
resourceInputs["type"] = state?.type;
resourceInputs["unitAmount"] = state?.unitAmount;
resourceInputs["unitAmountDecimal"] = state?.unitAmountDecimal;
}
else {
const args = argsOrState;
if (args?.currency === undefined && !opts.urn) {
throw new Error("Missing required property 'currency'");
}
if (args?.product === undefined && !opts.urn) {
throw new Error("Missing required property 'product'");
}
resourceInputs["active"] = args?.active;
resourceInputs["billingScheme"] = args?.billingScheme;
resourceInputs["currency"] = args?.currency;
resourceInputs["currencyOptions"] = args?.currencyOptions;
resourceInputs["customUnitAmount"] = args?.customUnitAmount;
resourceInputs["lookupKey"] = args?.lookupKey;
resourceInputs["metadata"] = args?.metadata;
resourceInputs["nickname"] = args?.nickname;
resourceInputs["product"] = args?.product;
resourceInputs["recurring"] = args?.recurring;
resourceInputs["taxBehavior"] = args?.taxBehavior;
resourceInputs["tiers"] = args?.tiers;
resourceInputs["tiersMode"] = args?.tiersMode;
resourceInputs["transferLookupKey"] = args?.transferLookupKey;
resourceInputs["transformQuantity"] = args?.transformQuantity;
resourceInputs["unitAmount"] = args?.unitAmount;
resourceInputs["unitAmountDecimal"] = args?.unitAmountDecimal;
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