@efaj/pulumi-dynamic-stripe 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Emmanuel Jimenez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # pulumi-dynamic-stripe
2
+
3
+ ![NPM Version](https://img.shields.io/npm/v/pulumi-dynamic-stripe)
4
+ ![License](https://img.shields.io/npm/l/pulumi-dynamic-stripe)
5
+ [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fefaj%2Fpulumi-dynamic-stripe.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fefaj%2Fpulumi-dynamic-stripe?ref=badge_shield)
6
+
7
+ A native Pulumi Dynamic Provider for Stripe.
8
+
9
+ ## Why this package?
10
+
11
+ The official `pulumi-stripe` package is a bridged Terraform provider that relies on an older version of the Stripe API. It lacks support for modern features, including Stripe Payment Links.
12
+
13
+ `pulumi-dynamic-stripe` solves this by natively wrapping the official Node.js `stripe` SDK using Pulumi's Dynamic Providers. Because it directly interfaces with the SDK, it can support any modern Stripe endpoint natively in TypeScript.
14
+
15
+ ## Features
16
+
17
+ This package provides native Pulumi resources for the following Stripe objects:
18
+ * **[Product](file:///media/efaj/data/workspace/pulumi-dynamic-stripe/src/index.ts#L57):** Represents a product you sell in Stripe.
19
+ * **[Price](file:///media/efaj/data/workspace/pulumi-dynamic-stripe/src/index.ts#L106):** Represents a price attached to a Product.
20
+ * **[PaymentLink](file:///media/efaj/data/workspace/pulumi-dynamic-stripe/src/index.ts#L48):** Represents a shareable URL that allows customers to purchase a Price.
21
+
22
+ ## Known Gaps
23
+
24
+ Currently, this library is focused on the core billing and checkout flow and only implements the three resources listed above (`Product`, `Price`, `PaymentLink`). Other Stripe objects (like `Customer`, `Subscription`, `Invoice`, etc.) are not yet supported.
25
+
26
+ Contributions to add more dynamic providers for other Stripe resources are highly welcome!
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ npm install pulumi-dynamic-stripe
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Here is a full example of provisioning a Product, attaching a Price to it, and generating a Payment Link for it—all managed as Pulumi infrastructure.
37
+
38
+ ```typescript
39
+ import * as pulumi from "@pulumi/pulumi";
40
+ import { Product, Price, PaymentLink } from "pulumi-dynamic-stripe";
41
+
42
+ const config = new pulumi.Config();
43
+ const stripeApiKey = config.requireSecret("stripeApiKey");
44
+
45
+ // 1. Create a Product
46
+ const premiumProduct = new Product("premium-product", {
47
+ apiKey: stripeApiKey,
48
+ name: "Premium Subscription",
49
+ description: "Access to all premium features",
50
+ });
51
+
52
+ // 2. Create a Price for the Product
53
+ const premiumPrice = new Price("premium-price", {
54
+ apiKey: stripeApiKey,
55
+ productId: premiumProduct.productId,
56
+ unitAmount: 2000, // $20.00
57
+ currency: "usd",
58
+ });
59
+
60
+ // 3. Generate a Payment Link for the Price
61
+ const premiumPaymentLink = new PaymentLink("premium-link", {
62
+ apiKey: stripeApiKey,
63
+ priceId: premiumPrice.priceId,
64
+ sparksAmount: "1000",
65
+ });
66
+
67
+ // Export the generated URL so it can be used in your application
68
+ export const paymentUrl = premiumPaymentLink.url;
69
+ ```
70
+
71
+ ## How it works
72
+
73
+ Behind the scenes, this library defines custom Pulumi Dynamic Resource Providers that implement the CRUD operations for Stripe entities via the `@pulumi/pulumi` and `stripe` Node packages.
@@ -0,0 +1,33 @@
1
+ import * as pulumi from "@pulumi/pulumi";
2
+ interface StripePaymentLinkArgs {
3
+ apiKey: pulumi.Input<string>;
4
+ priceId: pulumi.Input<string>;
5
+ sparksAmount: pulumi.Input<string>;
6
+ redirectUrl: pulumi.Input<string>;
7
+ allowPromotionCodes?: pulumi.Input<boolean>;
8
+ }
9
+ export declare class PaymentLink extends pulumi.dynamic.Resource {
10
+ readonly url: pulumi.Output<string>;
11
+ readonly paymentLinkId: pulumi.Output<string>;
12
+ constructor(name: string, args: StripePaymentLinkArgs, opts?: any);
13
+ }
14
+ interface StripeProductArgs {
15
+ apiKey: pulumi.Input<string>;
16
+ name: pulumi.Input<string>;
17
+ description?: pulumi.Input<string>;
18
+ }
19
+ export declare class Product extends pulumi.dynamic.Resource {
20
+ readonly productId: pulumi.Output<string>;
21
+ constructor(name: string, args: StripeProductArgs, opts?: any);
22
+ }
23
+ interface StripePriceArgs {
24
+ apiKey: pulumi.Input<string>;
25
+ productId: pulumi.Input<string>;
26
+ unitAmount: pulumi.Input<number>;
27
+ currency: pulumi.Input<string>;
28
+ }
29
+ export declare class Price extends pulumi.dynamic.Resource {
30
+ readonly priceId: pulumi.Output<string>;
31
+ constructor(name: string, args: StripePriceArgs, opts?: any);
32
+ }
33
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Price = exports.Product = exports.PaymentLink = void 0;
40
+ const pulumi = __importStar(require("@pulumi/pulumi"));
41
+ // @ts-ignore
42
+ const stripe_1 = __importDefault(require("stripe"));
43
+ class StripePaymentLinkProvider {
44
+ async create(inputs) {
45
+ const stripe = new stripe_1.default(inputs.apiKey, { apiVersion: '2022-11-15' }); // Using older API version to avoid typings mismatch if any
46
+ const paymentLink = await stripe.paymentLinks.create({
47
+ line_items: [{
48
+ price: inputs.priceId,
49
+ quantity: 1,
50
+ adjustable_quantity: {
51
+ enabled: true,
52
+ minimum: 1,
53
+ maximum: 100,
54
+ },
55
+ }],
56
+ after_completion: {
57
+ type: 'redirect',
58
+ redirect: {
59
+ url: inputs.redirectUrl,
60
+ }
61
+ },
62
+ allow_promotion_codes: inputs.allowPromotionCodes,
63
+ metadata: {
64
+ sparks: inputs.sparksAmount
65
+ }
66
+ });
67
+ return {
68
+ id: paymentLink.id,
69
+ outs: {
70
+ ...inputs,
71
+ paymentLinkId: paymentLink.id,
72
+ url: paymentLink.url,
73
+ }
74
+ };
75
+ }
76
+ async delete(id, props) {
77
+ const stripe = new stripe_1.default(props.apiKey, { apiVersion: '2022-11-15' });
78
+ // Payment links cannot be deleted, but they can be deactivated
79
+ await stripe.paymentLinks.update(id, { active: false });
80
+ }
81
+ }
82
+ const stripePaymentLinkProvider = new StripePaymentLinkProvider();
83
+ class PaymentLink extends pulumi.dynamic.Resource {
84
+ constructor(name, args, opts) {
85
+ super(stripePaymentLinkProvider, name, {
86
+ apiKey: args.apiKey,
87
+ priceId: args.priceId,
88
+ sparksAmount: args.sparksAmount,
89
+ redirectUrl: args.redirectUrl,
90
+ allowPromotionCodes: args.allowPromotionCodes,
91
+ paymentLinkId: undefined,
92
+ url: undefined,
93
+ }, opts);
94
+ }
95
+ }
96
+ exports.PaymentLink = PaymentLink;
97
+ class StripeProductProvider {
98
+ async create(inputs) {
99
+ const stripe = new stripe_1.default(inputs.apiKey, { apiVersion: '2022-11-15' });
100
+ const product = await stripe.products.create({
101
+ name: inputs.name,
102
+ description: inputs.description,
103
+ });
104
+ return {
105
+ id: product.id,
106
+ outs: {
107
+ ...inputs,
108
+ productId: product.id,
109
+ }
110
+ };
111
+ }
112
+ async update(id, olds, news) {
113
+ const stripe = new stripe_1.default(news.apiKey, { apiVersion: '2022-11-15' });
114
+ await stripe.products.update(id, {
115
+ name: news.name,
116
+ description: news.description,
117
+ });
118
+ return {
119
+ outs: {
120
+ ...news,
121
+ productId: id,
122
+ }
123
+ };
124
+ }
125
+ async delete(id, props) {
126
+ const stripe = new stripe_1.default(props.apiKey, { apiVersion: '2022-11-15' });
127
+ await stripe.products.update(id, { active: false });
128
+ }
129
+ }
130
+ class Product extends pulumi.dynamic.Resource {
131
+ constructor(name, args, opts) {
132
+ super(new StripeProductProvider(), name, { ...args, productId: undefined }, opts);
133
+ }
134
+ }
135
+ exports.Product = Product;
136
+ class StripePriceProvider {
137
+ async create(inputs) {
138
+ const stripe = new stripe_1.default(inputs.apiKey, { apiVersion: '2022-11-15' });
139
+ const price = await stripe.prices.create({
140
+ product: inputs.productId,
141
+ unit_amount: inputs.unitAmount,
142
+ currency: inputs.currency,
143
+ });
144
+ return {
145
+ id: price.id,
146
+ outs: {
147
+ ...inputs,
148
+ priceId: price.id,
149
+ }
150
+ };
151
+ }
152
+ async delete(id, props) {
153
+ const stripe = new stripe_1.default(props.apiKey, { apiVersion: '2022-11-15' });
154
+ await stripe.prices.update(id, { active: false });
155
+ }
156
+ }
157
+ class Price extends pulumi.dynamic.Resource {
158
+ constructor(name, args, opts) {
159
+ super(new StripePriceProvider(), name, { ...args, priceId: undefined }, opts);
160
+ }
161
+ }
162
+ exports.Price = Price;
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@efaj/pulumi-dynamic-stripe",
3
+ "version": "0.0.1",
4
+ "description": "A Pulumi Dynamic Provider for Stripe, supporting modern features like Payment Links.",
5
+ "keywords": [
6
+ "pulumi",
7
+ "stripe"
8
+ ],
9
+ "homepage": "https://github.com/efaj/pulumi-dynamic-stripe#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/efaj/pulumi-dynamic-stripe/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/efaj/pulumi-dynamic-stripe.git"
16
+ },
17
+ "license": "MIT",
18
+ "author": "Emmanuel Abarca Jimenez <efaj@crenet.games> (https://crenet.games/emmanuel)",
19
+ "type": "commonjs",
20
+ "main": "dist/index.js",
21
+ "types": "dist/index.d.ts",
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "prepare": "tsc"
25
+ },
26
+ "dependencies": {
27
+ "@pulumi/pulumi": "^3.259.0",
28
+ "stripe": "^22.6.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^26.4.0",
32
+ "typescript": "^6.0.3"
33
+ }
34
+ }