first commit

This commit is contained in:
2024-10-28 22:14:22 +01:00
commit b65352c452
40581 changed files with 5712079 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
drwxr-xr-x 3 30094 users 10 Oct 6 10:16 .
drwxr-xr-x 8 30094 users 20 Oct 6 10:16 ..
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 Form
-rw-r--r-- 1 30094 users 3837 Oct 14 2021 ShortcutAbstract.php
-rw-r--r-- 1 30094 users 3078 Oct 14 2021 ShortcutCart.php
-rw-r--r-- 1 30094 users 4444 Oct 14 2021 ShortcutConfiguration.php
-rw-r--r-- 1 30094 users 4027 Oct 14 2021 ShortcutPreview.php
-rw-r--r-- 1 30094 users 3564 Oct 14 2021 ShortcutProduct.php
-rw-r--r-- 1 30094 users 2909 Oct 14 2021 ShortcutSignup.php
-rw-r--r-- 1 30094 users 1399 Oct 14 2021 index.php

View File

@@ -0,0 +1,4 @@
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 .
drwxr-xr-x 3 30094 users 10 Oct 6 10:16 ..
drwxr-xr-x 2 30094 users 4 Oct 6 10:16 Definition
-rw-r--r-- 1 30094 users 1399 Oct 14 2021 index.php

View File

@@ -0,0 +1,4 @@
drwxr-xr-x 2 30094 users 4 Oct 6 10:16 .
drwxr-xr-x 3 30094 users 4 Oct 6 10:16 ..
-rw-r--r-- 1 30094 users 5823 Oct 14 2021 CustomizeButtonStyleSectionDefinition.php
-rw-r--r-- 1 30094 users 1399 Oct 14 2021 index.php

View File

