b339736a6f
* Save currency to db * Add missing translation * Get currency from user credentials server side * Adds stripe data schema Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: zomars <zomars@me.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
32 lines
845 B
TypeScript
32 lines
845 B
TypeScript
import Stripe from "stripe";
|
|
import { z } from "zod";
|
|
|
|
export type PaymentData = Stripe.Response<Stripe.PaymentIntent> & {
|
|
stripe_publishable_key: string;
|
|
stripeAccount: string;
|
|
};
|
|
|
|
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>;
|
|
|
|
const stripePrivateKey = process.env.STRIPE_PRIVATE_KEY!;
|
|
|
|
const stripe = new Stripe(stripePrivateKey, {
|
|
apiVersion: "2020-08-27",
|
|
});
|
|
|
|
export default stripe;
|