Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TYPO3 v11 PHP 81 support and PayPal rebatt amount #28

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
[WIP] compatibility with TYPO3 v11 and PHP v8.1
  • Loading branch information
krausandre committed Mar 17, 2023
commit f0e1f7f63f28addba1e845e2a3326d81bd785b86
56 changes: 53 additions & 3 deletions Classes/Controller/Order/PaymentController.php
Original file line number Diff line number Diff line change
@@ -16,7 +16,9 @@
use Extcode\CartPaypal\Event\Order\CancelEvent;
use Extcode\CartPaypal\Event\Order\NotifyEvent;
use Extcode\CartPaypal\Event\Order\SuccessEvent;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Log\LogManagerInterface;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -28,6 +30,8 @@

class PaymentController extends ActionController
{
use LoggerAwareTrait;

const PAYPAL_API_SANDBOX = 'https://www.sandbox.paypal.com/cgi-bin/webscr?';
const PAYPAL_API_LIVE = 'https://www.paypal.com/cgi-bin/webscr?';

@@ -78,7 +82,8 @@ public function __construct(
CartRepository $cartRepository,
PaymentRepository $paymentRepository
) {
$this->logger = $logManager->getLogger();
// $this->logger = $logManager->getLogger();
$this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
$this->persistenceManager = $persistenceManager;
$this->sessionHandler = $sessionHandler;
$this->cartRepository = $cartRepository;
@@ -186,6 +191,14 @@ public function cancelAction(): void
public function notifyAction()
{
if ($this->request->getMethod() !== 'POST') {
if ($this->cartPaypalConf['debug']) {
$this->logger->error(
'Notify Action called without Post vars. ' . ' In class ' . get_class($this) . ':' . __LINE__,
[
'order' => ((!empty($_GET['tx_cartpaypal_cart']['order'])) ? $_GET['tx_cartpaypal_cart']['order'] : 'No order ID given')
]
);
}
return $this->htmlResponse()->withStatus(405, 'Method not allowed.');
}

@@ -194,7 +207,7 @@ public function notifyAction()
$curlRequest = $this->getCurlRequestFromPostData($postData);

if ($this->cartPaypalConf['debug']) {
$this->logger->debug(
$this->logger->error(
'Log Data',
[
'$parsedPostData' => $postData,
@@ -207,12 +220,36 @@ public function notifyAction()

$cartSHash = $postData['custom'];
if (empty($cartSHash)) {
// debug
if ($this->cartPaypalConf['debug']) {
$this->logger->error(
'Notify Action called with empty cartSHash. ' . ' In class ' . get_class($this) . ':' . __LINE__,
[
'order' => ((!empty($_GET['tx_cartpaypal_cart']['order'])) ? $_GET['tx_cartpaypal_cart']['order'] : 'No order ID given'),
'$parsedPostData' => $postData,
'$curlRequest' => $curlRequest
]
);
}
// end debug
return $this->htmlResponse()->withStatus(403, 'Not allowed.');
}

$this->loadCartByHash($this->request->getArgument('hash'));

if ($this->cart === null) {
// debug
if ($this->cartPaypalConf['debug']) {
$this->logger->error(
'Notify Action but couldn`t load cart by hash. ' . ' In class ' . get_class($this) . ':' . __LINE__,
[
'order' => ((!empty($_GET['tx_cartpaypal_cart']['order'])) ? $_GET['tx_cartpaypal_cart']['order'] : 'No order ID given'),
'$parsedPostData' => $postData,
'$curlRequest' => $curlRequest
]
);
}
// end debug
return $this->htmlResponse()->withStatus(404, 'Page / Cart not found.');
}

@@ -226,6 +263,19 @@ public function notifyAction()

$notifyEvent = new NotifyEvent($this->cart->getCart(), $orderItem, $this->cartConf);
$this->eventDispatcher->dispatch($notifyEvent);
} else {
// debug
if ($this->cartPaypalConf['debug']) {
$this->logger->error(
'Notify Action success. ' . ' In class ' . get_class($this) . ':' . __LINE__,
[
'order' => ((!empty($_GET['tx_cartpaypal_cart']['order'])) ? $_GET['tx_cartpaypal_cart']['order'] : 'No order ID given'),
'$parsedPostData' => $postData,
'$curlRequest' => $curlRequest
]
);
}
// end debug
}

return $this->htmlResponse()->withStatus(200);
@@ -293,7 +343,7 @@ protected function execCurlRequest(string $curlRequest): bool
}

if ($this->cartPaypalConf['debug']) {
$this->logger->debug(
$this->logger->error(
'paypal-payment-api',
[
'curl_info' => curl_getinfo($ch, CURLINFO_HEADER_OUT),
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
}
},
"require": {
"php": ">=7.2.0 <7.5",
"php": ">=7.2.0 <8.2",
"ext-curl": "*",
"typo3/cms-core": "^11.5",
"typo3/cms-extbase": "^11.5",
9 changes: 0 additions & 9 deletions ext_emconf.php
Original file line number Diff line number Diff line change
@@ -7,16 +7,7 @@
'author' => 'Daniel Gohlke',
'author_email' => 'ext.cart@extco.de',
'author_company' => 'extco.de UG (haftungsbeschränkt)',
'shy' => '',
'priority' => '',
'module' => '',
'state' => 'beta',
'internal' => '',
'uploadfolder' => '0',
'createDirs' => '',
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'version' => '5.0.0',
'constraints' => [
'depends' => [