From c3dd61d383677d33fba577873fbfb213f265c2d8 Mon Sep 17 00:00:00 2001 From: Halil Beycan <50718965+BeycanDeveloper@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:20:11 +0800 Subject: [PATCH 1/4] added failed reason for verifier --- app/Pages/TransactionPage.php | 2 +- app/Services/Verifier.php | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Pages/TransactionPage.php b/app/Pages/TransactionPage.php index 0f721c2..2274904 100644 --- a/app/Pages/TransactionPage.php +++ b/app/Pages/TransactionPage.php @@ -191,7 +191,7 @@ public function page(): void $result .= $tx->params->sanction->source . ' with ' . $tx->params->sanction->api . ' API'; } - if (isset($tx->params->failedReason)) { + if (isset($tx->params->failedReason) && $tx->status == Status::FAILED->getValue()) { $result .= CPL_BR2 . esc_html__('Failed reason: ', 'cryptopay'); $result .= $tx->params->failedReason; } diff --git a/app/Services/Verifier.php b/app/Services/Verifier.php index 0b645a6..8aa1b83 100644 --- a/app/Services/Verifier.php +++ b/app/Services/Verifier.php @@ -144,12 +144,13 @@ public static function verifyPendingTransactions( /** @var TransactionType $transaction */ foreach ($transactions as $transaction) { + $paymentData = new PaymentDataType($model->getAddon()); + try { if ((strtotime(current_time('mysql')) - $transaction->getCreatedAt()->getTimestamp()) < 30) { continue; } - $paymentData = new PaymentDataType($model->getAddon()); $paymentData->setHash($transaction->getHash()); $paymentData->setOrder($transaction->getOrder()); $paymentData->setParams($transaction->getParams()); @@ -180,8 +181,10 @@ public static function verifyPendingTransactions( Hook::callAction('payment_finished', $paymentData); Hook::callAction('payment_finished_' . $model->getAddon(), $paymentData); } catch (\Exception $e) { - Helpers::debug($e->getMessage(), 'ERROR', $e); - $model->updateStatusToFailedByHash($transaction->getHash()); + $paymentData->setStatus(false); + Helpers::debug('Verifier payment finished error', 'ERROR', $e); + $paymentData->getParams()->set('failedReason', $e->getMessage()); + $paymentData->getModel()->updateWithPaymentData($paymentData, $transaction); } } } From b7f0f4332e367d286f41428f920adb35358f8837 Mon Sep 17 00:00:00 2001 From: Halil Beycan <50718965+BeycanDeveloper@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:08:47 +0800 Subject: [PATCH 2/4] fix --- app/PluginHero/Helpers/Debug.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/PluginHero/Helpers/Debug.php b/app/PluginHero/Helpers/Debug.php index 7fe6a32..30cde1b 100644 --- a/app/PluginHero/Helpers/Debug.php +++ b/app/PluginHero/Helpers/Debug.php @@ -53,6 +53,7 @@ public static function debug(string $message, string $level = 'INFO', array|\Thr $file = self::getProp('pluginDir') . 'debug.log'; if ($wp_filesystem->exists($file)) { + $content = $wp_filesystem->get_contents($file) . $content; $wp_filesystem->put_contents($file, $content, FS_CHMOD_FILE); } else { $wp_filesystem->put_contents($file, $content, FS_CHMOD_FILE); From 6119c6a20727dc752f8d9866ee8f2e78e3743d55 Mon Sep 17 00:00:00 2001 From: Halil Beycan <50718965+BeycanDeveloper@users.noreply.github.com> Date: Mon, 16 Sep 2024 14:36:22 +0800 Subject: [PATCH 3/4] updated --- app/PluginHero/templates/plugins.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PluginHero/templates/plugins.php b/app/PluginHero/templates/plugins.php index 05bcc45..3529ab9 100644 --- a/app/PluginHero/templates/plugins.php +++ b/app/PluginHero/templates/plugins.php @@ -13,8 +13,8 @@