Skip to content

Commit

Permalink
Mark whether purchases are made via the stripe test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
brundonsmith committed Jun 19, 2024
1 parent c71a458 commit 3b8c547
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions back-end/routes/v1/purchase.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Router, Status } from 'oak'
import { defineRoute } from './_common.ts'
import { stripe } from '../../utils/stripe.ts'
import { stripe, usingStripeTestKey } from '../../utils/stripe.ts'
import {
withDBConnection,
withDBTransaction,
Expand Down Expand Up @@ -157,7 +157,8 @@ export default function register(router: Router) {
await db.insertTable('purchase', {
owned_by_account_id: accountId,
purchase_type_id: purchaseType,
stripe_payment_intent
stripe_payment_intent,
is_test_purchase: usingStripeTestKey
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion back-end/types/db-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export type Tables = {
},
purchase: {
checked_in: boolean | null,
is_test_purchase: boolean,
owned_by_account_id: Tables['account']['account_id'] | null,
purchase_id: purchase__purchase_id_Type,
purchase_type_id: Tables['discount']['purchase_type_id'],
Expand Down Expand Up @@ -227,7 +228,7 @@ export const TABLE_COLUMNS = {
festival: ["email_banner_image","end_date","festival_id","festival_name","festival_site_id","info_url","sales_are_open","start_date"],
festival_site: ["festival_site_id","festival_site_name","location"],
invite_code: ["code","created_by_account_id","festival_id","used_by_account_id"],
purchase: ["checked_in","owned_by_account_id","purchase_id","purchase_type_id","purchased_on","stripe_payment_intent"],
purchase: ["checked_in","is_test_purchase","owned_by_account_id","purchase_id","purchase_type_id","purchased_on","stripe_payment_intent"],
purchase_type: ["available_from","available_to","description","festival_id","hidden_from_ui","is_attendance_ticket","low_income_only","max_available","max_per_account","price_in_cents","purchase_type_id"],
volunteer_type: ["description","volunteer_type_id"],
} as const
2 changes: 2 additions & 0 deletions back-end/utils/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export const stripe = new StripeSDK(env.STRIPE_SECRET_KEY, {
// @ts-ignore Use account-default API version
apiVersion: null,
})

export const usingStripeTestKey = env.STRIPE_SECRET_KEY.startsWith('sk_test_')

0 comments on commit 3b8c547

Please sign in to comment.