Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan202 committed Mar 5, 2021
2 parents f7be3f9 + 5302dde commit 8a5b9fd
Show file tree
Hide file tree
Showing 30 changed files with 388 additions and 140 deletions.
2 changes: 1 addition & 1 deletion 202/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<property name="src-dir" value="${basedir}" />
<property name="TARGETNAME" value="braintreeofficial" />
<property name="TARGETBRANCH" value="${env.GIT_BRANCH}" />
<property name="TARGETVERSION" value="1.2.3" />
<property name="TARGETVERSION" value="1.2.4" />
<property name="PHPVERSION" value="5.6" />
<property name="PSVERSION" value="1.7.5.x" />

Expand Down
2 changes: 2 additions & 0 deletions _dev/js/payment_bt.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ const BraintreeSubmitPayment = () => {
client: bt_client_instance,
}, (ThreeDSecureerror, threeDSecure) => {
if (ThreeDSecureerror) {
let popup_message = '';
btnConfirmation.prop('disabled', false);

switch (ThreeDSecureerror.code) {
case 'THREEDS_HTTPS_REQUIRED':
popup_message = bt_translations_https;
Expand Down
14 changes: 14 additions & 0 deletions _dev/scss/bt_admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
display: flex !important;
}

.bt__flex-wrap {
flex-wrap: wrap;
}

.stretchHeightForm form {
height: 100%;
}
Expand Down Expand Up @@ -109,4 +113,14 @@
margin-right: 20px;
}

.icon-lightbulb::before {
content: '\f0eb' !important;
}

@media (max-width: 768px) {
.container-fluid .flex {
flex-direction: column;
}
}


23 changes: 16 additions & 7 deletions braintreeofficial.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ public function hookActionOrderSlipAdd($params)
$message = '';
$ex_detailed_message = '';
$capture = $this->serviceBraintreeOfficialCapture->loadByOrderBraintreeId($braintreeOrder->id);

if (Validate::isLoadedObject($capture) && !$capture->id_capture) {
ProcessLoggerHandler::openLogger();
ProcessLoggerHandler::logError(
Expand All @@ -482,8 +483,9 @@ public function hookActionOrderSlipAdd($params)
$braintreeOrder->sandbox
);
ProcessLoggerHandler::closeLogger();
return true;
Tools::redirect($_SERVER['HTTP_REFERER'].'&not_payed_capture=1');
}

$status = $this->methodBraintreeOfficial->getTransactionStatus($braintreeOrder);

if ($status == "submitted_for_settlement") {
Expand All @@ -498,7 +500,7 @@ public function hookActionOrderSlipAdd($params)
$braintreeOrder->sandbox
);
ProcessLoggerHandler::closeLogger();
return true;
Tools::redirect($_SERVER['HTTP_REFERER'].'&not_payed_capture=1');
} else {
try {
$refund_response = $this->methodBraintreeOfficial->partialRefund($params);
Expand Down Expand Up @@ -537,6 +539,7 @@ public function hookActionOrderSlipAdd($params)
$braintreeOrder->sandbox
);
ProcessLoggerHandler::closeLogger();
Tools::redirect($_SERVER['HTTP_REFERER'].'&error_refund=1');
}
if ($ex_detailed_message) {
ProcessLoggerHandler::openLogger();
Expand All @@ -550,6 +553,7 @@ public function hookActionOrderSlipAdd($params)
$braintreeOrder->sandbox
);
ProcessLoggerHandler::closeLogger();
Tools::redirect($_SERVER['HTTP_REFERER'].'&error_refund=1');
}
}
}
Expand Down Expand Up @@ -894,7 +898,7 @@ public function hookDisplayAdminOrderTop($params)
protected function getPartialRefund()
{
$this->context->smarty->assign('chb_braintree_refund', $this->l('Refund Braintree'));
return $this->context->smarty->fetch('module:braintreeofficial/views/templates/hook/partialRefund.tpl');
return $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'braintreeofficial/views/templates/hook/partialRefund.tpl');
}

