diff --git a/functions/src/convert-mana-to-gift-card.ts b/functions/src/convert-mana-to-gift-card.ts index 75287c55..ba23dadb 100644 --- a/functions/src/convert-mana-to-gift-card.ts +++ b/functions/src/convert-mana-to-gift-card.ts @@ -1,27 +1,27 @@ import { APIError, newEndpoint } from './api' import { isProd, log } from './utils' import * as admin from 'firebase-admin' -import { PrivateUser, User } from 'common/user' +import { PrivateUser, User } from '../../common/user' import { runTxn, TxnData } from './transact' import { DEV_HOUSE_LIQUIDITY_PROVIDER_ID, HOUSE_LIQUIDITY_PROVIDER_ID, -} from 'common/antes' +} from '../../common/antes' // sandbox const API_KEY = 'TEST_k-dOX64gXbmZgaaPgbb_7aP6jhI-iXae_mASnHedTvQ' const FUNDING_ID = 'Y46Z09MJBQXY' const CAMPAIGN_ID = 'DVFR42FR12KO' + // prod -// const API_KEY = '' // const FUNDING_ID = '' // const CAMPAIGN_ID = 'T5436LGG2KP6' const firestore = admin.firestore() -const amount = 5000 -// Production environment -// var client = new Tremendous("[PRODUCTION_ACCESS_TOKEN]", "https://www.tremendous.com/api/v2/"); -export const convertmana = newEndpoint({}, async (req, auth) => { +const amount = 7500 +const opts = { secrets: ['TREMENDOUS_TEST_KEY'] } + +export const convertmana = newEndpoint(opts, async (req, auth) => { const result = await firestore.runTransaction(async (trans) => { log('Inside main transaction.') const userDoc = firestore.doc(`users/${auth.uid}`) @@ -60,9 +60,14 @@ export const convertmana = newEndpoint({}, async (req, auth) => { log('sending gift card to:', privateUser.email) // eslint-disable-next-line @typescript-eslint/no-var-requires const Tremendous = require('tremendous') + // TODO: this isn't working + // const apiKey = process.env.TREMENDOUS_TEST_KEY as string + const apiKey = API_KEY + log('apiKey:', apiKey) + // Sandbox environment const client = new Tremendous( - API_KEY, + apiKey, 'https://testflight.tremendous.com/api/v2/' ) const order_data = { diff --git a/functions/src/index.ts b/functions/src/index.ts index b3606d82..35efbfb8 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -1,6 +1,7 @@ import * as admin from 'firebase-admin' import { onRequest } from 'firebase-functions/v2/https' import { EndpointDefinition } from './api' +admin.initializeApp() // v2 import { health } from './health' import { transact } from './transact' @@ -21,8 +22,6 @@ import { unsubscribe } from './unsubscribe' import { createcheckoutsession, stripewebhook } from './stripe' import { convertmana } from './convert-mana-to-gift-card' -admin.initializeApp() - // v1 export * from './on-create-bet' export * from './on-create-comment-on-contract' diff --git a/web/pages/redeem.tsx b/web/pages/redeem.tsx index 26b3d5d2..b01cd44b 100644 --- a/web/pages/redeem.tsx +++ b/web/pages/redeem.tsx @@ -23,7 +23,7 @@ export default function RedeemManaPage() { const user = useUser() const privateUser = usePrivateUser(user?.id) useTracking('view redeem mana page') - const cost = 5000 + const cost = 7500 useEffect(() => { if (open) setSuccess(false) setError('')