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

One Page Checkout PS + Super Checkout compatibility #209

Merged
merged 31 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fadaeec
Merge branch 'RC/rc-1.2.4' of github.com:Invertus/saferpayofficial in…
MarijusCoding Oct 11, 2024
adb3b2c
Merge branch 'RC/rc-1.2.4' of github.com:Invertus/saferpayofficial in…
MarijusCoding Oct 12, 2024
8f8724b
Merge branch 'SV-28/thecheckout' of github.com:Invertus/saferpayoffic…
MarijusCoding Oct 14, 2024
fff2742
fi
MarijusCoding Oct 14, 2024
72ef707
Merge branch 'RC/rc-1.2.4' of github.com:Invertus/saferpayofficial in…
MarijusCoding Oct 15, 2024
e3732db
Merge branch 'RC/rc-1.2.4' of github.com:Invertus/saferpayofficial in…
MarijusCoding Oct 15, 2024
3e6440b
Merge branch 'RC/rc-1.2.4' of github.com:Invertus/saferpayofficial in…
MarijusCoding Oct 17, 2024
7ad57f3
fix conf
MarijusCoding Oct 17, 2024
092ff2d
added compatibility opcps
MarijusCoding Oct 17, 2024
38db797
compatibility
MarijusCoding Oct 17, 2024
e3bbf9c
revert
MarijusCoding Oct 17, 2024
e310a39
revert
MarijusCoding Oct 17, 2024
f5b367a
revert
MarijusCoding Oct 17, 2024
857ba82
revert
MarijusCoding Oct 17, 2024
0b7ffd7
Revert "revert"
MarijusCoding Oct 17, 2024
71bc3c1
Revert "revert"
MarijusCoding Oct 17, 2024
8401319
Revert "revert"
MarijusCoding Oct 17, 2024
65cec16
Revert "revert"
MarijusCoding Oct 17, 2024
dd2a277
fix
MarijusCoding Oct 18, 2024
7991127
fix
MarijusCoding Oct 18, 2024
3ad9df9
removed config
MarijusCoding Oct 18, 2024
a6f6d63
Merge branch 'SV-28/thecheckout' of github.com:Invertus/saferpayoffic…
MarijusCoding Oct 18, 2024
ed53990
fix
MarijusCoding Oct 18, 2024
8fca556
update sql
MarijusCoding Oct 20, 2024
ede7712
Merge branch 'RC/rc-1.2.4' of github.com:Invertus/saferpayofficial in…
MarijusCoding Oct 20, 2024
72a944c
Fixed SQL
MarijusCoding Oct 20, 2024
066d638
Merge branch 'RC/rc-1.2.4' of github.com:Invertus/saferpayofficial in…
MarijusCoding Oct 20, 2024
fad0c01
added more redirect payment to prevent double statuses
MarijusCoding Oct 21, 2024
3ce7e63
update
MarijusCoding Oct 22, 2024
a53468a
fixed google apple status
MarijusCoding Oct 22, 2024
c2b0d5c
Merge branch 'RC/rc-1.2.4' of github.com:Invertus/saferpayofficial in…
MarijusCoding Oct 22, 2024
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
14 changes: 13 additions & 1 deletion controllers/admin/AdminSaferPayOfficialSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,24 @@ public function postProcess()
{
parent::postProcess();

$isCreditCardSaveEnabled = Configuration::get(SaferPayConfig::CREDIT_CARD_SAVE);
/** @var \Invertus\SaferPay\Adapter\Configuration $configuration */
$configuration = $this->module->getService(\Invertus\SaferPay\Adapter\Configuration::class);

$isCreditCardSaveEnabled = $configuration->get(SaferPayConfig::CREDIT_CARD_SAVE);

if (!$isCreditCardSaveEnabled) {
/** @var SaferPaySavedCreditCardRepository $cardRepo */
$cardRepo = $this->module->getService(SaferPaySavedCreditCardRepository::class);
$cardRepo->deleteAllSavedCreditCards();
}

$haveFieldToken = $configuration->get(SaferPayConfig::FIELDS_ACCESS_TOKEN . SaferPayConfig::getConfigSuffix());
$haveBusinessLicense = $configuration->get(SaferPayConfig::BUSINESS_LICENSE . SaferPayConfig::getConfigSuffix());

if (!$haveFieldToken && $haveBusinessLicense) {
$configuration->set(SaferPayConfig::BUSINESS_LICENSE . SaferPayConfig::getConfigSuffix(), 0);
$this->errors[] = $this->module->l('Field Access Token is required to use business license');
}
}

