@@ -4,38 +4,38 @@ export default defineEventHandler(async (event) => {
44  try  { 
55    const  body  =  await  readBody ( event ) 
66
7-     logger . log ( '[PayOS Webhook] Received webhook data:' ,  body ) 
7+     console . log ( '[PayOS Webhook] Received webhook data:' ,  body ) 
88
99    const  webhookData  =  getPayOSAdmin ( ) . verifyPaymentWebhookData ( body ) 
1010
1111    if  ( ! webhookData )  { 
12-       logger . error ( '[PayOS Webhook] Invalid webhook data received:' ,  body ) 
12+       console . error ( '[PayOS Webhook] Invalid webhook data received:' ,  body ) 
1313      throw  createError ( { 
1414        statusCode : 400 , 
1515        message : ErrorMessage . INVALID_WEBHOOK_BODY , 
1616        data : body , 
1717      } ) 
1818    } 
1919
20-     logger . log ( '[PayOS Webhook] Verified webhook data:' ,  webhookData ) 
20+     console . log ( '[PayOS Webhook] Verified webhook data:' ,  webhookData ) 
2121    const  transactionStatus  =  webhookData . code  ===  '00'  ? PaymentStatus . RESOLVED  : PaymentStatus . FAILED 
2222
2323    const  {  updatePaymentStatus,  updateProviderTransactionStatus,  getProviderTransactionByOrderCode }  =  usePayment ( ) 
2424
2525    const  paymentTransactionOfProvider  =  await  getProviderTransactionByOrderCode ( String ( webhookData . orderCode ) ) 
2626
2727    if  ( ! paymentTransactionOfProvider ?. payment . order . package )  { 
28-       logger . warn ( `[PayOS Webhook] Transaction not found or invalid: orderCode=${ webhookData . orderCode }  ) 
28+       console . warn ( `[PayOS Webhook] Transaction not found or invalid: orderCode=${ webhookData . orderCode }  ) 
2929      return  {  success : true  } 
3030    } 
3131
32-     logger . log ( `[PayOS Webhook] Processing transaction: orderCode=${ webhookData . orderCode } ${ transactionStatus }  ) 
32+     console . log ( `[PayOS Webhook] Processing transaction: orderCode=${ webhookData . orderCode } ${ transactionStatus }  ) 
3333
3434    const  priceDiscount  =  Number ( paymentTransactionOfProvider . payment . order . package . price_discount ) 
3535    const  price  =  Number ( paymentTransactionOfProvider . payment . order . package . price ) 
3636
3737    if  ( priceDiscount  !==  Number ( webhookData . amount )  &&  price  !==  Number ( webhookData . amount ) )  { 
38-       logger . error ( `[PayOS Webhook] Amount mismatch, transaction [${ paymentTransactionOfProvider . id } ${ price } ${ webhookData . amount }  ) 
38+       console . error ( `[PayOS Webhook] Amount mismatch, transaction [${ paymentTransactionOfProvider . id } ${ price } ${ webhookData . amount }  ) 
3939
4040      throw  createError ( { 
4141        statusCode : 400 , 
@@ -48,33 +48,33 @@ export default defineEventHandler(async (event) => {
4848
4949    // The userId is already the UUID from our database since we've updated 
5050    // our schemas to use UUID references between tables 
51-     logger . log ( `[PayOS Webhook] Adding credits: userId=${ userId } ${ creditAmount }  ) 
51+     console . log ( `[PayOS Webhook] Adding credits: userId=${ userId } ${ creditAmount }  ) 
5252
5353    await  addCreditToUser ( userId ,  creditAmount ) 
5454
55-     logger . log ( `[PayOS Webhook] Credits added successfully: userId=${ userId } ${ creditAmount }  ) 
55+     console . log ( `[PayOS Webhook] Credits added successfully: userId=${ userId } ${ creditAmount }  ) 
5656
5757    if  ( ! paymentTransactionOfProvider ?. payment . order . package )  { 
58-       logger . error ( `[PayOS Webhook] No product found for transaction: ${ webhookData . orderCode }  ) 
58+       console . error ( `[PayOS Webhook] No product found for transaction: ${ webhookData . orderCode }  ) 
5959      throw  createError ( { 
6060        statusCode : 400 , 
6161        message : 'No product found for this transaction!' , 
6262      } ) 
6363    } 
6464
65-     logger . log ( `[PayOS Webhook] Updating transaction ${ paymentTransactionOfProvider . id } ${ transactionStatus }  ) 
65+     console . log ( `[PayOS Webhook] Updating transaction ${ paymentTransactionOfProvider . id } ${ transactionStatus }  ) 
6666
6767    await  updateProviderTransactionStatus ( paymentTransactionOfProvider . id ,  transactionStatus ,  webhookData . transactionDateTime ) 
6868
6969    await  updatePaymentStatus ( paymentTransactionOfProvider . payment . id ,  transactionStatus ) 
7070
71-     logger . log ( `[PayOS Webhook] Transaction updated successfully: id=${ paymentTransactionOfProvider . id } ${ transactionStatus }  ) 
71+     console . log ( `[PayOS Webhook] Transaction updated successfully: id=${ paymentTransactionOfProvider . id } ${ transactionStatus }  ) 
7272
73-     logger . log ( '[PayOS Webhook] Webhook processing completed successfully' ) 
73+     console . log ( '[PayOS Webhook] Webhook processing completed successfully' ) 
7474    return  {  success : true  } 
7575  } 
7676  catch  ( error : any )  { 
77-     logger . error ( '[PayOS Webhook] Error processing webhook:' ,  error ) 
77+     console . error ( '[PayOS Webhook] Error processing webhook:' ,  error ) 
7878
7979    throw  parseError ( error ) 
8080  } 
0 commit comments