@@ -0,0 +1,311 @@
<?php
/**
* 2007-2022 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 license@prestashop.com 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
namespace PaypalAddons\classes\Shortcut\Form\Definition;
class CustomizeButtonStyleSectionDefinition
{
/** @var string */
protected $nameColor;
/** @var int */
protected $typeColor;
/** @var string */
protected $nameShape;
/** @var int */
protected $typeShape;
/** @var string */
protected $nameLabel;
/** @var int */
protected $typeLabel;
/** @var string */
protected $nameWidth;
/** @var int */
protected $typeWidth;
/** @var string */
protected $nameHeight;
/** @var int */
protected $typeHeight;
/** @var array */
protected $errors;
/**
* @return string
*/
public function getNameColor()
{
return (string) $this->nameColor;
}
/**
* @param string $nameColor
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function setNameColor($nameColor)
{
$this->nameColor = $nameColor;
return $this;
}
/**
* @return int
*/
public function getTypeColor()
{
return (int) $this->typeColor;
}
/**
* @param int $typeColor
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function setTypeColor($typeColor)
{
$this->typeColor = $typeColor;
return $this;
}
/**
* @return string
*/
public function getNameShape()
{
return (string) $this->nameShape;
}
/**
* @param string $nameShape
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function setNameShape($nameShape)
{
$this->nameShape = $nameShape;
return $this;
}
/**
* @return int
*/
public function getTypeShape()
{
return (int) $this->typeShape;
}
/**
* @param int $typeShape
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function setTypeShape($typeShape)
{
$this->typeShape = $typeShape;
return $this;
}
/**
* @return string
*/
public function getNameLabel()
{
return (string) $this->nameLabel;
}
/**
* @param string $nameLabel
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function setNameLabel($nameLabel)
{
$this->nameLabel = $nameLabel;
return $this;
}
/**
* @return int
*/
public function getTypeLabel()
{
return (int) $this->typeLabel;
}
/**
* @param int $typeLabel
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function setTypeLabel($typeLabel)
{
$this->typeLabel = $typeLabel;
return $this;
}
/**
* @return string
*/
public function getNameWidth()
{
return (string) $this->nameWidth;
}
/**
* @param string $nameWidth
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function setNameWidth($nameWidth)
{
$this->nameWidth = $nameWidth;
return $this;
}
/**
* @return int
*/
public function getTypeWidth()
{
return (int) $this->typeWidth;
}
/**
* @param int $typeWidth
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function setTypeWidth($typeWidth)
{
$this->typeWidth = $typeWidth;
return $this;
}
/**
* @return string
*/
public function getNameHeight()
{
return (string) $this->nameHeight;
}
/**
* @param string $nameHeight
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function setNameHeight($nameHeight)
{
$this->nameHeight = $nameHeight;
return $this;
}
/**
* @return int
*/
public function getTypeHeight()
{
return (int) $this->typeHeight;
}
/**
* @param int $typeHeight
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function setTypeHeight($typeHeight)
{
$this->typeHeight = $typeHeight;
return $this;
}
/**
* @return array
*/
public function getErrors()
{
if (false === is_array($this->errors)) {
return [];
}
return $this->errors;
}
/**
* @param array $errors
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function setErrors($errors)
{
if (false === is_array($errors) || empty($errors)) {
$this->errors = [];
return $this;
}
foreach ($errors as $error) {
$this->addError($error);
}
return $this;
}
/**
* @param string $error
*
* @return CustomizeButtonStyleSectionDefinition
*/
public function addError($error)
{
if (false === is_string($error)) {
return $this;
}
$this->errors[] = $error;
return $this;
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to a commercial license from SARL 202 ecommence
* Use, copy, modification or distribution of this source file without written
* license agreement from the SARL 202 ecommence is strictly forbidden.
* In order to obtain a license, please contact us: tech@202-ecommerce.com
* ...........................................................................
* INFORMATION SUR LA LICENCE D'UTILISATION
*
* L'utilisation de ce fichier source est soumise a une licence commerciale
* concedee par la societe 202 ecommence
* Toute utilisation, reproduction, modification ou distribution du present
* fichier source sans contrat de licence ecrit de la part de la SARL 202 ecommence est
* expressement interdite.
* Pour obtenir une licence, veuillez contacter 202-ecommerce <tech@202-ecommerce.com>
* ...........................................................................
*
* @author 202-ecommerce <tech@202-ecommerce.com>
* @copyright Copyright (c) 202-ecommerce
* @license Commercial license
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,33 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to a commercial license from SARL 202 ecommence
* Use, copy, modification or distribution of this source file without written
* license agreement from the SARL 202 ecommence is strictly forbidden.
* In order to obtain a license, please contact us: tech@202-ecommerce.com
* ...........................................................................
* INFORMATION SUR LA LICENCE D'UTILISATION
*
* L'utilisation de ce fichier source est soumise a une licence commerciale
* concedee par la societe 202 ecommence
* Toute utilisation, reproduction, modification ou distribution du present
* fichier source sans contrat de licence ecrit de la part de la SARL 202 ecommence est
* expressement interdite.
* Pour obtenir une licence, veuillez contacter 202-ecommerce <tech@202-ecommerce.com>
* ...........................................................................
*
* @author 202-ecommerce <tech@202-ecommerce.com>
* @copyright Copyright (c) 202-ecommerce
* @license Commercial license
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,180 @@
<?php
/**
* 2007-2022 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 license@prestashop.com 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
namespace PaypalAddons\classes\Shortcut;
use Context;
use Hook;
use Module;
use PaypalAddons\classes\AbstractMethodPaypal;
use PaypalAddons\services\PaypalMedia;
abstract class ShortcutAbstract
{
/** @var Context */
protected $context;
/** @var Module */
protected $module;
/** @var AbstractMethodPaypal */
protected $method;
/** @var string */
protected $id;
public function __construct()
{
$this->context = Context::getContext();
$this->module = Module::getInstanceByName('paypal');
$this->method = AbstractMethodPaypal::load($this->getMethodType());
$this->setId(uniqid());
}
/**
* @return string html
*/
public function render()
{
$this->context->smarty->assign($this->getTplVars());
$this->context->smarty->assign('JSvars', $this->getJSvars());
$this->context->smarty->assign('JSscripts', $this->getJS());
$this->context->smarty->assign('psPaypalDir', _PS_MODULE_DIR_ . 'paypal');
return $this->context->smarty->fetch($this->getTemplatePath());
}
/**
* @return []
*/
protected function getJSvars()
{
$JSvars = [];
$JSvars['sc_init_url'] = $this->context->link->getModuleLink($this->module->name, 'ScInit', [], true);
$JSvars['scOrderUrl'] = $this->context->link->getModuleLink($this->module->name, 'scOrder', [], true);
$JSvars['styleSetting'] = $this->getStyleSetting();
return $JSvars;
}
/**
* @return []
*/
protected function getJS()
{
$JSscripts = [];
if ($this->isAddJquery()) {
foreach ($this->getJqueryPath() as $index => $lib) {
$JSscripts['jq-lib-' . $index] = ['src' => $lib];
}
}
$JSscripts['tot-paypal-sdk'] = [
'src' => $this->method->getUrlJsSdkLib(),
'data-namespace' => 'totPaypalSdkButtons',
];
$JSscripts['shortcut'] = [
'src' => __PS_BASE_URI__ . 'modules/' . $this->module->name . '/views/js/shortcut.js?v=' . $this->module->version,
];
return $JSscripts;
}
/**
* @return string|null
*/
protected function getMethodType()
{
return null;
}
/**
* @return string
*/
protected function getTemplatePath()
{
return 'module:paypal/views/templates/shortcut/shortcut-layout.tpl';
}
/**
* @return []
*/
abstract protected function getTplVars();
protected function getStyleSetting()
{
$styleSetting = [];
$styleSetting['label'] = 'pay';
$styleSetting['height'] = 35;
return $styleSetting;
}
/**
* @return int
*/
public function getId()
{
return (string) $this->id;
}
/**
* @param string $id
*
* @return ShortcutAbstract
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/** @return []*/
public function getJqueryPath()
{
return $this->getPaypalMedia()->getJqueryPath();
}
/** @return PaypalMedia*/
public function getPaypalMedia()
{
return new PaypalMedia();
}
public function isAddJquery()
{
$isAddJquery = version_compare(_PS_VERSION_, '1.7.7', '<');
try {
Hook::exec('actionPaypalShortcutIsAddJquery', ['isAddJquery' => &$isAddJquery]);
} catch (\Throwable $e) {
}
return $isAddJquery;
}
}