public function initOptions()
Expand Down
4 changes: 4 additions & 0 deletions controllers/front/return.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public function postProcess()

$orderPayment = $assertResponseBody->getPaymentMeans()->getBrand()->getPaymentMethod();

if (!empty($assertResponseBody->getPaymentMeans()->getWallet())) {
$orderPayment = $assertResponseBody->getPaymentMeans()->getWallet();
}

/** @var SaferPayFieldRepository $saferPayFieldRepository */
$saferPayFieldRepository = $this->module->getService(SaferPayFieldRepository::class);

Expand Down
4 changes: 3 additions & 1 deletion src/Config/SaferPayConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ public static function isRedirectPayment($paymentMethod)
self::PAYMENT_APPLEPAY,
self::PAYMENT_GOOGLEPAY,
self::PAYMENT_TWINT,
self::PAYMENT_POSTFINANCE_PAY
self::PAYMENT_POSTFINANCE_PAY,
self::PAYMENT_DIRECTDEBIT,
self::PAYMENT_SOFORT
];

return in_array($paymentMethod, $paymentsAlwaysRedirect);
Expand Down
20 changes: 19 additions & 1 deletion src/DTO/Response/PaymentMeans.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,23 @@ class PaymentMeans
* @var Card
*/
private $card;
/**
* @var string
*/
private $wallet;

/**
* PaymentMeans constructor.
* @param Brand|null $brand
* @param string $displayText
* @param Card|null $card
*/
public function __construct(Brand $brand = null, $displayText = null, Card $card = null)
public function __construct(Brand $brand = null, $displayText = null, Card $card = null, $wallet = null)
{
$this->brand = $brand;
$this->displayText = $displayText;
$this->card = $card;
$this->wallet = $wallet;
}

/**
Expand Down Expand Up @@ -97,11 +102,24 @@ public function getCard()
return $this->card;
}

/**
* @return string
*/
public function getWallet()
{
return $this->wallet;
}

/**
* @param Card $card
*/
public function setCard($card)
{
$this->card = $card;
}

public function setWallet($wallet)
{
$this->wallet = $wallet;
}
}
6 changes: 3 additions & 3 deletions src/Install/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,17 @@ private function installSaferPayLog()
{
return Db::getInstance()->execute(
'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . pSQL(\SaferPayLog::$definition['table']) . '(
`id_saferpay_log` INTEGER(10) NOT NULL AUTO_INCREMENT,
`id_saferpay_log` INTEGER(10) unsigned NOT NULL AUTO_INCREMENT,
`id_log` INT(10) NOT NULL,
`id_shop` INT(10) NOT NULL DEFAULT ' . (int) Configuration::get('PS_SHOP_DEFAULT') . ',
`message` TEXT DEFAULT NULL,
`request` MEDIUMTEXT DEFAULT NULL,
`response` MEDIUMTEXT DEFAULT NULL,
`context` TEXT DEFAULT NULL,
`date_add` DATETIME NOT NULL,
`date_add` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(`id_saferpay_log`, `id_log`, `id_shop`),
INDEX(`id_log`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;'
);
}

Expand Down
37 changes: 35 additions & 2 deletions src/Presentation/Loader/PaymentFormAssetLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Configuration;
use Invertus\SaferPay\Adapter\LegacyContext;
use Invertus\SaferPay\Config\SaferPayConfig;
use Invertus\SaferPay\DTO\Request\Order;
use Invertus\SaferPay\Enum\ControllerName;
use Invertus\SaferPay\Enum\PaymentType;
use Invertus\SaferPay\Factory\ModuleFactory;
Expand Down Expand Up @@ -84,7 +85,23 @@ public function register($controller)

private function registerOnePageCheckoutAssets($controller)
{
// TODO: will be implemented in other branches
if (!$controller instanceof \OrderControllerCore) {
return;
}

$controller->addCSS("{$this->module->getPathUri()}views/css/front/saferpay_checkout.css");

if (method_exists($controller, 'registerJavascript')) {
$controller->registerJavascript(
'saved_card_hosted_fields_opc',
"modules/saferpayofficial/views/js/front/opc/onepagecheckoutps/hosted_fields.js"
);
} else {
$controller->addJs(
$this->module->getPathUri() . 'views/js/front/opc/onepagecheckoutps/hosted_fields.js',
false
);
}
}

private function registerTheCheckoutAssets($controller)
Expand All @@ -110,7 +127,23 @@ private function registerTheCheckoutAssets($controller)

private function registerSuperCheckoutAssets($controller)
{
// TODO: will be implemented in other branches
if (!$controller instanceof \SupercheckoutSupercheckoutModuleFrontController) {
return;
}

$controller->addCSS("{$this->module->getPathUri()}views/css/front/saferpay_checkout.css");

if (method_exists($controller, 'registerJavascript')) {
$controller->registerJavascript(
'saved_card_hosted_fields_opc',
"modules/saferpayofficial/views/js/front/opc/supercheckout/hosted_fields.js"
);
} else {
$controller->addJs(
$this->module->getPathUri() . 'views/js/front/opc/supercheckout/hosted_fields.js',
false
);
}
}

private function registerDefaultCheckoutAssets($controller)
Expand Down
3 changes: 3 additions & 0 deletions src/Service/Response/ResponseObjectCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ protected function createPaymentMeans($paymentMeans)
}
$paymentMeansObj->setBrand($brandObj);
$paymentMeansObj->setDisplayText($paymentMeans->DisplayText);
if (isset($paymentMeans->Wallet)) {
$paymentMeansObj->setWallet($paymentMeans->Wallet);
}

return $paymentMeansObj;
}
Expand Down
13 changes: 13 additions & 0 deletions views/css/front/saferpay_checkout.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,16 @@
.payment-logo {
max-width: 40px;
}

