Skip to content

Commit

Permalink
Release 1.0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
edgaraswallee committed Jan 8, 2024
1 parent 240085d commit 9881f0d
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ account dashboard.

## Documentation

[Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/jtl-5/1.0.14/docs/en/documentation.html)
[Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/jtl-5/1.0.15/docs/en/documentation.html)

## License

Expand Down
20 changes: 17 additions & 3 deletions Services/PostFinanceCheckoutTransactionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,13 @@ public function getLineItems(array $products): array
case \C_WARENKORBPOS_TYP_VERPACKUNG:
case \C_WARENKORBPOS_TYP_GRATISGESCHENK:
default:
$lineItems[] = $this->createLineItemProductItem($product);
$isDiscount = false;
if (\in_array($product->nPosTyp, [
\C_WARENKORBPOS_TYP_KUPON
], true)) {
$isDiscount = true;
}
$lineItems[] = $this->createLineItemProductItem($product, $isDiscount);
}
}

Expand Down Expand Up @@ -442,7 +448,7 @@ private function downloadDocument($document)
* @param CartItem $productData
* @return LineItemCreate
*/
private function createLineItemProductItem(CartItem $productData): LineItemCreate
private function createLineItemProductItem(CartItem $productData, $isDiscount = false): LineItemCreate
{

$lineItem = new LineItemCreate();
Expand All @@ -460,8 +466,16 @@ private function createLineItemProductItem(CartItem $productData): LineItemCreat
$priceDecimal = number_format(floatval(($price[0][0] . '.' . $price[0][1])), 2);
$priceDecimal = (float)str_replace(',', '', $priceDecimal);

if ($priceDecimal > 0 && $isDiscount) {
$priceDecimal = -1 * $priceDecimal;
}
$lineItem->setAmountIncludingTax($priceDecimal);
$lineItem->setType(LineItemType::PRODUCT);

$type = LineItemType::PRODUCT;
if ($isDiscount) {
$type = LineItemType::DISCOUNT;
}
$lineItem->setType($type);

return $lineItem;
}
Expand Down
2 changes: 1 addition & 1 deletion 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/pfpayments/jtl-5/releases/tag/1.0.14/">
<a href="https://github.com/pfpayments/jtl-5/releases/tag/1.0.15/">
Source
</a>
</li>
Expand Down
Binary file added frontend/assets/spinner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions frontend/js/postfinancecheckout-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@

activateLoader: function (activate) {
const buttons = document.querySelectorAll('button');
const spinnerExists = !!document.getElementById('spinner');
if (activate) {
if (spinnerExists) {
document.getElementById('spinner').style.display = 'inline-block';
}
for (let i = 0; i < buttons.length; i++) {
buttons[i].disabled = true;
}
} else {
if (spinnerExists) {
document.getElementById('spinner').style.display = 'none';
}
for (let i = 0; i < buttons.length; i++) {
buttons[i].disabled = false;
}
Expand Down Expand Up @@ -105,14 +112,14 @@
if (this.measureIframe(iframeContainer) < 30) {
PostFinanceCheckoutCheckout.handler.submit();
}
}, 500);
}, 1000);
});
PostFinanceCheckoutCheckout.handler.setHeightChangeCallback((height)=>{
setTimeout(function () {
if(height < 30) {
PostFinanceCheckoutCheckout.handler.submit();
}
}, 500);
}, 1000);
});
PostFinanceCheckoutCheckout.handler.create(iframeContainer);
}
Expand Down
13 changes: 6 additions & 7 deletions frontend/postfinancecheckout_failed_payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
unset($_SESSION['transactionId']);

$errorMessage = $transaction->getUserFailureMessage() ?? '';
$alertHelper = Shop::Container()->getAlertService();
$alertHelper->addAlert(Alert::TYPE_ERROR, $errorMessage, md5($errorMessage), ['saveInSession' => true]);

if (str_contains(strtolower($errorMessage), 'timeout')) {
unset($_SESSION['transactionId']);
unset($_SESSION['arrayOfPossibleMethods']);
}
$alertHelper = Shop::Container()->getAlertService();
$alertHelper->addAlert(Alert::TYPE_ERROR, $errorMessage, 'display error on payment page', ['saveInSession' => true]);
}

if (!function_exists('restoreCart')) {
Expand All @@ -37,7 +37,7 @@ function restoreCart($cartItems)
continue;
}

$quantityBefore = (int) $cartItem->fLagerbestandVorAbschluss;
$quantityBefore = (int)$cartItem->fLagerbestandVorAbschluss;
if ($quantityBefore < 1) {
continue;
}
Expand All @@ -59,7 +59,6 @@ function restoreCart($cartItems)
}
}

$alertHelper = Shop::Container()->getAlertService();
$alertHelper->addAlert(Alert::TYPE_ERROR, $errorMessage, 'display error on payment page', ['saveInSession' => true]);
\header('Location:' . Shop::getURL() . '/Bestellvorgang?editVersandart=1');
$linkHelper = Shop::Container()->getLinkService();
\header('Location: ' . $linkHelper->getStaticRoute('bestellvorgang.php') . '?editZahlungsart=1');
exit;
13 changes: 11 additions & 2 deletions frontend/postfinancecheckout_iframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@
/** @global JTL\Plugin\PluginInterface $plugin */

$translations = PostFinanceCheckoutHelper::getTranslations($plugin->getLocalization(), [
'jtl_postfinancecheckout_pay',
'jtl_postfinancecheckout_cancel',
'jtl_postfinancecheckout_pay',
'jtl_postfinancecheckout_cancel',
], false);

$isTwint = false;
if (strpos(strtolower($_SESSION['Zahlungsart']->cName), "twint") !== false || strpos(strtolower($_SESSION['Zahlungsart']->cTSCode), "twint") !== false) {
$isTwint = true;
}

