Skip to content

Commit

Permalink
fix: add new required field userId to mint card
Browse files Browse the repository at this point in the history
  • Loading branch information
EresDev committed Dec 12, 2024
1 parent d8a21a0 commit e70d817
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions functions/post-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export async function onRequest(ctx: Context): Promise<Response> {
return Response.json({ message: "The permit has already claimed a gift card." }, { status: 400 });
}

const order = await orderGiftCard(productId, giftCardValue, orderId, accessToken);
const order = await orderGiftCard(txReceipt.from.toLowerCase(), productId, giftCardValue, orderId, accessToken);

if (order.status != "REFUNDED" && order.status != "FAILED") {
return Response.json(order, { status: 200 });
Expand Down Expand Up @@ -138,7 +138,13 @@ export async function getGiftCardById(productId: number, accessToken: AccessToke
return responseJson as GiftCard;
}

async function orderGiftCard(productId: number, cardValue: number, identifier: string, accessToken: AccessToken): Promise<ReloadlyOrderResponse> {
async function orderGiftCard(
userId: string,
productId: number,
cardValue: number,
identifier: string,
accessToken: AccessToken
): Promise<ReloadlyOrderResponse> {
const url = `${getReloadlyApiBaseUrl(accessToken.isSandbox)}/orders`;
console.log(`Placing order at url: ${url}`);

Expand All @@ -148,6 +154,9 @@ async function orderGiftCard(productId: number, cardValue: number, identifier: s
unitPrice: cardValue.toFixed(2),
customIdentifier: identifier,
preOrder: false,
productAdditionalRequirements: {
userId: userId,
},
});

console.log(`Placing order at url: ${url}`);
Expand Down

0 comments on commit e70d817

Please sign in to comment.