public function hookDisplayAdminOrder($params)
Expand Down Expand Up @@ -986,8 +990,8 @@ public function hookDisplayBackOfficeHeader()

foreach ($ps_order_details as $order_detail) {
// Switch to back order if needed
$product_stock = StockAvailable::getQuantityAvailableByProduct($order_detail['product_id'], $order_detail['product_attribute_id']);
if (Configuration::get('PS_STOCK_MANAGEMENT') && $product_stock <= 0) {
if (Configuration::get('PS_STOCK_MANAGEMENT') &&
(int)$order_detail['product_quantity'] > (int)$order_detail['product_quantity_in_stock']) {
$paid_state = Configuration::get('PS_OS_OUTOFSTOCK_PAID');
}
}
Expand Down Expand Up @@ -1067,9 +1071,12 @@ public function hookHeader()
$carrierFees = $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING);

if ($carrierFees == 0) {
$messageForCustomer = $this->context->smarty->fetch('module:braintreeofficial/views/templates/front/_partials/messageForCustomerOne.tpl');
$messageForCustomer = $this->context->smarty
->assign('isSandbox', $this->methodBraintreeOfficial->isSandbox())
->fetch('module:braintreeofficial/views/templates/front/_partials/messageForCustomerOne.tpl');
} else {
$this->context->smarty->assign('carrierFees', Tools::displayPrice($carrierFees));
$this->context->smarty->assign('isSandbox', $this->methodBraintreeOfficial->isSandbox());
$messageForCustomer = $this->context->smarty->fetch('module:braintreeofficial/views/templates/front/_partials/messageForCustomerTwo.tpl');
}

Expand Down Expand Up @@ -1252,7 +1259,8 @@ public function generateFormPB()
'path' => $this->_path,
'bt_method' => BRAINTREE_PAYPAL_PAYMENT,
'active_vaulting'=> Configuration::get('BRAINTREEOFFICIAL_VAULTING'),
'show_paypal_benefits' => Configuration::get('BRAINTREEOFFICIAL_SHOW_PAYPAL_BENEFITS')
'show_paypal_benefits' => Configuration::get('BRAINTREEOFFICIAL_SHOW_PAYPAL_BENEFITS'),
'isSandbox' => $this->methodBraintreeOfficial->isSandbox()
));
if (Configuration::get('BRAINTREEOFFICIAL_VAULTING')) {
$payment_methods = $this->serviceBraintreeOfficialVaulting->getCustomerMethods($this->context->customer->id, BRAINTREE_PAYPAL_PAYMENT);
Expand Down Expand Up @@ -1306,6 +1314,7 @@ public function generateFormBT()
'braintreeSubmitUrl'=> $this->context->link->getModuleLink($this->name, 'validation', array(), true),
'baseDir' => $this->context->link->getBaseLink($this->context->shop->id, true),
'method_bt' => BRAINTREE_CARD_PAYMENT,
'isSandbox' => $this->methodBraintreeOfficial->isSandbox()
));

return $this->context->smarty->fetch('module:braintreeofficial/views/templates/front/payment_bt.tpl');
Expand Down
23 changes: 23 additions & 0 deletions classes/AdminBraintreeOfficialController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public function __construct()

public function init()
{
if (\Tools::getValue('action') === 'set_sandbox_mode') {
\Configuration::updateValue('BRAINTREEOFFICIAL_SANDBOX', (int)\Tools::getValue('sandbox_mode'));
}

parent::init();

if ((int)\Configuration::get('BRAINTREEOFFICIAL_MIGRATION_FAILED') == 1) {
Expand All @@ -49,6 +53,7 @@ public function init()
}

$this->context->smarty->assign('moduleDir', _MODULE_DIR_);
$this->context->smarty->assign('isModeSandbox', (int)\Configuration::get('BRAINTREEOFFICIAL_SANDBOX'));
}

