Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(app-connections): add Stripe app connection

Calvin551d66026236
diff --git a/.env.dev.example b/.env.dev.example
index fbc3c73063..233cb1a300 100644
--- a/.env.dev.example
+++ b/.env.dev.example
@@ -138,6 +138,13 @@ INF_APP_CONNECTION_AZURE_CLIENT_SECRETS_CLIENT_SECRET=
INF_APP_CONNECTION_AZURE_DEVOPS_CLIENT_ID=
INF_APP_CONNECTION_AZURE_DEVOPS_CLIENT_SECRET=
+# stripe app connection
+# Stripe issues a different install link per mode (sandbox/test/live); the link and the secret key
+# below must be for the same mode. Copy the link from the Stripe dashboard.
+INF_APP_CONNECTION_STRIPE_OAUTH_CLIENT_ID=
+INF_APP_CONNECTION_STRIPE_OAUTH_AUTHORIZE_URL=
+INF_APP_CONNECTION_STRIPE_SECRET_KEY=
+
# heroku app connection
INF_APP_CONNECTION_HEROKU_OAUTH_CLIENT_ID=
INF_APP_CONNECTION_HEROKU_OAUTH_CLIENT_SECRET=
diff --git a/.env.example b/.env.example
index b66bc323ba..60f46db05e 100644
--- a/.env.example
+++ b/.env.example
@@ -125,6 +125,13 @@ INF_APP_CONNECTION_AZURE_CLIENT_SECRETS_CLIENT_SECRET=
INF_APP_CONNECTION_AZURE_DEVOPS_CLIENT_ID=
INF_APP_CONNECTION_AZURE_DEVOPS_CLIENT_SECRET=
+# stripe app connection
+# Stripe issues a different install link per mode (sandbox/test/live); the link and the secret key
+# below must be for the same mode. Copy the link from the Stripe dashboard.
+INF_APP_CONNECTION_STRIPE_OAUTH_CLIENT_ID=
+INF_APP_CONNECTION_STRIPE_OAUTH_AUTHORIZE_URL=
+INF_APP_CONNECTION_STRIPE_SECRET_KEY=
+
# heroku app connection
INF_APP_CONNECTION_HEROKU_OAUTH_CLIENT_ID=
INF_APP_CONNECTION_HEROKU_OAUTH_CLIENT_SECRET=
diff --git a/CLAUDE.md b/CLAUDE.md
index fd0b4fc09b..b00885356b 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -23,6 +23,7 @@ infisical/
├── frontend/ # React 18 SPA (see frontend/CLAUDE.md)
├── wasm/ # Rust crates compiled to WASM for the frontend (see wasm/<crate>/CLAUDE.md)
├── e2e/ # External Playwright suite — gates prod deploys against gamma (see e2e/CLAUDE.md)
+├── stripe-app/ # Stripe App manifest granting Infisical api_key_write (see stripe-app/README.md)
├── docs/ # Documentation site (Mintlify-based)
├── build-versions.env # Versions pinned across several Dockerfiles (see Dependency Policy)
├── docker-compose.dev.yml # Local dev (PostgreSQL, Redis, backend, frontend, Nginx)
diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.ts
index 5c69295a71..517e8126fe 100644
--- a/backend/src/lib/config/env.ts
+++ b/backend/src/lib/config/env.ts
@@ -560,6 +560,11 @@ const envSchema = z
INF_APP_CONNECTION_HEROKU_OAUTH_CLIENT_ID: zpStr(z.string().optional()),
INF_APP_CONNECTION_HEROKU_OAUTH_CLIENT_SECRET: zpStr(z.string().optional()),
+ // Stripe App Connection
+ INF_APP_CONNECTION_STRIPE_OAUTH_CLIENT_ID: zpStr(z.string().optional()),
+ INF_APP_CONNECTION_STRIPE_SECRET_KEY: zpStr(z.string().optional()),
+ INF_APP_CONNECTION_STRIPE_OAUTH_AUTHORIZE_URL: zpStr(z.string().optional()),
+
// datadog
SHOULD_USE_DATADOG_TRACER: zodStrBool.default("false"),
DATADOG_PROFILING_ENABLED: zodStrBool.default("false"),
@@ -1077,6 +1082,25 @@ export const overwriteSchema: {
}
]
},
+ stripe: {
+ name: "Stripe",
+ fields: [
+ {
+ key: "INF_APP_CONNECTION_STRIPE_OAUTH_CLIENT_ID",
+ description: "The Client ID of your Stripe app."
+ },
+ {
+ key: "INF_APP_CONNECTION_STRIPE_OAUTH_AUTHORIZE_URL",
+ description:
+ "The OAuth install link for your Stripe app, copied from the Stripe dashboard. Stripe issues a different link per mode, and the link must match the mode of the secret key below."
+ },
+ {
+ key: "INF_APP_CONNECTION_STRIPE_SECRET_KEY",
+ description:
+ "The secret API key of the Stripe account that owns your Stripe app. Infisical authenticates as this account and names the customer's account with Stripe-Context."
+ }
+ ]
+ },
secretSharing: {
name: "Secret Sharing",
fields: [
diff --git a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
index 3df65a765a..0176cdecef 100644
--- a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
@@ -228,6 +228,7 @@ import {
SpaceliftConnectionListItemSchema
} from "@app/services/app-connection/spacelift";
import { SanitizedSshConnectionSchema, SshConnectionListItemSchema } from "@app/services/app-connection/ssh";
+import { SanitizedStripeConnectionSchema, StripeConnectionListItemSchema } from "@app/services/app-connection/stripe";
import {
SanitizedSupabaseConnectionSchema,
SupabaseConnectionListItemSchema
@@ -350,7 +351,8 @@ const SanitizedAppConnectionSchema = z.union([
...SanitizedFireworksConnectionSchema.options,
...SanitizedNutanixPrismCentralConnectionSchema.options,
...SanitizedSpaceliftConnectionSchema.options,
- ...SanitizedDaytonaConnectionSchema.options
+ ...SanitizedDaytonaConnectionSchema.options,
+ ...SanitizedStripeConnectionSchema.options
]);
const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
@@ -437,7 +439,8 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
FireworksConnectionListItemSchema,
NutanixPrismCentralConnectionListItemSchema,
SpaceliftConnectionListItemSchema,
- DaytonaConnectionListItemSchema
+ DaytonaConnectionListItemSchema,
+ StripeConnectionListItemSchema
]);
export const registerAppConnectionRouter = async (server: FastifyZodProvider) => {
diff --git a/backend/src/server/routes/v1/app-connection-routers/index.ts b/backend/src/server/routes/v1/app-connection-routers/index.ts
index 1c0bd300ce..fe6d35a1f8 100644
--- a/backend/src/server/routes/v1/app-connection-routers/index.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/index.ts
@@ -73,6 +73,7 @@ import { registerSmbConnectionRouter } from "./smb-connection-router";
import { registerSnowflakeConnectionRouter } from "./snowflake-connection-router";
import { registerSpaceliftConnectionRouter } from "./spacelift-connection-router";
import { registerSshConnectionRouter } from "./ssh-connection-router";
+import { registerStripeConnectionRouter } from "./stripe-connection-router";
import { registerSupabaseConnectionRouter } from "./supabase-connection-router";
import { registerTeamCityConnectionRouter } from "./teamcity-connection-router";
import { registerTerraformCloudConnectionRouter } from "./terraform-cloud-router";
@@ -172,5 +173,6 @@ export const APP_CONNECTION_REGISTER_ROUTER_MAP: Record<AppConnection, (server:
[AppConnection.Fireworks]: registerFireworksConnectionRouter,
[AppConnection.NutanixPrismCentral]: registerNutanixPrismCentralConnectionRouter,
[AppConnection.Spacelift]: registerSpaceliftConnectionRouter,
- [AppConnection.Daytona]: registerDaytonaConnectionRouter
+ [AppConnection.Daytona]: registerDaytonaConnectionRouter,
+ [AppConnection.Stripe]: registerStripeConnectionRouter
};
diff --git a/backend/src/server/routes/v1/app-connection-routers/stripe-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/stripe-connection-router.ts
new file mode 100644
index 0000000000..56c520c355
--- /dev/null
+++ b/backend/src/server/routes/v1/app-connection-routers/stripe-connection-router.ts
@@ -0,0 +1,18 @@
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import {
+ CreateStripeConnectionSchema,
+ SanitizedStripeConnectionSchema,
+ UpdateStripeConnectionSchema
+} from "@app/services/app-connection/stripe";
+
+import { registerAppConnectionEndpoints } from "./app-connection-endpoints";
+
+export const registerStripeConnectionRouter = async (server: FastifyZodProvider) => {
+ registerAppConnectionEndpoints({
+ app: AppConnection.Stripe,
+ server,
+ sanitizedResponseSchema: SanitizedStripeConnectionSchema,
+ createSchema: CreateStripeConnectionSchema,
+ updateSchema: UpdateStripeConnectionSchema
+ });
+};
diff --git a/backend/src/services/app-connection/app-connection-enums.ts b/backend/src/services/app-connection/app-connection-enums.ts
index fc25ba96ee..eccea4851d 100644
--- a/backend/src/services/app-connection/app-connection-enums.ts
+++ b/backend/src/services/app-connection/app-connection-enums.ts
@@ -82,7 +82,8 @@ export enum AppConnection {
MicrosoftIntune = "microsoft-intune",
NutanixPrismCentral = "nutanix-prism-central",
Spacelift = "spacelift",
- Daytona = "daytona"
+ Daytona = "daytona",
+ Stripe = "stripe"
}
export enum AWSRegion {
diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.ts
index f406d616cd..953bb48a50 100644
--- a/backend/src/services/app-connection/app-connection-fns.ts
+++ b/backend/src/services/app-connection/app-connection-fns.ts
@@ -263,6 +263,8 @@ import {
validateSpaceliftConnectionCredentials
} from "./spacelift";
import { getSshConnectionListItem, SshConnectionMethod, validateSshConnectionCredentials } from "./ssh";
+import { StripeConnectionMethod } from "./stripe";
+import { getStripeConnectionListItem, validateStripeConnectionCredentials } from "./stripe/stripe-connection-fns";
import {
getSupabaseConnectionListItem,
SupabaseConnectionMethod,
@@ -427,7 +429,8 @@ export const listAppConnectionOptions = (projectType?: ProjectType) => {
getFireworksConnectionListItem(),
getNutanixPrismCentralConnectionListItem(),
getSpaceliftConnectionListItem(),
- getDaytonaConnectionListItem()
+ getDaytonaConnectionListItem(),
+ getStripeConnectionListItem()
]
.filter((option) => {
switch (projectType) {
@@ -683,7 +686,8 @@ export const validateAppConnectionCredentials = async (
[AppConnection.NutanixPrismCentral]:
validateNutanixPrismCentralConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.Spacelift]: validateSpaceliftConnectionCredentials as TAppConnectionCredentialsValidator,
- [AppConnection.Daytona]: validateDaytonaConnectionCredentials as TAppConnectionCredentialsValidator
+ [AppConnection.Daytona]: validateDaytonaConnectionCredentials as TAppConnectionCredentialsValidator,
+ [AppConnection.Stripe]: validateStripeConnectionCredentials as TAppConnectionCredentialsValidator
};
return VALIDATE_APP_CONNECTION_CREDENTIALS_MAP[appConnection.app](appConnection, gatewayService, gatewayV2Service);
@@ -707,6 +711,7 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>
case HerokuConnectionMethod.OAuth:
case GitLabConnectionMethod.OAuth:
case VenafiTppConnectionMethod.OAuth:
+ case StripeConnectionMethod.OAuth:
return "OAuth";
case HerokuConnectionMethod.AuthToken:
return "Auth Token";
@@ -955,7 +960,8 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<
[AppConnection.Fireworks]: platformManagedCredentialsNotSupported,
[AppConnection.NutanixPrismCentral]: platformManagedCredentialsNotSupported,
[AppConnection.Spacelift]: platformManagedCredentialsNotSupported,
- [AppConnection.Daytona]: platformManagedCredentialsNotSupported
+ [AppConnection.Daytona]: platformManagedCredentialsNotSupported,
+ [AppConnection.Stripe]: platformManagedCredentialsNotSupported
};
export const enterpriseAppCheck = async (
diff --git a/backend/src/services/app-connection/app-connection-maps.ts b/backend/src/services/app-connection/app-connection-maps.ts
index ed5a59f6eb..4fc48d36dc 100644
--- a/backend/src/services/app-connection/app-connection-maps.ts
+++ b/backend/src/services/app-connection/app-connection-maps.ts
@@ -84,7 +84,8 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {
[AppConnection.NutanixPrismCentral]: "Nutanix Prism Central",
[AppConnection.Spacelift]: "Spacelift",
[AppConnection.Daytona]: "Daytona",
- [AppConnection.MicrosoftIntune]: "Microsoft Intune"
+ [AppConnection.MicrosoftIntune]: "Microsoft Intune",
+ [AppConnection.Stripe]: "Stripe"
};
export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanType> = {
@@ -171,5 +172,6 @@ export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanTyp
[AppConnection.NutanixPrismCentral]: AppConnectionPlanType.Regular,
[AppConnection.Spacelift]: AppConnectionPlanType.Regular,
[AppConnection.Daytona]: AppConnectionPlanType.Regular,
- [AppConnection.MicrosoftIntune]: AppConnectionPlanType.Enterprise
+ [AppConnection.MicrosoftIntune]: AppConnectionPlanType.Enterprise,
+ [AppConnection.Stripe]: AppConnectionPlanType.Regular
};
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index fe8a3940a0..b4fd93297e 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -181,6 +181,7 @@ import { snowflakeConnectionService } from "./snowflake/snowflake-connection-ser
import { ValidateSpaceliftConnectionCredentialsSchema } from "./spacelift";
import { spaceliftConnectionService } from "./spacelift/spacelift-connection-service";
import { ValidateSshConnectionCredentialsSchema } from "./ssh";
+import { ValidateStripeConnectionCredentialsSchema } from "./stripe";
import { ValidateSupabaseConnectionCredentialsSchema } from "./supabase";
import { supabaseConnectionService } from "./supabase/supabase-connection-service";
import { ValidateTeamCityConnectionCredentialsSchema } from "./teamcity";
@@ -308,7 +309,8 @@ const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAp
[AppConnection.Fireworks]: ValidateFireworksConnectionCredentialsSchema,
[AppConnection.NutanixPrismCentral]: ValidateNutanixPrismCentralConnectionCredentialsSchema,
[AppConnection.Spacelift]: ValidateSpaceliftConnectionCredentialsSchema,
- [AppConnection.Daytona]: ValidateDaytonaConnectionCredentialsSchema
+ [AppConnection.Daytona]: ValidateDaytonaConnectionCredentialsSchema,
+ [AppConnection.Stripe]: ValidateStripeConnectionCredentialsSchema
};
export const appConnectionServiceFactory = ({
diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.ts
index 27a67e730c..ead8f24301 100644
--- a/backend/src/services/app-connection/app-connection-types.ts
+++ b/backend/src/services/app-connection/app-connection-types.ts
@@ -431,6 +431,12 @@ import {
TSshConnectionInput,
TValidateSshConnectionCredentialsSchema
} from "./ssh";
+import {
+ TStripeConnection,
+ TStripeConnectionConfig,
+ TStripeConnectionInput,
+ TValidateStripeConnectionCredentialsSchema
+} from "./stripe";
import {
TSupabaseConnection,
TSupabaseConnectionConfig,
@@ -585,6 +591,7 @@ export type TAppConnection = { id: string; configuration?: TAppConnectionConfigu
| TNutanixPrismCentralConnection
| TSpaceliftConnection
| TDaytonaConnection
+ | TStripeConnection
);
export type TAppConnectionRaw = NonNullable<Awaited<ReturnType<TAppConnectionDALFactory["findById"]>>>;
@@ -680,6 +687,7 @@ export type TAppConnectionInput = { id: string } & (
| TNutanixPrismCentralConnectionInput
| TSpaceliftConnectionInput
| TDaytonaConnectionInput
+ | TStripeConnectionInput
);
export type TSqlConnectionInput =
@@ -806,7 +814,8 @@ export type TAppConnectionConfig =
| TFireworksConnectionConfig
| TNutanixPrismCentralConnectionConfig
| TSpaceliftConnectionConfig
- | TDaytonaConnectionConfig;
+ | TDaytonaConnectionConfig
+ | TStripeConnectionConfig;
export type TValidateAppConnectionCredentialsSchema =
| TValidateAwsConnectionCredentialsSchema
@@ -892,7 +901,8 @@ export type TValidateAppConnectionCredentialsSchema =
| TValidateFireworksConnectionCredentialsSchema
| TValidateNutanixPrismCentralConnectionCredentialsSchema
| TValidateSpaceliftConnectionCredentialsSchema
- | TValidateDaytonaConnectionCredentialsSchema;
+ | TValidateDaytonaConnectionCredentialsSchema
+ | TValidateStripeConnectionCredentialsSchema;
export type TListAwsConnectionKmsKeys = {
connectionId: string;
diff --git a/backend/src/services/app-connection/stripe/index.ts b/backend/src/services/app-connection/stripe/index.ts
new file mode 100644
index 0000000000..28ad524180
--- /dev/null
+++ b/backend/src/services/app-connection/stripe/index.ts
@@ -0,0 +1,3 @@
+export * from "./stripe-connection-enums";
+export * from "./stripe-connection-schemas";
+export * from "./stripe-connection-types";
diff --git a/backend/src/services/app-connection/stripe/stripe-connection-enums.ts b/backend/src/services/app-connection/stripe/stripe-connection-enums.ts
new file mode 100644
index 0000000000..ffae78bfd6
--- /dev/null
+++ b/backend/src/services/app-connection/stripe/stripe-connection-enums.ts
@@ -0,0 +1,3 @@
+export enum StripeConnectionMethod {
+ OAuth = "oauth"
+}
diff --git a/backend/src/services/app-connection/stripe/stripe-connection-fns.ts b/backend/src/services/app-connection/stripe/stripe-connection-fns.ts
new file mode 100644
index 0000000000..93b8087d9a
--- /dev/null
+++ b/backend/src/services/app-connection/stripe/stripe-connection-fns.ts
@@ -0,0 +1,121 @@
+import { AxiosError } from "axios";
+
+import { getConfig } from "@app/lib/config/env";
+import { request } from "@app/lib/config/request";
+import { BadRequestError, InternalServerError } from "@app/lib/errors";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
+
+import { StripeConnectionMethod } from "./stripe-connection-enums";
+import { TStripeConnectionConfig } from "./stripe-connection-types";
+
+// The Managed API Keys API is in private preview and is only served under a preview API version.
+const STRIPE_PREVIEW_API_VERSION = "2026-08-26.preview";
+
+type TStripeOAuthTokenResponse = {
+ // The initial exchange names the account stripe_user_id; the refresh grant names it account_id.
+ stripe_user_id?: string;
+ account_id?: string;
+};
+
+const getStripeSecretKey = () => {
+ const { INF_APP_CONNECTION_STRIPE_SECRET_KEY } = getConfig();
+
+ if (!INF_APP_CONNECTION_STRIPE_SECRET_KEY) {
+ throw new InternalServerError({
+ message: "Stripe is not configured on this instance. Set the Stripe App Connection credentials to enable it."
+ });
+ }
+
+ return INF_APP_CONNECTION_STRIPE_SECRET_KEY;
+};
+
+export const getStripeConnectionListItem = () => {
+ const { INF_APP_CONNECTION_STRIPE_OAUTH_CLIENT_ID, INF_APP_CONNECTION_STRIPE_OAUTH_AUTHORIZE_URL } = getConfig();
+
+ return {
+ name: "Stripe" as const,
+ app: AppConnection.Stripe as const,
+ methods: Object.values(StripeConnectionMethod) as [StripeConnectionMethod.OAuth],
+ oauthClientId: INF_APP_CONNECTION_STRIPE_OAUTH_CLIENT_ID,
+ // Stripe embeds a per-app, per-mode channel link ID in the install URL path, so it cannot be
+ // derived from the client ID and has to be copied out of the Stripe dashboard.
+ oauthAuthorizeUrl: INF_APP_CONNECTION_STRIPE_OAUTH_AUTHORIZE_URL
+ };
+};
+
+/**
+ * Infisical authenticates as itself and names the customer with Stripe-Context, so the tokens this
+ * exchange returns are never used. It runs because it is the only proof that the installer controls
+ * the account they are claiming: a client-supplied account ID would be unverified.
+ */
+const exchangeStripeOAuthCode = async (code: string): Promise<string> => {
+ let data: TStripeOAuthTokenResponse;
+
+ try {
+ ({ data } = await request.post<TStripeOAuthTokenResponse>(
+ IntegrationUrls.STRIPE_TOKEN_URL,
+ new URLSearchParams({ grant_type: "authorization_code", code }),
+ {
+ auth: { username: getStripeSecretKey(), password: "" },
+ headers: { "Content-Type": "application/x-www-form-urlencoded" }
+ }
+ ));
+ } catch (error) {
+ if (error instanceof AxiosError) {
+ const description = (error.response?.data as { error_description?: string } | undefined)?.error_description;
+
+ throw new BadRequestError({
+ message: `Stripe rejected the app installation: ${description ?? error.message}`
+ });
+ }
+
+ throw error;
+ }
+
+ const accountId = data?.stripe_user_id ?? data?.account_id;
+
+ if (!accountId) {
+ throw new BadRequestError({
+ message: "Stripe did not return an account ID for the installed app. Reinstall the app and try again."
+ });
+ }
+
+ return accountId;
+};
+
+/**
+ * Probes the Managed API Keys API with the same credentials rotation will use, so a connection that
+ * cannot manage keys fails here rather than at rotation time.
+ */
+const assertCanManageApiKeys = async (accountId: string) => {
+ try {
+ await request.get(`${IntegrationUrls.STRIPE_API_URL}/v2/iam/api_keys`, {
+ auth: { username: getStripeSecretKey(), password: "" },
+ headers: {
+ "Stripe-Version": STRIPE_PREVIEW_API_VERSION,
+ "Stripe-Context": accountId
+ }
+ });
+ } catch (error) {
+ if (error instanceof AxiosError) {
+ const message = (error.response?.data as { error?: { message?: string } } | undefined)?.error?.message;
+
+ throw new BadRequestError({
+ message: `Infisical cannot manage API keys on Stripe account '${accountId}'. Stripe returned ${
+ error.response?.status ?? "no status"
+ }: ${message ?? error.message}`
+ });
+ }
+
+ throw error;
+ }
+};
+
+export const validateStripeConnectionCredentials = async (config: TStripeConnectionConfig) => {
+ const accountId = await exchangeStripeOAuthCode(config.credentials.code);
+
+ await assertCanManageApiKeys(accountId);
+
+ return { accountId };
+};
diff --git a/backend/src/services/app-connection/stripe/stripe-connection-schemas.ts b/backend/src/services/app-connection/stripe/stripe-connection-schemas.ts
new file mode 100644
index 0000000000..ed40026e64
--- /dev/null
+++ b/backend/src/services/app-connection/stripe/stripe-connection-schemas.ts
@@ -0,0 +1,74 @@
+import z from "zod";
+
+import { AppConnections } from "@app/lib/api-docs";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import {
+ BaseAppConnectionSchema,
+ GenericCreateAppConnectionFieldsSchema,
+ GenericUpdateAppConnectionFieldsSchema
+} from "@app/services/app-connection/app-connection-schemas";
+
+import { APP_CONNECTION_NAME_MAP } from "../app-connection-maps";
+import { StripeConnectionMethod } from "./stripe-connection-enums";
+
+export const StripeConnectionOAuthCredentialsSchema = z.object({
+ code: z.string().trim().min(1, "OAuth code required").max(500)
+});
+
+// Infisical authenticates with its own Stripe key and names the account with Stripe-Context, so the
+// account ID is the only thing worth keeping from the OAuth exchange.
+export const StripeConnectionOAuthOutputCredentialsSchema = z.object({
+ accountId: z.string().trim()
+});
+
+const BaseStripeConnectionSchema = BaseAppConnectionSchema.extend({
+ app: z.literal(AppConnection.Stripe)
+});
+
+export const StripeConnectionSchema = z.intersection(
+ BaseStripeConnectionSchema,
+ z.discriminatedUnion("method", [
+ z.object({
+ method: z.literal(StripeConnectionMethod.OAuth),
+ credentials: StripeConnectionOAuthOutputCredentialsSchema
+ })
+ ])
+);
+
+export const SanitizedStripeConnectionSchema = z.discriminatedUnion("method", [
+ BaseStripeConnectionSchema.extend({
+ method: z.literal(StripeConnectionMethod.OAuth),
+ credentials: StripeConnectionOAuthOutputCredentialsSchema
+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.Stripe]} (OAuth)` }))
+]);
+
+export const ValidateStripeConnectionCredentialsSchema = z.discriminatedUnion("method", [
+ z.object({
+ method: z.literal(StripeConnectionMethod.OAuth).describe(AppConnections.CREATE(AppConnection.Stripe).method),
+ credentials: StripeConnectionOAuthCredentialsSchema.describe(
+ AppConnections.CREATE(AppConnection.Stripe).credentials
+ )
+ })
+]);
+
+export const CreateStripeConnectionSchema = ValidateStripeConnectionCredentialsSchema.and(
+ GenericCreateAppConnectionFieldsSchema(AppConnection.Stripe)
+);
+
+export const UpdateStripeConnectionSchema = z
+ .object({
+ credentials: StripeConnectionOAuthCredentialsSchema.optional().describe(
+ AppConnections.UPDATE(AppConnection.Stripe).credentials
+ )
+ })
+ .and(GenericUpdateAppConnectionFieldsSchema(AppConnection.Stripe));
+
+export const StripeConnectionListItemSchema = z
+ .object({
+ name: z.literal("Stripe"),
+ app: z.literal(AppConnection.Stripe),
+ methods: z.nativeEnum(StripeConnectionMethod).array(),
+ oauthClientId: z.string().optional(),
+ oauthAuthorizeUrl: z.string().optional()
+ })
+ .describe(JSON.stringify({ title: APP_CONNECTION_NAME_MAP[AppConnection.Stripe] }));
diff --git a/backend/src/services/app-connection/stripe/stripe-connection-types.ts b/backend/src/services/app-connection/stripe/stripe-connection-types.ts
new file mode 100644
index 0000000000..163409a8cf
--- /dev/null
+++ b/backend/src/services/app-connection/stripe/stripe-connection-types.ts
@@ -0,0 +1,22 @@
+import z from "zod";
+
+import { DiscriminativePick } from "@app/lib/types";
+
+import { AppConnection } from "../app-connection-enums";
+import {
+ CreateStripeConnectionSchema,
+ StripeConnectionSchema,
+ ValidateStripeConnectionCredentialsSchema
+} from "./stripe-connection-schemas";
+
+export type TStripeConnection = z.infer<typeof StripeConnectionSchema>;
+
+export type TStripeConnectionInput = z.infer<typeof CreateStripeConnectionSchema> & {
+ app: AppConnection.Stripe;
+};
+
+export type TValidateStripeConnectionCredentialsSchema = typeof ValidateStripeConnectionCredentialsSchema;
+
+export type TStripeConnectionConfig = DiscriminativePick<TStripeConnectionInput, "method" | "app" | "credentials"> & {
+ orgId: string;
+};
diff --git a/backend/src/services/integration-auth/integration-list.ts b/backend/src/services/integration-auth/integration-list.ts
index 8c541337bd..e3c0aaeaa2 100644
--- a/backend/src/services/integration-auth/integration-list.ts
+++ b/backend/src/services/integration-auth/integration-list.ts
@@ -64,10 +64,12 @@ export enum IntegrationUrls {
GITLAB_TOKEN_URL = "https://gitlab.com/oauth/token",
BITBUCKET_TOKEN_URL = "https://bitbucket.org/site/oauth2/access_token",
CAMUNDA_TOKEN_URL = "https://login.cloud.camunda.io/oauth/token",
+ STRIPE_TOKEN_URL = "https://api.stripe.com/v1/oauth/token",
// integration apps endpoints
GCP_API_URL = "https://cloudresourcemanager.googleapis.com",
HEROKU_API_URL = "https://api.heroku.com",
+ STRIPE_API_URL = "https://api.stripe.com",
GITLAB_URL = "https://gitlab.com",
GITLAB_API_URL = `${GITLAB_URL}/api`,
GITHUB_API_URL = "https://api.github.com",
diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.ts
index 3f127e4f4a..3c25a6f858 100644
--- a/frontend/src/helpers/appConnections.ts
+++ b/frontend/src/helpers/appConnections.ts
@@ -94,6 +94,7 @@ import { SmbConnectionMethod } from "@app/hooks/api/appConnections/types/smb-con
import { SnowflakeConnectionMethod } from "@app/hooks/api/appConnections/types/snowflake-connection";
import { SpaceliftConnectionMethod } from "@app/hooks/api/appConnections/types/spacelift-connection";
import { SshConnectionMethod } from "@app/hooks/api/appConnections/types/ssh-connection";
+import { StripeConnectionMethod } from "@app/hooks/api/appConnections/types/stripe-connection";
import { SupabaseConnectionMethod } from "@app/hooks/api/appConnections/types/supabase-connection";
import { TravisCIConnectionMethod } from "@app/hooks/api/appConnections/types/travis-ci-connection";
import { TriggerDevConnectionMethod } from "@app/hooks/api/appConnections/types/trigger-dev-connection";
@@ -289,6 +290,12 @@ export const APP_CONNECTION_MAP: Record<
category: "HOSTING",
description: "App and config var access for Heroku."
},
+ [AppConnection.Stripe]: {
+ name: "Stripe",
+ image: "Stripe.svg",
+ category: "PLATFORM",
+ description: "API key management for Stripe."
+ },
[AppConnection.Render]: {
name: "Render",
image: "Render.png",
@@ -659,6 +666,7 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])
case HerokuConnectionMethod.OAuth:
case GitLabConnectionMethod.OAuth:
case VenafiTppConnectionMethod.OAuth:
+ case StripeConnectionMethod.OAuth:
return { name: "OAuth", icon: IdCardIcon };
case AwsConnectionMethod.AccessKey:
case OCIConnectionMethod.AccessKey:
diff --git a/frontend/src/hooks/api/appConnections/enums.ts b/frontend/src/hooks/api/appConnections/enums.ts
index 179e3988d2..7f5ceced14 100644
--- a/frontend/src/hooks/api/appConnections/enums.ts
+++ b/frontend/src/hooks/api/appConnections/enums.ts
@@ -82,5 +82,6 @@ export enum AppConnection {
Fireworks = "fireworks",
NutanixPrismCentral = "nutanix-prism-central",
Spacelift = "spacelift",
- Daytona = "daytona"
+ Daytona = "daytona",
+ Stripe = "stripe"
}
diff --git a/frontend/src/hooks/api/appConnections/types/app-options.ts b/frontend/src/hooks/api/appConnections/types/app-options.ts
index 0fbb1fa7fd..3bad24622f 100644
--- a/frontend/src/hooks/api/appConnections/types/app-options.ts
+++ b/frontend/src/hooks/api/appConnections/types/app-options.ts
@@ -127,6 +127,12 @@ export type THerokuConnectionOption = TAppConnectionOptionBase & {
oauthClientId?: string;
};
+export type TStripeConnectionOption = TAppConnectionOptionBase & {
+ app: AppConnection.Stripe;
+ oauthClientId?: string;
+ oauthAuthorizeUrl?: string;
+};
+
export type TOnePassConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.OnePass;
};
@@ -375,6 +381,7 @@ export type TAppConnectionOption =
| TOCIConnectionOption
| TOnePassConnectionOption
| THerokuConnectionOption
+ | TStripeConnectionOption
| TRenderConnectionOption
| TFlyioConnectionOption
| TGitlabConnectionOption
@@ -461,6 +468,7 @@ export type TAppConnectionOptionMap = {
[AppConnection.OCI]: TOCIConnectionOption;
[AppConnection.OnePass]: TOnePassConnectionOption;
[AppConnection.Heroku]: THerokuConnectionOption;
+ [AppConnection.Stripe]: TStripeConnectionOption;
[AppConnection.Render]: TRenderConnectionOption;
[AppConnection.Flyio]: TFlyioConnectionOption;
[AppConnection.GitLab]: TGitlabConnectionOption;
diff --git a/frontend/src/hooks/api/appConnections/types/index.ts b/frontend/src/hooks/api/appConnections/types/index.ts
index 1eeb819542..4eb6d35960 100644
--- a/frontend/src/hooks/api/appConnections/types/index.ts
+++ b/frontend/src/hooks/api/appConnections/types/index.ts
@@ -73,6 +73,7 @@ import { TSmbConnection } from "./smb-connection";
import { TSnowflakeConnection } from "./snowflake-connection";
import { TSpaceliftConnection } from "./spacelift-connection";
import { TSshConnection } from "./ssh-connection";
+import { TStripeConnection } from "./stripe-connection";
import { TSupabaseConnection } from "./supabase-connection";
import { TTeamCityConnection } from "./teamcity-connection";
import { TTerraformCloudConnection } from "./terraform-cloud-connection";
@@ -155,6 +156,7 @@ export * from "./smb-connection";
export * from "./snowflake-connection";
export * from "./spacelift-connection";
export * from "./ssh-connection";
+export * from "./stripe-connection";
export * from "./supabase-connection";
export * from "./teamcity-connection";
export * from "./terraform-cloud-connection";
@@ -251,7 +253,8 @@ export type TAppConnection =
| TFireworksConnection
| TNutanixPrismCentralConnection
| TSpaceliftConnection
- | TDaytonaConnection;
+ | TDaytonaConnection
+ | TStripeConnection;
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id" | "projectId">;
diff --git a/frontend/src/hooks/api/appConnections/types/stripe-connection.ts b/frontend/src/hooks/api/appConnections/types/stripe-connection.ts
new file mode 100644
index 0000000000..b415197ee3
--- /dev/null
+++ b/frontend/src/hooks/api/appConnections/types/stripe-connection.ts
@@ -0,0 +1,13 @@
+import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
+
+export enum StripeConnectionMethod {
+ OAuth = "oauth"
+}
+
+export type TStripeConnection = TRootAppConnection & { app: AppConnection.Stripe } & {
+ method: StripeConnectionMethod.OAuth;
+ credentials: {
+ code: string;
+ };
+};
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
index ef03e0bf80..df1229e6b6 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
@@ -87,6 +87,7 @@ import { SmbConnectionForm } from "./SmbConnectionForm";
import { SnowflakeConnectionForm } from "./SnowflakeConnectionForm";
import { SpaceliftConnectionForm } from "./SpaceliftConnectionForm";
import { SshConnectionForm } from "./SshConnectionForm";
+import { StripeConnectionForm } from "./StripeConnectionForm";
import { SupabaseConnectionForm } from "./SupabaseConnectionForm";
import { TeamCityConnectionForm } from "./TeamCityConnectionForm";
import { TerraformCloudConnectionForm } from "./TerraformCloudConnectionForm";
@@ -253,6 +254,8 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {
return <OnePassConnectionForm onSubmit={onSubmit} />;
case AppConnection.Heroku:
return <HerokuConnectionForm onSubmit={onSubmit} projectId={projectId} />;
+ case AppConnection.Stripe:
+ return <StripeConnectionForm onSubmit={onSubmit} projectId={projectId} />;
case AppConnection.HasuraCloud:
return <HasuraCloudConnectionForm onSubmit={onSubmit} />;
case AppConnection.Render:
@@ -526,6 +529,14 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {
projectId={appConnection.projectId}
/>
);
+ case AppConnection.Stripe:
+ return (
+ <StripeConnectionForm
+ onSubmit={onSubmit}
+ appConnection={appConnection}
+ projectId={appConnection.projectId}
+ />
+ );
case AppConnection.HasuraCloud:
return <HasuraCloudConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
case AppConnection.Render:
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/StripeConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/StripeConnectionForm.tsx
new file mode 100644
index 0000000000..2a3fa98740
--- /dev/null
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/StripeConnectionForm.tsx
@@ -0,0 +1,152 @@
+import crypto from "crypto";
+
+import { useState } from "react";
+import { FormProvider, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { Button, SheetFooter } from "@app/components/v3";
+import { useGetAppConnectionOauthReturnUrl } from "@app/helpers/appConnections";
+import { isInfisicalCloud } from "@app/helpers/platform";
+import { useScopeVariant } from "@app/hooks";
+import { useGetAppConnectionOption } from "@app/hooks/api/appConnections";
+import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import {
+ StripeConnectionMethod,
+ TStripeConnection
+} from "@app/hooks/api/appConnections/types/stripe-connection";
+
+import { useAppConnectionForm, useAppConnectionFormDirtyState } from "./AppConnectionFormContext";
+import {
+ genericAppConnectionFieldsSchema,
+ GenericAppConnectionsFields
+} from "./GenericAppConnectionFields";
+
+type Props = {
+ appConnection?: TStripeConnection;
+ onSubmit: (formData: FormData) => Promise<void>;
+ projectId: string | undefined | null;
+};
+
+const formSchema = genericAppConnectionFieldsSchema.extend({
+ app: z.literal(AppConnection.Stripe),
+ method: z.literal(StripeConnectionMethod.OAuth),
+ credentials: z.object({
+ code: z.string().min(1, "Code is required")
+ })
+});
+
+type FormData = z.infer<typeof formSchema>;
+
+export const StripeConnectionForm = ({ appConnection, projectId }: Props) => {
+ const isUpdate = Boolean(appConnection);
+ const { onCancel } = useAppConnectionForm();
+ const scopeVariant = useScopeVariant();
+ const [isRedirecting, setIsRedirecting] = useState(false);
+
+ const returnUrl = useGetAppConnectionOauthReturnUrl();
+
+ const {
+ option: { oauthClientId, oauthAuthorizeUrl },
+ isLoading
+ } = useGetAppConnectionOption(AppConnection.Stripe);
+
+ const form = useForm<FormData>({
+ resolver: zodResolver(formSchema),
+ // The real code arrives from the Stripe redirect, so the form carries a placeholder to satisfy
+ // the schema. This mirrors every other OAuth connection form.
+ defaultValues: appConnection
+ ? { ...appConnection, credentials: { code: "custom" } }
+ : ({
+ app: AppConnection.Stripe,
+ method: StripeConnectionMethod.OAuth,
+ credentials: { code: "custom" }
+ } as FormData)
+ });
+
+ const {
+ handleSubmit,
+ formState: { isSubmitting, isDirty }
+ } = form;
+
+ useAppConnectionFormDirtyState(isDirty);
+
+ const isMissingConfig = !oauthClientId || !oauthAuthorizeUrl;
+
+ let submitLabel = "Connect to Stripe";
+ if (isRedirecting) submitLabel = "Redirecting to Stripe...";
+ else if (isUpdate) submitLabel = "Reconnect to Stripe";
+
+ const onSubmit = (formData: FormData) => {
+ if (!oauthClientId || !oauthAuthorizeUrl) return;
+
+ setIsRedirecting(true);
+
+ const state = crypto.randomBytes(16).toString("hex");
+
+ localStorage.setItem("latestCSRFToken", state);
+ localStorage.setItem(
+ "stripeConnectionFormData",
+ JSON.stringify({
+ ...formData,
+ connectionId: appConnection?.id,
+ returnUrl,
+ projectId
+ })
+ );
+
+ // Stripe's install link already carries client_id and redirect_uri, so the whole link can be
+ // pasted into config as-is. Setting them again keeps the redirect in step with the origin the
+ // user is actually on.
+ const oauthUrl = new URL(oauthAuthorizeUrl);
+ oauthUrl.searchParams.set("client_id", oauthClientId);
+ oauthUrl.searchParams.set(
+ "redirect_uri",
+ `${window.location.origin}/organization/app-connections/stripe/oauth/callback`
+ );
+ oauthUrl.searchParams.set("state", state);
+
+ window.location.assign(oauthUrl.toString());
+ };
+
+ return (
+ <FormProvider {...form}>
+ <form onSubmit={handleSubmit(onSubmit)}>
+ {!isUpdate && <GenericAppConnectionsFields />}
+
+ <p className="mb-4 text-sm text-mineshaft-400">
+ You will be redirected to Stripe to install the Infisical app and choose the account
+ Infisical should manage API keys for.
+ </p>
+
+ {!isLoading && isMissingConfig && (
+ <p className="mb-4 text-sm text-red">
+ Environment variables have not been configured.{" "}
+ {isInfisicalCloud()
+ ? "Please contact Infisical."
+ : "See Docs to configure Stripe Connections."}
+ </p>
+ )}
+
+ <SheetFooter className="sticky bottom-0 -mx-4 items-center border-t bg-popover">
+ <Button
+ type="submit"
+ variant={scopeVariant}
+ isPending={isSubmitting || isRedirecting}
+ isDisabled={isSubmitting || (!isUpdate && !isDirty) || isMissingConfig || isRedirecting}
+ >
+ {submitLabel}
+ </Button>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={onCancel}
+ isDisabled={isSubmitting || isRedirecting}
+ >
+ Cancel
+ </Button>
+ </SheetFooter>
+ </form>
+ </FormProvider>
+ );
+};
diff --git a/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsx b/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsx
index 76a2614fc4..f10820b7fd 100644
--- a/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsx
+++ b/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsx
@@ -20,6 +20,7 @@ import {
GitHubConnectionMethod,
GitLabConnectionMethod,
HerokuConnectionMethod,
+ StripeConnectionMethod,
TAppConnection,
useCreateAppConnection,
useUpdateAppConnection
@@ -36,7 +37,8 @@ const formDataStorageFieldMap: Partial<Record<AppConnection, string>> = {
[AppConnection.AzureAppConfiguration]: "azureAppConfigurationConnectionFormData",
[AppConnection.AzureClientSecrets]: "azureClientSecretsConnectionFormData",
[AppConnection.AzureDevOps]: "azureDevOpsConnectionFormData",
- [AppConnection.Heroku]: "herokuConnectionFormData"
+ [AppConnection.Heroku]: "herokuConnectionFormData",
+ [AppConnection.Stripe]: "stripeConnectionFormData"
};
export const OAuthCallbackPage = () => {
@@ -605,6 +607,56 @@ export const OAuthCallbackPage = () => {
};
}, []);
+ const handleStripe = useCallback(async () => {
+ const formData = getFormData(AppConnection.Stripe);
+ if (formData === null) return null;
+
+ clearState(AppConnection.Stripe);
+
+ const { connectionId, name, description, returnUrl, projectId } = formData;
+
+ let connection: TAppConnection;
+
+ try {
+ if (connectionId) {
+ connection = await updateAppConnection.mutateAsync({
+ app: AppConnection.Stripe,
+ connectionId,
+ credentials: {
+ code: code as string
+ }
+ });
+ } else {
+ connection = await createAppConnection.mutateAsync({
+ app: AppConnection.Stripe,
+ name,
+ description,
+ method: StripeConnectionMethod.OAuth,
+ projectId,
+ credentials: {
+ code: code as string
+ }
+ });
+ }
+ } catch {
+ navigate({
+ to: returnUrl,
+ params: {
+ projectId
+ }
+ });
+ return null;
+ }
+
+ return {
+ connectionId,
+ returnUrl,
+ appConnectionName: formData.app,
+ projectId,
+ connection
+ };
+ }, []);
+
// Ensure that the localstorage is ready for use, to avoid the form data being malformed
useEffect(() => {
if (!isReady) {
@@ -641,6 +693,8 @@ export const OAuthCallbackPage = () => {
data = await handleAzureDevOps();
} else if (appConnection === AppConnection.Heroku) {
data = await handleHeroku();
+ } else if (appConnection === AppConnection.Stripe) {
+ data = await handleStripe();
}
} catch {
createNotification({
diff --git a/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.types.ts b/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.types.ts
index c07ae81121..7554d46ee3 100644
--- a/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.types.ts
+++ b/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.types.ts
@@ -7,7 +7,8 @@ import {
TGitHubConnection,
TGitHubRadarConnection,
TGitLabConnection,
- THerokuConnection
+ THerokuConnection,
+ TStripeConnection
} from "@app/hooks/api/appConnections";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
@@ -63,6 +64,9 @@ export type AzureDevOpsFormData = BaseFormData &
export type HerokuFormData = BaseFormData &
Pick<THerokuConnection, "name" | "method" | "description">;
+export type StripeFormData = BaseFormData &
+ Pick<TStripeConnection, "name" | "method" | "description">;
+
export type FormDataMap = {
[AppConnection.GitHub]: GitHubFormData & { app: AppConnection.GitHub };
[AppConnection.GitHubRadar]: GitHubRadarFormData & { app: AppConnection.GitHubRadar };
@@ -80,4 +84,7 @@ export type FormDataMap = {
[AppConnection.Heroku]: HerokuFormData & {
app: AppConnection.Heroku;
};
+ [AppConnection.Stripe]: StripeFormData & {
+ app: AppConnection.Stripe;
+ };
};
diff --git a/stripe-app/.gitignore b/stripe-app/.gitignore
new file mode 100644
index 0000000000..f396c497b1
--- /dev/null
+++ b/stripe-app/.gitignore
@@ -0,0 +1,4 @@
+/node_modules
+/.build
+.env.local
+.DS_Store
diff --git a/stripe-app/.npmrc b/stripe-app/.npmrc
new file mode 100644
index 0000000000..7253a5ceee
--- /dev/null
+++ b/stripe-app/.npmrc
@@ -0,0 +1 @@
+min-release-age=7
diff --git a/stripe-app/README.md b/stripe-app/README.md
new file mode 100644
index 0000000000..b915d7c4c6
--- /dev/null
+++ b/stripe-app/README.md
@@ -0,0 +1,45 @@
+# Infisical Stripe app
+
+Stripe does not let any API key create another API key. The only principal that can is an
+installed Stripe App holding the `api_key_write` permission, so Stripe API key rotation requires
+Infisical to be a Stripe app vendor. This directory is that app.
+
+The app has no UI (`extensions` is `null`) and no dependencies. It exists purely to carry the
+permission grant and the OAuth redirect URIs, so `stripe-app.json` is the whole thing.
+
+## The manifest is the source of truth
+
+`stripe-app.json` is not editable in the Stripe dashboard. Stripe stores whatever the CLI last
+uploaded, as an immutable version. To change anything, including a redirect URI, edit the file,
+bump `version`, and upload:
+
+```bash
+$ cd stripe-app
+$ stripe apps upload --api-key=<secret key of the account that owns the app>
+```
+
+For a public app, point "External test version" at the new version afterwards in the Stripe
+dashboard under Apps > Created.
+
+## Redirect URIs
+
+Stripe requires HTTPS on every entry, including for local development, so `http://localhost:8080`
+is not an option. The entry here is one developer's ngrok host, which means changing developer means
+editing this file, bumping the version and re-uploading. A shared redirect URI that every developer
+can use is still an open decision.
+
+The URI has to match what the browser sends exactly. The frontend builds it from
+`window.location.origin`, so `SITE_URL` and the ngrok host have to agree with this file or Stripe
+rejects the authorize request before the user sees a consent screen.
+
+The path is the app connection callback the frontend already registers for every OAuth connection.
+It carries no organization ID and forwards `code` and `state` into the org-scoped page
+(`frontend/src/routes.ts`, `frontend/src/pages/redirects/oauth-callback-redirect.tsx`).
+
+## Account setup
+
+Getting an account into a state where it can publish this app and call the Managed API Keys API
+takes a sequence of steps that are mostly undocumented by Stripe, including a private-then-public
+upload dance and two separate manual gating requests. Those are written up in the
+[Stripe secret rotation setup doc](https://app.notion.com/p/infisical/Stripe-secret-rotation-setup-3d8564692229802f9082f2aa848b5eea).
+Ask Daniel for access to a gated sandbox rather than trying to gate a new one.
diff --git a/stripe-app/icon.png b/stripe-app/icon.png
new file mode 100644
index 0000000000..5349c16baf
Binary files /dev/null and b/stripe-app/icon.png differ
diff --git a/stripe-app/package-lock.json b/stripe-app/package-lock.json
new file mode 100644
index 0000000000..38514804c7
--- /dev/null
+++ b/stripe-app/package-lock.json
@@ -0,0 +1,13 @@
+{
+ "name": "infisical-integration-dev",
+ "version": "0.0.4",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "infisical-integration-dev",
+ "version": "0.0.4",
+ "license": "UNLICENSED"
+ }
+ }
+}
diff --git a/stripe-app/package.json b/stripe-app/package.json
new file mode 100644
index 0000000000..3b4f5b7f6d
--- /dev/null
+++ b/stripe-app/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "infisical-integration-dev",
+ "description": "OAuth grant for Infisical Stripe secret rotation",
+ "version": "0.0.4",
+ "private": true,
+ "license": "UNLICENSED"
+}
diff --git a/stripe-app/stripe-app.json b/stripe-app/stripe-app.json
new file mode 100644
index 0000000000..4ea1c8fee5
--- /dev/null
+++ b/stripe-app/stripe-app.json
@@ -0,0 +1,20 @@
+{
+ "$schema": "https://stripe.com/stripe-app.schema.json",
+ "id": "infisical-integration-dev",
+ "name": "Infisical Integration DEV",
+ "version": "0.0.4",
+ "icon": "./icon.png",
+ "extensions": null,
+ "permissions": [
+ {
+ "permission": "api_key_write",
+ "purpose": "Lets Infisical create, rotate and expire API keys in your account so your Stripe credentials can be rotated automatically."
+ }
+ ],
+ "allowed_redirect_uris": [
+ "https://provable-triceps-maximum.ngrok-free.dev/organization/app-connections/stripe/oauth/callback"
+ ],
+ "distribution_type": "public",
+ "stripe_api_access_type": "oauth",
+ "sandbox_install_compatible": true
+}
\ No newline at end of file