From e62258efada85eb3188af31b112398a6a03156d6 Mon Sep 17 00:00:00 2001 From: nikhilsharma1100 Date: Fri, 22 Jul 2022 11:25:25 +0530 Subject: [PATCH] added condition to update amount paid variable --- Controller/Payment/Webhook.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Controller/Payment/Webhook.php b/Controller/Payment/Webhook.php index 0ec04a17..55543fa8 100644 --- a/Controller/Payment/Webhook.php +++ b/Controller/Payment/Webhook.php @@ -180,11 +180,21 @@ public function execute() $orderId = $post['payload']['payment']['entity']['notes']['merchant_order_id']; $paymentId = $post['payload']['payment']['entity']['id']; $orderWebhookData = $this->getOrderWebhookData($orderId); + $amountPaid = $post['payload']['payment']['entity']['amount']; if (empty($orderWebhookData['rzp_webhook_notified_at']) === true) { $this->setWebhookNotifiedAt($orderWebhookData['entity_id']); - $this->setWebhookData($orderWebhookData['entity_id'], true, $paymentId, $post['event'], $post['payload']['payment']['entity']['amount']); + + if ($post['event'] === 'payment.authorized') + { + $amountPaid = $post['payload']['payment']['entity']['amount']; + } + else if ($post['event'] === 'order.paid') + { + $amountPaid = $post['payload']['order']['entity']['amount_paid']; + } + $this->setWebhookData($orderWebhookData['entity_id'], true, $paymentId, $post['event'], $amountPaid); $this->logger->info("Razorpay Webhook: Updated WebhookNotifiedAt.");