Skip to content

Commit

Permalink
Merge pull request #363 from 202ecommerce/feature/46227-remove-hosted…
Browse files Browse the repository at this point in the history
…-fields

refs #46227 remove hosted fieldes
  • Loading branch information
bogdan202 authored Sep 19, 2024
2 parents 6906e7a + 0ff284f commit 0771af6
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 112 deletions.
10 changes: 2 additions & 8 deletions 202/_dev/js/acdc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ const ACDC = function(conf) {
this.isMoveButtonAtEnd = conf['isMoveButtonAtEnd'] === undefined ? null : conf['isMoveButtonAtEnd'];

this.buttonForm = conf['buttonForm'] === undefined ? null : conf['buttonForm'];

this.isCardFields = conf['isCardFields'] === undefined ? false : conf['isCardFields'];
};

ACDC.prototype.initButton = function() {
Expand Down Expand Up @@ -71,7 +69,7 @@ ACDC.prototype.getIdOrder = function() {
headers: {
'content-type': 'application/json;charset=utf-8'
},
body: JSON.stringify({page: 'cart', addAddress: 1, sca_verification: (this.isCardFields ? 'SCA_WHEN_REQUIRED' : '')}),
body: JSON.stringify({page: 'cart', addAddress: 1, sca_verification: 'SCA_WHEN_REQUIRED'}),
}).then(function(res) {
return res.json();
}).then(function(data) {
Expand Down Expand Up @@ -111,11 +109,7 @@ ACDC.prototype.getPaypalButtonsContainer = function() {
};

ACDC.prototype.initFields = function() {
if (this.isCardFields) {
this.initCardFields();
} else {
this.initHostedFields();
}
this.initCardFields();
};

ACDC.prototype.initCardFields = function() {
Expand Down
26 changes: 2 additions & 24 deletions classes/ACDC/AcdcPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

use Configuration;
use Context;
use PayPal;
use PaypalAddons\classes\AbstractMethodPaypal;
use PaypalAddons\classes\Constants\PaypalConfigurations;

Expand Down Expand Up @@ -66,11 +65,7 @@ public function render()

protected function getTemplatePath()
{
if ($this->isCardFields()) {
return 'module:paypal/views/templates/acdc/payment-option-card-fields.tpl';
} else {
return 'module:paypal/views/templates/acdc/payment-option.tpl';
}
return 'module:paypal/views/templates/acdc/payment-option.tpl';
}

protected function getTplVars()
Expand All @@ -79,7 +74,6 @@ protected function getTplVars()
'psPaypalDir' => _PS_MODULE_DIR_ . 'paypal',
'JSvars' => [
PaypalConfigurations::MOVE_BUTTON_AT_END => (int) Configuration::get(PaypalConfigurations::MOVE_BUTTON_AT_END),
'isCardFields' => $this->isCardFields(),
],
'JSscripts' => $this->getScripts(),
];
Expand All @@ -90,23 +84,12 @@ protected function getTplVars()
protected function getScripts()
{
$scripts = [];

if ($this->isCardFields()) {
$srcLib = $this->method->getUrlJsSdkLib(['components' => 'card-fields,marks']);
} else {
$srcLib = $this->method->getUrlJsSdkLib(['components' => 'hosted-fields,marks']);
}

$srcLib = $this->method->getUrlJsSdkLib(['components' => 'card-fields,marks']);
$scripts['tot-paypal-acdc-sdk'] = [
'src' => $srcLib,
'data-namespace' => 'totPaypalAcdcSdk',
'data-partner-attribution-id' => $this->getPartnerId(),
];

if (!$this->isCardFields()) {
$scripts['tot-paypal-acdc-sdk']['data-client-token'] = $this->getClientToken();
}

$scripts['acdc'] = [
'src' => __PS_BASE_URI__ . 'modules/paypal/views/js/acdc.js',
];
Expand All @@ -129,9 +112,4 @@ protected function getClientToken()

return '';
}

protected function isCardFields()
{
return (int) Configuration::get(PayPal::USE_CARD_FIELDS);
}
}
4 changes: 2 additions & 2 deletions controllers/front/webhookhandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function run()
}

if (false == ($this->module->getWebhookOption()->isEnable() && $this->module->getWebhookOption()->isAvailable())) {
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
header($_SERVER['SERVER_PROTOCOL'] . ' 405 Method Not Allowed', true, 405);

return;
}
Expand Down Expand Up @@ -102,7 +102,7 @@ public function run()
null
);
ProcessLoggerHandler::closeLogger();
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request', true, 400);
}
} catch (\Exception $exception) {
} catch (\Throwable $exception) {//for php version > 7
Expand Down
3 changes: 0 additions & 3 deletions paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ class PayPal extends \PaymentModule implements WidgetInterface

const ACCESS_TOKEN = 'PAYPAL_ACCESS_TOKEN';

const USE_CARD_FIELDS = 'PAYPAL_USE_CARD_FIELDS';

const SCA_WHEN_REQUIRED = 'SCA_WHEN_REQUIRED';

const SCA_ALWAYS = 'SCA_ALWAYS';
Expand Down Expand Up @@ -416,7 +414,6 @@ public function __construct()
PaypalConfigurations::PUI_ENABLED => 1,
PaypalConfigurations::SEPA_ENABLED => 1,
PaypalConfigurations::ACDC_OPTION => 1,
self::USE_CARD_FIELDS => 1,
];

if (version_compare(_PS_VERSION_, '1.7.6', '<')) {
Expand Down
69 changes: 0 additions & 69 deletions views/templates/acdc/payment-option-card-fields.tpl

This file was deleted.

8 changes: 2 additions & 6 deletions views/templates/acdc/payment-option.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@

{block name='style'}
<style>
.pp-input {
border: solid;
border-width: thin;
height: 30px;
padding: 0 10px;
#cvv {
min-width: 120px;
}
.pp-flex {
Expand Down Expand Up @@ -136,7 +133,6 @@
messages: messages,
buttonForm: document.querySelector('[paypal-acdc-form-button]'),
isMoveButtonAtEnd: PAYPAL_MOVE_BUTTON_AT_END,
isCardFields: isCardFields,
});
acdcObj.initFields();
acdcObj.hideElementTillPaymentOptionChecked(
Expand Down

0 comments on commit 0771af6

Please sign in to comment.