first commit

This commit is contained in:
2024-11-11 18:46:54 +01:00
commit a630d17338
25634 changed files with 4923715 additions and 0 deletions

View File

@@ -0,0 +1,287 @@
<?php
/**
* 2007-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
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,32 @@
<?php
/**
* 2007-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\classes\Shortcut\Form\Field;
interface FieldInteface
{
public function render();
}

View File

@@ -0,0 +1,107 @@
<?php
/**
* 2007-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\classes\Shortcut\Form\Field;
use Context;
use PayPalHttp\Serializer\Text;
class InputChain implements FieldInteface
{
/** @var TextInput[]*/
protected $inputs;
/** @var string*/
protected $label;
public function __construct($inputs)
{
$this->setInputs($inputs);
}
public function render()
{
return Context::getContext()->smarty
->assign('inputs', $this->getInputs())
->assign('label', $this->getLabel())
->fetch(_PS_MODULE_DIR_ . 'paypal/views/templates/admin/_partials/form/fields/inputChain.tpl');
}
/**
* @param TextInput[] $inputs
* @return InputChain
*/
public function setInputs($inputs)
{
$this->inputs = [];
if (empty($inputs)) {
return $this;
}
foreach ($inputs as $input) {
$this->addInput($input);
}
return $this;
}
/**
* @param TextInput $input
* @return InputChain
*/
public function addInput(TextInput $input)
{
$this->inputs[] = $input;
return $this;
}
/**
* @return TextInput[]
*/
public function getInputs()
{
return $this->inputs;
}
/**
* @return string
*/
public function getLabel()
{
return (string) $this->label;
}
/**
* @param string $label
* @return InputChain
*/
public function setLabel($label)
{
$this->label = $label;
return $this;
}
}

View File

@@ -0,0 +1,249 @@
<?php
/**
* 2007-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\classes\Shortcut\Form\Field;
use Context;
class Select implements FieldInteface
{
/** @var string*/
protected $name;
/** @var array*/
protected $options;
/** @var string*/
protected $label;
/** @var mixed*/
protected $value;
/** @var string*/
protected $type;
/** @var string*/
protected $afterSelectContent;
/** @var string*/
protected $css;
/** @var string*/
protected $hint;
public function __construct($name, $options, $label = null, $value = null, $type = null, $hint = null, $css = null)
{
$this->setName($name);
$this->setOptions($options);
$this->setLabel($label);
$this->setValue($value);
$this->setType($type);
$this->setHint($hint);
}
public function render()
{
if (false === empty($this->options)) {
foreach ($this->options as $key => $option) {
if ($this->getValue() == $option->getValue()) {
$option->setIsSelected(true);
}
}
}
return Context::getContext()->smarty
->assign('name', $this->getName())
->assign('options', $this->getOptions())
->assign('label', $this->getLabel())
->assign('configType', $this->getType())
->assign('afterSelectContent', $this->getAfterSelectContent())
->assign('css', $this->getCss())
->fetch(_PS_MODULE_DIR_ . 'paypal/views/templates/admin/_partials/form/fields/select.tpl');
}
/**
* @return string
*/
public function getName()
{
return (string) $this->name;
}
/**
* @param string $name
* @return Select
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @return SelectOption[]
*/
public function getOptions()
{
return $this->options;
}
/**
* @param array $options
* @return Select
*/
public function setOptions($options)
{
$this->options = [];
if (empty($options)) {
return $this;
}
foreach ($options as $option) {
$this->addOption($option);
}
return $this;
}
/**
* @param SelectOption $option
* @return Select
*/
public function addOption(SelectOption $option)
{
$this->options[] = $option;
return $this;
}
/**
* @return string
*/
public function getLabel()
{
return (string) $this->label;
}
/**
* @param string $label
* @return Select
*/
public function setLabel($label)
{
$this->label = $label;
return $this;
}
/**
* @return mixed
*/
public function getValue()
{
return $this->value;
}
/**
* @param mixed $value
* @return Select
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* @return string
*/
public function getType()
{
return (string) $this->type;
}
/**
* @param string $type
* @return Select
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* @return string
*/
public function getAfterSelectContent()
{
return (string) $this->afterSelectContent;
}
/**
* @param string $afterSelectContent
* @return Select
*/
public function setAfterSelectContent($afterSelectContent)
{
$this->afterSelectContent = (string) $afterSelectContent;
return $this;
}
/**
* @return string
*/
public function getCss()
{
return (string) $this->css;
}
/**
* @param string $css
* @return Select
*/
public function setCss($css)
{
$this->css = $css;
return $this;
}
/**
* @return string
*/
public function getHint()
{
return (string) $this->hint;
}
/**
* @param string $hint
* @return Select
*/
public function setHint($hint)
{
$this->hint = $hint;
return $this;
}
}

View File

