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
|
|
|
|
|
|
|
export type PaymentData = Stripe.Response<Stripe.PaymentIntent> & {
|
|
|
|
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
|
|
|
|
|
|
|
const stripePrivateKey = process.env.STRIPE_PRIVATE_KEY!;
|
|
|
|
|
|
|
|
const stripe = new Stripe(stripePrivateKey, {
|
|
|
|
apiVersion: "2020-08-27",
|
|
|
|
});
|
|
|
|
|
|
|
|
export default stripe;
|