@@ -57,7 +57,7 @@ export async function validatePaymentIntent(
5757 // Look up payment intent in database (temporary implementation)
5858 const existingPayment = await db . payment . findFirst ( {
5959 where : {
60- paymentIntentId,
60+ gatewayPaymentId : paymentIntentId ,
6161 order : {
6262 storeId, // Multi-tenant isolation
6363 } ,
@@ -73,7 +73,7 @@ export async function validatePaymentIntent(
7373
7474 // If payment already exists and is completed, prevent duplicate order creation
7575 if ( existingPayment ) {
76- if ( existingPayment . status === 'COMPLETED ' ) {
76+ if ( existingPayment . status === 'PAID ' ) {
7777 return {
7878 isValid : false ,
7979 reason : 'Payment intent already used for a completed order' ,
@@ -84,7 +84,7 @@ export async function validatePaymentIntent(
8484 } ;
8585 }
8686
87- if ( existingPayment . status === 'FAILED ' || existingPayment . status === 'CANCELLED ' ) {
87+ if ( existingPayment . status === 'REFUNDED ' || existingPayment . status === 'DISPUTED ' ) {
8888 return {
8989 isValid : false ,
9090 reason : `Payment intent has status: ${ existingPayment . status } ` ,
@@ -144,13 +144,13 @@ export async function validatePaymentIntent(
144144 * Prevents tampering where client submits payment intent with lower amount
145145 * than actual order total.
146146 *
147- * @param paymentIntentId - Stripe payment intent ID
148- * @param expectedAmount - Server-calculated order total ( in cents)
147+ * @param _paymentIntentId - Stripe payment intent ID (unused in mock)
148+ * @param _expectedAmount - Server-calculated order total in cents (unused in mock )
149149 * @returns True if amounts match within 1 cent tolerance
150150 */
151151export async function verifyPaymentIntentAmount (
152- paymentIntentId : string ,
153- expectedAmount : number
152+ _paymentIntentId : string ,
153+ _expectedAmount : number
154154) : Promise < boolean > {
155155 // TODO: Implement Stripe API call to retrieve payment intent amount
156156 // const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
@@ -185,7 +185,7 @@ export async function verifyPaymentIntentStore(
185185 // For now, check database payment records
186186 const payment = await db . payment . findFirst ( {
187187 where : {
188- paymentIntentId,
188+ gatewayPaymentId : paymentIntentId ,
189189 order : {
190190 storeId,
191191 } ,
@@ -203,9 +203,8 @@ export async function verifyPaymentIntentStore(
203203 */
204204export function getValidCheckoutStatuses ( ) : string [ ] {
205205 return [
206- 'requires_confirmation' ,
207- 'requires_action' ,
208- 'processing' ,
209- 'succeeded' ,
206+ 'PENDING' , // Payment initiated
207+ 'AUTHORIZED' , // Payment authorized (not captured)
208+ // Note: 'PAID' is excluded - if payment is already PAID, order likely exists
210209 ] ;
211210}
0 commit comments