Skip to content

Commit

Permalink
Release 1.1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
vttn committed Sep 18, 2020
1 parent 59969e8 commit e7062cc
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 48 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -13,15 +13,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.1.18/docs/en/documentation.html)
* [English](https://plugin-documentation.wallee.com/wallee-payment/prestashop-1.6/1.1.19/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.1.18/LICENSE) for more information.
Please see the [license file](https://github.com/wallee-payment/prestashop-1.6/blob/1.1.19/LICENSE) for more information.

## Other PrestaShop Versions

Expand Down
1 change: 1 addition & 0 deletions docs/en/assets/base.css
Expand Up @@ -545,6 +545,7 @@ ol.glossary li::before {
}

.listingblock pre code {
display: block;
padding: 20px;
}

Expand Down
2 changes: 2 additions & 0 deletions docs/en/assets/base.js
@@ -1,5 +1,7 @@
(function($){

hljs.initHighlightingOnLoad();

$(document).ready(function(){
$('.col-right-wrapper').stick_in_parent({
parent: '.layout-content'
Expand Down
6 changes: 6 additions & 0 deletions docs/en/assets/highlight.js

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions docs/en/assets/monokai-sublime.css
@@ -0,0 +1,83 @@
/*
Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-license.org/
*/

.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #23241f;
}

.hljs,
.hljs-tag,
.hljs-subst {
color: #f8f8f2;
}

.hljs-strong,
.hljs-emphasis {
color: #a8a8a2;
}

.hljs-bullet,
.hljs-quote,
.hljs-number,
.hljs-regexp,
.hljs-literal,
.hljs-link {
color: #ae81ff;
}

.hljs-code,
.hljs-title,
.hljs-section,
.hljs-selector-class {
color: #a6e22e;
}

.hljs-strong {
font-weight: bold;
}

.hljs-emphasis {
font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-name,
.hljs-attr {
color: #f92672;
}

.hljs-symbol,
.hljs-attribute {
color: #66d9ef;
}

.hljs-params,
.hljs-class .hljs-title {
color: #f8f8f2;
}

.hljs-string,
.hljs-type,
.hljs-built_in,
.hljs-builtin-name,
.hljs-selector-id,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-addition,
.hljs-variable,
.hljs-template-variable {
color: #e6db74;
}

.hljs-comment,
.hljs-deletion,
.hljs-meta {
color: #75715e;
}
6 changes: 4 additions & 2 deletions docs/en/documentation.html
Expand Up @@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="keywords" value="wallee, PrestaShop 1.6, PrestaShop Module, Payment, Payment Integration, Documentation"><meta name="description" value="The documentation for the PrestaShop 1.6 module that enables processing payments with wallee."> <link rel="canonical" href="https://plugin-documentation.wallee.com/wallee-payment/prestashop-1.6/master/docs/en/documentation.html" />
<title>wallee PrestaShop</title>
<link href="assets/monokai-sublime.css" rel="stylesheet" />
<link href="assets/base.css" rel="stylesheet" />
</head>
<body class="documentation">
Expand All @@ -21,7 +22,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/wallee-payment/prestashop-1.6/releases/tag/1.1.18/">
<a href="https://github.com/wallee-payment/prestashop-1.6/releases/tag/1.1.19/">
Source
</a>
</li>
Expand Down Expand Up @@ -50,7 +51,7 @@ <h1>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://github.com/wallee-payment/prestashop-1.6/releases/tag/1.1.18/">Download</a> the module.</p>
<p><a href="https://github.com/wallee-payment/prestashop-1.6/releases/tag/1.1.19/">Download</a> the module.</p>
</li>
<li>
<p>Login to the backend of your PrestsShop store.</p>
Expand Down Expand Up @@ -535,6 +536,7 @@ <h1>
<script type="text/javascript" src="assets/jquery.js"></script>
<script type="text/javascript" src="assets/scrollspy.js"></script>
<script type="text/javascript" src="assets/sticky-kit.js"></script>
<script type="text/javascript" src="assets/highlight.js"></script>
<script type="text/javascript" src="assets/base.js"></script>
</body>
</html>
73 changes: 54 additions & 19 deletions inc/Basemodule.php
Expand Up @@ -31,6 +31,8 @@ class WalleeBasemodule

const CK_PACKING_SLIP = 'WLE_PACKING_SLIP_DOWNLOAD';

const CK_LINE_ITEM_CONSISTENCY = 'WLE_LINE_ITEM_CONSISTENCY';

const CK_FEE_ITEM = 'WLE_FEE_ITEM';

const CK_SURCHARGE_ITEM = 'WLE_SURCHARGE_ITEM';
Expand Down Expand Up @@ -132,29 +134,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_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_SPACE_ID) && Configuration::deleteByName(self::CK_SPACE_VIEW_ID) &&
Configuration::deleteByName(self::CK_MAIL) && Configuration::deleteByName(self::CK_INVOICE) &&
Configuration::deleteByName(self::CK_PACKING_SLIP) && Configuration::deleteByName(self::CK_FEE_ITEM) &&
Configuration::deleteByName(self::CK_SURCHARGE_ITEM) && Configuration::deleteByName(self::CK_SURCHARGE_TAX) &&
return
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_MAIL) &&
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_SURCHARGE_ITEM) &&
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_TOTAL) &&
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_DECLINED) && Configuration::deleteByName(
self::CK_STATUS_FULFILL
);
Configuration::deleteByName(self::CK_STATUS_VOIDED) &&
Configuration::deleteByName(self::CK_STATUS_COMPLETED) &&
Configuration::deleteByName(self::CK_STATUS_MANUAL) &&
Configuration::deleteByName(self::CK_STATUS_DECLINED) &&
Configuration::deleteByName(self::CK_STATUS_FULFILL);
}


Expand Down Expand Up @@ -273,6 +281,7 @@ public static function getConfigurationKeys()
self::CK_MAIL,
self::CK_INVOICE,
self::CK_PACKING_SLIP,
self::CK_LINE_ITEM_CONSISTENCY,
self::CK_FEE_ITEM,
self::CK_SURCHARGE_ITEM,
self::CK_SURCHARGE_TAX,
Expand Down Expand Up @@ -347,7 +356,8 @@ public static function handleSaveFeeItem(Wallee $module)
$output = "";
if (Tools::isSubmit('submit' . $module->name . '_fee_item')) {
if (! $module->getContext()->shop->isFeatureActive() || $module->getContext()->shop->getContext() == Shop::CONTEXT_SHOP) {
Configuration::updateValue(self::CK_FEE_ITEM, Tools::getValue(self::CK_FEE_ITEM));
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_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 @@ -726,6 +736,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' => 'text',
'label' => $module->l('Surcharge Amount', 'basemodule'),
Expand Down Expand Up @@ -818,7 +851,8 @@ 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);
$values[self::CK_SURCHARGE_AMOUNT] = (float) Configuration::get(self::CK_SURCHARGE_AMOUNT);
Expand Down Expand Up @@ -1136,7 +1170,7 @@ public static function hookWalleeSettingsChanged(Wallee $module, $params)
$errors[] = $module->l('Update of Manual Tasks failed.', 'basemodule');
}
self::deleteCachedEntries();
if (empty(! $errors)) {
if (! empty($errors)) {
return $module->l(
'Please check your credentials and grant the application user the necessary rights (Account Admin) for your space.',
'basemodule'
Expand Down Expand Up @@ -1187,7 +1221,8 @@ public static function getParametersFromMethodConfiguration(
}
$parameters['name'] = $name;
$parameters['image'] = '';
if (! empty($methodConfiguration->getImage()) && $methodConfiguration->isShowImage()) {
$img = $methodConfiguration->getImage();
if (! empty($img) && $methodConfiguration->isShowImage()) {
$parameters['image'] = WalleeHelper::getResourceUrl(
$methodConfiguration->getImageBase(),
$methodConfiguration->getImage(),
Expand Down
43 changes: 32 additions & 11 deletions inc/Helper.php
Expand Up @@ -167,18 +167,35 @@ 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 $currency
* @return \Wallee\Sdk\Model\LineItemCreate[]
*/
public static function cleanupLineItems(array $lineItems, $expectedSum, $currencyCode)
* @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);
$roundedExcpected = self::roundAmount($expectedSum, $currencyCode);
$diff = $roundedExcpected - $effectiveSum;
$roundedExpected = self::roundAmount($expectedSum, $currencyCode);
$diff = $roundedExpected - $effectiveSum;
if ($diff != 0) {
throw new WalleeExceptionInvalidtransactionamount($effectiveSum, $roundedExcpected);
if((int) Configuration::getGlobalValue(WalleeBasemodule::CK_LINE_ITEM_CONSISTENCY)){
throw new WalleeExceptionInvalidtransactionamount($effectiveSum, $roundedExpected);
}else{
$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($diff)->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 @@ -188,8 +205,10 @@ public static function cleanupLineItems(array $lineItems, $expectedSum, $currenc
* Ensures uniqueness of the line items.
*
* @param \Wallee\Sdk\Model\LineItemCreate[] $lineItems
*
* @return \Wallee\Sdk\Model\LineItemCreate[]
*/
* @throws \Exception
*/
public static function ensureUniqueIds(array $lineItems)
{
$uniqueIds = array();
Expand Down Expand Up @@ -450,7 +469,9 @@ public static function computeOrderSecret(Order $order)
* Sorts an array of WalleeModelMethodconfiguration by their sort order
*
* @param WalleeModelMethodconfiguration[] $configurations
*/
*
* @return array
*/
public static function sortMethodConfiguration(array $configurations)
{
usort(
Expand Down

0 comments on commit e7062cc

Please sign in to comment.