Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
margud authored Jun 6, 2020
2 parents eec2435 + 9054de8 commit 5dc41db
Show file tree
Hide file tree
Showing 1,437 changed files with 114,837 additions and 106,671 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"config": {
"platform": {
"php": "5.6"
}
},
"prepend-autoloader": false
},
"type": "prestashop-module"
}
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>mollie</name>
<displayName><![CDATA[Mollie]]></displayName>
<version><![CDATA[4.0.1]]></version>
<version><![CDATA[4.0.4]]></version>
<description><![CDATA[Mollie Payments]]></description>
<author><![CDATA[Mollie B.V.]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
4 changes: 2 additions & 2 deletions controllers/front/payScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
* @codingStandardsIgnoreStart
*/

use _PhpScoper5ece82d7231e4\Mollie\Api\MollieApiClient;
use _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod;
use _PhpScoper5ea00cc67502b\Mollie\Api\MollieApiClient;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod;

class MolliePayScreenModuleFrontController extends ModuleFrontController
{
Expand Down
12 changes: 6 additions & 6 deletions controllers/front/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
* @codingStandardsIgnoreStart
*/

use _PhpScoper5ece82d7231e4\Mollie\Api\Exceptions\ApiException;
use _PhpScoper5ece82d7231e4\Mollie\Api\Resources\Order as MollieOrderAlias;
use _PhpScoper5ece82d7231e4\Mollie\Api\Resources\Payment as MolliePaymentAlias;
use _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod;
use _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentStatus;
use _PhpScoper5ece82d7231e4\PrestaShop\Decimal\Number;
use _PhpScoper5ea00cc67502b\Mollie\Api\Exceptions\ApiException;
use _PhpScoper5ea00cc67502b\Mollie\Api\Resources\Order as MollieOrderAlias;
use _PhpScoper5ea00cc67502b\Mollie\Api\Resources\Payment as MolliePaymentAlias;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentStatus;
use _PhpScoper5ea00cc67502b\PrestaShop\Decimal\Number;
use Mollie\Config\Config;
use Mollie\Repository\PaymentMethodRepository;
use Mollie\Service\PaymentMethodService;
Expand Down
10 changes: 5 additions & 5 deletions controllers/front/qrcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
* @codingStandardsIgnoreStart
*/

use _PhpScoper5ece82d7231e4\Mollie\Api\Exceptions\ApiException;
use _PhpScoper5ece82d7231e4\Mollie\Api\Resources\Payment as MolliePaymentAlias;
use _PhpScoper5ece82d7231e4\Mollie\Api\Resources\Order as MollieOrderAlias;
use _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod;
use _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentStatus;
use _PhpScoper5ea00cc67502b\Mollie\Api\Exceptions\ApiException;
use _PhpScoper5ea00cc67502b\Mollie\Api\Resources\Payment as MolliePaymentAlias;
use _PhpScoper5ea00cc67502b\Mollie\Api\Resources\Order as MollieOrderAlias;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentStatus;
use Mollie\Repository\PaymentMethodRepository;
use Mollie\Service\ApiService;
use Mollie\Service\PaymentMethodService;
Expand Down
6 changes: 3 additions & 3 deletions controllers/front/return.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
* @codingStandardsIgnoreStart
*/

use _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod;
use _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentStatus;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentStatus;
use Mollie\Repository\PaymentMethodRepository;
use Mollie\Service\OrderStatusService;
use PrestaShop\PrestaShop\Adapter\CoreException;
Expand Down Expand Up @@ -326,8 +326,8 @@ protected function processGetStatus()
}

$orderStatusId = (int)Mollie\Config\Config::getStatuses()[$orderStatus];
$orderStatusService->setOrderStatus($orderId, $orderStatusId);
$this->savePaymentStatus($transactionId, $orderStatus, $orderId);
$orderStatusService->setOrderStatus($orderId, $orderStatusId);

$successUrl = $this->context->link->getPageLink(
'order-confirmation',
Expand Down
16 changes: 8 additions & 8 deletions controllers/front/webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
* @codingStandardsIgnoreStart
*/

use _PhpScoper5ece82d7231e4\Mollie\Api\Exceptions\ApiException;
use _PhpScoper5ece82d7231e4\Mollie\Api\Resources\Payment;
use _PhpScoper5ece82d7231e4\Mollie\Api\Resources\Payment as MolliePaymentAlias;
use _PhpScoper5ece82d7231e4\Mollie\Api\Resources\Order as MollieOrderAlias;
use _PhpScoper5ece82d7231e4\Mollie\Api\Resources\ResourceFactory;
use _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod;
use _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentStatus;
use _PhpScoper5ece82d7231e4\Mollie\Api\Types\RefundStatus;
use _PhpScoper5ea00cc67502b\Mollie\Api\Exceptions\ApiException;
use _PhpScoper5ea00cc67502b\Mollie\Api\Resources\Payment;
use _PhpScoper5ea00cc67502b\Mollie\Api\Resources\Payment as MolliePaymentAlias;
use _PhpScoper5ea00cc67502b\Mollie\Api\Resources\Order as MollieOrderAlias;
use _PhpScoper5ea00cc67502b\Mollie\Api\Resources\ResourceFactory;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentStatus;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\RefundStatus;
use Mollie\Repository\PaymentMethodRepository;
use Mollie\Service\OrderStatusService;
use PrestaShop\PrestaShop\Adapter\CoreException;
Expand Down
52 changes: 29 additions & 23 deletions mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Mollie extends PaymentModule
private $moduleContainer;

const DISABLE_CACHE = true;
/** @var _PhpScoper5ece82d7231e4\Mollie\Api\MollieApiClient|null */
/** @var _PhpScoper5ea00cc67502b\Mollie\Api\MollieApiClient|null */
public $api = null;
/** @var string $currentOrderReference */
public $currentOrderReference;
Expand All @@ -86,7 +86,7 @@ public function __construct()
{
$this->name = 'mollie';
$this->tab = 'payments_gateways';
$this->version = '4.0.3';
$this->version = '4.0.4';
$this->author = 'Mollie B.V.';
$this->need_instance = 1;
$this->bootstrap = true;
Expand Down Expand Up @@ -154,26 +154,26 @@ private function compile()
{
$containerCache = $this->getLocalPath() . 'var/cache/container.php';

if (class_exists(_PhpScoper5ece82d7231e4\Symfony\Component\Config\ConfigCache::class)) {
$containerConfigCache = new _PhpScoper5ece82d7231e4\Symfony\Component\Config\ConfigCache($containerCache, self::DISABLE_CACHE);
if (class_exists(_PhpScoper5ea00cc67502b\Symfony\Component\Config\ConfigCache::class)) {
$containerConfigCache = new _PhpScoper5ea00cc67502b\Symfony\Component\Config\ConfigCache($containerCache, self::DISABLE_CACHE);
} else {
PrestaShopAutoload::getInstance()->generateIndex();
Media::clearCache();
Tools::clearSmartyCache();
Tools::clearSf2Cache();
Tools::clearXMLCache();

$containerConfigCache = new _PhpScoper5ece82d7231e4\Symfony\Component\Config\ConfigCache($containerCache, self::DISABLE_CACHE);
$containerConfigCache = new _PhpScoper5ea00cc67502b\Symfony\Component\Config\ConfigCache($containerCache, self::DISABLE_CACHE);
}

$containerClass = get_class($this) . 'Container';
if (!$containerConfigCache->isFresh()) {
$containerBuilder = new _PhpScoper5ece82d7231e4\Symfony\Component\DependencyInjection\ContainerBuilder();
$locator = new _PhpScoper5ece82d7231e4\Symfony\Component\Config\FileLocator($this->getLocalPath() . 'config');
$loader = new _PhpScoper5ece82d7231e4\Symfony\Component\DependencyInjection\Loader\YamlFileLoader($containerBuilder, $locator);
$containerBuilder = new _PhpScoper5ea00cc67502b\Symfony\Component\DependencyInjection\ContainerBuilder();
$locator = new _PhpScoper5ea00cc67502b\Symfony\Component\Config\FileLocator($this->getLocalPath() . 'config');
$loader = new _PhpScoper5ea00cc67502b\Symfony\Component\DependencyInjection\Loader\YamlFileLoader($containerBuilder, $locator);
$loader->load('config.yml');
$containerBuilder->compile();
$dumper = new _PhpScoper5ece82d7231e4\Symfony\Component\DependencyInjection\Dumper\PhpDumper($containerBuilder);
$dumper = new _PhpScoper5ea00cc67502b\Symfony\Component\DependencyInjection\Dumper\PhpDumper($containerBuilder);
$containerConfigCache->write(
$dumper->dump(['class' => $containerClass]),
$containerBuilder->getResources()
Expand Down Expand Up @@ -557,7 +557,7 @@ public function hookDisplayPayment()
$apiMethods = $paymentMethodService->getMethodsForCheckout();
$issuerList = [];
foreach ($apiMethods as $apiMethod) {
if ($apiMethod['id_payment_method'] === _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod::IDEAL) {
if ($apiMethod['id_payment_method'] === _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod::IDEAL) {
$issuerList = $issuerService->getIdealIssuers();
}
}
Expand Down Expand Up @@ -623,7 +623,7 @@ public function hookDisplayPaymentEU()
$methods = $paymentMethodService->getMethodsForCheckout();
$issuerList = [];
foreach ($methods as $apiMethod) {
if ($apiMethod['id_method'] === _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod::IDEAL) {
if ($apiMethod['id'] === _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod::IDEAL) {
$issuerList = $issuerService->getIdealIssuers();
}
}
Expand Down Expand Up @@ -679,7 +679,7 @@ public function hookPaymentOptions()
$issuerList = [];
foreach ($methodIds as $methodId) {
$methodObj = new MolPaymentMethod($methodId['id_payment_method']);
if ($methodObj->id_method === _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod::IDEAL) {
if ($methodObj->id_method === _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod::IDEAL) {
$issuerList = $issuerService->getIdealIssuers();
}
}
Expand All @@ -688,8 +688,8 @@ public function hookPaymentOptions()
$cart = $context->cart;

$context->smarty->assign([
'idealIssuers' => isset($issuerList[_PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod::IDEAL])
? $issuerList[_PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod::IDEAL]
'idealIssuers' => isset($issuerList[_PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod::IDEAL])
? $issuerList[_PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod::IDEAL]
: [],
'link' => $this->context->link,
'qrCodeEnabled' => Configuration::get(Mollie\Config\Config::MOLLIE_QRENABLED),
Expand All @@ -711,9 +711,9 @@ public function hookPaymentOptions()
$methodObj = new MolPaymentMethod($methodId['id_payment_method']);
$paymentFee = \Mollie\Utility\PaymentFeeUtility::getPaymentFee($methodObj, $cart->getOrderTotal());

$isIdealMethod = $methodObj->id_method === _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod::IDEAL;
$isIdealMethod = $methodObj->id_method === _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod::IDEAL;
$isIssuersOnClick = Configuration::get(Mollie\Config\Config::MOLLIE_ISSUERS) === Mollie\Config\Config::ISSUERS_ON_CLICK;
$isCreditCardMethod = $methodObj->id_method === _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentMethod::CREDITCARD;
$isCreditCardMethod = $methodObj->id_method === _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentMethod::CREDITCARD;

if ($isIdealMethod && $isIssuersOnClick) {
$newOption = new PrestaShop\PrestaShop\Core\Payment\PaymentOption();
Expand Down Expand Up @@ -881,7 +881,7 @@ public function hookDisplayOrderConfirmation()
/** @var \Mollie\Repository\PaymentMethodRepository $paymentMethodRepo */
$paymentMethodRepo = $this->getContainer(\Mollie\Repository\PaymentMethodRepository::class);
$payment = $paymentMethodRepo->getPaymentBy('cart_id', (int)Tools::getValue('id_cart'));
if ($payment && $payment['bank_status'] == _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentStatus::STATUS_PAID) {
if ($payment && $payment['bank_status'] == _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentStatus::STATUS_PAID) {
$this->context->smarty->assign('okMessage', $this->l('Thank you. Your payment has been received.'));

return $this->display(__FILE__, 'ok.tpl');
Expand All @@ -906,7 +906,7 @@ public function displayAjaxMollieMethodConfig()
try {

$methodsForConfig = $apiService->getMethodsForConfig($this->api, $this->getPathUri());
} catch (_PhpScoper5ece82d7231e4\Mollie\Api\Exceptions\ApiException $e) {
} catch (_PhpScoper5ea00cc67502b\Mollie\Api\Exceptions\ApiException $e) {
return [
'success' => false,
'methods' => null,
Expand Down Expand Up @@ -1079,8 +1079,8 @@ public function hookActionOrderStatusUpdate($params = [])
return;
}

$length = Tools::strlen(_PhpScoper5ece82d7231e4\Mollie\Api\Endpoints\OrderEndpoint::RESOURCE_ID_PREFIX);
if (Tools::substr($dbPayment['transaction_id'], 0, $length) !== _PhpScoper5ece82d7231e4\Mollie\Api\Endpoints\OrderEndpoint::RESOURCE_ID_PREFIX
$length = Tools::strlen(_PhpScoper5ea00cc67502b\Mollie\Api\Endpoints\OrderEndpoint::RESOURCE_ID_PREFIX);
if (Tools::substr($dbPayment['transaction_id'], 0, $length) !== _PhpScoper5ea00cc67502b\Mollie\Api\Endpoints\OrderEndpoint::RESOURCE_ID_PREFIX
) {
// No need to check regular payments
return;
Expand All @@ -1097,7 +1097,7 @@ public function hookActionOrderStatusUpdate($params = [])
}

$apiOrder->shipAll($shipmentInfo);
} catch (\_PhpScoper5ece82d7231e4\Mollie\Api\Exceptions\ApiException $e) {
} catch (\_PhpScoper5ea00cc67502b\Mollie\Api\Exceptions\ApiException $e) {
PrestaShopLogger::addLog("Mollie module error: {$e->getMessage()}");
return;
} catch (Exception $e) {
Expand All @@ -1108,6 +1108,12 @@ public function hookActionOrderStatusUpdate($params = [])

public function hookActionEmailSendBefore($params)
{
if($params['template'] === 'order_conf') {
if ( Order::getByCartId($params['cart']->id)->module === $this->name) {
return false;
}
}

if ($params['template'] === 'order_conf' ||
$params['template'] === 'account' ||
$params['template'] === 'backoffice_order' ||
Expand Down Expand Up @@ -1172,9 +1178,9 @@ private function setApiKey()
$apiService = $this->getContainer(\Mollie\Service\ApiService::class);
try {
$this->api = $apiService->setApiKey(Configuration::get(Mollie\Config\Config::MOLLIE_API_KEY), $this->version);
} catch (_PhpScoper5ece82d7231e4\Mollie\Api\Exceptions\IncompatiblePlatform $e) {
} catch (_PhpScoper5ea00cc67502b\Mollie\Api\Exceptions\IncompatiblePlatform $e) {
PrestaShopLogger::addLog(__METHOD__ . ' - System incompatible: ' . $e->getMessage(), Mollie\Config\Config::CRASH);
} catch (_PhpScoper5ece82d7231e4\Mollie\Api\Exceptions\ApiException $e) {
} catch (_PhpScoper5ea00cc67502b\Mollie\Api\Exceptions\ApiException $e) {
$this->warning = $this->l('Payment error:') . $e->getMessage();
PrestaShopLogger::addLog(__METHOD__ . ' said: ' . $this->warning, Mollie\Config\Config::CRASH);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Builder/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

NameSpace Mollie\Builder;

use _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentStatus;
use _PhpScoper5ece82d7231e4\Mollie\Api\Types\RefundStatus;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentStatus;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\RefundStatus;
use Configuration;
use HelperForm;
use Mollie;
Expand Down
5 changes: 3 additions & 2 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

namespace Mollie\Config;

use _PhpScoper5ece82d7231e4\Mollie\Api\Types\PaymentStatus;
use _PhpScoper5ece82d7231e4\Mollie\Api\Types\RefundStatus;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\PaymentStatus;
use _PhpScoper5ea00cc67502b\Mollie\Api\Types\RefundStatus;
use Configuration;

class Config
Expand Down Expand Up @@ -157,6 +157,7 @@ class Config
const MOLLIE_MAIL_WHEN_EXPIRED = 'MOLLIE_MAIL_WHEN_EXPIRED';
const MOLLIE_MAIL_WHEN_REFUNDED = 'MOLLIE_MAIL_WHEN_REFUNDED';
const PARTIAL_REFUND_CODE = 'partial_refund';
const MOLLIE_STATUS_INITIATED = 'MOLLIE_STATUS_INITIATED';

const MOLLIE_CARRIER_URL_SOURCE = 'MOLLIE_CARRIER_URL_SOURCE_';
const MOLLIE_CARRIER_CUSTOM_URL = 'MOLLIE_CARRIER_CUSTOM_URL_';
Expand Down
68 changes: 39 additions & 29 deletions src/Install/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,9 @@ public function install()
$context = Context::getContext();

try {
$this->partialRefundOrderState($context->language->id);
$this->createMollieStatuses($context->language->id);
} catch (Exception $e) {
$this->errors[] = $this->module->l('Unable to install Mollie partially refunded order state');
return false;
}
try {
$this->awaitingMollieOrderState($context->language->id);
} catch (Exception $e) {
$this->errors[] = $this->module->l('Unable to install Mollie awaiting state');
$this->errors[] = $this->module->l('Unable to install Mollie statuses');
return false;
}

Expand Down Expand Up @@ -119,7 +113,8 @@ public static function getHooks()
'actionFrontControllerSetMedia',
'actionEmailSendBefore',
'actionOrderStatusUpdate',
'displayPDFInvoice'
'displayPDFInvoice',
'actionEmailSendBefore'
];
}

Expand All @@ -144,31 +139,46 @@ private function partialRefundOrderState($languageId)
break;
}
}
if (!$stateExists) {
$orderState = new OrderState();
$orderState->send_email = false;
$orderState->color = '#6F8C9F';
$orderState->hidden = false;
$orderState->delivery = false;
$orderState->logable = false;
$orderState->invoice = false;
$orderState->module_name = $this->module->name;
$orderState->name = [];
$languages = Language::getLanguages(false);
foreach ($languages as $language) {
$orderState->name[$language['id_lang']] = $this->module->lang('Mollie partially refunded');
}
if ($orderState->add()) {
$source = _PS_MODULE_DIR_ . 'mollie/views/img/logo_small.png';
$destination = _PS_ROOT_DIR_ . '/img/os/' . (int)$orderState->id . '.gif';
@copy($source, $destination);
}
Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PARTIAL_REFUND, (int)$orderState->id);
if ($stateExists) {
return true;
}
$orderState = new OrderState();
$orderState->send_email = false;
$orderState->color = '#6F8C9F';
$orderState->hidden = false;
$orderState->delivery = false;
$orderState->logable = false;
$orderState->invoice = false;
$orderState->module_name = $this->module->name;
$orderState->name = [];
$languages = Language::getLanguages(false);
foreach ($languages as $language) {
$orderState->name[$language['id_lang']] = $this->module->lang('Mollie partially refunded');
}
if ($orderState->add()) {
$source = _PS_MODULE_DIR_ . 'mollie/views/img/logo_small.png';
$destination = _PS_ROOT_DIR_ . '/img/os/' . (int)$orderState->id . '.gif';
@copy($source, $destination);
}
Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PARTIAL_REFUND, (int)$orderState->id);


return true;
}

public function createMollieStatuses($languageId)
{
if (!$this->partialRefundOrderState($languageId)) {
return false;
}
if (!$this->awaitingMollieOrderState($languageId)) {
return false;
}

return true;

}

/**
* @param $languageId
* @return bool
Expand Down
Loading

0 comments on commit 5dc41db

Please sign in to comment.