Skip to content

Commit

Permalink
compatibility update for shopware 5.7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Horst Fickel committed Mar 20, 2023
1 parent a491b96 commit 27f58d0
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 124 deletions.
54 changes: 27 additions & 27 deletions Frontend/QentaCheckoutPage/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function getCapabilities()
*/
public function getVersion()
{
return '2.0.1';
return '2.0.2';
}

/**
Expand Down Expand Up @@ -116,7 +116,7 @@ public function install() {
$this->createForm();
$this->createTranslations();

foreach (Shopware()->QentaCheckoutPage()->getConfig()->getDbTables() as $sql) {
foreach (Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->getDbTables() as $sql) {
Shopware()->Db()->exec($sql);
}

Expand Down Expand Up @@ -746,7 +746,7 @@ public function addLessFiles(Enlight_Event_EventArgs $args)
*/
protected function createPayments()
{
$oConfig = Shopware()->QentaCheckoutPage()->getConfig();
$oConfig = Shopware()->Container()->get('QentaCheckoutPage')->getConfig();

$prefixName = $oConfig->getPrefix('name');

Expand All @@ -770,7 +770,7 @@ protected function createPayments()

$aTranslations = array();
$i = 80;
foreach (Shopware()->QentaCheckoutPage()->getPaymentMethods()->getList() as $pm) {
foreach (Shopware()->Container()->get('QentaCheckoutPage')->getPaymentMethods()->getList() as $pm) {
$oPayment = $this->Payments()->findOneBy(array('name' => $prefixName . $pm['name']));
if(!$oPayment) {
$payment = array(
Expand Down Expand Up @@ -825,9 +825,9 @@ public function pluginConfig()
public static function init()
{
// Register resource QentaCheckoutPage
// The instance is available with Shopware()->QentaCheckoutPage()
if (!Shopware()->Bootstrap()->issetResource('QentaCheckoutPage')) {
Shopware()->Bootstrap()->registerResource(
// The instance is available with Shopware()->Container()->get('QentaCheckoutPage')
if (!Shopware()->Container()->initialized('QentaCheckoutPage')) {
Shopware()->Container()->set(
'QentaCheckoutPage',
new Shopware_Plugins_Frontend_QentaCheckoutPage_Models_Resources()
);
Expand Down Expand Up @@ -864,7 +864,7 @@ public static function onGetControllerPathFrontend(Enlight_Event_EventArgs $args
*/
public function getPayolutionLink()
{
$mid = Shopware()->QentaCheckoutPage()->getConfig()->PAYOLUTION_MID;
$mid = Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->PAYOLUTION_MID;
if (strlen($mid) === 0) {
return false;
}
Expand Down Expand Up @@ -917,7 +917,7 @@ public function onPreDispatch(Enlight_Event_EventArgs $args)
$financialInstitution = $args->getSubject()->Request()->get('financialInstitution');
if (isset($financialInstitution)) {
self::init();
Shopware()->QentaCheckoutPage()->financialInstitution = $financialInstitution;
Shopware()->Container()->get('QentaCheckoutPage')->financialInstitution = $financialInstitution;
}
$birthDate = $args->getSubject()->Request()->get('birthdate');
if (!empty($birthDate)) {
Expand Down Expand Up @@ -965,7 +965,7 @@ public function onPostDispatch(Enlight_Event_EventArgs $args)
$view->addTemplateDir($this->Path() . 'Views/responsive/');

// Output of common errors
if (null != Shopware()->QentaCheckoutPage()->qenta_action) {
if (null != Shopware()->Container()->get('QentaCheckoutPage')->qenta_action) {
self::showErrorMessages($view);
}
break;
Expand All @@ -975,7 +975,7 @@ public function onPostDispatch(Enlight_Event_EventArgs $args)
$view->addTemplateDir($this->Path() . 'Views/responsive/');

// Output of common errors
if (null != Shopware()->QentaCheckoutPage()->qenta_action) {
if (null != Shopware()->Container()->get('QentaCheckoutPage')->qenta_action) {
self::showErrorMessages($view);
}

Expand All @@ -984,18 +984,18 @@ public function onPostDispatch(Enlight_Event_EventArgs $args)
$view->paymentDesc = Shopware()->Session()->sOrderVariables['sUserData']['additional']['payment']['description'];
$view->paymentName = $paymentName;
$view->paymentLogo = 'frontend/_public/images/' . $paymentName . '.png';
$view->financialInstitutionSelectionEnabled = Shopware()->QentaCheckoutPage()->getConfig()->FINANCIAL_INSTITUTION_SELECTION_ENABLED;
$view->financialInstitutionSelectionEnabled = Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->FINANCIAL_INSTITUTION_SELECTION_ENABLED;

if(Shopware()->Session()->offsetGet('qcpConsumerDeviceId') != null) {
$consumerDeviceId = Shopware()->Session()->offsetGet('qcpConsumerDeviceId');
} else {
$timestamp = microtime();
$consumerDeviceId = md5(Shopware()->QentaCheckoutPage()->getConfig()->customerid . "_" . $timestamp);
$consumerDeviceId = md5(Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->customerid . "_" . $timestamp);
Shopware()->Session()->offsetSet('qcpConsumerDeviceId', $consumerDeviceId);
}
$paymentName = Shopware()->QentaCheckoutPage()->getPaymentShortName();
if ((Shopware()->QentaCheckoutPage()->getConfig()->INVOICE_PROVIDER == 'ratepay' && $paymentName == 'qcp_invoice') ||
(Shopware()->QentaCheckoutPage()->getConfig()->INSTALLMENT_PROVIDER == 'ratepay' && $paymentName == 'qcp_installment')) {
$paymentName = Shopware()->Container()->get('QentaCheckoutPage')->getPaymentShortName();
if ((Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->INVOICE_PROVIDER == 'ratepay' && $paymentName == 'qcp_invoice') ||
(Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->INSTALLMENT_PROVIDER == 'ratepay' && $paymentName == 'qcp_installment')) {
$ratepay = '<script language="JavaScript">var di = {t:"' . $consumerDeviceId . '",v:"WDWL",l:"Checkout"};</script>';
$ratepay .= '<script type="text/javascript" src="//d.ratepay.com/' . $consumerDeviceId . '/di.js"></script>';
$ratepay .= '<noscript><link rel="stylesheet" type="text/css" href="//d.ratepay.com/di.css?t=' . $consumerDeviceId . '&v=WDWL&l=Checkout"></noscript>';
Expand Down Expand Up @@ -1029,19 +1029,19 @@ public function onPostDispatch(Enlight_Event_EventArgs $args)
$view->bMonth = $birthday[1];
$view->bDay = $birthday[2];

if ((Shopware()->QentaCheckoutPage()->getConfig()->INVOICE_PROVIDER == 'payolution' && $paymentName == 'INVOICE') ||
(Shopware()->QentaCheckoutPage()->getConfig()->INSTALLMENT_PROVIDER == 'payolution' && $paymentName == 'INSTALLMENT')
if ((Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->INVOICE_PROVIDER == 'payolution' && $paymentName == 'INVOICE') ||
(Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->INSTALLMENT_PROVIDER == 'payolution' && $paymentName == 'INSTALLMENT')
) {
$view->payolutionTerms = Shopware()->QentaCheckoutPage()->getConfig()->PAYOLUTION_TERMS;
if (Shopware()->QentaCheckoutPage()->getConfig()->PAYOLUTION_TERMS) {
$view->payolutionTerms = Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->PAYOLUTION_TERMS;
if (Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->PAYOLUTION_TERMS) {
$view->qcpPayolutionLink1 = '<a id="qcp-payolutionlink" href="https://payment.payolution.com/payolution-payment/infoport/dataprivacyconsent?mId=' . $this->getPayolutionLink() . '" target="_blank">';
$view->qcpPayolutionLink2 = '</a>';
}
}

$view->epsFinancialInstitutions = QentaCEE_QPay_PaymentType::getFinancialInstitutions('EPS');
$view->idlFinancialInstitutions = QentaCEE_QPay_PaymentType::getFinancialInstitutions('IDL');
$view->financialInstitutionsSelected = Shopware()->QentaCheckoutPage()->financialInstitution;
$view->financialInstitutionsSelected = Shopware()->Container()->get('QentaCheckoutPage')->financialInstitution;

break;

Expand Down Expand Up @@ -1070,7 +1070,7 @@ private function isActivePayment($paymentName)
{
switch ($paymentName) {
case 'qcp_invoice':
$currencies = Shopware()->QentaCheckoutPage()->getConfig()->INVOICE_CURRENCY;
$currencies = Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->INVOICE_CURRENCY;
if (isset($currencies)) {
$currentCurrency = Shopware()->Shop()->getCurrency()->getCurrency();

Expand All @@ -1086,7 +1086,7 @@ private function isActivePayment($paymentName)

return true;
case 'qcp_installment':
$currencies = Shopware()->QentaCheckoutPage()->getConfig()->INSTALLMENT_CURRENCY;
$currencies = Shopware()->Container()->get('QentaCheckoutPage')->getConfig()->INSTALLMENT_CURRENCY;
if (isset($currencies)) {
$currentCurrency = Shopware()->Shop()->getCurrency()->getCurrency();

Expand Down Expand Up @@ -1136,10 +1136,10 @@ protected function hidePayment($payments, $paymentName)
*/
protected static function showErrorMessages($view)
{
$view->qenta_error = Shopware()->QentaCheckoutPage()->qenta_action;
$view->qenta_message = Shopware()->QentaCheckoutPage()->qenta_message;
Shopware()->QentaCheckoutPage()->qenta_action = null;
Shopware()->QentaCheckoutPage()->qenta_message = null;
$view->qenta_error = Shopware()->Container()->get('QentaCheckoutPage')->qenta_action;
$view->qenta_message = Shopware()->Container()->get('QentaCheckoutPage')->qenta_message;
Shopware()->Container()->get('QentaCheckoutPage')->qenta_action = null;
Shopware()->Container()->get('QentaCheckoutPage')->qenta_message = null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ protected function _sendRequest()
$httpClient = $this->_getHttpClient();

$request = $httpClient->post($this->_getRequestUrl(), [
'body' => $this->_requestData,
'form_params' => $this->_requestData,
'headers' => [
'User-Agent' => $this->getUserAgentString()
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public function __construct($response)
{
if ($response instanceof Response) {
$this->_response = QentaCEE_Stdlib_SerialApi::decode($response->getBody());
} elseif ($response instanceof \GuzzleHttp\Psr7\Response) {
$this->_response = QentaCEE_Stdlib_SerialApi::decode($response->getBody()->getContents());
} elseif (is_array($response)) {
$this->_response = $response;
} else {
Expand Down
Loading

0 comments on commit 27f58d0

Please sign in to comment.