File tree Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ // TODO: (store) Create a function to check if a given product and variant are sellable to a given user
2
+ // If it is sellable, return the price ID to create a stripe checkout session for
3
+
4
+ import { type DynamoDBClient } from "@aws-sdk/client-dynamodb" ;
5
+ import { type Redis } from "api/types.js" ;
6
+
7
+ // If not, return null.
8
+ export type CheckItemSellableInputs = {
9
+ userId : string ; // This is generally their Illinois email
10
+ productId : string ;
11
+ variantId : string ;
12
+ dynamoClient : DynamoDBClient ;
13
+ redisClient : Redis ;
14
+ } ;
15
+
16
+ export type CheckItemSellableOutputs = null | string ;
17
+
18
+ export async function checkItemSellable ( {
19
+ userId,
20
+ productId,
21
+ variantId,
22
+ dynamoClient,
23
+ redisClient,
24
+ } : CheckItemSellableInputs ) : Promise < CheckItemSellableOutputs > {
25
+ // In a transaction:
26
+ // First, check if there is stock.
27
+ // If there is stock, check that the user is still under their limit.
28
+ // If there is, check if they are a paid member.
29
+ // If paid member return member_price_id for the variant request, if not return the nonmember_price_id
30
+ return null ;
31
+ }
32
+
33
+ export type CreateCheckoutSessionInputs = {
34
+ priceId : string ;
35
+ username : string ;
36
+ stripeApiKey : string ;
37
+ } ;
38
+
39
+ export type CreateCheckoutSessionOutputs = string ;
40
+
41
+ export async function createCheckoutSession ( {
42
+ priceId,
43
+ } : CreateCheckoutSessionInputs ) : Promise < CreateCheckoutSessionOutputs > {
44
+ // Check stripe modules createCheckoutSession function
45
+ // initatior string should be "acm-store"
46
+ return "" ;
47
+ }
Original file line number Diff line number Diff line change @@ -64,6 +64,8 @@ export type GenericConfigType = {
64
64
UserInfoTable : string ;
65
65
SigInfoTableName : string ;
66
66
EntraHostedDomainName : string ;
67
+ StoreInventoryTableName : string ;
68
+ // TODO: (store) add other tables
67
69
} ;
68
70
69
71
type EnvironmentConfigType = {
@@ -106,6 +108,7 @@ const genericConfig: GenericConfigType = {
106
108
UserInfoTable : "infra-core-api-user-info" ,
107
109
SigInfoTableName : "infra-core-api-sigs" ,
108
110
EntraHostedDomainName : "acmillinois.onmicrosoft.com" ,
111
+ StoreInventoryTableName : "infra-core-api-store-inventory"
109
112
} as const ;
110
113
111
114
const environmentConfig : EnvironmentConfigType = {
Original file line number Diff line number Diff line change @@ -339,3 +339,22 @@ resource "aws_dynamodb_table" "sig_info" {
339
339
projection_type = " KEYS_ONLY"
340
340
}
341
341
}
342
+
343
+ resource "aws_dynamodb_table" "store_inventory" {
344
+ billing_mode = " PAY_PER_REQUEST"
345
+ name = " ${ var . ProjectId } -store-inventory"
346
+ deletion_protection_enabled = true
347
+ hash_key = " productId"
348
+ range_key = " variantId"
349
+ point_in_time_recovery {
350
+ enabled = true
351
+ }
352
+ attribute {
353
+ name = " productId"
354
+ type = " S"
355
+ }
356
+ attribute {
357
+ name = " variantId"
358
+ type = " S"
359
+ }
360
+ }
You can’t perform that action at this time.
0 commit comments