Skip to content

Commit

Permalink
Enable manual usd cashouts with temp payments table
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Sep 24, 2024
1 parent a9a2ff2 commit 9e6ec70
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
12 changes: 9 additions & 3 deletions backend/api/src/gidx/complete-cashout-session.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { APIError, APIHandler } from 'api/helpers/endpoint'
import {
CompleteSessionDirectCashierResponse,
PaymentMethod,
ProcessSessionCode,
} from 'common/gidx/gidx'
import {
Expand Down Expand Up @@ -117,7 +118,7 @@ export const completeCashoutSession: APIHandler<
}
if (PaymentStatusCode === '1') {
// This should always return a '0' for pending, but just in case
await debitCoins(userId, manaCashAmount, cashierResponse)
await debitCoins(userId, manaCashAmount, cashierResponse, PaymentMethod)
return {
status: 'success',
message: 'Payment successful',
Expand Down Expand Up @@ -154,7 +155,7 @@ export const completeCashoutSession: APIHandler<
gidxMessage: PaymentStatusMessage,
}
} else if (PaymentStatusCode === '0') {
await debitCoins(userId, manaCashAmount, cashierResponse)
await debitCoins(userId, manaCashAmount, cashierResponse, PaymentMethod)
return {
status: 'pending',
message: 'Payment pending',
Expand All @@ -171,7 +172,8 @@ export const completeCashoutSession: APIHandler<
const debitCoins = async (
userId: string,
manaCashAmount: number,
response: CompleteSessionDirectCashierResponse
response: CompleteSessionDirectCashierResponse,
paymentMethod: Omit<PaymentMethod, 'Token' | 'DisplayName'>
) => {
const {
MerchantTransactionID,
Expand Down Expand Up @@ -236,6 +238,10 @@ const debitCoins = async (
{ response }
)
}
await tx.none(
`insert into delete_after_reading (user_id, data) values ($1, $2)`,
[userId, JSON.stringify(paymentMethod)]
)
log('Run cashout txn, redeemable:', redeemablePrizeCash)
log('Cash balance for user prior to txn', cash)
const txn = await runTxn(tx, manaCashoutTxn)
Expand Down
9 changes: 9 additions & 0 deletions backend/supabase/delete_after_reading.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
create table
delete_after_reading (
id bigint primary key generated always as identity,
created_time timestamp with time zone default now() not null,
user_id text not null references users (id),
data jsonb
);

alter table delete_after_reading enable row level security;
2 changes: 1 addition & 1 deletion common/src/envs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const CONFIGS: { [env: string]: EnvConfig } = {
}

export const TWOMBA_ENABLED = true
export const TWOMBA_CASHOUT_ENABLED = false
export const TWOMBA_CASHOUT_ENABLED = true
export const PRODUCT_MARKET_FIT_ENABLED = false
export const SPICE_PRODUCTION_ENABLED = false
export const SPICE_TO_MANA_CONVERSION_RATE = 1
Expand Down

0 comments on commit 9e6ec70

Please sign in to comment.