Skip to content

Commit

Permalink
Release 1.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Bossert committed Nov 4, 2021
1 parent d4ab7db commit 3176b8e
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 179 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ This repository contains the PrestaShop wallee payment module that enables the s

## Documentation

* [English](https://plugin-documentation.wallee.com/wallee-payment/prestashop-1.6/1.2.9/docs/en/documentation.html)
* [English](https://plugin-documentation.wallee.com/wallee-payment/prestashop-1.6/1.2.10/docs/en/documentation.html)

## Support

Support queries can be issued on the [wallee support site](https://app-wallee.com/space/select?target=/support).

## License

Please see the [license file](https://github.com/wallee-payment/prestashop-1.6/blob/1.2.9/LICENSE) for more information.
Please see the [license file](https://github.com/wallee-payment/prestashop-1.6/blob/1.2.10/LICENSE) for more information.

## Other PrestaShop Versions

Expand Down
4 changes: 2 additions & 2 deletions docs/en/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/wallee-payment/prestashop-1.6/releases/tag/1.2.9/">
<a href="https://github.com/wallee-payment/prestashop-1.6/releases/tag/1.2.10/">
Source
</a>
</li>
Expand Down Expand Up @@ -54,7 +54,7 @@ <h1>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://github.com/wallee-payment/prestashop-1.6/releases/tag/1.2.9/">Download</a> the module.</p>
<p><a href="https://github.com/wallee-payment/prestashop-1.6/releases/tag/1.2.10/">Download</a> the module.</p>
</li>
<li>
<p>Login to the backend of your PrestsShop store.</p>
Expand Down
5 changes: 3 additions & 2 deletions inc/Backend/Defaultstrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ public function validateAndParseData(Order $order, array $postData)
);
}

public function simplifiedRefund(array $postData) {
public function simplifiedRefund(array $postData)
{
$cancelledItems = array();
// count of items
$quantity = 0;
// cost of items
$amount = 0;
foreach ($postData["cancel_product"] as $key=>$value) {
foreach ($postData["cancel_product"] as $key => $value) {
if (strpos($key, 'quantity') !== false) {
$quantity += $value;
}
Expand Down
122 changes: 39 additions & 83 deletions inc/Basemodule.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,35 +138,35 @@ public static function installConfigurationValues()
{
return Configuration::updateGlobalValue(self::CK_MAIL, true) &&
Configuration::updateGlobalValue(self::CK_INVOICE, true) &&
Configuration::updateGlobalValue(self::CK_PACKING_SLIP, true) &&
Configuration::updateGlobalValue(self::CK_LINE_ITEM_CONSISTENCY, true);
Configuration::updateGlobalValue(self::CK_PACKING_SLIP, true) &&
Configuration::updateGlobalValue(self::CK_LINE_ITEM_CONSISTENCY, true);
}

public static function uninstallConfigurationValues()
{
return
Configuration::deleteByName(self::CK_USER_ID) &&
Configuration::deleteByName(self::CK_APP_KEY) &&
Configuration::deleteByName(self::CK_USER_ID) &&
Configuration::deleteByName(self::CK_APP_KEY) &&
Configuration::deleteByName(self::CK_SPACE_ID) &&
Configuration::deleteByName(self::CK_SPACE_VIEW_ID) &&
Configuration::deleteByName(self::CK_SPACE_VIEW_ID) &&
Configuration::deleteByName(self::CK_MAIL) &&
Configuration::deleteByName(self::CK_INVOICE) &&
Configuration::deleteByName(self::CK_INVOICE) &&
Configuration::deleteByName(self::CK_PACKING_SLIP) &&
Configuration::deleteByName(self::CK_LINE_ITEM_CONSISTENCY) &&
Configuration::deleteByName(self::CK_FEE_ITEM) &&
Configuration::deleteByName(self::CK_LINE_ITEM_CONSISTENCY) &&
Configuration::deleteByName(self::CK_FEE_ITEM) &&
Configuration::deleteByName(self::CK_SURCHARGE_ITEM) &&
Configuration::deleteByName(self::CK_SURCHARGE_TAX) &&
Configuration::deleteByName(self::CK_SURCHARGE_TAX) &&
Configuration::deleteByName(self::CK_SURCHARGE_AMOUNT) &&
Configuration::deleteByName(self::CK_SURCHARGE_TOTAL) &&
Configuration::deleteByName(self::CK_SURCHARGE_BASE) &&
Configuration::deleteByName(self::CK_SURCHARGE_BASE) &&
Configuration::deleteByName(WalleeServiceManualtask::CONFIG_KEY) &&
Configuration::deleteByName(self::CK_STATUS_FAILED) &&
Configuration::deleteByName(self::CK_STATUS_AUTHORIZED) &&
Configuration::deleteByName(self::CK_STATUS_VOIDED) &&
Configuration::deleteByName(self::CK_STATUS_COMPLETED) &&
Configuration::deleteByName(self::CK_STATUS_MANUAL) &&
Configuration::deleteByName(self::CK_STATUS_COMPLETED) &&
Configuration::deleteByName(self::CK_STATUS_MANUAL) &&
Configuration::deleteByName(self::CK_STATUS_DECLINED) &&
Configuration::deleteByName(self::CK_STATUS_FULFILL);
Configuration::deleteByName(self::CK_STATUS_FULFILL);
}


Expand Down Expand Up @@ -361,7 +361,7 @@ public static function handleSaveFeeItem(Wallee $module)
if (Tools::isSubmit('submit' . $module->name . '_fee_item')) {
if (! $module->getContext()->shop->isFeatureActive() || $module->getContext()->shop->getContext() == Shop::CONTEXT_SHOP) {
Configuration::updateValue(self::CK_LINE_ITEM_CONSISTENCY, Tools::getValue(self::CK_LINE_ITEM_CONSISTENCY));
Configuration::updateValue(self::CK_FEE_ITEM, Tools::getValue(self::CK_FEE_ITEM));
Configuration::updateValue(self::CK_FEE_ITEM, Tools::getValue(self::CK_FEE_ITEM));
Configuration::updateValue(self::CK_SURCHARGE_ITEM, Tools::getValue(self::CK_SURCHARGE_ITEM));
Configuration::updateValue(self::CK_SURCHARGE_TAX, Tools::getValue(self::CK_SURCHARGE_TAX));
Configuration::updateValue(self::CK_SURCHARGE_AMOUNT, Tools::getValue(self::CK_SURCHARGE_AMOUNT));
Expand Down Expand Up @@ -740,29 +740,29 @@ public static function getFeeForm(Wallee $module)
),
'lang' => false
),
array(
'type' => 'switch',
'label' => $module->l('Line item consistency', 'basemodule'),
'name' => self::CK_LINE_ITEM_CONSISTENCY,
'desc' => $module->l(
'If this option is enabled line item totals will always match the order total.',
'basemodule'
),
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $module->l('Allow', 'basemodule')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $module->l('Disallow', 'basemodule')
)
),
'lang' => false
),
array(
'type' => 'switch',
'label' => $module->l('Line item consistency', 'basemodule'),
'name' => self::CK_LINE_ITEM_CONSISTENCY,
'desc' => $module->l(
'If this option is enabled line item totals will always match the order total.',
'basemodule'
),
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $module->l('Allow', 'basemodule')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $module->l('Disallow', 'basemodule')
)
),
'lang' => false
),
array(
'type' => 'text',
'label' => $module->l('Surcharge Amount', 'basemodule'),
Expand Down Expand Up @@ -855,7 +855,7 @@ public static function getFeeItemConfigValues(Wallee $module)
{
$values = array();
if (! $module->getContext()->shop->isFeatureActive() || $module->getContext()->shop->getContext() == Shop::CONTEXT_SHOP) {
$values[self::CK_FEE_ITEM] = (int) Configuration::get(self::CK_FEE_ITEM);
$values[self::CK_FEE_ITEM] = (int) Configuration::get(self::CK_FEE_ITEM);
$values[self::CK_LINE_ITEM_CONSISTENCY] = (int) Configuration::get(self::CK_LINE_ITEM_CONSISTENCY);
$values[self::CK_SURCHARGE_ITEM] = (int) Configuration::get(self::CK_SURCHARGE_ITEM);
$values[self::CK_SURCHARGE_TAX] = (int) Configuration::get(self::CK_SURCHARGE_TAX);
Expand Down Expand Up @@ -1481,51 +1481,6 @@ public static function validateOrder(
}
}

public static function hookActionProductCancel(Wallee $module, $params)
{
// check version too here to only run on > 1.7.7 for now
// as there is some overlap in functionality with some previous versions 1.7+
if ($params['action'] === CancellationActionType::PARTIAL_REFUND && version_compare(_PS_VERSION_, '1.7.7', '>=')) {

$idOrder = Tools::getValue('id_order');
$refundParameters = Tools::getAllValues();

$order = $params['order'];

if (! Validate::isLoadedObject($order) || $order->module != $module->name) {
return;
}

$strategy = WalleeBackendStrategyprovider::getStrategy();
if ($strategy->isVoucherOnlyWallee($order, $refundParameters)) {
return;
}

// need to manually set this here as it's expected downstream
$refundParameters['partialRefund'] = true;

$backendController = Context::getContext()->controller;
$editAccess = 0;

$access = Profile::getProfileAccess(
Context::getContext()->employee->id_profile,
(int) Tab::getIdFromClassName('AdminOrders')
);
$editAccess = isset($access['edit']) && $access['edit'] == 1;

if ($editAccess) {
try {
$parsedData = $strategy->simplifiedRefund($refundParameters);
WalleeServiceRefund::instance()->executeRefund($order, $parsedData);
} catch (Exception $e) {
$backendController->errors[] = WalleeHelper::cleanExceptionMessage($e->getMessage());
}
} else {
$backendController->errors[] = Tools::displayError('You do not have permission to delete this.');
}
}
}

public static function hookDisplayOrderDetail(Wallee $module, $params)
{
$order = $params['order'];
Expand Down Expand Up @@ -2152,6 +2107,7 @@ public static function hookDisplayAdminOrder(Wallee $module, $params)
$templateVars['refundPending'] = true;
}
$module->getContext()->smarty->assign($templateVars);
WalleeVersionadapter::getAdminOrderTemplate();
if (version_compare(_PS_VERSION_, '1.7.7', '>=')) {
return $module->display(dirname(dirname(__FILE__)), 'views/templates/admin/hook/admin_order177.tpl');
} else {
Expand Down
66 changes: 33 additions & 33 deletions inc/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,36 +167,36 @@ public static function getTotalAmountIncludingTax(array $lineItems)
/**
* Cleans the given line items by ensuring uniqueness and introducing adjustment line items if necessary.
*
* @param \Wallee\Sdk\Model\LineItemCreate[] $lineItems
* @param float $expectedSum
* @param string $currencyCode
*
* @return \Wallee\Sdk\Model\LineItemCreate[]
* @throws \WalleeExceptionInvalidtransactionamount
*/
* @param \Wallee\Sdk\Model\LineItemCreate[] $lineItems
* @param float $expectedSum
* @param string $currencyCode
*
* @return \Wallee\Sdk\Model\LineItemCreate[]
* @throws \WalleeExceptionInvalidtransactionamount
*/
public static function cleanupLineItems(array &$lineItems, $expectedSum, $currencyCode)
{
$effectiveSum = self::roundAmount(self::getTotalAmountIncludingTax($lineItems), $currencyCode);
$roundedExpected = self::roundAmount($expectedSum, $currencyCode);
$diff = $roundedExpected - $effectiveSum;
if ($diff != 0) {
if((int) Configuration::getGlobalValue(WalleeBasemodule::CK_LINE_ITEM_CONSISTENCY)){
throw new WalleeExceptionInvalidtransactionamount($effectiveSum, $roundedExpected);
}else{
$diffAmount = self::roundAmount($diff, $currencyCode);
$lineItem = (new \Wallee\Sdk\Model\LineItemCreate())
->setName(self::getModuleInstance()->l('Adjustment LineItem', 'helper'))
->setUniqueId('Adjustment-Line-Item')
->setSku('Adjustment-Line-Item')
->setQuantity(1);
/** @noinspection PhpParamsInspection */
$lineItem->setAmountIncludingTax($diffAmount)->setType(($diff > 0) ? \Wallee\Sdk\Model\LineItemType::FEE : \Wallee\Sdk\Model\LineItemType::DISCOUNT);

if (!$lineItem->valid()) {
throw new \Exception('Adjustment LineItem payload invalid:' . json_encode($lineItem->listInvalidProperties()));
}
$lineItems[] = $lineItem;
}
if ((int) Configuration::getGlobalValue(WalleeBasemodule::CK_LINE_ITEM_CONSISTENCY)) {
throw new WalleeExceptionInvalidtransactionamount($effectiveSum, $roundedExpected);
} else {
$diffAmount = self::roundAmount($diff, $currencyCode);
$lineItem = (new \Wallee\Sdk\Model\LineItemCreate())
->setName(self::getModuleInstance()->l('Adjustment LineItem', 'helper'))
->setUniqueId('Adjustment-Line-Item')
->setSku('Adjustment-Line-Item')
->setQuantity(1);
/** @noinspection PhpParamsInspection */
$lineItem->setAmountIncludingTax($diffAmount)->setType(($diff > 0) ? \Wallee\Sdk\Model\LineItemType::FEE : \Wallee\Sdk\Model\LineItemType::DISCOUNT);

if (!$lineItem->valid()) {
throw new \Exception('Adjustment LineItem payload invalid:' . json_encode($lineItem->listInvalidProperties()));
}
$lineItems[] = $lineItem;
}
}

return self::ensureUniqueIds($lineItems);
Expand All @@ -206,10 +206,10 @@ public static function cleanupLineItems(array &$lineItems, $expectedSum, $curren
* Ensures uniqueness of the line items.
*
* @param \Wallee\Sdk\Model\LineItemCreate[] $lineItems
*
*
* @return \Wallee\Sdk\Model\LineItemCreate[]
* @throws \Exception
*/
* @throws \Exception
*/
public static function ensureUniqueIds(array $lineItems)
{
$uniqueIds = array();
Expand Down Expand Up @@ -470,9 +470,9 @@ public static function computeOrderSecret(Order $order)
* Sorts an array of WalleeModelMethodconfiguration by their sort order
*
* @param WalleeModelMethodconfiguration[] $configurations
*
* @return array
*/
*
* @return array
*/
public static function sortMethodConfiguration(array $configurations)
{
usort(
Expand Down Expand Up @@ -650,14 +650,14 @@ public static function generateUUID()
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}

public static function getMaxExecutionTime() {
public static function getMaxExecutionTime()
{
$maxExecutionTime = ini_get('max_execution_time');

// Returns the default value, in case the ini_get fails.
if ($maxExecutionTime === null || empty($maxExecutionTime) || $maxExecutionTime < 0) {
return 30;
}
else {
} else {
return intval($maxExecutionTime);
}
}
Expand Down
Loading

0 comments on commit 3176b8e

Please sign in to comment.