action is not available to runAction / app / typescript
the stripe.ts and its actions are visible on dashboard but not available to ts / runAction





"use node";
import { v } from "convex/values";
import Stripe from "stripe";
import { api, internal } from "./_generated/api";
import { action } from "./_generated/server";
export const createCheckoutSession = action({
args: { priceId: v.string() },
handler: async (ctx) => {
const stripe = new Stripe(process.env.STRIPE_KEY!, {
apiVersion: "2024-06-20",
});
let customer;
const { data: dbCustomer } = await ctx.runQuery(api.users.getCustomer);
const { data: user } = await ctx.runQuery(api.users.getCurrentUser);
if (!user) {
return { data: null, error: "Not authenticated" };
}
if (!dbCustomer) {
const stripeCustomer = await stripe.customers.create({
email: user?.email,
name: user?.name,
});
const { data: stripe_customer_id } = await ctx.runMutation(
internal.users.createCustomer,
{
stripe_customer_id: stripeCustomer.id,
}
);
customer = stripe_customer_id;
} else {
customer = dbCustomer?.stripe_customer_id;
}
if (!customer) {
return { data: null, error: "No customer found" };
}
const session = (await stripe.checkout.sessions.create({
payment_method_types: ["card"],
billing_address_collection: "auto",
customer: customer,
customer_update: {
address: "auto",
},
line_items: [
{
price: "priceId",
quantity: 1,
},
],
mode: "subscription",
allow_promotion_codes: true,
success_url: `${process.env.NEXT_PUBLIC_SITE_URL}/app/settings'`,
cancel_url: `${process.env.NEXT_PUBLIC_SITE_URL}/app/settings`,
})) as any;
console.log(session.url);
return { data: session.url };
},
});/* eslint-disable */
/**
* Generated `api` utility.
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@1.14.1.
* To regenerate, run `npx convex dev`.
* @module
*/
import type {
ApiFromModules,
FilterApi,
FunctionReference,
} from "convex/server";
import type * as auth from "../auth.js";
import type * as feedbacks from "../feedbacks.js";
import type * as http from "../http.js";
import type * as renders from "../renders.js";
import type * as stripe from "../stripe.js";
import type * as users from "../users.js";
/**
* A utility for referencing Convex functions in your app's API.
*
* Usage:
*/
declare const fullApi: ApiFromModules<{
auth: typeof auth;
feedbacks: typeof feedbacks;
http: typeof http;
renders: typeof renders;
stripe: typeof stripe;
users: typeof users;
}>;
export declare const api: FilterApi<
typeof fullApi,
FunctionReference<any, "public">
>;
export declare const internal: FilterApi<
typeof fullApi,
FunctionReference<any, "internal">
>;