2022-03-09 22:56:05 +00:00
|
|
|
import Stripe from "stripe";
|
2022-06-20 19:09:22 +00:00
|
|
|
import { z } from "zod";
|
2022-03-09 22:56:05 +00:00
|
|
|
|
2023-02-08 20:36:22 +00:00
|
|
|
export type StripePaymentData = Stripe.Response<Stripe.PaymentIntent> & {
|
2022-03-09 22:56:05 +00:00
|
|
|
stripe_publishable_key: string;
|
|
|
|
stripeAccount: string;
|
|
|
|
};
|
|
|
|
|
2022-06-20 19:09:22 +00:00
|
|
|
export const stripeOAuthTokenSchema = z.object({
|
|
|
|
access_token: z.string().optional(),
|
|
|
|
scope: z.string().optional(),
|
|
|
|
livemode: z.boolean().optional(),
|
|
|
|
token_type: z.literal("bearer").optional(),
|
|
|
|
refresh_token: z.string().optional(),
|
|
|
|
stripe_user_id: z.string().optional(),
|
|
|
|
stripe_publishable_key: z.string().optional(),
|
|
|
|
});
|
|
|
|
|
|
|
|
export const stripeDataSchema = stripeOAuthTokenSchema.extend({
|
|
|
|
default_currency: z.string(),
|
|
|
|
});
|
|
|
|
|
|
|
|
export type StripeData = z.infer<typeof stripeDataSchema>;
|
2022-03-09 22:56:05 +00:00
|
|
|
|
2022-12-21 20:31:09 +00:00
|
|
|
/** Figure out a way to get this from the DB without too much wreckage. */
|
2022-03-09 22:56:05 +00:00
|
|
|
const stripePrivateKey = process.env.STRIPE_PRIVATE_KEY!;
|
|
|
|
const stripe = new Stripe(stripePrivateKey, {
|
|
|
|
apiVersion: "2020-08-27",
|
|
|
|
});
|
|
|
|
|
|
|
|
export default stripe;
|