$linkHelper = Shop::Container()->getLinkService();
$smarty
->assign('translations', $translations)
->assign('integration', 'iframe')
->assign('paymentName', $_SESSION['Zahlungsart']->angezeigterName[PostFinanceCheckoutHelper::getLanguageIso(false)])
->assign('paymentId', $_SESSION['possiblePaymentMethodId'])
->assign('iframeJsUrl', $_SESSION['javascriptUrl'])
->assign('appJsUrl', $_SESSION['appJsUrl'])
->assign('isTwint', $isTwint)
->assign('spinner', $plugin->getPaths()->getBaseURL() . 'frontend/assets/spinner.gif')
->assign('cancelUrl', $linkHelper->getStaticRoute('bestellvorgang.php') . '?editZahlungsart=1')
->assign('mainCssUrl', $plugin->getPaths()->getBaseURL() . 'frontend/css/postfinancecheckout-main.css');
27 changes: 21 additions & 6 deletions frontend/template/postfinancecheckout_iframe.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<b>{$paymentName}</b>
</div>
<hr/>

<div id="postfinancecheckout-payment-panel"
class="postfinancecheckout-payment-panel"
data-postfinancecheckout-checkout-plugin="true"
Expand All @@ -16,27 +17,31 @@
</div>
<input value="false" type="hidden" name="postfinancecheckout_payment_handler_validation_status"
form="confirmOrderForm">
<div id="postfinancecheckout-payment-iframe"
class="postfinancecheckout-payment-iframe"></div>
<div id="postfinancecheckout-payment-iframe" class="postfinancecheckout-payment-iframe">
<img {if !$isTwint}id="spinner"{/if} src="{$spinner}" alt="Loading..." title="Loading..."/>
</div>
</div>
</div>
</div>

{if !$isTwint}
<hr/>
{/if}

<div class="checkout-aside-action">
<form name="confirmOrderForm" id="confirmOrderForm">
<input type="hidden" id="cartRecreateUrl" value="/"/>
<input type="hidden" id="cartRecreateUrl" value="{$cancelUrl}"/>
<input type="hidden" id="checkoutUrl" value="/postfinancecheckout-payment-page"/>
<button id="confirmFormSubmit"

<button {if $isTwint}style="display: none"{/if} id="confirmFormSubmit"
class="btn btn-primary btn-block btn-lg"
form="confirmOrderForm"
disabled
type="submit">
{$translations.jtl_postfinancecheckout_pay}
</button>
<button style="visibility: hidden" type="button"
class="btn btn-outline-primary header-minimal-back-to-shop-button"
<button {if $isTwint}style="display: none"{/if} style="margin-top: 20px" type="button"
class="btn btn-danger btn-block btn-lg"
id="postfinancecheckoutOrderCancel">{$translations.jtl_postfinancecheckout_cancel}
</button>
</form>
Expand All @@ -48,4 +53,14 @@
<script>
$('head').append('<link rel="stylesheet" type="text/css" href="{$mainCssUrl}">');
$("#header-top-bar > div > ul").hide();
{if !$isTwint}
const confirmFormSubmitElement = document.getElementById('confirmFormSubmit');
confirmFormSubmitElement.addEventListener('click', function() {
const spinnerElement = document.getElementById('spinner');
if (spinnerElement) {
spinnerElement.remove();
}
});
{/if}
</script>
2 changes: 1 addition & 1 deletion info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Icon>logo.jpg</Icon>
<PluginID>jtl_postfinancecheckout</PluginID>
<CreateDate>2023-05-29</CreateDate>
<Version>1.0.14</Version>
<Version>1.0.15</Version>
<Install>
<Locales>
<Variable>
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit2a1573929158a4937e0265b0d1d6b14b::getLoader();
return ComposerAutoloaderInit57d0c39f7310acaf79518396f2adaa52::getLoader();
8 changes: 4 additions & 4 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit2a1573929158a4937e0265b0d1d6b14b
class ComposerAutoloaderInit57d0c39f7310acaf79518396f2adaa52
{
private static $loader;

Expand All @@ -24,12 +24,12 @@ public static function getLoader()

require __DIR__ . '/platform_check.php';

spl_autoload_register(array('ComposerAutoloaderInit2a1573929158a4937e0265b0d1d6b14b', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit57d0c39f7310acaf79518396f2adaa52', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit2a1573929158a4937e0265b0d1d6b14b', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit57d0c39f7310acaf79518396f2adaa52', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit2a1573929158a4937e0265b0d1d6b14b::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit57d0c39f7310acaf79518396f2adaa52::getInitializer($loader));

$loader->register(true);

Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit2a1573929158a4937e0265b0d1d6b14b
class ComposerStaticInit57d0c39f7310acaf79518396f2adaa52
{
public static $prefixLengthsPsr4 = array (
'W' =>
Expand Down Expand Up @@ -35,9 +35,9 @@ class ComposerStaticInit2a1573929158a4937e0265b0d1d6b14b
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit2a1573929158a4937e0265b0d1d6b14b::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit2a1573929158a4937e0265b0d1d6b14b::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit2a1573929158a4937e0265b0d1d6b14b::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit57d0c39f7310acaf79518396f2adaa52::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit57d0c39f7310acaf79518396f2adaa52::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit57d0c39f7310acaf79518396f2adaa52::$classMap;

}, null, ClassLoader::class);
}
Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '3e33321f2c76a8962258cbc4535727b072d74f39',
'reference' => 'f2f778045b84ed2e85697adf06297e35f549c941',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '3e33321f2c76a8962258cbc4535727b072d74f39',
'reference' => 'f2f778045b84ed2e85697adf06297e35f549c941',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down

0 comments on commit 9881f0d

Please sign in to comment.