Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SL-264 Prestashop 1.6 Problems #217

Merged
merged 6 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions controllers/admin/AdminSaferPayOfficialSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ public function initOptions()
{
$this->context->smarty->assign(SaferPayConfig::PASSWORD, SaferPayConfig::WEB_SERVICE_PASSWORD_PLACEHOLDER);

$savedCardSetting = SaferPayConfig::isVersion17() ? [
'type' => 'radio',
'title' => $this->l('Credit card saving for customers'),
'validation' => 'isInt',
'choices' => [
1 => $this->l('Enable'),
0 => $this->l('Disable'),
],
'desc' => $this->l('Allow customers to save credit card for faster purchase'),
'form_group_class' => 'thumbs_chose',
] : null;

$this->fields_options = [
'login_configurations' => [
'title' => $this->l('TEST MODE'),
Expand Down Expand Up @@ -261,17 +273,7 @@ public function initOptions()
'desc' => $this->l('Default payment behavior for payment without 3-D Secure'),
'form_group_class' => 'thumbs_chose',
],
SaferPayConfig::CREDIT_CARD_SAVE => [
'type' => 'radio',
'title' => $this->l('Credit card saving for customers'),
'validation' => 'isInt',
'choices' => [
1 => $this->l('Enable'),
0 => $this->l('Disable'),
],
'desc' => $this->l('Allow customers to save credit card for faster purchase'),
'form_group_class' => 'thumbs_chose',
],
SaferPayConfig::CREDIT_CARD_SAVE => $savedCardSetting,
SaferPayConfig::RESTRICT_REFUND_AMOUNT_TO_CAPTURED_AMOUNT => [
'type' => 'radio',
'title' => $this->l('Restrict RefundAmount To Captured Amount'),
Expand Down
9 changes: 8 additions & 1 deletion controllers/front/successIFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,16 @@ public function initContent()
$this->setTemplate(SaferPayConfig::SAFERPAY_TEMPLATE_LOCATION . '/front/loading.tpl');
return;
}

$jsUrl = "{$this->module->getPathUri()}views/js/front/saferpay_iframe_16.js";

if (SaferPayConfig::isVersion17()) {
$jsUrl = "{$this->module->getPathUri()}views/js/front/saferpay_iframe.js";
}

$this->context->smarty->assign([
'cssUrl' => "{$this->module->getPathUri()}views/css/front/loading.css",
'jsUrl' => "{$this->module->getPathUri()}views/js/front/saferpay_iframe.js",
'jsUrl' => $jsUrl,
'redirectUrl' => $orderLink,
]);
$this->setTemplate('loading_16.tpl');
Expand Down
2 changes: 1 addition & 1 deletion saferpayofficial.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function hookActionObjectOrderPaymentAddAfter($params)

public function hookPaymentOptions($params)
{
/** @var Invertus\SaferPay\Service\SaferPayCartService $assertService */
/** @var Invertus\SaferPay\Service\SaferPayCartService $cartService */
$cartService = $this->getService(\Invertus\SaferPay\Service\SaferPayCartService::class);
if (!$cartService->isCurrencyAvailable($params['cart'])) {
return [];
Expand Down
12 changes: 5 additions & 7 deletions src/Validation/CustomerCreditCardValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ public function __construct(SaferPayCardAliasRepository $saferPayCardAliasReposi
*/
public function validate($idSavedCard, $idCustomer)
{
if (
!is_numeric($idCustomer) || !is_numeric($idSavedCard)
|| !isset($idCustomer) || !isset($idSavedCard))
if ($idSavedCard <= 0 || empty($idSavedCard)) {
return true;
}

if (!is_numeric($idCustomer) || !is_numeric($idSavedCard))
{
$this->logger->error(sprintf('%s - Invalid data or bad types', self::FILE_NAME), [
'context' => [],
Expand All @@ -73,10 +75,6 @@ public function validate($idSavedCard, $idCustomer)
throw SaferPayException::unknownError();
}

if ($idSavedCard <= 0) {
return true;
}

$cardOwnerId = $this->saferPayCardAliasRepository->getCustomerIdByReferenceId(pSQL($idSavedCard), pSQL($idCustomer));

if (empty($cardOwnerId)) {
Expand Down
29 changes: 29 additions & 0 deletions views/js/front/saferpay_iframe_16.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
*NOTICE OF LICENSE
*
*This source file is subject to the Open Software License (OSL 3.0)
*that is bundled with this package in the file LICENSE.txt.
*It is also available through the world-wide-web at this URL:
*http://opensource.org/licenses/osl-3.0.php
*If you did not receive a copy of the license and are unable to
*obtain it through the world-wide-web, please send an email
*to [email protected] so we can send you a copy immediately.
*
*DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
*versions in the future. If you wish to customize PrestaShop for your
*needs please refer to http://www.prestashop.com for more information.
*
*@author INVERTUS UAB www.invertus.eu <[email protected]>
*@copyright SIX Payment Services
*@license SIX Payment Services
*/

(function () {
// NOTE: Replacing because javascript gives "&amp;" instead of "&" in the URL
redirectUrl = redirectUrl.replace(/&amp;/g, "&");
if (top.location !== window.location) {
top.location.href = redirectUrl;
}
})();
Loading