diff --git a/README.md b/README.md
index 2f7d72e..a97c493 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/Services/PostFinanceCheckoutTransactionService.php b/Services/PostFinanceCheckoutTransactionService.php
index 0f0802a..c2f5562 100644
--- a/Services/PostFinanceCheckoutTransactionService.php
+++ b/Services/PostFinanceCheckoutTransactionService.php
@@ -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);
}
}
@@ -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();
@@ -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;
}
diff --git a/docs/en/documentation.html b/docs/en/documentation.html
index fcd5b48..0a5571c 100644
--- a/docs/en/documentation.html
+++ b/docs/en/documentation.html
@@ -22,7 +22,7 @@
Documentation
-
+
Source
diff --git a/frontend/assets/spinner.gif b/frontend/assets/spinner.gif
new file mode 100644
index 0000000..e1c0a20
Binary files /dev/null and b/frontend/assets/spinner.gif differ
diff --git a/frontend/js/postfinancecheckout-app.js b/frontend/js/postfinancecheckout-app.js
index aa30c23..7b221c7 100644
--- a/frontend/js/postfinancecheckout-app.js
+++ b/frontend/js/postfinancecheckout-app.js
@@ -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;
}
@@ -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);
}
diff --git a/frontend/postfinancecheckout_failed_payment.php b/frontend/postfinancecheckout_failed_payment.php
index 9f847e8..f8fb357 100644
--- a/frontend/postfinancecheckout_failed_payment.php
+++ b/frontend/postfinancecheckout_failed_payment.php
@@ -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')) {
@@ -37,7 +37,7 @@ function restoreCart($cartItems)
continue;
}
- $quantityBefore = (int) $cartItem->fLagerbestandVorAbschluss;
+ $quantityBefore = (int)$cartItem->fLagerbestandVorAbschluss;
if ($quantityBefore < 1) {
continue;
}
@@ -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;
diff --git a/frontend/postfinancecheckout_iframe.php b/frontend/postfinancecheckout_iframe.php
index cea068c..0f36ff9 100644
--- a/frontend/postfinancecheckout_iframe.php
+++ b/frontend/postfinancecheckout_iframe.php
@@ -6,10 +6,16 @@
/** @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')
@@ -17,4 +23,7 @@
->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');
diff --git a/frontend/template/postfinancecheckout_iframe.tpl b/frontend/template/postfinancecheckout_iframe.tpl
index b80fe3b..71aa29f 100644
--- a/frontend/template/postfinancecheckout_iframe.tpl
+++ b/frontend/template/postfinancecheckout_iframe.tpl
@@ -7,6 +7,7 @@
{$paymentName}
+
-
+
+
+
+ {if !$isTwint}
+ {/if}
@@ -48,4 +53,14 @@
diff --git a/info.xml b/info.xml
index 198bf6e..e2c3ec5 100644
--- a/info.xml
+++ b/info.xml
@@ -9,7 +9,7 @@
logo.jpg
jtl_postfinancecheckout
2023-05-29
-
1.0.14
+
1.0.15
diff --git a/vendor/autoload.php b/vendor/autoload.php
index 78b61e2..333d2f8 100644
--- a/vendor/autoload.php
+++ b/vendor/autoload.php
@@ -22,4 +22,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
-return ComposerAutoloaderInit2a1573929158a4937e0265b0d1d6b14b::getLoader();
+return ComposerAutoloaderInit57d0c39f7310acaf79518396f2adaa52::getLoader();
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
index f5d9416..65812fb 100644
--- a/vendor/composer/autoload_real.php
+++ b/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
-class ComposerAutoloaderInit2a1573929158a4937e0265b0d1d6b14b
+class ComposerAutoloaderInit57d0c39f7310acaf79518396f2adaa52
{
private static $loader;
@@ -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);
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
index 2cb7ce3..a7d6bb4 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -4,7 +4,7 @@
namespace Composer\Autoload;
-class ComposerStaticInit2a1573929158a4937e0265b0d1d6b14b
+class ComposerStaticInit57d0c39f7310acaf79518396f2adaa52
{
public static $prefixLengthsPsr4 = array (
'W' =>
@@ -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);
}
diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php
index ec3ad28..a967068 100644
--- a/vendor/composer/installed.php
+++ b/vendor/composer/installed.php
@@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '3e33321f2c76a8962258cbc4535727b072d74f39',
+ 'reference' => 'f2f778045b84ed2e85697adf06297e35f549c941',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '3e33321f2c76a8962258cbc4535727b072d74f39',
+ 'reference' => 'f2f778045b84ed2e85697adf06297e35f549c941',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),