-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Module no longer valid if order amount is 0
- Loading branch information
Franck Allimant
committed
Oct 2, 2023
1 parent
a5db0cc
commit c6ee3a1
Showing
2 changed files
with
40 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
<descriptive locale="en_US"> | ||
<title>Wire transfer payment</title> | ||
</descriptive> | ||
<version>2.1.2</version> | ||
<version>2.1.3</version> | ||
<author> | ||
<name>Thelia</name> | ||
<email>[email protected]</email> | ||
|
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 |
---|---|---|
@@ -1,25 +1,30 @@ | ||
<?php | ||
/*************************************************************************************/ | ||
/* */ | ||
/* Thelia */ | ||
/* */ | ||
/* Copyright (c) OpenStudio */ | ||
/* email : [email protected] */ | ||
/* web : http://www.thelia.net */ | ||
/* */ | ||
/* This program is free software; you can redistribute it and/or modify */ | ||
/* it under the terms of the GNU General Public License as published by */ | ||
/* the Free Software Foundation; either version 3 of the License */ | ||
/* */ | ||
/* This program is distributed in the hope that it will be useful, */ | ||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | ||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | ||
/* GNU General Public License for more details. */ | ||
/* */ | ||
/* You should have received a copy of the GNU General Public License */ | ||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
/* */ | ||
/*************************************************************************************/ | ||
|
||
/* | ||
* This file is part of the Thelia package. | ||
* http://www.thelia.net | ||
* | ||
* (c) OpenStudio <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/* Copyright (c) OpenStudio */ | ||
/* email : [email protected] */ | ||
/* web : http://www.thelia.net */ | ||
|
||
/* This program is free software; you can redistribute it and/or modify */ | ||
/* it under the terms of the GNU General Public License as published by */ | ||
/* the Free Software Foundation; either version 3 of the License */ | ||
|
||
/* This program is distributed in the hope that it will be useful, */ | ||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | ||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | ||
/* GNU General Public License for more details. */ | ||
|
||
/* You should have received a copy of the GNU General Public License */ | ||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
|
||
namespace WireTransfer; | ||
|
||
|
@@ -33,58 +38,53 @@ | |
use Thelia\Module\AbstractPaymentModule; | ||
|
||
/** | ||
* Class WireTransfer | ||
* @package WireTransfer | ||
* author Thelia <[email protected]> | ||
* Class WireTransfer. | ||
*/ | ||
class WireTransfer extends AbstractPaymentModule | ||
{ | ||
const MESSAGE_DOMAIN = 'wiretransfer'; | ||
public const MESSAGE_DOMAIN = 'wiretransfer'; | ||
|
||
/** | ||
* @param Order $order | ||
*/ | ||
public function pay(Order $order) | ||
public function pay(Order $order): void | ||
{ | ||
// Nothing special to do. | ||
} | ||
|
||
/** | ||
* @return boolean true if all parameters have been entered. | ||
* @return bool true if all parameters have been entered | ||
*/ | ||
public function isValidPayment(): bool | ||
{ | ||
// Check that all parameters have been entered. | ||
$valid = | ||
$this->getConfigValue('name', '') != '' | ||
self::getConfigValue('name', '') !== '' | ||
&& | ||
$this->getConfigValue('bic', '') != '' | ||
self::getConfigValue('bic', '') !== '' | ||
&& | ||
$this->getConfigValue('iban', '') != '' | ||
self::getConfigValue('iban', '') !== '' | ||
; | ||
|
||
if (! $valid) { | ||
if (!$valid) { | ||
Tlog::getInstance()->addError( | ||
Translator::getInstance()->trans( | ||
"Bank information parameters have not been defined.", [], self::MESSAGE_DOMAIN | ||
'Bank information parameters have not been defined.', [], self::MESSAGE_DOMAIN | ||
) | ||
); | ||
} | ||
|
||
return $valid; | ||
return $valid && $this->getCurrentOrderTotalAmount() > 0; | ||
} | ||
|
||
public function install(ConnectionInterface $con = null): void | ||
{ | ||
$database = new Database($con->getWrappedConnection()); | ||
|
||
// Insert email message | ||
$database->insertSql(null, array(__DIR__ . "/Config/setup.sql")); | ||
$database->insertSql(null, [__DIR__.'/Config/setup.sql']); | ||
|
||
/* insert the images from image folder if not already done */ | ||
$moduleModel = $this->getModuleModel(); | ||
|
||
if (! $moduleModel->isModuleImageDeployed($con)) { | ||
if (!$moduleModel->isModuleImageDeployed($con)) { | ||
$this->deployImageFolder($moduleModel, sprintf('%s/images', __DIR__), $con); | ||
} | ||
} | ||
|
@@ -101,9 +101,7 @@ public function destroy(ConnectionInterface $con = null, $deleteModuleData = fal | |
|
||
/** | ||
* if you want, you can manage stock in your module instead of order process. | ||
* Return false to decrease the stock when order status switch to pay | ||
* | ||
* @return bool | ||
* Return false to decrease the stock when order status switch to pay. | ||
*/ | ||
public function manageStockOnCreation(): bool | ||
{ | ||
|