@@ -0,0 +1,110 @@
<?php
/**
* 2007-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\classes\Shortcut\Form\Field;
use Context;
class SelectOption implements FieldInteface
{
/** @var string*/
protected $description;
/** @var string*/
protected $value;
/** @var bool*/
protected $isSelected;
public function __construct($value, $description)
{
$this->setDescription($description);
$this->setValue($value);
}
public function render()
{
return Context::getContext()->smarty
->assign('value', $this->getValue())
->assign('description', $this->getDescription())
->assign('isSelected', $this->isSelected())
->fetch(_PS_MODULE_DIR_ . 'paypal/views/templates/admin/_partials/form/fields/selectOption.tpl');
}
/**
* @return string
*/
public function getDescription()
{
return (string) $this->description;
}
/**
* @param string $description
* @return SelectOption
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* @return string
*/
public function getValue()
{
return (string) $this->value;
}
/**
* @param string $value
* @return SelectOption
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* @return bool
*/
public function isSelected()
{
return (bool) $this->isSelected;
}
/**
* @param bool $isSelected
* @return SelectOption
*/
public function setIsSelected($isSelected)
{
$this->isSelected = (bool) $isSelected;
return $this;
}
}

View File

@@ -0,0 +1,162 @@
<?php
/**
* 2007-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\classes\Shortcut\Form\Field;
use Context;
class TextInput implements FieldInteface
{
/** @var string*/
protected $name;
/** @var string*/
protected $value;
/** @var string*/
protected $label;
/** @var string*/
protected $type;
/** @var array*/
protected $attributes;
public function __construct($name, $value, $label, $type = null, $attributes = null)
{
$this->setName($name);
$this->setValue($value);
$this->setLabel($label);
$this->setType($type);
$this->setAttributes($attributes);
}
public function render()
{
return Context::getContext()->smarty
->assign('name', $this->getName())
->assign('value', $this->getValue())
->assign('label', $this->getLabel())
->assign('configType', $this->getType())
->assign('attributes', $this->getAttributes())
->fetch(_PS_MODULE_DIR_ . 'paypal/views/templates/admin/_partials/form/fields/textInput.tpl');
}
/**
* @return string
*/
public function getName()
{
return (string) $this->name;
}
/**
* @param string $name
* @return TextInput
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @return string
*/
public function getValue()
{
return (string) $this->value;
}
/**
* @param string $value
* @return TextInput
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* @return string
*/
public function getLabel()
{
return (string) $this->label;
}
/**
* @param string $label
* @return TextInput
*/
public function setLabel($label)
{
$this->label = $label;
return $this;
}
/**
* @return string
*/
public function getType()
{
return (string) $this->type;
}
/**
* @param string $type
* @return TextInput
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* @return array
*/
public function getAttributes()
{
return (array) $this->attributes;
}
/**
* @param array $attributes
* @return TextInput
*/
public function setAttributes($attributes)
{
if (false === is_array($attributes)) {
return $this;
}
$this->attributes = $attributes;
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,145 @@
<?php
/**
* 2007-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\classes\Shortcut;
use Context;
use Media;
use Module;
use PaypalAddons\classes\AbstractMethodPaypal;
use Symfony\Component\VarDumper\VarDumper;
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());
return $this->context->smarty->fetch($this->getTemplatePath());
}
/**
* @return []
*/
protected function getJSvars()
{
$JSvars = [];
$JSvars['sc_init_url'] = $this->context->link->getModuleLink($this->module->name, 'ScInit', array(), true);
$JSvars['scOrderUrl'] = $this->context->link->getModuleLink($this->module->name, 'scOrder', array(), true);
$JSvars['styleSetting'] = $this->getStyleSetting();
return $JSvars;
}
/**
* @return []
*/
protected function getJS()
{
$JSscripts = [];
foreach (Media::getJqueryPath() as $index => $lib) {
$JSscripts['jq-lib-' . $index] = $lib;
}
$JSscripts['paypal-lib'] = $this->method->getUrlJsSdkLib();
$JSscripts['shortcut'] = '/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;
}
}

View File

@@ -0,0 +1,78 @@
<?php
/**
* 2007-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
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 = array(
'shop_url' => $shop_url,
'PayPal_payment_type' => $this->getMethodType(),
'action_url' => $this->context->link->getModuleLink($this->module->name, 'ScInit', array(), 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-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
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,186 @@
<?php
/**
* 2007-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
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 _PS_MODULE_DIR_ . 'paypal/views/templates/shortcut/shortcut-preview.tpl';
}
protected function getJS()
{
$jsScripts = [];
$jsScripts['paypal-lib'] = $this->method->getUrlJsSdkLib();
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,92 @@
<?php
/**
* 2007-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\classes\Shortcut;
use Configuration;
use Symfony\Component\VarDumper\VarDumper;
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 = array(
'shop_url' => $shop_url,
'PayPal_payment_type' => $this->getMethodType(),
'action_url' => $this->context->link->getModuleLink($this->module->name, 'ScInit', array(), 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,60 @@
<?php
/**
* 2007-2020 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-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\classes\Shortcut;
use Configuration;
class ShortcutSignup extends ShortcutCart
{
protected function 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;
}
}

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;