-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from payrexx/bugfix/PP-12929
bugfix/PP-12929: Webhooks for Confirmed Transactions Should Not Be Sent After 60 Days.
- Loading branch information
Showing
4 changed files
with
53 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* needs please refer to http://www.prestashop.com for more information. | ||
* | ||
* @author Payrexx <[email protected]> | ||
* @copyright 2023 Payrexx | ||
* @copyright 2024 Payrexx | ||
* @license MIT License | ||
*/ | ||
if (!defined('_PS_VERSION_')) { | ||
|
@@ -19,7 +19,24 @@ | |
|
||
class PayrexxGatewayModuleFrontController extends ModuleFrontController | ||
{ | ||
public function initContent() | ||
/** | ||
* Process post values. | ||
*/ | ||
public function postProcess() | ||
{ | ||
try { | ||
$this->processWebhook(); | ||
echo 'Webhook processed successfully'; | ||
} catch (Exception $e) { | ||
echo 'Webhook Error: ' . $e->getMessage(); | ||
} | ||
exit; // Avoid template load error. | ||
} | ||
|
||
/** | ||
* Process webhook values | ||
*/ | ||
private function processWebhook() | ||
{ | ||
if (version_compare(_PS_VERSION_, '1.7.6', '<')) { | ||
$payrexxOrderService = new PayrexxOrderService(); | ||
|
@@ -35,11 +52,11 @@ public function initContent() | |
$order = Order::getByCartId($cartId); | ||
|
||
if (!$this->validRequest($transaction, $cartId, $requestStatus)) { | ||
exit; | ||
return; | ||
} | ||
|
||
if (!$prestaStatus = $payrexxOrderService->getPrestaStatusByPayrexxStatus($requestStatus)) { | ||
exit; | ||
return; | ||
} | ||
|
||
$pm = $payrexxDbService->getPaymentMethodByCartId($cartId); | ||
|
@@ -56,18 +73,17 @@ public function initContent() | |
'transaction_id' => $transaction['id'], | ||
] | ||
); | ||
exit; | ||
return; | ||
} | ||
|
||
if ($order->module !== $this->module->name) { | ||
exit; | ||
return; | ||
} | ||
|
||
// Update status if transition allowed | ||
if ($order && $payrexxOrderService->transitionAllowed($prestaStatus, $order->current_state)) { | ||
$payrexxOrderService->updateOrderStatus($prestaStatus, $order); | ||
} | ||
exit; | ||
} | ||
|
||
private function validRequest($transaction, $cartId, $requestStatus): bool | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters