Skip to content

Commit

Permalink
feature/payment: update webhook for verify url
Browse files Browse the repository at this point in the history
  • Loading branch information
MinhhTien committed May 5, 2024
1 parent 1b68e8c commit fd618ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async function bootstrap() {
}

// Example: process.env.CORS_VALID_ORIGINS=localhost,ngrok-free => parse to [ /localhost/, /ngrok-free/ ]
const origins = process.env.CORS_VALID_ORIGINS.split(',').map((origin) => new RegExp(origin)) || [
const origins = process.env.CORS_VALID_ORIGINS?.split(',').map((origin) => new RegExp(origin)) || [
/localhost/,
/ngrok-free/
]
Expand Down
10 changes: 5 additions & 5 deletions src/payment/controllers/payment.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class PaymentController {
//1. Validate signature with other data
const result = this.paymentService.verifyPaymentWebhookData(momoPaymentResponseDto)
if (!result) return false

//2. Process webhook
return this.paymentService.processWebhook(PaymentMethod.MOMO, momoPaymentResponseDto)
}
Expand All @@ -55,13 +55,13 @@ export class PaymentController {
console.log('Handling PAYOS webhook', JSON.stringify(webhookData))
this.paymentService.setStrategy(PaymentMethod.PAY_OS)

// just skip for confirmWebhook
if (webhookData.data.orderCode == 123) return true

//1. Validate signature with other data
const result = this.paymentService.verifyPaymentWebhookData(webhookData)
if (!result) return false

// // just skip for confirmWebhook
// if (webhookData.data.orderCode == 123) return true

//2. Process webhook
return this.paymentService.processWebhook(PaymentMethod.PAY_OS, webhookData)
}
Expand All @@ -72,7 +72,7 @@ export class PaymentController {
// @Post('webhook/payos-confirm')
// async verifyWebhook() {
// console.log('Handling Confirm Webhook URL for PAYOS')

// await this.paymentService.payOSPaymentStrategy.verifyWebhookUrl()
// }
}

0 comments on commit fd618ba

Please sign in to comment.