View File

@@ -0,0 +1,78 @@
<?php
/**
* 2007-2022 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 license@prestashop.com 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
namespace PaypalAddons\classes\Shortcut;
use Configuration;
use Tools;
class ShortcutCart extends ShortcutAbstract
{
protected function getTemplatePath()
{
return 'module:paypal/views/templates/shortcut/shortcut-cart.tpl';
}
protected function getTplVars()
{
$environment = ($this->method->isSandbox() ? 'sandbox' : 'live');
$shop_url = $this->context->link->getBaseLink($this->context->shop->id, true);
$return = [
'shop_url' => $shop_url,
'PayPal_payment_type' => $this->getMethodType(),
'action_url' => $this->context->link->getModuleLink($this->module->name, 'ScInit', [], true),
'ec_sc_in_context' => Configuration::get('PAYPAL_EXPRESS_CHECKOUT_IN_CONTEXT'),
'merchant_id' => Configuration::get('PAYPAL_MERCHANT_ID_' . Tools::strtoupper($environment)),
'environment' => $environment,
];
return $return;
}
protected function getStyleSetting()
{
if (Configuration::get(ShortcutConfiguration::CUSTOMIZE_STYLE)) {
$styleSetting = [
'label' => Configuration::get(ShortcutConfiguration::STYLE_LABEL_CART, null, null, null, ShortcutConfiguration::STYLE_LABEL_CHECKOUT),
'color' => Configuration::get(ShortcutConfiguration::STYLE_COLOR_CART, null, null, null, ShortcutConfiguration::STYLE_COLOR_GOLD),
'shape' => Configuration::get(ShortcutConfiguration::STYLE_SHAPE_CART, null, null, null, ShortcutConfiguration::STYLE_SHAPE_RECT),
'height' => (int) Configuration::get(ShortcutConfiguration::STYLE_HEIGHT_CART, null, null, null, 35),
'width' => (int) Configuration::get(ShortcutConfiguration::STYLE_WIDTH_CART, null, null, null, 200),
];
} else {
$styleSetting = [
'label' => ShortcutConfiguration::STYLE_LABEL_CHECKOUT,
'color' => ShortcutConfiguration::STYLE_COLOR_GOLD,
'shape' => ShortcutConfiguration::STYLE_SHAPE_RECT,
'height' => 35,
'width' => 200,
];
}
return $styleSetting;
}
}

View File

@@ -0,0 +1,142 @@
<?php
/**
* 2007-2022 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 license@prestashop.com 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
namespace PaypalAddons\classes\Shortcut;
class ShortcutConfiguration
{
const SHOW_ON_SIGNUP_STEP = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_SIGNUP';
const SHOW_ON_CART_PAGE = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_CART';
const SHOW_ON_PRODUCT_PAGE = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT';
const CUSTOMIZE_STYLE = 'PAYPAL_EXPRESS_CHECKOUT_CUSTOMIZE_SHORTCUT_STYLE';
const DISPLAY_MODE_PRODUCT = 'PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_PRODUCT';
const DISPLAY_MODE_SIGNUP = 'PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_SIGNUP';
const DISPLAY_MODE_CART = 'PAYPAL_EXPRESS_CHECKOUT_DISPLAY_MODE_CART';
const DISPLAY_MODE_TYPE_HOOK = 1;
const DISPLAY_MODE_TYPE_WIDGET = 2;
const HOOK_PRODUCT_ACTIONS = 'displayProductActions';
const HOOK_REASSURANCE = 'displayReassurance';
const HOOK_AFTER_PRODUCT_THUMBS = 'displayAfterProductThumbs';
const HOOK_AFTER_PRODUCT_ADDITIONAL_INFO = 'displayProductAdditionalInfo';
const HOOK_FOOTER_PRODUCT = 'displayFooterProduct';
const HOOK_EXPRESS_CHECKOUT = 'displayExpressCheckout';
const HOOK_SHOPPING_CART_FOOTER = 'displayShoppingCartFooter';
const HOOK_PERSONAL_INFORMATION_TOP = 'displayPersonalInformationTop';
const PRODUCT_PAGE_HOOK = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_HOOK_PRODUCT';
const CART_PAGE_HOOK = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_HOOK_CART';
const STYLE_LABEL_PRODUCT = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_LABEL_PRODUCT';
const STYLE_LABEL_CART = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_LABEL_CART';
const STYLE_LABEL_SIGNUP = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_LABEL_SIGNUP';
const STYLE_HEIGHT_PRODUCT = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_HEIGHT_PRODUCT';
const STYLE_HEIGHT_CART = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_HEIGHT_CART';
const STYLE_HEIGHT_SIGNUP = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_HEIGHT_SIGNUP';
const STYLE_WIDTH_PRODUCT = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_WIDTH_PRODUCT';
const STYLE_WIDTH_CART = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_WIDTH_CART';
const STYLE_WIDTH_SIGNUP = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_WIDTH_SIGNUP';
const STYLE_COLOR_PRODUCT = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_COLOR_PRODUCT';
const STYLE_COLOR_CART = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_COLOR_CART';
const STYLE_COLOR_SIGNUP = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_COLOR_SIGNUP';
const STYLE_SHAPE_PRODUCT = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_SHAPE_PRODUCT';
const STYLE_SHAPE_CART = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_SHAPE_CART';
const STYLE_SHAPE_SIGNUP = 'PAYPAL_EXPRESS_CHECKOUT_SHORTCUT_STYLE_SHAPE_SIGNUP';
const TYPE_STYLE_SELECT = 1;
const TYPE_STYLE_TEXT = 2;
const STYLE_COLOR_GOLD = 'gold';
const STYLE_COLOR_BLUE = 'blue';
const STYLE_COLOR_SILVER = 'silver';
const STYLE_COLOR_WHITE = 'white';
const STYLE_COLOR_BLACK = 'black';
const STYLE_SHAPE_RECT = 'rect';
const STYLE_SHAPE_PILL = 'pill';
const STYLE_LABEL_PAYPAL = 'paypal';
const STYLE_LABEL_CHECKOUT = 'checkout';
const STYLE_LABEL_BUYNOW = 'buynow';
const STYLE_LABEL_PAY = 'pay';
const CONFIGURATION_TYPE_COLOR = 'color';
const CONFIGURATION_TYPE_SHAPE = 'shape';
const CONFIGURATION_TYPE_LABEL = 'label';
const CONFIGURATION_TYPE_WIDTH = 'width';
const CONFIGURATION_TYPE_HEIGHT = 'height';
const SOURCE_PAGE_PRODUCT = 1;
const SOURCE_PAGE_CART = 2;
const SOURCE_PAGE_SIGNUP = 3;
const USE_OLD_HOOK = 'PAYPAL_USE_OLD_HOOK';
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* 2007-2022 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 license@prestashop.com 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
namespace PaypalAddons\classes\Shortcut;
use Configuration;
use MethodMB;
use PaypalAddons\classes\AbstractMethodPaypal;
use Tools;
class ShortcutPaymentStep extends ShortcutAbstract
{
public function __construct()
{
parent::__construct();
if ($this->method instanceof MethodMB) {
$this->method = AbstractMethodPaypal::load('EC');
}
}
public function getTemplatePath()
{
return 'module:paypal/views/templates/shortcut/shortcut-payment-step.tpl';
}
/**
* @return []
*/
protected function getTplVars()
{
$environment = ($this->method->isSandbox() ? 'sandbox' : 'live');
$shop_url = $this->context->link->getBaseLink($this->context->shop->id, true);
$return = [
'shop_url' => $shop_url,
'PayPal_payment_type' => $this->getMethodType(),
'action_url' => $this->context->link->getModuleLink($this->module->name, 'ScInit', [], true),
'ec_sc_in_context' => true,
'merchant_id' => Configuration::get('PAYPAL_MERCHANT_ID_' . Tools::strtoupper($environment)),
'environment' => $environment,
];
return $return;
}
protected function getJSvars()
{
$vars = parent::getJSvars();
$vars['scOrderUrl'] = $this->method->getReturnUrl();
return $vars;
}
}

