Update amount, try using secrets

This commit is contained in:
Ian Philips 2022-07-28 10:57:57 -07:00
parent 167aa1cd1b
commit 2490524477
3 changed files with 15 additions and 11 deletions

View File

@ -1,27 +1,27 @@
import { APIError, newEndpoint } from './api' import { APIError, newEndpoint } from './api'
import { isProd, log } from './utils' import { isProd, log } from './utils'
import * as admin from 'firebase-admin' import * as admin from 'firebase-admin'
import { PrivateUser, User } from 'common/user' import { PrivateUser, User } from '../../common/user'
import { runTxn, TxnData } from './transact' import { runTxn, TxnData } from './transact'
import { import {
DEV_HOUSE_LIQUIDITY_PROVIDER_ID, DEV_HOUSE_LIQUIDITY_PROVIDER_ID,
HOUSE_LIQUIDITY_PROVIDER_ID, HOUSE_LIQUIDITY_PROVIDER_ID,
} from 'common/antes' } from '../../common/antes'
// sandbox // sandbox
const API_KEY = 'TEST_k-dOX64gXbmZgaaPgbb_7aP6jhI-iXae_mASnHedTvQ' const API_KEY = 'TEST_k-dOX64gXbmZgaaPgbb_7aP6jhI-iXae_mASnHedTvQ'
const FUNDING_ID = 'Y46Z09MJBQXY' const FUNDING_ID = 'Y46Z09MJBQXY'
const CAMPAIGN_ID = 'DVFR42FR12KO' const CAMPAIGN_ID = 'DVFR42FR12KO'
// prod // prod
// const API_KEY = ''
// const FUNDING_ID = '' // const FUNDING_ID = ''
// const CAMPAIGN_ID = 'T5436LGG2KP6' // const CAMPAIGN_ID = 'T5436LGG2KP6'
const firestore = admin.firestore() const firestore = admin.firestore()
const amount = 5000 const amount = 7500
// Production environment const opts = { secrets: ['TREMENDOUS_TEST_KEY'] }
// var client = new Tremendous("[PRODUCTION_ACCESS_TOKEN]", "https://www.tremendous.com/api/v2/");
export const convertmana = newEndpoint({}, async (req, auth) => { export const convertmana = newEndpoint(opts, async (req, auth) => {
const result = await firestore.runTransaction(async (trans) => { const result = await firestore.runTransaction(async (trans) => {
log('Inside main transaction.') log('Inside main transaction.')
const userDoc = firestore.doc(`users/${auth.uid}`) 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) log('sending gift card to:', privateUser.email)
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
const Tremendous = require('tremendous') 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 // Sandbox environment
const client = new Tremendous( const client = new Tremendous(
API_KEY, apiKey,
'https://testflight.tremendous.com/api/v2/' 'https://testflight.tremendous.com/api/v2/'
) )
const order_data = { const order_data = {

View File

@ -1,6 +1,7 @@
import * as admin from 'firebase-admin' import * as admin from 'firebase-admin'
import { onRequest } from 'firebase-functions/v2/https' import { onRequest } from 'firebase-functions/v2/https'
import { EndpointDefinition } from './api' import { EndpointDefinition } from './api'
admin.initializeApp()
// v2 // v2
import { health } from './health' import { health } from './health'
import { transact } from './transact' import { transact } from './transact'
@ -21,8 +22,6 @@ import { unsubscribe } from './unsubscribe'
import { createcheckoutsession, stripewebhook } from './stripe' import { createcheckoutsession, stripewebhook } from './stripe'
import { convertmana } from './convert-mana-to-gift-card' import { convertmana } from './convert-mana-to-gift-card'
admin.initializeApp()
// v1 // v1
export * from './on-create-bet' export * from './on-create-bet'
export * from './on-create-comment-on-contract' export * from './on-create-comment-on-contract'

View File

@ -23,7 +23,7 @@ export default function RedeemManaPage() {
const user = useUser() const user = useUser()
const privateUser = usePrivateUser(user?.id) const privateUser = usePrivateUser(user?.id)
useTracking('view redeem mana page') useTracking('view redeem mana page')
const cost = 5000 const cost = 7500
useEffect(() => { useEffect(() => {
if (open) setSuccess(false) if (open) setSuccess(false)
setError('') setError('')