input[type="radio"][name^="saved_card_"] {
opacity: 1 !important;
width: 15px !important;
position: relative !important;
vertical-align: middle !important;
margin: 0 !important;
}
.saved_credit_cards span {
padding-left: 3px !important;
vertical-align: middle !important;
margin: 0 !important;
}
59 changes: 59 additions & 0 deletions views/js/front/opc/onepagecheckoutps/hosted_fields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
*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
*/

$(document).ready(function () {
$('body').on('change', "input[name^='saved_card_']", function () {
var $selectedCard = $(this);
var method = $selectedCard.closest('div.saved_cards').find('.saved_card_method').val();
$("input[name='selectedCreditCard_" + method + "']").val($selectedCard.val());
});
});

$('body').on('submit', '[id^=pay-with-][id$=-form] form', function (event) {
event.preventDefault();

var selectedCardMethod = $(this).find("[name=saved_card_method]").val();
var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val();

//NOTE: not saved card chosen, continuing with normal procedures.
if (selectedCard <= 0) {
event.target.submit();

return;
}

$.ajax(saferpay_official_ajax_url, {
method: 'POST',
data: {
action: 'submitHostedFields',
paymentMethod: selectedCardMethod,
selectedCard: selectedCard,
isBusinessLicence: 1,
ajax: 1
},
success: function (response) {
var data = jQuery.parseJSON(response);

window.location = data.url;
},
});
});
59 changes: 59 additions & 0 deletions views/js/front/opc/supercheckout/hosted_fields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
*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
*/

$(document).ready(function () {
$('body').on('change', "input[name^='saved_card_']", function () {
var $selectedCard = $(this);
var method = $selectedCard.closest('div.saved_cards').find('.saved_card_method').val();
$("input[name='selectedCreditCard_" + method + "']").val($selectedCard.val());
});
});

$('body').on('submit', '[id^=pay-with-][id$=-form] form', function (event) {
event.preventDefault();

var selectedCardMethod = $(this).find("[name=saved_card_method]").val();
var selectedCard = $(this).find("[name=selectedCreditCard_" + selectedCardMethod + "]").val();

//NOTE: not saved card chosen, continuing with normal procedures.
if (selectedCard <= 0) {
event.target.submit();

return;
}

$.ajax(saferpay_official_ajax_url, {
method: 'POST',
data: {
action: 'submitHostedFields',
paymentMethod: selectedCardMethod,
selectedCard: selectedCard,
isBusinessLicence: 1,
ajax: 1
},
success: function (response) {
var data = jQuery.parseJSON(response);

window.location = data.url;
},
});
});
Loading