public function renderForm($fields_form = null)
Expand Down Expand Up @@ -201,4 +206,22 @@ public function getHooksUnregisteredMessage($hooks)
$this->context->smarty->assign('hooks', $hooks);
return $this->context->smarty->fetch($this->getTemplatePath() . '_partials/unregisteredHooksMessage.tpl');
}

public function initPageHeaderToolbar()
{
$query = [
'token' => $this->token,
'action' => 'set_sandbox_mode',
'sandbox_mode' => \Configuration::get('BRAINTREEOFFICIAL_SANDBOX') ? 0 : 1
];
$this->page_header_toolbar_btn['switch_sandbox'] = [
'desc' => $this->l('Sandbox mode'),
'icon' => 'process-icon-toggle-' . (\Configuration::get('BRAINTREEOFFICIAL_SANDBOX') ? 'on' : 'off'),
'help' => $this->l('Sandbox mode is the test environment where you\'ll be not able to collect any real payments.'),
'href' => self::$currentIndex . '?' . http_build_query($query)
];

parent::initPageHeaderToolbar();
$this->context->smarty->clearAssign('help_link');
}
}
8 changes: 8 additions & 0 deletions classes/MethodBraintreeOfficial.php
Original file line number Diff line number Diff line change
Expand Up @@ -1035,4 +1035,12 @@ public function getShortcutJsVars($page)

return $tplVars;
}

