From 00fa8a9741e6abaca844651903509d37143f29ac Mon Sep 17 00:00:00 2001 From: jahooma Date: Fri, 7 Jan 2022 16:45:27 -0600 Subject: [PATCH] Set up product ids and endpoint for stripe prod --- functions/src/stripe.ts | 20 ++++++++++++++------ web/lib/service/stripe.ts | 7 +++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/functions/src/stripe.ts b/functions/src/stripe.ts index c67da656..aac128cb 100644 --- a/functions/src/stripe.ts +++ b/functions/src/stripe.ts @@ -10,12 +10,20 @@ const stripe = new Stripe(functions.config().stripe.apikey, { }) // manage at https://dashboard.stripe.com/test/products?active=true -const manticDollarStripePrice = { - 500: 'price_1K8W10GdoFKoCJW7KWORLec1', - 1000: 'price_1K8bC1GdoFKoCJW76k3g5MJk', - 2500: 'price_1K8bDSGdoFKoCJW7avAwpV0e', - 10000: 'price_1K8bEiGdoFKoCJW7Us4UkRHE', -} +const manticDollarStripePrice = + admin.instanceId().app.options.projectId === 'mantic-markets' + ? { + 500: 'price_1KFQXcGdoFKoCJW770gTNBrm', + 1000: 'price_1KFQp1GdoFKoCJW7Iu0dsF65', + 2500: 'price_1KFQqNGdoFKoCJW7SDvrSaEB', + 10000: 'price_1KFQraGdoFKoCJW77I4XCwM3', + } + : { + 500: 'price_1K8W10GdoFKoCJW7KWORLec1', + 1000: 'price_1K8bC1GdoFKoCJW76k3g5MJk', + 2500: 'price_1K8bDSGdoFKoCJW7avAwpV0e', + 10000: 'price_1K8bEiGdoFKoCJW7Us4UkRHE', + } export const createCheckoutSession = functions .runWith({ minInstances: 1 }) diff --git a/web/lib/service/stripe.ts b/web/lib/service/stripe.ts index 129492b2..a5f6c4a0 100644 --- a/web/lib/service/stripe.ts +++ b/web/lib/service/stripe.ts @@ -1,10 +1,13 @@ +import { isProd } from '../firebase/init' + export const checkoutURL = ( userId: string, manticDollarQuantity: number, referer = '' ) => { - const endpoint = - 'https://us-central1-mantic-markets.cloudfunctions.net/createCheckoutSession' + const endpoint = isProd + ? 'https://us-central1-mantic-markets.cloudfunctions.net/createCheckoutSession' + : 'https://us-central1-dev-mantic-markets.cloudfunctions.net/createCheckoutSession' return `${endpoint}?userId=${userId}&manticDollarQuantity=${manticDollarQuantity}&referer=${referer}` }