View File

@@ -0,0 +1,199 @@
<?php
/**
* 2007-2022 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 license@prestashop.com 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
namespace PaypalAddons\classes\Shortcut;
class ShortcutPreview extends ShortcutAbstract
{
/** @var string */
protected $label = null;
/** @var int */
protected $height = null;
/** @var int */
protected $width = null;
/** @var string */
protected $color = null;
/** @var string */
protected $shape = null;
public function __construct(
$label,
$height,
$width,
$color,
$shape
) {
parent::__construct();
$this->label = $label;
$this->height = $height;
$this->width = $width;
$this->color = $color;
$this->shape = $shape;
}
/**
* @return []
*/
protected function getTplVars()
{
return [
'shortcutID' => $this->getId(),
'styleSetting' => $this->getStyleSetting(),
];
}
protected function getTemplatePath()
{
return 'extends:' . _PS_MODULE_DIR_ . 'paypal/views/templates/shortcut/shortcut-layout.tpl|' . _PS_MODULE_DIR_ . 'paypal/views/templates/shortcut/shortcut-preview.tpl';
}
protected function getJS()
{
$jsScripts = [];
$jsScripts['tot-paypal-sdk'] = [
'src' => $this->method->getUrlJsSdkLib(),
'data-namespace' => 'totPaypalSdkButtons',
];
return $jsScripts;
}
protected function getStyleSetting()
{
return [
'label' => $this->getLabel(),
'height' => $this->getHeight(),
'width' => $this->getWidth(),
'color' => $this->getColor(),
'shape' => $this->getShape(),
];
}
/**
* @return string
*/
public function getLabel()
{
return (string) $this->label;
}
/**
* @param string $label
*
* @return ShortcutPreview
*/
public function setLabel($label)
{
$this->label = (string) $label;
return $this;
}
/**
* @return int
*/
public function getHeight()
{
return (int) $this->height;
}
/**
* @param int $height
*
* @return ShortcutPreview
*/
public function setHeight($height)
{
$this->height = (int) $height;
return $this;
}
/**
* @return int
*/
public function getWidth()
{
return (int) $this->width;
}
/**
* @param int $width
*
* @return ShortcutPreview
*/
public function setWidth($width)
{
$this->width = $width;
return $this;
}
/**
* @return string
*/
public function getColor()
{
return (string) $this->color;
}
/**
* @param string $color
*
* @return ShortcutPreview
*/
public function setColor($color)
{
$this->color = $color;
return $this;
}
/**
* @return string
*/
public function getShape()
{
return (string) $this->shape;
}
/**
* @param string $shape
*
* @return ShortcutPreview
*/
public function setShape($shape)
{
$this->shape = $shape;
return $this;
}
}