/**
* @return bool
*/
public function isSandbox()
{
return (int)Configuration::get('BRAINTREEOFFICIAL_SANDBOX');
}
}
2 changes: 1 addition & 1 deletion controllers/admin/AdminBraintreeOfficialHelp.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function init()
*/
public function initContent()
{
$need_rounding = (Configuration::get('PS_ROUND_TYPE') != Order::ROUND_ITEM) || (Configuration::get('PS_PRICE_ROUND_MODE') != PS_ROUND_HALF_DOWN);
$need_rounding = (Configuration::get('PS_ROUND_TYPE') != Order::ROUND_ITEM) || (Configuration::get('PS_PRICE_ROUND_MODE') != PS_ROUND_HALF_UP);
$tpl_vars = array(
'need_rounding' => $need_rounding,
);
Expand Down
5 changes: 0 additions & 5 deletions controllers/admin/AdminBraintreeOfficialSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ public function initContent()
$formMerchantAccounts = $this->renderForm();
$this->clearFieldsForm();

$this->initEnvironmentSettings();
$formEnvironmentSettings = $this->renderForm();
$this->clearFieldsForm();

$this->initStatusBlock();
$formStatus = $this->renderForm();
$this->clearFieldsForm();
Expand All @@ -75,7 +71,6 @@ public function initContent()
'formAccountSettings' => $formAccountSettings,
'formPaymentSettings' => $formPaymentSettings,
'formMerchantAccounts' => $formMerchantAccounts,
'formEnvironmentSettings' => $formEnvironmentSettings,
'formStatus' => $formStatus,
'showMessageAboutStateName' => (int)Configuration::get('BRAINTREEOFFICIAL_SHOW_MESSAGE_ABOUT_STATE_NAME')

Expand Down
30 changes: 30 additions & 0 deletions translations/br.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* 2007-2021 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 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/afl-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 2007-2021 PayPal
* @author 202 ecommerce <[email protected]>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

global $_MODULE;
$_MODULE = array();
$_MODULE['<{braintreeofficial}prestashop>messagesandbox_e8fdd95502f3d9eef321833fe60aed0c'] = 'Modo Sandbox : todas as transações serão fictícias';
$_MODULE['<{braintreeofficial}prestashop>adminbraintreeofficialcontroller_b38308023e216ac4faf73789566556c2'] = 'Modo Sandbox : é o ambiente de teste onde você não será capaz de coletar nenhum pagamento real';
6 changes: 4 additions & 2 deletions translations/de.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* 2007-2020 PayPal
* 2007-2021 PayPal
*
* NOTICE OF LICENSE
*
Expand All @@ -18,7 +18,7 @@
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 PayPal
* @author 2007-2021 PayPal
* @author 202 ecommerce <[email protected]>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Expand Down Expand Up @@ -261,3 +261,5 @@
$_MODULE['<{braintreeofficial}prestashop>adminbraintreeofficialmigration_51a9f5fc2e4d9b1c8aa4a60a7c725243'] = 'Beim Erstellen Ihres Web-Ablaufs ist ein Fehler aufgetreten. Überprüfen Sie Ihre Zugangsdaten.';
$_MODULE['<{braintreeofficial}prestashop>help_5c4a03273ee4e687ae2547a2416f59c0'] = 'Der Zugriff auf die API über ein Braintree-Konto ist nicht möglich?';
$_MODULE['<{braintreeofficial}prestashop>formaccount_5c4a03273ee4e687ae2547a2416f59c0'] = 'Der Zugriff auf die API über ein Braintree-Konto ist nicht möglich?';
$_MODULE['<{braintreeofficial}prestashop>messagesandbox_e8fdd95502f3d9eef321833fe60aed0c'] = 'Sandbox-Modus: Alle Transaktionen sind rein fiktiv';
$_MODULE['<{braintreeofficial}prestashop>adminbraintreeofficialcontroller_b38308023e216ac4faf73789566556c2'] = 'Sandbox-Modus: dies ist die Testumgebung, in der Sie keine echten Zahlungen veranlassen können';
6 changes: 4 additions & 2 deletions translations/en.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* 2007-2020 PayPal
* 2007-2021 PayPal
*
* NOTICE OF LICENSE
*
Expand All @@ -18,7 +18,7 @@
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 PayPal
* @author 2007-2021 PayPal
* @author 202 ecommerce <[email protected]>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Expand Down Expand Up @@ -250,3 +250,5 @@
$_MODULE['<{braintreeofficial}prestashop>tablelogs_88427ec035734b45aae9f7d8859a5008'] = 'Transaction ID:';
$_MODULE['<{braintreeofficial}prestashop>tablelogs_7761b2ef39506fa88f2a02bb18f00d29'] = 'Payment tools';
$_MODULE['<{braintreeofficial}prestashop>tablelogs_b5a7adde1af5c87d7fd797b6245c2a39'] = 'Description';
$_MODULE['<{braintreeofficial}prestashop>messagesandbox_e8fdd95502f3d9eef321833fe60aed0c'] = 'Sandbox mode : all transactions will be fictitious';
$_MODULE['<{braintreeofficial}prestashop>adminbraintreeofficialcontroller_b38308023e216ac4faf73789566556c2'] = 'Sandbox mode : is the test environment where you will not be able to collect any real payments';
6 changes: 4 additions & 2 deletions translations/es.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* 2007-2020 PayPal
* 2007-2021 PayPal
*
* NOTICE OF LICENSE
*
Expand All @@ -18,7 +18,7 @@
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 PayPal
* @author 2007-2021 PayPal
* @author 202 ecommerce <[email protected]>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Expand Down Expand Up @@ -273,3 +273,5 @@
$_MODULE['<{braintreeofficial}prestashop>adminbraintreeofficialmigration_51a9f5fc2e4d9b1c8aa4a60a7c725243'] = 'Se ha producido un error al crear tu experiencia web. Comprueba tus credenciales.';
$_MODULE['<{braintreeofficial}prestashop>help_5c4a03273ee4e687ae2547a2416f59c0'] = '¿Es imposible acceder a la API a través de la cuenta Braintree?';
$_MODULE['<{braintreeofficial}prestashop>formaccount_5c4a03273ee4e687ae2547a2416f59c0'] = '¿Es imposible acceder a la API a través de la cuenta Braintree?';
$_MODULE['<{braintreeofficial}prestashop>messagesandbox_e8fdd95502f3d9eef321833fe60aed0c'] = 'Modo Sandbox: todas las transacciones serán ficticias';
$_MODULE['<{braintreeofficial}prestashop>adminbraintreeofficialcontroller_b38308023e216ac4faf73789566556c2'] = 'Modo Sandbox: es el entorno de prueba en el que no podrás cobrar ningún pago real';
6 changes: 4 additions & 2 deletions translations/fr.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* 2007-2020 PayPal
* 2007-2021 PayPal
*
* NOTICE OF LICENSE
*
Expand All @@ -18,7 +18,7 @@
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 PayPal
* @author 2007-2021 PayPal
* @author 202 ecommerce <[email protected]>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Expand Down Expand Up @@ -274,3 +274,5 @@
$_MODULE['<{braintreeofficial}prestashop>adminbraintreeofficialmigration_51a9f5fc2e4d9b1c8aa4a60a7c725243'] = 'Une erreur est survenue lors de la création de votre expérience web. Vérifiez vos identifiants.';
$_MODULE['<{braintreeofficial}prestashop>help_5c4a03273ee4e687ae2547a2416f59c0'] = 'Impossible d\'accéder à l\'API via le compte Braintree?';
$_MODULE['<{braintreeofficial}prestashop>formaccount_5c4a03273ee4e687ae2547a2416f59c0'] = 'Impossible d\'accéder à l\'API via le compte Braintree?';
$_MODULE['<{braintreeofficial}prestashop>messagesandbox_e8fdd95502f3d9eef321833fe60aed0c'] = 'Mode Sanbox: Toutes les transactions seront fictives';
$_MODULE['<{braintreeofficial}prestashop>adminbraintreeofficialcontroller_b38308023e216ac4faf73789566556c2'] = 'Mode Sanbox: est un environement de test sur lequel vous ne collecterez pas de paiements réels';
6 changes: 3 additions & 3 deletions translations/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* 2007-2020 PayPal
* 2007-2021 PayPal
*
* NOTICE OF LICENSE
*
Expand All @@ -17,8 +17,8 @@
* 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 2007-2020 PayPal
*
* @author 2007-2021 PayPal
* @author 202 ecommerce <[email protected]>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Expand Down
6 changes: 4 additions & 2 deletions translations/it.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* 2007-2020 PayPal
* 2007-2021 PayPal
*
* NOTICE OF LICENSE
*
Expand All @@ -18,7 +18,7 @@
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 PayPal
* @author 2007-2021 PayPal
* @author 202 ecommerce <[email protected]>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Expand Down Expand Up @@ -273,3 +273,5 @@
$_MODULE['<{braintreeofficial}prestashop>adminbraintreeofficialmigration_51a9f5fc2e4d9b1c8aa4a60a7c725243'] = 'Errore durante la creazione della tua esperienza web. Controlla le credenziali.';
$_MODULE['<{braintreeofficial}prestashop>help_5c4a03273ee4e687ae2547a2416f59c0'] = 'Impossibile accedere all\'API tramite l\'account Braintree?';
$_MODULE['<{braintreeofficial}prestashop>formaccount_5c4a03273ee4e687ae2547a2416f59c0'] = 'Impossibile accedere all\'API tramite l\'account Braintree?';
$_MODULE['<{braintreeofficial}prestashop>messagesandbox_e8fdd95502f3d9eef321833fe60aed0c'] = 'Modalità Sandbox: tutte le transazioni saranno fittizie';
$_MODULE['<{braintreeofficial}prestashop>adminbraintreeofficialcontroller_b38308023e216ac4faf73789566556c2'] = 'Modalità Sandbox: è l\'ambiente di prova dove non sarete in grado di raccogliere alcun pagamento reale';
Loading

0 comments on commit 8a5b9fd

Please sign in to comment.