Skip to content

Commit b57c92c

Browse files
committed
fix: transaction mismatch
1 parent a73d332 commit b57c92c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thecodeorigin/nuxt",
33
"type": "module",
4-
"version": "2.4.7",
4+
"version": "2.4.8",
55
"publishConfig": {
66
"registry": "https://registry.npmjs.org",
77
"access": "public"

server/api/payments/payos/webhook.post.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ export default defineEventHandler(async (event) => {
3131

3232
logger.log(`[PayOS Webhook] Processing transaction: orderCode=${webhookData.orderCode}, status=${transactionStatus}`)
3333

34+
const priceDiscount = Number(paymentTransactionOfProvider.payment.order.package.price_discount)
35+
const price = Number(paymentTransactionOfProvider.payment.order.package.price)
36+
37+
if (priceDiscount !== Number(webhookData.amount) && price !== Number(webhookData.amount)) {
38+
logger.error(`[PayOS Webhook] Amount mismatch, transaction [${paymentTransactionOfProvider.id}]: expected=${price}, received=${webhookData.amount}`)
39+
40+
throw createError({
41+
statusCode: 400,
42+
message: 'Amount mismatch!',
43+
})
44+
}
45+
3446
const creditAmount = Number(paymentTransactionOfProvider.payment.order.package.amount)
3547
const userId = paymentTransactionOfProvider.payment.order.user_id
3648

0 commit comments

Comments
 (0)