View File

@@ -0,0 +1,91 @@
<?php
/**
* 2007-2022 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 license@prestashop.com 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
namespace PaypalAddons\classes\Shortcut;
use Configuration;
use Tools;
class ShortcutProduct extends ShortcutAbstract
{
protected $idProduct;
protected $idProductAttribute;
public function __construct($idProduct, $idProductAttribute = null)
{
parent::__construct();
$this->idProduct = $idProduct;
$this->idProductAttribute = $idProductAttribute;
}
protected function getTemplatePath()
{
return 'module:paypal/views/templates/shortcut/shortcut-product.tpl';
}
protected function getTplVars()
{
$environment = ($this->method->isSandbox() ? 'sandbox' : 'live');
$shop_url = $this->context->link->getBaseLink($this->context->shop->id, true);
$return = [
'shop_url' => $shop_url,
'PayPal_payment_type' => $this->getMethodType(),
'action_url' => $this->context->link->getModuleLink($this->module->name, 'ScInit', [], true),
'ec_sc_in_context' => Configuration::get('PAYPAL_EXPRESS_CHECKOUT_IN_CONTEXT'),
'merchant_id' => Configuration::get('PAYPAL_MERCHANT_ID_' . Tools::strtoupper($environment)),
'environment' => $environment,
'es_cs_product_attribute' => $this->idProductAttribute ? $this->idProductAttribute : '',
'paypalIdProduct' => $this->idProduct,
];
return $return;
}
protected function getStyleSetting()
{
if (Configuration::get(ShortcutConfiguration::CUSTOMIZE_STYLE)) {
$styleSetting = [
'label' => Configuration::get(ShortcutConfiguration::STYLE_LABEL_PRODUCT, null, null, null, ShortcutConfiguration::STYLE_LABEL_BUYNOW),
'color' => Configuration::get(ShortcutConfiguration::STYLE_COLOR_PRODUCT, null, null, null, ShortcutConfiguration::STYLE_COLOR_GOLD),
'shape' => Configuration::get(ShortcutConfiguration::STYLE_SHAPE_PRODUCT, null, null, null, ShortcutConfiguration::STYLE_SHAPE_RECT),
'height' => (int) Configuration::get(ShortcutConfiguration::STYLE_HEIGHT_PRODUCT, null, null, null, 35),
'width' => (int) Configuration::get(ShortcutConfiguration::STYLE_WIDTH_PRODUCT, null, null, null, 200),
];
} else {
$styleSetting = [
'label' => ShortcutConfiguration::STYLE_LABEL_BUYNOW,
'color' => ShortcutConfiguration::STYLE_COLOR_GOLD,
'shape' => ShortcutConfiguration::STYLE_SHAPE_RECT,
'height' => 35,
'width' => 200,
];
}
return $styleSetting;
}
}

View File

@@ -0,0 +1,93 @@
<?php
/**
* 2007-2022 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 license@prestashop.com 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
namespace PaypalAddons\classes\Shortcut;
use Configuration;
class ShortcutSignup extends ShortcutCart
{
/** @var bool */
protected $isWidget;
public function __construct()
{
parent::__construct();
$this->setIsWidget(false);
}
protected function getTemplatePath()
{
if ($this->isWidget()) {
return parent::getTemplatePath();
}
return 'module:paypal/views/templates/shortcut/shortcut-signup.tpl';
}
protected function getStyleSetting()
{
if (Configuration::get(ShortcutConfiguration::CUSTOMIZE_STYLE)) {
$styleSetting = [
'label' => Configuration::get(ShortcutConfiguration::STYLE_LABEL_SIGNUP, null, null, null, ShortcutConfiguration::STYLE_LABEL_CHECKOUT),
'color' => Configuration::get(ShortcutConfiguration::STYLE_COLOR_SIGNUP, null, null, null, ShortcutConfiguration::STYLE_COLOR_GOLD),
'shape' => Configuration::get(ShortcutConfiguration::STYLE_SHAPE_SIGNUP, null, null, null, ShortcutConfiguration::STYLE_SHAPE_RECT),
'height' => (int) Configuration::get(ShortcutConfiguration::STYLE_HEIGHT_SIGNUP, null, null, null, 35),
'width' => (int) Configuration::get(ShortcutConfiguration::STYLE_WIDTH_SIGNUP, null, null, null, 200),
];
} else {
$styleSetting = [
'label' => ShortcutConfiguration::STYLE_LABEL_CHECKOUT,
'color' => ShortcutConfiguration::STYLE_COLOR_GOLD,
'shape' => ShortcutConfiguration::STYLE_SHAPE_RECT,
'height' => 35,
'width' => 200,
];
}
return $styleSetting;
}
/**
* @return bool
*/
public function isWidget()
{
return $this->isWidget;
}
/**
* @param bool $isWidget
*
* @return ShortcutSignup
*/
public function setIsWidget($isWidget)
{
$this->isWidget = $isWidget;
return $this;
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to a commercial license from SARL 202 ecommence
* Use, copy, modification or distribution of this source file without written
* license agreement from the SARL 202 ecommence is strictly forbidden.
* In order to obtain a license, please contact us: tech@202-ecommerce.com
* ...........................................................................
* INFORMATION SUR LA LICENCE D'UTILISATION
*
* L'utilisation de ce fichier source est soumise a une licence commerciale
* concedee par la societe 202 ecommence
* Toute utilisation, reproduction, modification ou distribution du present
* fichier source sans contrat de licence ecrit de la part de la SARL 202 ecommence est
* expressement interdite.
* Pour obtenir une licence, veuillez contacter 202-ecommerce <tech@202-ecommerce.com>
* ...........................................................................
*
* @author 202-ecommerce <tech@202-ecommerce.com>
* @copyright Copyright (c) 202-ecommerce
* @license Commercial license
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;