V1.3.2 released: Guest Checkout, New Designed Checkout Page, Custom CMS Link, Data cleaner Module
This commit is contained in:
@@ -33,4 +33,4 @@ after_failure:
|
||||
- cat /etc/apache2/sites-available/000-default.conf
|
||||
- sudo cat /var/log/php-fpm.log
|
||||
- sudo ls -l /var/log/apache2
|
||||
- sudo cat /var/log/apache2/other_vhosts_access.log
|
||||
- sudo cat /var/log/apache2/other_vhosts_access.log
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
####################################
|
||||
# V1.3.2
|
||||
####################################
|
||||
|
||||
## Added Features:
|
||||
|
||||
[+] CO : pscleaner module is added for cleaning demo data from QloApps.
|
||||
|
||||
[+] FO : Option for Guest checkout is given at Preferences->Orders tab. So Guest Checkout is enabled.
|
||||
|
||||
[+] FO : Option for Shorter registration/address form is given at Preferences->Customers tab. (In this case address will be created from customer chosen room type's hotel address automatically).
|
||||
|
||||
[+] CO : wkfooterexploreblock :: Admin can add custom explore links to show at footer explore block and navigation menu also. table 'htl_custom_explore_link' added with multilang.
|
||||
|
||||
## Improved/changed features:
|
||||
|
||||
[-] BO : New category option from "quick access" links is removed.
|
||||
[+] FO : Checkout page design has been changed.
|
||||
[+] CO : Images validation improved.
|
||||
|
||||
|
||||
## Bug/Issues Resolved:
|
||||
|
||||
[-] CO : 56% Installation issue.
|
||||
|
||||
[-] BO : Dashboard graphs not loading issues on php 7.2
|
||||
[-] BO : feature update issue on not selecting image while updating the feature.
|
||||
[-] BO : Category bug resolve (Should not be created updated deleted from anywhere). Will be handled from hotel creation/updation/deletion.
|
||||
|
||||
|
||||
####################################
|
||||
# V1.3.1
|
||||
####################################
|
||||
@@ -342,4 +372,4 @@
|
||||
[-] MO : wktestimonialblock : Fixed while adding the image in valid format on configuration page then showing error page.
|
||||
[-] MO : wkpaypaladaptive : Fixed paypal is not working because paypal api has been changed.
|
||||
[-] MO : wkpaypaladaptive : Fixed fopen issues fixed, done by CURL.
|
||||
[-] MO : wkpaypaladaptive : Fixed payment negative value bug fixed.
|
||||
[-] MO : wkpaypaladaptive : Fixed payment negative value bug fixed.
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
<div id="category_block">
|
||||
{$category_tree}
|
||||
</div>
|
||||
<a class="btn btn-link bt-icon confirm_leave" href="{$link->getAdminLink('AdminCategories')|escape:'html':'UTF-8'}&addcategory">
|
||||
{* <a class="btn btn-link bt-icon confirm_leave" href="{$link->getAdminLink('AdminCategories')|escape:'html':'UTF-8'}&addcategory">
|
||||
<i class="icon-plus-sign"></i> {l s='Create new category'} <i class="icon-external-link-sign"></i>
|
||||
</a>
|
||||
</a> *}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
@@ -203,6 +203,8 @@ class AddressCore extends ObjectModel
|
||||
if (Validate::isUnsignedId($this->id_customer)) {
|
||||
Customer::resetAddressCache($this->id_customer, $this->id);
|
||||
}
|
||||
// reset checkout process if addresses deletes
|
||||
CheckoutProcess::refreshCheckoutProcess();
|
||||
|
||||
if (!$this->isUsed()) {
|
||||
return parent::delete();
|
||||
|
||||
@@ -433,10 +433,11 @@ class CategoryCore extends ObjectModel
|
||||
}
|
||||
$right = (int)$n++;
|
||||
|
||||
Db::getInstance()->execute('
|
||||
UPDATE '._DB_PREFIX_.'category
|
||||
SET nleft = '.(int)$left.', nright = '.(int)$right.'
|
||||
WHERE id_category = '.(int)$id_category.' LIMIT 1');
|
||||
Db::getInstance()->execute(
|
||||
'UPDATE '._DB_PREFIX_.'category
|
||||
SET nleft = '.(int)$left.', nright = '.(int)$right.'
|
||||
WHERE id_category = '.(int)$id_category.' LIMIT 1'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ class FeatureCore extends ObjectModel
|
||||
'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
||||
|
||||
/* Lang fields */
|
||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
|
||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -418,8 +418,7 @@ class HookCore extends ObjectModel
|
||||
*
|
||||
* @return string/array modules output
|
||||
*/
|
||||
public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true,
|
||||
$use_push = false, $id_shop = null)
|
||||
public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true, $use_push = false, $id_shop = null)
|
||||
{
|
||||
if (defined('PS_INSTALLATION_IN_PROGRESS')) {
|
||||
return;
|
||||
@@ -462,7 +461,11 @@ class HookCore extends ObjectModel
|
||||
|
||||
// Look on modules list
|
||||
$altern = 0;
|
||||
$output = '';
|
||||
if ($array_return) {
|
||||
$output = array();
|
||||
} else {
|
||||
$output = '';
|
||||
}
|
||||
|
||||
if ($disable_non_native_modules && !isset(Hook::$native_module)) {
|
||||
Hook::$native_module = Module::getNativeModuleList();
|
||||
|
||||
82
classes/checkoutProcess/AbstractCheckoutStep.php
Normal file
82
classes/checkoutProcess/AbstractCheckoutStep.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* 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 PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
abstract class AbstractCheckoutStep implements CheckoutStepInterface
|
||||
{
|
||||
public $step_is_reachable = 0;
|
||||
public $step_is_complete = 0;
|
||||
public $step_is_current = 0;
|
||||
public $step_key;
|
||||
private $checkoutProcess;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
|
||||
public function setCheckoutProcess(CheckoutProcess $checkoutProcess)
|
||||
{
|
||||
$this->checkoutProcess = $checkoutProcess;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setReachable($step_is_reachable)
|
||||
{
|
||||
$this->step_is_reachable = $step_is_reachable;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isReachable()
|
||||
{
|
||||
return $this->step_is_reachable;
|
||||
}
|
||||
|
||||
public function setComplete($step_is_complete)
|
||||
{
|
||||
$this->step_is_complete = $step_is_complete;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isComplete()
|
||||
{
|
||||
return $this->step_is_complete;
|
||||
}
|
||||
|
||||
public function setCurrent($step_is_current)
|
||||
{
|
||||
$this->step_is_current = $step_is_current;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isCurrent()
|
||||
{
|
||||
return $this->step_is_current;
|
||||
}
|
||||
}
|
||||
44
classes/checkoutProcess/CheckoutCartSummaryStep.php
Normal file
44
classes/checkoutProcess/CheckoutCartSummaryStep.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2018 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through this link for complete license : https://store.webkul.com/license.html
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to newer
|
||||
* versions in the future. If you wish to customize this module for your
|
||||
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
|
||||
*
|
||||
* @author Webkul IN <support@webkul.com>
|
||||
* @copyright 2010-2018 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
class CheckoutCartSummaryStep extends AbstractCheckoutStep
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->step_key = 'checkout_rooms_summary';
|
||||
}
|
||||
|
||||
public function handleRequest()
|
||||
{
|
||||
// set data in checkout_session cookie
|
||||
if (Tools::getValue('proceed_to_customer_dtl')) {
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_complete = 1;
|
||||
$this->step_is_current = 0;
|
||||
$this->context->cookie->__set('cart_summary_proceeded', 1);
|
||||
} elseif ($this->context->cookie->__get('cart_summary_proceeded')) {
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_complete = 1;
|
||||
$this->step_is_current = 0;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
77
classes/checkoutProcess/CheckoutCustomerDetailsStep.php
Normal file
77
classes/checkoutProcess/CheckoutCustomerDetailsStep.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2018 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through this link for complete license : https://store.webkul.com/license.html
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to newer
|
||||
* versions in the future. If you wish to customize this module for your
|
||||
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
|
||||
*
|
||||
* @author Webkul IN <support@webkul.com>
|
||||
* @copyright 2010-2018 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
class CheckoutCustomerDetailsStep extends AbstractCheckoutStep
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->step_key = 'checkout_customer';
|
||||
}
|
||||
|
||||
public function handleRequest()
|
||||
{
|
||||
$idAddressDelivery = $this->context->cart->id_address_delivery;
|
||||
$objAddress = new Address($idAddressDelivery);
|
||||
if (Tools::getValue('proceed_to_customer_dtl')) {
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_current = 1;
|
||||
if ($idAddressDelivery) {
|
||||
if (!Validate::isLoadedObject($objAddress)) {
|
||||
if ($this->context->cookie->__get('customer_details_proceeded')) {
|
||||
$this->step_is_current = 0;
|
||||
$this->step_is_complete = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (Tools::getValue('proceed_to_payment')) {
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_current = 1;
|
||||
if ($idAddressDelivery) {
|
||||
if (Validate::isLoadedObject($objAddress)) {
|
||||
$this->step_is_current = 0;
|
||||
$this->step_is_complete = 1;
|
||||
$this->context->cookie->__set('customer_details_proceeded', 1);
|
||||
}
|
||||
}
|
||||
} elseif ($this->context->cookie->__get('customer_details_proceeded')
|
||||
|| $this->context->cookie->__get('cart_summary_proceeded')
|
||||
) {
|
||||
if ($idAddressDelivery) {
|
||||
if (!Validate::isLoadedObject($objAddress)) {
|
||||
$this->context->cookie->__set('customer_details_proceeded', 0);
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_current = 1;
|
||||
}
|
||||
} else {
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_current = 1;
|
||||
$this->context->cookie->__set('customer_details_proceeded', 0);
|
||||
}
|
||||
} elseif ($this->context->customer->logged) {
|
||||
$this->step_is_reachable = 1;
|
||||
if ($idAddressDelivery) {
|
||||
$this->step_is_complete = 1;
|
||||
} else {
|
||||
$this->step_is_complete = 0;
|
||||
$this->step_is_current = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
classes/checkoutProcess/CheckoutPaymentStep.php
Normal file
37
classes/checkoutProcess/CheckoutPaymentStep.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2018 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through this link for complete license : https://store.webkul.com/license.html
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to newer
|
||||
* versions in the future. If you wish to customize this module for your
|
||||
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
|
||||
*
|
||||
* @author Webkul IN <support@webkul.com>
|
||||
* @copyright 2010-2018 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
class CheckoutPaymentStep extends AbstractCheckoutStep
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->step_key = 'checkout_payment';
|
||||
}
|
||||
|
||||
public function handleRequest()
|
||||
{
|
||||
if ($this->context->cookie->__get('customer_details_proceeded')) {
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_current = 1;
|
||||
$this->step_is_complete = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
109
classes/checkoutProcess/CheckoutProcess.php
Normal file
109
classes/checkoutProcess/CheckoutProcess.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2018 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through this link for complete license : https://store.webkul.com/license.html
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to newer
|
||||
* versions in the future. If you wish to customize this module for your
|
||||
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
|
||||
*
|
||||
* @author Webkul IN <support@webkul.com>
|
||||
* @copyright 2010-2018 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
class CheckoutProcess
|
||||
{
|
||||
public $steps = array();
|
||||
|
||||
public function handleRequest()
|
||||
{
|
||||
foreach ($this->steps as $step) {
|
||||
$step->handleRequest();
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addStep(CheckoutStepInterface $step)
|
||||
{
|
||||
$step->setCheckoutProcess($this);
|
||||
$this->steps[] = $step;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSteps()
|
||||
{
|
||||
return $this->steps;
|
||||
}
|
||||
|
||||
public function setNextStepReachable()
|
||||
{
|
||||
foreach ($this->getSteps() as $step) {
|
||||
if (!$step->isReachable()) {
|
||||
$step->setReachable(true);
|
||||
break;
|
||||
}
|
||||
if (!$step->isComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function markCurrentStep()
|
||||
{
|
||||
$steps = $this->getSteps();
|
||||
|
||||
foreach ($steps as $step) {
|
||||
if ($step->isCurrent()) {
|
||||
// If a step marked itself as current
|
||||
// then we assume it has a good reason
|
||||
// to do so and we don't auto-advance.
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($steps as $position => $step) {
|
||||
$nextStep = ($position < count($steps) - 1) ? $steps[$position + 1] : null;
|
||||
|
||||
if ($step->isReachable() && (!$step->isComplete() || ($nextStep && !$nextStep->isReachable()))) {
|
||||
$step->setCurrent(true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function invalidateAllStepsAfterCurrent()
|
||||
{
|
||||
$markAsUnreachable = false;
|
||||
foreach ($this->getSteps() as $step) {
|
||||
if ($markAsUnreachable) {
|
||||
$step->setComplete(false)->setReachable(false);
|
||||
}
|
||||
|
||||
if ($step->isCurrent()) {
|
||||
$markAsUnreachable = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// if any event occurred which is changing cart/address/payment/customer then reset cehckout cookies
|
||||
public static function refreshCheckoutProcess()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$context->cookie->__set('cart_summary_proceeded', 0);
|
||||
$context->cookie->__set('customer_details_proceeded', 0);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2018 Webkul.
|
||||
*
|
||||
@@ -17,11 +18,7 @@
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
$(document).ready(function()
|
||||
interface CheckoutStepInterface
|
||||
{
|
||||
$(".jsFooterTraverseBlock").on("click", function() {
|
||||
var block = $(this).attr('data-block');
|
||||
$('html ,body').animate({
|
||||
scrollTop:$(block).offset().top}, 2000);
|
||||
});
|
||||
});
|
||||
public function handleRequest();
|
||||
}
|
||||
@@ -45,6 +45,11 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// redirect to admin dashboard as no entry allowed in category controller. It will be managed solely from
|
||||
// hotel creation , updation and deletion
|
||||
$this->context = Context::getContext();
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminDashboard'));
|
||||
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'category';
|
||||
$this->className = 'Category';
|
||||
@@ -54,8 +59,6 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
$this->_defaultOrderBy = 'position';
|
||||
$this->allow_export = true;
|
||||
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$this->fieldImageSettings = array(
|
||||
'name' => 'image',
|
||||
'dir' => 'c'
|
||||
|
||||
@@ -113,6 +113,13 @@ class AdminCustomerPreferencesControllerCore extends AdminController
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_CUSTOMER_ADDRESS_CREATION' => array(
|
||||
'title' => $this->l('Enable customer address creation at checkout'),
|
||||
'hint' => $this->l('If disabled, At checkout process, guest has to fill only personal details and address will be created according to the hotel address which rooms guest has in his cart. If enabled, guest has to fill his address details in checkout process.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
),
|
||||
'submit' => array('title' => $this->l('Save')),
|
||||
),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -73,13 +73,13 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
'value' => PS_ORDER_PROCESS_OPC,
|
||||
'identifier' => 'value',
|
||||
),*/
|
||||
/*'PS_GUEST_CHECKOUT_ENABLED' => array(
|
||||
'PS_GUEST_CHECKOUT_ENABLED' => array(
|
||||
'title' => $this->l('Enable guest checkout'),
|
||||
'hint' => $this->l('Allow guest visitors to place an order without registering.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'hidden'
|
||||
),*/
|
||||
'type' => 'bool'
|
||||
),
|
||||
/*'PS_DISALLOW_HISTORY_REORDERING' => array(
|
||||
'title' => $this->l('Disable Reordering Option'),
|
||||
'hint' => $this->l('Disable the option to allow customers to reorder in one click from the order history page (required in some European countries).'),
|
||||
|
||||
@@ -476,12 +476,14 @@ class AdminProductsControllerCore extends AdminController
|
||||
$full_tree = Tools::getValue('fullTree', 0);
|
||||
$use_check_box = Tools::getValue('useCheckBox', 1);
|
||||
$selected = Tools::getValue('selected', array());
|
||||
$id_tree = Tools::getValue('type');
|
||||
$input_name = str_replace(array('[', ']'), '', Tools::getValue('inputName', null));
|
||||
|
||||
$tree = new HelperTreeCategories('subtree_associated_categories');
|
||||
$tree->setTemplate('subtree_associated_categories.tpl')
|
||||
->setUseCheckBox($use_check_box)
|
||||
->setUseSearch(true)
|
||||
->setUseSearch(false)
|
||||
->setIdTree($id_tree)
|
||||
->setSelectedCategories($selected)
|
||||
->setFullTree($full_tree)
|
||||
->setChildrenOnly(true)
|
||||
@@ -3666,7 +3668,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
->setHeaderTemplate('tree_associated_header.tpl')
|
||||
->setRootCategory($root->id)
|
||||
->setUseCheckBox(true)
|
||||
->setUseSearch(true)
|
||||
->setUseSearch(false)
|
||||
->setFullTree(0)
|
||||
->setSelectedCategories($categories);
|
||||
|
||||
$data->assign(array('default_category' => $default_category,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -72,14 +72,19 @@ class CartControllerCore extends FrontController
|
||||
if ($this->context->cookie->exists() && !$this->errors && !($this->context->customer->isLogged() && !$this->isTokenValid())) {
|
||||
if (Tools::getIsset('add') || Tools::getIsset('update')) {
|
||||
$this->processChangeProductInCart();
|
||||
CheckoutProcess::refreshCheckoutProcess();
|
||||
} elseif (Tools::getIsset('delete')) {
|
||||
$this->processDeleteProductInCart();
|
||||
CheckoutProcess::refreshCheckoutProcess();
|
||||
} elseif (Tools::getIsset('changeAddressDelivery')) {
|
||||
$this->processChangeProductAddressDelivery();
|
||||
CheckoutProcess::refreshCheckoutProcess();
|
||||
} elseif (Tools::getIsset('allowSeperatedPackage')) {
|
||||
$this->processAllowSeperatedPackage();
|
||||
CheckoutProcess::refreshCheckoutProcess();
|
||||
} elseif (Tools::getIsset('duplicate')) {
|
||||
$this->processDuplicateProduct();
|
||||
CheckoutProcess::refreshCheckoutProcess();
|
||||
}
|
||||
// Make redirection
|
||||
if (!$this->errors && !$this->ajax) {
|
||||
@@ -392,7 +397,7 @@ class CartControllerCore extends FrontController
|
||||
if ($chkQty < $req_rm) {
|
||||
$obj_htl_cart_booking_data = new HotelCartBookingData();
|
||||
$obj_htl_cart_booking_data->id_cart = $this->context->cart->id;
|
||||
$obj_htl_cart_booking_data->id_guest = $this->context->cookie->id_guest;
|
||||
$obj_htl_cart_booking_data->id_guest = $this->context->cart->id_guest;
|
||||
$obj_htl_cart_booking_data->id_customer = $id_customer;
|
||||
$obj_htl_cart_booking_data->id_currency = $id_currency;
|
||||
$obj_htl_cart_booking_data->id_product = $val_hotel_room_info['id_product'];
|
||||
|
||||
@@ -68,7 +68,6 @@ class GuestTrackingControllerCore extends FrontController
|
||||
if (!empty($order_reference)) {
|
||||
$order_collection = Order::getByReference($order_reference);
|
||||
}
|
||||
|
||||
$email = Tools::getValue('email');
|
||||
|
||||
if (empty($order_reference) && empty($id_order)) {
|
||||
@@ -117,11 +116,12 @@ class GuestTrackingControllerCore extends FrontController
|
||||
if (count($this->errors)) {
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'action' => $this->context->link->getPageLink('guest-tracking.php', true),
|
||||
'errors' => $this->errors,
|
||||
));
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'action' => $this->context->link->getPageLink('guest-tracking.php', true),
|
||||
'errors' => $this->errors,
|
||||
)
|
||||
);
|
||||
$this->setTemplate(_PS_THEME_DIR_.'guest-tracking.tpl');
|
||||
}
|
||||
|
||||
@@ -143,7 +143,24 @@ class GuestTrackingControllerCore extends FrontController
|
||||
$order_list[] = $order;
|
||||
}
|
||||
|
||||
//by webkul to show order details properly on order history page
|
||||
if ($hotelresInstalled = Module::isInstalled('hotelreservationsystem')) {
|
||||
include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
|
||||
$objHtlBranchInfo = new HotelBranchInformation();
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$objRoomType = new HotelRoomType();
|
||||
$objCustomerAdv = new HotelCustomerAdvancedPayment();
|
||||
$objOrdRefundInfo = new HotelOrderRefundInfo();
|
||||
$objRefundStages = new HotelOrderRefundStages();
|
||||
|
||||
$nonRequestedRooms = 0;
|
||||
$anyBackOrder = 0;
|
||||
$processedProducts = array();
|
||||
$cartHotelData = array();
|
||||
}
|
||||
|
||||
foreach ($order_list as &$order) {
|
||||
$idOrder = $order->id;
|
||||
/** @var Order $order */
|
||||
$order->id_order_state = (int)$order->getCurrentState();
|
||||
$order->invoice = (OrderState::invoiceAvailable((int)$order->id_order_state) && $order->invoice_number);
|
||||
@@ -169,20 +186,155 @@ class GuestTrackingControllerCore extends FrontController
|
||||
}
|
||||
$order->hook_orderdetaildisplayed = Hook::exec('displayOrderDetail', array('order' => $order));
|
||||
|
||||
// enter the details of the booking the order
|
||||
if ($hotelresInstalled) {
|
||||
if ($orderProducts = $order->getProducts()) {
|
||||
foreach ($orderProducts as $type_key => $type_value) {
|
||||
if (in_array($type_value['product_id'], $processedProducts)) {
|
||||
continue;
|
||||
}
|
||||
$processedProducts[] = $type_value['product_id'];
|
||||
|
||||
$objProduct = new Product($type_value['product_id'], false, $this->context->language->id);
|
||||
$cover_image_arr = $objProduct->getCover($type_value['product_id']);
|
||||
|
||||
if (!empty($cover_image_arr)) {
|
||||
$cover_img = $this->context->link->getImageLink($objProduct->link_rewrite, $objProduct->id.'-'.$cover_image_arr['id_image'], 'small_default');
|
||||
} else {
|
||||
$cover_img = $this->context->link->getImageLink($objProduct->link_rewrite, $this->context->language->iso_code.'-default', 'small_default');
|
||||
}
|
||||
|
||||
if (isset($customer->id)) {
|
||||
$obj_cart = new Cart($order->id_cart);
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($idOrder, $obj_cart->id_guest, $type_value['product_id'], $customer->id);
|
||||
} else {
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($idOrder, $customer->id_guest, $type_value['product_id']);
|
||||
}
|
||||
$rm_dtl = $objRoomType->getRoomTypeInfoByIdProduct($type_value['product_id']);
|
||||
|
||||
$cartHotelData[$type_key]['id_product'] = $type_value['product_id'];
|
||||
$cartHotelData[$type_key]['cover_img'] = $cover_img;
|
||||
$cartHotelData[$type_key]['adult'] = $rm_dtl['adult'];
|
||||
$cartHotelData[$type_key]['children'] = $rm_dtl['children'];
|
||||
|
||||
// by webkul to calculate rates of the product from hotelreservation syatem tables with feature prices....
|
||||
|
||||
|
||||
//END
|
||||
foreach ($order_bk_data as $data_k => $data_v) {
|
||||
$date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']);
|
||||
|
||||
/*Product price when order was created*/
|
||||
$order_details_obj = new OrderDetail($data_v['id_order_detail']);
|
||||
$prod_ord_dtl_name = $order_details_obj->product_name;
|
||||
$cartHotelData[$type_key]['name'] = $prod_ord_dtl_name;
|
||||
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity;
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity;
|
||||
|
||||
//work on entring refund data
|
||||
|
||||
$ord_refnd_info = $objOrdRefundInfo->getOderRefundInfoByIdOrderIdProductByDate($idOrder, $type_value['product_id'], $data_v['date_from'], $data_v['date_to']);
|
||||
if ($ord_refnd_info) {
|
||||
$stage_name = $objRefundStages->getNameById($ord_refnd_info['refund_stage_id']);
|
||||
} else {
|
||||
$stage_name = '';
|
||||
$nonRequestedRooms = 1;
|
||||
}
|
||||
if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
|
||||
|
||||
$num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'];
|
||||
$var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']*$var_quant;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']*$var_quant;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$anyBackOrder = 1;
|
||||
}
|
||||
//refund_stage
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['stage_name'] = $stage_name;
|
||||
} else {
|
||||
$num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$anyBackOrder = 1;
|
||||
}
|
||||
//refund_stage
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['stage_name'] = $stage_name;
|
||||
}
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl;
|
||||
|
||||
$feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']);
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff;
|
||||
|
||||
//enter hotel name
|
||||
$hotelInfo = $objHtlBranchInfo->hotelBranchesInfo(
|
||||
Configuration::get('PS_LANG_DEFAULT'),
|
||||
2,
|
||||
0,
|
||||
$data_v['id_hotel']
|
||||
);
|
||||
$cartHotelData[$type_key]['hotel_name'] = $hotelInfo['hotel_name'];
|
||||
}
|
||||
}
|
||||
//For Advanced Payment
|
||||
$order_adv_dtl = $objCustomerAdv->getCstAdvPaymentDtlByIdOrder($idOrder);
|
||||
}
|
||||
}
|
||||
// end booking details entries
|
||||
$redirectTermsLink = $this->context->link->getCMSLink(
|
||||
new CMS(3, $this->context->language->id),
|
||||
null, $this->context->language->id
|
||||
);
|
||||
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'any_back_order' => $anyBackOrder,
|
||||
'shw_bo_msg' => Configuration::get('WK_SHOW_MSG_ON_BO'),
|
||||
'back_ord_msg' => Configuration::get('WK_BO_MESSAGE'),
|
||||
'order_has_invoice' => $order->hasInvoice(),
|
||||
'redirect_link_terms', $redirectTermsLink,
|
||||
'cart_htl_data' => $cartHotelData,
|
||||
'non_requested_rooms' => $nonRequestedRooms,
|
||||
'order_adv_dtl' => $order_adv_dtl
|
||||
)
|
||||
);
|
||||
//end
|
||||
|
||||
Hook::exec('actionOrderDetail', array('carrier' => $order->carrier, 'order' => $order));
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'shop_name' => Configuration::get('PS_SHOP_NAME'),
|
||||
'order_collection' => $order_list,
|
||||
'return_allowed' => false,
|
||||
'invoiceAllowed' => (int)Configuration::get('PS_INVOICE'),
|
||||
'is_guest' => true,
|
||||
'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC),
|
||||
'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE,
|
||||
'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD,
|
||||
'use_tax' => Configuration::get('PS_TAX'),
|
||||
));
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'shop_name' => Configuration::get('PS_SHOP_NAME'),
|
||||
'order_collection' => $order_list,
|
||||
'return_allowed' => false,
|
||||
'invoiceAllowed' => (int)Configuration::get('PS_INVOICE'),
|
||||
'is_guest' => true,
|
||||
'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC),
|
||||
'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE,
|
||||
'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD,
|
||||
'use_tax' => Configuration::get('PS_TAX'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
|
||||
@@ -321,21 +321,28 @@ class OrderDetailControllerCore extends FrontController
|
||||
$customer = new Customer($order->id_customer);
|
||||
|
||||
//by webkul to show order details properly on order history page
|
||||
if (Module::isInstalled('hotelreservationsystem')) {
|
||||
require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
|
||||
|
||||
if ($hotelresInstalled = Module::isInstalled('hotelreservationsystem')) {
|
||||
include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
|
||||
$objHtlBranchInfo = new HotelBranchInformation();
|
||||
$obj_cart_bk_data = new HotelCartBookingData();
|
||||
$obj_htl_bk_dtl = new HotelBookingDetail();
|
||||
$obj_rm_type = new HotelRoomType();
|
||||
$non_requested_rooms = 0;
|
||||
$any_back_order = 0;
|
||||
$processed_product = array();
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$objRoomType = new HotelRoomType();
|
||||
$objCustomerAdv = new HotelCustomerAdvancedPayment();
|
||||
$objOrdRefundInfo = new HotelOrderRefundInfo();
|
||||
|
||||
$nonRequestedRooms = 0;
|
||||
$anyBackOrder = 0;
|
||||
$processedProducts = array();
|
||||
$cartHotelData = array();
|
||||
}
|
||||
|
||||
if ($hotelresInstalled) {
|
||||
if (!empty($products)) {
|
||||
foreach ($products as $type_key => $type_value) {
|
||||
if (in_array($type_value['product_id'], $processed_product)) {
|
||||
if (in_array($type_value['product_id'], $processedProducts)) {
|
||||
continue;
|
||||
}
|
||||
$processed_product[] = $type_value['product_id'];
|
||||
$processedProducts[] = $type_value['product_id'];
|
||||
|
||||
$product = new Product($type_value['product_id'], false, $this->context->language->id);
|
||||
$cover_image_arr = $product->getCover($type_value['product_id']);
|
||||
@@ -348,85 +355,79 @@ class OrderDetailControllerCore extends FrontController
|
||||
|
||||
if (isset($customer->id)) {
|
||||
$obj_cart = new Cart($order->id_cart);
|
||||
$order_bk_data = $obj_htl_bk_dtl->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id);
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id);
|
||||
} else {
|
||||
$order_bk_data = $obj_htl_bk_dtl->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']);
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']);
|
||||
}
|
||||
$rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['product_id']);
|
||||
$rm_dtl = $objRoomType->getRoomTypeInfoByIdProduct($type_value['product_id']);
|
||||
|
||||
$cart_htl_data[$type_key]['id_product'] = $type_value['product_id'];
|
||||
$cart_htl_data[$type_key]['cover_img'] = $cover_img;
|
||||
$cart_htl_data[$type_key]['adult'] = $rm_dtl['adult'];
|
||||
$cart_htl_data[$type_key]['children'] = $rm_dtl['children'];
|
||||
$cartHotelData[$type_key]['id_product'] = $type_value['product_id'];
|
||||
$cartHotelData[$type_key]['cover_img'] = $cover_img;
|
||||
$cartHotelData[$type_key]['adult'] = $rm_dtl['adult'];
|
||||
$cartHotelData[$type_key]['children'] = $rm_dtl['children'];
|
||||
|
||||
// by webkul to calculate rates of the product from hotelreservation syatem tables with feature prices....
|
||||
|
||||
$hotelCartBookingData = new HotelCartBookingData();
|
||||
//END
|
||||
foreach ($order_bk_data as $data_k => $data_v) {
|
||||
$date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']);
|
||||
|
||||
/*Product price when order was created*/
|
||||
$order_details_obj = new OrderDetail($data_v['id_order_detail']);
|
||||
$prod_ord_dtl_name = $order_details_obj->product_name;
|
||||
$cart_htl_data[$type_key]['name'] = $prod_ord_dtl_name;
|
||||
$cartHotelData[$type_key]['name'] = $prod_ord_dtl_name;
|
||||
|
||||
$cart_htl_data[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity;
|
||||
$cart_htl_data[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity;
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity;
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity;
|
||||
|
||||
//work on entring refund data
|
||||
$obj_ord_ref_info = new HotelOrderRefundInfo();
|
||||
$ord_refnd_info = $obj_ord_ref_info->getOderRefundInfoByIdOrderIdProductByDate($id_order, $type_value['product_id'], $data_v['date_from'], $data_v['date_to']);
|
||||
$ord_refnd_info = $objOrdRefundInfo->getOderRefundInfoByIdOrderIdProductByDate($id_order, $type_value['product_id'], $data_v['date_from'], $data_v['date_to']);
|
||||
if ($ord_refnd_info) {
|
||||
$obj_refund_stages = new HotelOrderRefundStages();
|
||||
$stage_name = $obj_refund_stages->getNameById($ord_refnd_info['refund_stage_id']);
|
||||
$stage_name = $objRefundStages->getNameById($ord_refnd_info['refund_stage_id']);
|
||||
} else {
|
||||
$stage_name = '';
|
||||
$non_requested_rooms = 1;
|
||||
$nonRequestedRooms = 1;
|
||||
}
|
||||
if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) {
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
|
||||
if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
|
||||
|
||||
$num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'];
|
||||
$var_quant = (int) $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'];
|
||||
$num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'];
|
||||
$var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'];
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']*$var_quant;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']*$var_quant;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']*$var_quant;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']*$var_quant;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$any_back_order = 1;
|
||||
$anyBackOrder = 1;
|
||||
}
|
||||
//refund_stage
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['stage_name'] = $stage_name;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['stage_name'] = $stage_name;
|
||||
} else {
|
||||
$num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
|
||||
$num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$any_back_order = 1;
|
||||
$anyBackOrder = 1;
|
||||
}
|
||||
//refund_stage
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['stage_name'] = $stage_name;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['stage_name'] = $stage_name;
|
||||
}
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl;
|
||||
|
||||
$feature_price_diff = (float)($cart_htl_data[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff;
|
||||
$feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']);
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff;
|
||||
|
||||
//enter hotel name
|
||||
$hotelInfo = $objHtlBranchInfo->hotelBranchesInfo(
|
||||
@@ -435,66 +436,64 @@ class OrderDetailControllerCore extends FrontController
|
||||
0,
|
||||
$data_v['id_hotel']
|
||||
);
|
||||
$cart_htl_data[$type_key]['hotel_name'] = $hotelInfo['hotel_name'];
|
||||
$cartHotelData[$type_key]['hotel_name'] = $hotelInfo['hotel_name'];
|
||||
}
|
||||
}
|
||||
$redirect_link_terms = $this->context->link->getCMSLink(new CMS(3, $this->context->language->id), null, $this->context->language->id);
|
||||
$this->context->smarty->assign('redirect_link_terms', $redirect_link_terms);
|
||||
$this->context->smarty->assign('cart_htl_data', $cart_htl_data);
|
||||
$this->context->smarty->assign('non_requested_rooms', $non_requested_rooms);
|
||||
$redirectTermsLink = $this->context->link->getCMSLink(new CMS(3, $this->context->language->id), null, $this->context->language->id);
|
||||
|
||||
//For Advanced Payment
|
||||
$obj_customer_adv = new HotelCustomerAdvancedPayment();
|
||||
$order_adv_dtl = $obj_customer_adv->getCstAdvPaymentDtlByIdOrder($order->id);
|
||||
if ($order_adv_dtl) {
|
||||
$this->context->smarty->assign('order_adv_dtl', $order_adv_dtl);
|
||||
}
|
||||
$orderAdvDetail = $objCustomerAdv->getCstAdvPaymentDtlByIdOrder($order->id);
|
||||
|
||||
$shw_bo_msg = Configuration::get('WK_SHOW_MSG_ON_BO');
|
||||
$bo_msg = Configuration::get('WK_BO_MESSAGE');
|
||||
$this->context->smarty->assign(array(
|
||||
'any_back_order' => $any_back_order,
|
||||
'shw_bo_msg' => $shw_bo_msg,
|
||||
'back_ord_msg' => $bo_msg,
|
||||
));
|
||||
$order_has_invoice = $order->hasInvoice();
|
||||
$this->context->smarty->assign('order_has_invoice', $order_has_invoice);
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'any_back_order' => $anyBackOrder,
|
||||
'shw_bo_msg' => Configuration::get('WK_SHOW_MSG_ON_BO'),
|
||||
'back_ord_msg' => Configuration::get('WK_BO_MESSAGE'),
|
||||
'order_has_invoice' => $order->hasInvoice(),
|
||||
'redirect_link_terms', $redirectTermsLink,
|
||||
'cart_htl_data' => $cartHotelData,
|
||||
'non_requested_rooms' => $nonRequestedRooms,
|
||||
'order_adv_dtl' => $orderAdvDetail
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
//end
|
||||
$this->context->smarty->assign(array(
|
||||
'shop_name' => strval(Configuration::get('PS_SHOP_NAME')),
|
||||
'order' => $order,
|
||||
'return_allowed' => (int) $order->isReturnable(),
|
||||
'currency' => new Currency($order->id_currency),
|
||||
'order_state' => (int) $id_order_state,
|
||||
'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'),
|
||||
'invoice' => (OrderState::invoiceAvailable($id_order_state) && count($order->getInvoicesCollection())),
|
||||
'logable' => (bool) $order_status->logable,
|
||||
'order_history' => $order->getHistory($this->context->language->id, false, true),
|
||||
'products' => $products,
|
||||
'discounts' => $order->getCartRules(),
|
||||
'carrier' => $carrier,
|
||||
'address_invoice' => $addressInvoice,
|
||||
'invoiceState' => (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state) ? new State($addressInvoice->id_state) : false,
|
||||
'address_delivery' => $addressDelivery,
|
||||
'inv_adr_fields' => $inv_adr_fields,
|
||||
'dlv_adr_fields' => $dlv_adr_fields,
|
||||
'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues,
|
||||
'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues,
|
||||
'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) ? new State($addressDelivery->id_state) : false,
|
||||
'is_guest' => false,
|
||||
'messages' => CustomerMessage::getMessagesByOrderId((int) $order->id, false),
|
||||
'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE,
|
||||
'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD,
|
||||
'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'),
|
||||
'use_tax' => Configuration::get('PS_TAX'),
|
||||
'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC),
|
||||
/* DEPRECATED: customizedDatas @since 1.5 */
|
||||
'customizedDatas' => $customizedDatas,
|
||||
/* DEPRECATED: customizedDatas @since 1.5 */
|
||||
'reorderingAllowed' => !(bool) Configuration::get('PS_DISALLOW_HISTORY_REORDERING'),
|
||||
));
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'shop_name' => strval(Configuration::get('PS_SHOP_NAME')),
|
||||
'order' => $order,
|
||||
'return_allowed' => (int) $order->isReturnable(),
|
||||
'currency' => new Currency($order->id_currency),
|
||||
'order_state' => (int) $id_order_state,
|
||||
'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'),
|
||||
'invoice' => (OrderState::invoiceAvailable($id_order_state) && count($order->getInvoicesCollection())),
|
||||
'logable' => (bool) $order_status->logable,
|
||||
'order_history' => $order->getHistory($this->context->language->id, false, true),
|
||||
'products' => $products,
|
||||
'discounts' => $order->getCartRules(),
|
||||
'carrier' => $carrier,
|
||||
'address_invoice' => $addressInvoice,
|
||||
'invoiceState' => (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state) ? new State($addressInvoice->id_state) : false,
|
||||
'address_delivery' => $addressDelivery,
|
||||
'inv_adr_fields' => $inv_adr_fields,
|
||||
'dlv_adr_fields' => $dlv_adr_fields,
|
||||
'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues,
|
||||
'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues,
|
||||
'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) ? new State($addressDelivery->id_state) : false,
|
||||
'is_guest' => false,
|
||||
'messages' => CustomerMessage::getMessagesByOrderId((int) $order->id, false),
|
||||
'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE,
|
||||
'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD,
|
||||
'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'),
|
||||
'use_tax' => Configuration::get('PS_TAX'),
|
||||
'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC),
|
||||
/* DEPRECATED: customizedDatas @since 1.5 */
|
||||
'customizedDatas' => $customizedDatas,
|
||||
/* DEPRECATED: customizedDatas @since 1.5 */
|
||||
'reorderingAllowed' => !(bool) Configuration::get('PS_DISALLOW_HISTORY_REORDERING'),
|
||||
)
|
||||
);
|
||||
|
||||
if ($carrier->url && $order->shipping_number) {
|
||||
$this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
|
||||
|
||||
@@ -382,33 +382,65 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($this->context->cart->id_address_delivery) {
|
||||
// send address formatted layout data
|
||||
if (Validate::isLoadedObject($address = new Address($this->context->cart->id_address_delivery))) {
|
||||
$addressLayout = AddressFormat::getFormattedLayoutData($address);
|
||||
$orderedAddressFields = AddressFormat::getOrderedAddressFields($address->id_country, false, true);
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'orderedAddressFields' => $orderedAddressFields,
|
||||
'addressLayout' => $addressLayout
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'free_shipping' => $free_shipping,
|
||||
'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0,
|
||||
'countries' => $countries,
|
||||
'sl_country' => (int)Tools::getCountry(),
|
||||
'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'),
|
||||
'errorCarrier' => Tools::displayError('You must choose a carrier.', false),
|
||||
'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false),
|
||||
'isPaymentStep' => isset($_GET['isPaymentStep']) && $_GET['isPaymentStep'],
|
||||
'genders' => Gender::getGenders(),
|
||||
'one_phone_at_least' => (int)Configuration::get('PS_ONE_PHONE_AT_LEAST'),
|
||||
'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'),
|
||||
'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')
|
||||
));
|
||||
// assign checkout process steps
|
||||
$this->setCheckoutProcess();
|
||||
|
||||
// if there is cookie variable in the url the redirect
|
||||
if (Tools::getValue('proceed_to_customer_dtl') || Tools::getValue('proceed_to_payment')) {
|
||||
Tools::redirect($this->context->link->getPageLink('order-opc', null, $this->context->language->id));
|
||||
}
|
||||
|
||||
$this->context->smarty->assign('checkout_process_steps', $this->checkoutProcess->getSteps());
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'THEME_DIR' => _THEME_DIR_,
|
||||
'PS_CUSTOMER_ADDRESS_CREATION' => Configuration::get('PS_CUSTOMER_ADDRESS_CREATION'),
|
||||
'free_shipping' => $free_shipping,
|
||||
'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0,
|
||||
'countries' => $countries,
|
||||
'sl_country' => (int)Tools::getCountry(),
|
||||
'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'),
|
||||
'errorCarrier' => Tools::displayError('You must choose a carrier.', false),
|
||||
'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false),
|
||||
'isPaymentStep' => isset($_GET['isPaymentStep']) && $_GET['isPaymentStep'],
|
||||
'genders' => Gender::getGenders(),
|
||||
'one_phone_at_least' => (int)Configuration::get('PS_ONE_PHONE_AT_LEAST'),
|
||||
'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'),
|
||||
'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')
|
||||
)
|
||||
);
|
||||
$years = Tools::dateYears();
|
||||
$months = Tools::dateMonths();
|
||||
$days = Tools::dateDays();
|
||||
$this->context->smarty->assign(array(
|
||||
'years' => $years,
|
||||
'months' => $months,
|
||||
'days' => $days,
|
||||
));
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'years' => $years,
|
||||
'months' => $months,
|
||||
'days' => $days,
|
||||
)
|
||||
);
|
||||
|
||||
/* Load guest informations */
|
||||
if ($this->isLogged && $this->context->cookie->is_guest) {
|
||||
$this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
|
||||
if ($this->isLogged) {
|
||||
if ($this->context->cookie->is_guest) {
|
||||
$this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
|
||||
} else {
|
||||
$this->context->smarty->assign('guestInformations', (array)$this->context->customer);
|
||||
}
|
||||
}
|
||||
// ADDRESS
|
||||
if ($this->isLogged) {
|
||||
@@ -433,11 +465,14 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
$id_product = Tools::getValue('id_product');
|
||||
$date_from = Tools::getValue('date_from');
|
||||
$date_to = Tools::getValue('date_to');
|
||||
|
||||
$obj_cart_bk_data = new HotelCartBookingData();
|
||||
$cart_data_dlt = $obj_cart_bk_data->deleteRoomDataFromOrderLine($this->context->cart->id, $this->context->cart->id_guest, $id_product, $date_from, $date_to);
|
||||
|
||||
if ($cart_data_dlt) {
|
||||
if ($cart_data_dlt = $obj_cart_bk_data->deleteRoomDataFromOrderLine(
|
||||
$this->context->cart->id,
|
||||
$this->context->cart->id_guest,
|
||||
$id_product,
|
||||
$date_from,
|
||||
$date_to
|
||||
)) {
|
||||
Tools::redirect($link->getPageLink('order-opc', null, $this->context->language->id));
|
||||
}
|
||||
}
|
||||
@@ -447,7 +482,7 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
$this->setTemplate(_PS_THEME_DIR_ . 'order-opc-advanced.tpl');
|
||||
} else {
|
||||
if (Module::isInstalled('hotelreservationsystem')) {
|
||||
require_once(_PS_MODULE_DIR_.'hotelreservationsystem/define.php');
|
||||
require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
|
||||
|
||||
$obj_cart_bk_data = new HotelCartBookingData();
|
||||
$obj_htl_bk_dtl = new HotelBookingDetail();
|
||||
@@ -498,9 +533,8 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
}
|
||||
}
|
||||
$this->context->smarty->assign('cartChanged', $cartChanged);
|
||||
$cart_htl_data = HotelCartBookingData::getHotelCartBookingData();
|
||||
if ($cart_htl_data) {
|
||||
$this->context->smarty->assign('cart_htl_data', $cart_htl_data);
|
||||
if ($cartBookingInfo = HotelCartBookingData::getHotelCartBookingData()) {
|
||||
$this->context->smarty->assign('cart_htl_data', $cartBookingInfo);
|
||||
}
|
||||
|
||||
// For Advanced Payment
|
||||
@@ -567,7 +601,6 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
$customer_adv_dtl['total_to_be_paid'] = ($customer_adv_dtl['total_paid_amount'] - $total_discount) > 0 ? ($customer_adv_dtl['total_paid_amount'] - $total_discount) : 0;
|
||||
$this->context->smarty->assign('customer_adv_dtl', $customer_adv_dtl);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign('adv_amount', $adv_amount);
|
||||
$this->context->smarty->assign('advance_payment_active', $advance_payment_active);
|
||||
}
|
||||
@@ -585,6 +618,25 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
}
|
||||
}
|
||||
|
||||
// sets checkout process steps as per current values
|
||||
private function setCheckoutProcess()
|
||||
{
|
||||
$this->checkoutProcess = new CheckoutProcess();
|
||||
// add the steps you want to add in checkout process
|
||||
$this->checkoutProcess
|
||||
->addStep(new CheckoutCartSummaryStep())
|
||||
->addStep(new CheckoutCustomerDetailsStep())
|
||||
->addStep(new CheckoutPaymentStep());
|
||||
|
||||
$this->checkoutProcess->handleRequest();
|
||||
|
||||
// for making steps synced
|
||||
$this->checkoutProcess
|
||||
->setNextStepReachable()
|
||||
->markCurrentStep()
|
||||
->invalidateAllStepsAfterCurrent();
|
||||
}
|
||||
|
||||
protected function _getGuestInformations()
|
||||
{
|
||||
$customer = $this->context->customer;
|
||||
@@ -866,7 +918,6 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
$dlv_adr_fields[] = trim($field_name);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($require_form_fields_list as $field_name) {
|
||||
if (!in_array($field_name, $inv_adr_fields)) {
|
||||
$inv_adr_fields[] = trim($field_name);
|
||||
@@ -886,11 +937,13 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
${$adr_type.'_adr_fields'} = array_unique(${$adr_type.'_adr_fields'});
|
||||
${$adr_type.'_all_fields'} = array_unique(${$adr_type.'_all_fields'});
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
$adr_type.'_adr_fields' => ${$adr_type.'_adr_fields'},
|
||||
$adr_type.'_all_fields' => ${$adr_type.'_all_fields'},
|
||||
'required_fields' => $require_form_fields_list
|
||||
));
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
$adr_type.'_adr_fields' => ${$adr_type.'_adr_fields'},
|
||||
$adr_type.'_all_fields' => ${$adr_type.'_all_fields'},
|
||||
'required_fields' => $require_form_fields_list
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,6 +244,7 @@ class InstallControllerConsoleProcess extends InstallControllerConsole
|
||||
'admin_lastname' => $this->datas->admin_lastname,
|
||||
'admin_password' => $this->datas->admin_password,
|
||||
'admin_email' => $this->datas->admin_email,
|
||||
'marketing_consent' => $this->datas->marketing_consent,
|
||||
'configuration_agrement' => true,
|
||||
'send_informations' => true,
|
||||
));
|
||||
|
||||
@@ -49,6 +49,7 @@ class InstallControllerHttpConfigure extends InstallControllerHttp
|
||||
$this->session->admin_lastname = trim(Tools::getValue('admin_lastname'));
|
||||
$this->session->admin_email = trim(Tools::getValue('admin_email'));
|
||||
$this->session->send_informations = Tools::getValue('send_informations');
|
||||
$this->session->marketing_consent = Tools::getValue('marketing_consent');
|
||||
if ($this->session->send_informations) {
|
||||
// Qlo Notification
|
||||
$qloData = [
|
||||
@@ -59,6 +60,7 @@ class InstallControllerHttpConfigure extends InstallControllerHttp
|
||||
'firstname' => Tools::ucfirst(Tools::getValue('admin_firstname')),
|
||||
'lastname' => Tools::ucfirst(Tools::getValue('admin_lastname')),
|
||||
'countryCode' => Tools::getValue('shop_country'),
|
||||
'marketingConsent' => Tools::getValue('marketing_consent'),
|
||||
];
|
||||
$objModelInstall = new InstallModelInstall();
|
||||
$objModelInstall->setNotification($qloData);
|
||||
|
||||
@@ -194,17 +194,18 @@ class InstallControllerHttpProcess extends InstallControllerHttp
|
||||
$this->initializeContext();
|
||||
|
||||
$success = $this->model_install->configureShop(array(
|
||||
'shop_name' => $this->session->shop_name,
|
||||
'shop_activity' => $this->session->shop_activity,
|
||||
'shop_country' => $this->session->shop_country,
|
||||
'shop_timezone' => $this->session->shop_timezone,
|
||||
'admin_firstname' => $this->session->admin_firstname,
|
||||
'admin_lastname' => $this->session->admin_lastname,
|
||||
'admin_password' => $this->session->admin_password,
|
||||
'admin_email' => $this->session->admin_email,
|
||||
'send_informations' => $this->session->send_informations,
|
||||
'configuration_agrement' => $this->session->configuration_agrement,
|
||||
'rewrite_engine' => $this->session->rewrite_engine,
|
||||
'shop_name' => $this->session->shop_name,
|
||||
'shop_activity' => $this->session->shop_activity,
|
||||
'shop_country' => $this->session->shop_country,
|
||||
'shop_timezone' => $this->session->shop_timezone,
|
||||
'admin_firstname' => $this->session->admin_firstname,
|
||||
'admin_lastname' => $this->session->admin_lastname,
|
||||
'admin_password' => $this->session->admin_password,
|
||||
'admin_email' => $this->session->admin_email,
|
||||
'marketing_consent' => $this->session->marketing_consent,
|
||||
'send_informations' => $this->session->send_informations,
|
||||
'configuration_agrement' => $this->session->configuration_agrement,
|
||||
'rewrite_engine' => $this->session->rewrite_engine,
|
||||
));
|
||||
|
||||
if (!$success || $this->model_install->getErrors()) {
|
||||
|
||||
@@ -160,4 +160,4 @@ class InstallControllerHttpSystem extends InstallControllerHttp
|
||||
|
||||
$this->displayTemplate('system');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
<field name="link"/>
|
||||
</fields>
|
||||
<entities>
|
||||
<quick_access id="New_category" new_window="0">
|
||||
<link>index.php?controller=AdminCategories&addcategory</link>
|
||||
</quick_access>
|
||||
<quick_access id="New_product" new_window="0">
|
||||
<link>index.php?controller=AdminProducts&addproduct</link>
|
||||
</quick_access>
|
||||
|
||||
@@ -69,9 +69,9 @@
|
||||
<tab id="Products" id_parent="Catalog" active="1" hide_host_mode="0">
|
||||
<class_name>AdminProducts</class_name>
|
||||
</tab>
|
||||
<tab id="Categories" id_parent="Catalog" active="1" hide_host_mode="0">
|
||||
<!-- <tab id="Categories" id_parent="Catalog" active="1" hide_host_mode="0">
|
||||
<class_name>AdminCategories</class_name>
|
||||
</tab>
|
||||
</tab> -->
|
||||
<!-- <tab id="Monitoring" id_parent="Catalog" active="1" hide_host_mode="0">
|
||||
<class_name>AdminTracking</class_name>
|
||||
</tab> -->
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<field name="id_shop"/>
|
||||
</fields>
|
||||
<entities>
|
||||
<connections id="connections_1" id_guest="guest_1" id_page="1" ip_address="10424105181" id_shop_group="1" id_shop="1">
|
||||
<connections id="connections_1" id_guest="guest_1" id_page="1" ip_address="2130706433" id_shop_group="1" id_shop="1">
|
||||
<http_referer>http://www.qloapps.com</http_referer>
|
||||
</connections>
|
||||
</entities>
|
||||
|
||||
@@ -25,4 +25,4 @@
|
||||
*/
|
||||
|
||||
define('_PS_INSTALL_VERSION_', '1.6.1.1');
|
||||
define('_QLO_INSTALL_VERSION_', '1.3.1');
|
||||
define('_QLO_INSTALL_VERSION_', '1.3.2');
|
||||
@@ -2,7 +2,6 @@
|
||||
<entity_quick_access>
|
||||
<quick_access id="Home" name="Home"/>
|
||||
<quick_access id="My_Shop" name="My Shop"/>
|
||||
<quick_access id="New_category" name="New category"/>
|
||||
<quick_access id="New_product" name="New product"/>
|
||||
<quick_access id="New_voucher" name="New voucher"/>
|
||||
</entity_quick_access>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<entity_quick_access>
|
||||
<quick_access id="Home" name="Home"/>
|
||||
<quick_access id="My_Shop" name="My Shop"/>
|
||||
<quick_access id="New_category" name="New category"/>
|
||||
<quick_access id="New_product" name="New product"/>
|
||||
<quick_access id="New_voucher" name="New voucher"/>
|
||||
</entity_quick_access>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<entity_quick_access>
|
||||
<quick_access id="Home" name="Home"/>
|
||||
<quick_access id="My_Shop" name="My Shop"/>
|
||||
<quick_access id="New_category" name="New category"/>
|
||||
<quick_access id="New_product" name="New product"/>
|
||||
<quick_access id="New_voucher" name="New voucher"/>
|
||||
</entity_quick_access>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<entity_quick_access>
|
||||
<quick_access id="Home" name="Home"/>
|
||||
<quick_access id="My_Shop" name="My Shop"/>
|
||||
<quick_access id="New_category" name="New category"/>
|
||||
<quick_access id="New_product" name="New product"/>
|
||||
<quick_access id="New_voucher" name="New voucher"/>
|
||||
</entity_quick_access>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<entity_quick_access>
|
||||
<quick_access id="Home" name="Home"/>
|
||||
<quick_access id="My_Shop" name="My Shop"/>
|
||||
<quick_access id="New_category" name="New category"/>
|
||||
<quick_access id="New_product" name="New product"/>
|
||||
<quick_access id="New_voucher" name="New voucher"/>
|
||||
</entity_quick_access>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<entity_quick_access>
|
||||
<quick_access id="Home" name="Home"/>
|
||||
<quick_access id="My_Shop" name="My Shop"/>
|
||||
<quick_access id="New_category" name="New category"/>
|
||||
<quick_access id="New_product" name="New product"/>
|
||||
<quick_access id="New_voucher" name="New voucher"/>
|
||||
</entity_quick_access>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<entity_quick_access>
|
||||
<quick_access id="Home" name="Home"/>
|
||||
<quick_access id="My_Shop" name="My Shop"/>
|
||||
<quick_access id="New_category" name="New category"/>
|
||||
<quick_access id="New_product" name="New product"/>
|
||||
<quick_access id="New_voucher" name="New voucher"/>
|
||||
</entity_quick_access>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<entity_quick_access>
|
||||
<quick_access id="Home" name="Home"/>
|
||||
<quick_access id="My_Shop" name="My Shop"/>
|
||||
<quick_access id="New_category" name="New category"/>
|
||||
<quick_access id="New_product" name="New product"/>
|
||||
<quick_access id="New_voucher" name="New voucher"/>
|
||||
</entity_quick_access>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<entity_quick_access>
|
||||
<quick_access id="Home" name="Home"/>
|
||||
<quick_access id="My_Shop" name="My Shop"/>
|
||||
<quick_access id="New_category" name="New category"/>
|
||||
<quick_access id="New_product" name="New product"/>
|
||||
<quick_access id="New_voucher" name="New voucher"/>
|
||||
</entity_quick_access>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<entity_quick_access>
|
||||
<quick_access id="Home" name="Home"/>
|
||||
<quick_access id="My_Shop" name="My Shop"/>
|
||||
<quick_access id="New_category" name="New category"/>
|
||||
<quick_access id="New_product" name="New product"/>
|
||||
<quick_access id="New_voucher" name="New voucher"/>
|
||||
</entity_quick_access>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<entity_quick_access>
|
||||
<quick_access id="Home" name="Home"/>
|
||||
<quick_access id="My_Shop" name="My Shop"/>
|
||||
<quick_access id="New_category" name="New category"/>
|
||||
<quick_access id="New_product" name="New product"/>
|
||||
<quick_access id="New_voucher" name="New voucher"/>
|
||||
</entity_quick_access>
|
||||
|
||||
@@ -611,6 +611,7 @@ class InstallModelInstall extends InstallAbstractModel
|
||||
'firstname' => Tools::ucfirst($data['admin_firstname']),
|
||||
'lastname' => Tools::ucfirst($data['admin_lastname']),
|
||||
'countryCode' => $data['shop_country'],
|
||||
'marketingConsent' => $data['marketing_consent'],
|
||||
];
|
||||
|
||||
// Qlo Notification
|
||||
|
||||
@@ -155,10 +155,14 @@ var default_iso = '<?php echo $this->session->shop_country ?>';
|
||||
</div>
|
||||
<?php echo $this->displayError('admin_password_confirm') ?>
|
||||
</div>
|
||||
<br />
|
||||
<span><small><?php echo sprintf($this->l('The information you give us is collected by us and is subject to data processing and statistics. Under the current "Act on Data Processing, Data Files and Individual Liberties" you have the right to access, rectify and oppose to the processing of your personal data through this <a href="%s" onclick="return !window.open(this.href)">link</a>.'), 'mailto:support@qloapps.com'); ?></small></span>
|
||||
<div style="margin-top:20px">
|
||||
<span><small><?php echo sprintf($this->l('The information you give us is collected by us and is subject to data processing and statistics. Under the current "Act on Data Processing, Data Files and Individual Liberties" you have the right to access, rectify and oppose to the processing of your personal data through this <a href="%s" onclick="return !window.open(this.href)">link</a>.'), 'mailto:support@qloapps.com'); ?></small></span>
|
||||
</div>
|
||||
<div style="margin-top:10px;margin-bottom:20px">
|
||||
<input type="checkbox" id="set_license" class="required" name="marketing_consent" value="1" style="vertical-align: middle;float:left" <?php if ($this->session->marketing_consent): ?>checked="checked"<?php endif; ?> />
|
||||
<div style="float:left;width:600px;margin-left:8px"><label for="set_license"><strong><?php echo $this->l('I agree to receive the Newsletter and promotional offers from QloApps.') ?></strong></label></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Partners form -->
|
||||
<div id="benefitsBlock" style="display:none"></div>
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
-------------------------
|
||||
# V1.2.1 to V1.2.2
|
||||
-------------------------
|
||||
|
||||
## Improved/changed features:
|
||||
|
||||
[+] CO : Demo data insertion improved.
|
||||
[+] CO : getHotelCartBookingData() improved as used many places in QloApps.
|
||||
|
||||
[+] CO : Call to HotelImage::validateImage() is deprecated.
|
||||
[+] CO : Call to Hotelhelper::validImageExt() is deprecated.
|
||||
|
||||
|
||||
[+] BO : Unused category deletion process added on hotel deletion. function deleteUnusedHotelCategories() added.
|
||||
[+] BO : Hotel creation code improved.
|
||||
[+] BO : Images validation improved.
|
||||
[+] BO : Zipcode validation is improved as per selected country.
|
||||
|
||||
|
||||
## Bug/Issues Resolved:
|
||||
|
||||
[-] CO : Zipcode in demo data is now dynamic for selected country while QloApps installation.
|
||||
|
||||
|
||||
|
||||
## Update Policy
|
||||
|
||||
- Mobule need only file update, can be updated only by UPLOADING new version on module
|
||||
|
||||
|
||||
-------------------------
|
||||
# V1.2.0 to V1.2.1
|
||||
-------------------------
|
||||
|
||||
@@ -1530,4 +1530,4 @@ class HotelBookingDetail extends ObjectModel
|
||||
{
|
||||
return Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `id_order`='.(int) $id_order.' AND `id_product`='.(int) $id_product.' AND `date_from`=\''.$date_from.'\' AND `date_to`= \''.$date_to.'\'');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,6 +316,7 @@ class HotelBranchInformation extends ObjectModel
|
||||
{
|
||||
$objHotelInfo = new HotelBranchInformation($this->id);
|
||||
$oldStatus = $objHotelInfo->active;
|
||||
|
||||
if ($return = parent::update()) {
|
||||
if ($oldStatus && !$this->active) {
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
@@ -341,11 +342,73 @@ class HotelBranchInformation extends ObjectModel
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function addCategory($name, $parent_cat = false, $group_ids, $ishotel = false, $idHotel = false)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
if (!$parent_cat) {
|
||||
$parent_cat = Category::getRootCategory()->id;
|
||||
}
|
||||
if ($ishotel && $idHotel) {
|
||||
if ($catIdHotel = Db::getInstance()->getValue(
|
||||
'SELECT `id_category` FROM `'._DB_PREFIX_.'htl_branch_info` WHERE id = '.(int)$idHotel
|
||||
)) {
|
||||
$category = new Category($catIdHotel);
|
||||
foreach (Language::getLanguages(true) as $lang) {
|
||||
if (is_array($name) && isset($name[$lang['id_lang']])) {
|
||||
$catName = $name[$lang['id_lang']];
|
||||
} else {
|
||||
$catName = $name;
|
||||
}
|
||||
$category->name[$lang['id_lang']] = $catName;
|
||||
$category->description[$lang['id_lang']] = $this->moduleInstance->l(
|
||||
'Hotel Branch Category',
|
||||
'HotelBranchInformation'
|
||||
);
|
||||
$category->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($catName);
|
||||
}
|
||||
$category->id_parent = $parent_cat;
|
||||
$category->groupBox = $group_ids;
|
||||
$category->save();
|
||||
return $category->id;
|
||||
}
|
||||
}
|
||||
if (is_array($name) && isset($name[Configuration::get('PS_LANG_DEFAULT')])) {
|
||||
$catName = $name[Configuration::get('PS_LANG_DEFAULT')];
|
||||
} else {
|
||||
$catName = $name;
|
||||
}
|
||||
if ($categoryExists = Category::searchByNameAndParentCategoryId(
|
||||
Configuration::get('PS_LANG_DEFAULT'),
|
||||
$catName,
|
||||
$parent_cat
|
||||
)) {
|
||||
return $categoryExists['id_category'];
|
||||
} else {
|
||||
$category = new Category();
|
||||
foreach (Language::getLanguages(true) as $lang) {
|
||||
if (is_array($name) && isset($name[$lang['id_lang']])) {
|
||||
$catName = $name[$lang['id_lang']];
|
||||
} else {
|
||||
$catName = $name;
|
||||
}
|
||||
$category->name[$lang['id_lang']] = $catName;
|
||||
$category->description[$lang['id_lang']] = $this->moduleInstance->l(
|
||||
'Hotel Branch Category', 'HotelBranchInformation'
|
||||
);
|
||||
$category->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($catName);
|
||||
}
|
||||
$category->id_parent = $parent_cat;
|
||||
$category->groupBox = $group_ids;
|
||||
$category->add();
|
||||
return $category->id;
|
||||
}
|
||||
}
|
||||
|
||||
//Overrided ObjectModet::delete() to delete all the dependencies of the hotel
|
||||
public function delete()
|
||||
{
|
||||
$contextController = Context::getContext()->controller;
|
||||
if ($idHotel = $this->id) {
|
||||
$contextController = Context::getContext()->controller;
|
||||
// room types of this hotel
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$idsProduct = $objHotelRoomType->getIdProductByHotelId($idHotel);
|
||||
@@ -383,6 +446,13 @@ class HotelBranchInformation extends ObjectModel
|
||||
'HotelBranchInformation'
|
||||
);
|
||||
}
|
||||
// delete hotel unused categories of this hotel
|
||||
if (!$this->deleteUnusedHotelCategories($idHotel)) {
|
||||
$contextController->errors[] = $this->moduleInstance->l(
|
||||
'Some error has occurred while deleting unused hotel categories.',
|
||||
'HotelBranchInformation'
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!count($contextController->errors)) {
|
||||
if ($result = parent::delete()) {
|
||||
@@ -393,69 +463,60 @@ class HotelBranchInformation extends ObjectModel
|
||||
}
|
||||
}
|
||||
|
||||
public function addCategory($name, $parent_cat = false, $group_ids, $ishotel = false, $idHotel = false)
|
||||
/**
|
||||
* returns all the categories used by all the hotels
|
||||
* @param array $excludeIdHotels [array of the hotels which categories you dont want]
|
||||
* @return [array] returns array of all the categories used by all the hotels
|
||||
*/
|
||||
public function getAllHotelCategories($excludeIdHotels = array())
|
||||
{
|
||||
$context = Context::getContext();
|
||||
if (!$parent_cat) {
|
||||
$parent_cat = Category::getRootCategory()->id;
|
||||
$hotelrelatedCategs = array();
|
||||
$sql = 'SELECT `id_category` FROM `'._DB_PREFIX_.'htl_branch_info`';
|
||||
if ($excludeIdHotels && count($excludeIdHotels)) {
|
||||
$sql .= ' WHERE `id` NOT IN ('.implode(',', $excludeIdHotels).')';
|
||||
}
|
||||
if ($ishotel && $idHotel) {
|
||||
$catIdHotel = Db::getInstance()->getValue(
|
||||
'SELECT `id_category` FROM `'._DB_PREFIX_.'htl_branch_info` WHERE id='.$idHotel
|
||||
);
|
||||
if ($catIdHotel) {
|
||||
$category = new Category($catIdHotel);
|
||||
foreach (Language::getLanguages(true) as $lang) {
|
||||
if (is_array($name) && isset($name[$lang['id_lang']])) {
|
||||
$catName = $name[$lang['id_lang']];
|
||||
} else {
|
||||
$catName = $name;
|
||||
// get all the hotel name categories
|
||||
if ($hotelCategs = Db::getInstance()->executeS($sql)) {
|
||||
foreach ($hotelCategs as $rowCateg) {
|
||||
if (Validate::isLoadedObject($objCategory = new Category($rowCateg['id_category']))) {
|
||||
if ($parentCategs = $objCategory->getParentsCategories(Configuration::get('PS_LANG_DEFAULT'))) {
|
||||
foreach ($parentCategs as $categInfo) {
|
||||
// enter only unique categories in the array
|
||||
if (!in_array($categInfo['id_category'], $hotelrelatedCategs)) {
|
||||
$hotelrelatedCategs[] = $categInfo['id_category'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$category->name[$lang['id_lang']] = $catName;
|
||||
$category->description[$lang['id_lang']] = $this->moduleInstance->l(
|
||||
'Hotel Branch Category',
|
||||
'HotelBranchInformation'
|
||||
);
|
||||
$category->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($catName);
|
||||
}
|
||||
$category->id_parent = $parent_cat;
|
||||
$category->groupBox = $group_ids;
|
||||
$category->save();
|
||||
$cat_id = $category->id;
|
||||
return $cat_id;
|
||||
}
|
||||
}
|
||||
if (is_array($name) && isset($name[$context->language->id])) {
|
||||
$catName = $name[$context->language->id];
|
||||
} else {
|
||||
$catName = $name;
|
||||
}
|
||||
if ($categoryExists = Category::searchByNameAndParentCategoryId(
|
||||
$context->language->id,
|
||||
$catName,
|
||||
$parent_cat
|
||||
)) {
|
||||
return $categoryExists['id_category'];
|
||||
} else {
|
||||
$category = new Category();
|
||||
foreach (Language::getLanguages(true) as $lang) {
|
||||
if (is_array($name) && isset($name[$lang['id_lang']])) {
|
||||
$catName = $name[$lang['id_lang']];
|
||||
} else {
|
||||
$catName = $name;
|
||||
}
|
||||
$category->name[$lang['id_lang']] = $catName;
|
||||
$category->description[$lang['id_lang']] = $this->moduleInstance->l(
|
||||
'Hotel Branch Category', 'HotelBranchInformation'
|
||||
);
|
||||
$category->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($catName);
|
||||
}
|
||||
$category->id_parent = $parent_cat;
|
||||
$category->groupBox = $group_ids;
|
||||
$category->add();
|
||||
$cat_id = $category->id;
|
||||
return $hotelrelatedCategs;
|
||||
}
|
||||
|
||||
return $cat_id;
|
||||
/**
|
||||
* Deletes all the unused categories created by hotel creation of a hotel
|
||||
* @param [int] $idHotel which categories you want to delete
|
||||
* @return true if all the categories will be deleted
|
||||
*/
|
||||
public function deleteUnusedHotelCategories($idHotel)
|
||||
{
|
||||
if (Validate::isLoadedObject($objHotel = new HotelBranchInformation($idHotel))) {
|
||||
$idCategory = $objHotel->id_category;
|
||||
if (Validate::isLoadedObject($objCategory = new Category($idCategory))) {
|
||||
$hotelCategories = $this->getAllHotelCategories(array($idHotel));
|
||||
// check if category is not root or home category and not used by other hotels
|
||||
while ($idCategory
|
||||
&& !in_array($idCategory, $hotelCategories)
|
||||
&& $idCategory != Configuration::get('PS_HOME_CATEGORY')
|
||||
) {
|
||||
if ($objCategory->delete()) {
|
||||
// continue deleting the unused parent hotel categories
|
||||
$idCategory = $objCategory->id_parent;
|
||||
$objCategory = new Category($idCategory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,110 +632,171 @@ class HotelCartBookingData extends ObjectModel
|
||||
*/
|
||||
public static function getHotelCartBookingData()
|
||||
{
|
||||
$cartHotelData = array();
|
||||
$context = Context::getContext();
|
||||
$total_rooms = 0;
|
||||
$cart_htl_data = array();
|
||||
$price_tax = HotelBookingDetail::useTax();
|
||||
if ($cartRoomTypes = $context->cart->getProducts()) {
|
||||
$idLang = $context->language->id;
|
||||
$price_tax = HotelBookingDetail::useTax();
|
||||
// create needed objects
|
||||
$objCartBooking = new self();
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$objRoomType = new HotelRoomType();
|
||||
$objHotelBranch = new HotelBranchInformation();
|
||||
$objHtlFeatures = new HotelFeatures();
|
||||
|
||||
if (Module::isInstalled('hotelreservationsystem')) {
|
||||
require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
|
||||
$objHtlBranchInfo = new HotelBranchInformation();
|
||||
$obj_cart_bk_data = new self();
|
||||
$obj_htl_bk_dtl = new HotelBookingDetail();
|
||||
$obj_rm_type = new HotelRoomType();
|
||||
|
||||
$htl_rm_types = $context->cart->getProducts();
|
||||
if (!empty($htl_rm_types)) {
|
||||
foreach ($htl_rm_types as $type_key => $type_value) {
|
||||
$product = new Product($type_value['id_product'], false, $context->language->id);
|
||||
$cover_image_arr = $product->getCover($type_value['id_product']);
|
||||
|
||||
if (!empty($cover_image_arr)) {
|
||||
$cover_img = $context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default');
|
||||
foreach ($cartRoomTypes as $prodKey => $product) {
|
||||
if (Validate::isLoadedObject(
|
||||
$objProduct = new Product($product['id_product'], false, $idLang)
|
||||
)) {
|
||||
$coverImageArr = $objProduct->getCover($product['id_product']);
|
||||
// get cover image link
|
||||
if (!empty($coverImageArr)) {
|
||||
$coverImg = $context->link->getImageLink(
|
||||
$objProduct->link_rewrite,
|
||||
$objProduct->id.'-'.$coverImageArr['id_image'],
|
||||
'small_default'
|
||||
);
|
||||
} else {
|
||||
$cover_img = $context->link->getImageLink($product->link_rewrite, $context->language->iso_code.'-default', 'small_default');
|
||||
$coverImg = $context->link->getImageLink(
|
||||
$objProduct->link_rewrite,
|
||||
$context->language->iso_code.'-default',
|
||||
'small_default'
|
||||
);
|
||||
}
|
||||
$unitPrice = Product::getPriceStatic(
|
||||
$product['id_product'],
|
||||
$price_tax,
|
||||
null,
|
||||
6,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
1
|
||||
);
|
||||
$unitPriceWithoutReduction = $objProduct->getPriceWithoutReduct(!$price_tax);
|
||||
$roomDetail = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product']);
|
||||
$cartHotelData[$prodKey]['adult'] = $roomDetail['adult'];
|
||||
$cartHotelData[$prodKey]['children'] = $roomDetail['children'];
|
||||
$cartHotelData[$prodKey]['total_num_rooms'] = 0;
|
||||
$cartHotelData[$prodKey]['id_product'] = $product['id_product'];
|
||||
$cartHotelData[$prodKey]['cover_img'] = $coverImg;
|
||||
$cartHotelData[$prodKey]['name'] = $objProduct->name;
|
||||
$cartHotelData[$prodKey]['unit_price'] = $unitPrice;
|
||||
$cartHotelData[$prodKey]['unit_price_without_reduction'] = $unitPriceWithoutReduction;
|
||||
// add hotel info of the room
|
||||
if ($hotelInfo = $objHotelBranch->hotelBranchesInfo(false, 2, 1, $roomDetail['id_hotel'])) {
|
||||
$hotelInfo['location'] = $hotelInfo['hotel_name'].', '.$hotelInfo['city'].', '.
|
||||
State::getNameById($hotelInfo['state_id']).', '.
|
||||
Country::getNameById($idLang, $hotelInfo['country_id'])
|
||||
.', '.$hotelInfo['zipcode'];
|
||||
|
||||
$unit_price = Product::getPriceStatic($type_value['id_product'], $price_tax, null, 6, null, false, true, 1);
|
||||
$unitPriceWithoutReduction = $product->getPriceWithoutReduct(!$price_tax);
|
||||
if (isset($context->customer->id)) {
|
||||
$cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($context->cart->id, $context->cart->id_guest, $type_value['id_product']);
|
||||
} else {
|
||||
$cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($context->cart->id, $context->cart->id_guest, $type_value['id_product']);
|
||||
}
|
||||
$rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['id_product']);
|
||||
$cart_htl_data[$type_key]['total_num_rooms'] = 0;
|
||||
$cart_htl_data[$type_key]['id_product'] = $type_value['id_product'];
|
||||
$cart_htl_data[$type_key]['cover_img'] = $cover_img;
|
||||
$cart_htl_data[$type_key]['name'] = $product->name;
|
||||
$cart_htl_data[$type_key]['unit_price'] = $unit_price;
|
||||
$cart_htl_data[$type_key]['unit_price_without_reduction'] = $unitPriceWithoutReduction;
|
||||
$cart_htl_data[$type_key]['adult'] = $rm_dtl['adult'];
|
||||
$cart_htl_data[$type_key]['children'] = $rm_dtl['children'];
|
||||
if (isset($cart_bk_data) && $cart_bk_data) {
|
||||
foreach ($cart_bk_data as $data_k => $data_v) {
|
||||
$date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']);
|
||||
if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) {
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
|
||||
$total_rooms += 1;
|
||||
$num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'];
|
||||
$vart_quant = (int) $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'];
|
||||
//// By webkul New way to calculate product prices with feature Prices
|
||||
$roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice($type_value['id_product'], $data_v['date_from'], $data_v['date_to']);
|
||||
if (!$price_tax) {
|
||||
$amount = $roomTypeDateRangePrice['total_price_tax_excl'];
|
||||
} else {
|
||||
$amount = $roomTypeDateRangePrice['total_price_tax_incl'];
|
||||
// append hotel features
|
||||
if ($hotelFeaureIds = $objHotelBranch->getFeaturesOfHotelByHotelId($roomDetail['id_hotel'])) {
|
||||
$hotelFeatures = array();
|
||||
foreach ($hotelFeaureIds as $value) {
|
||||
$htlFeatureInfo = $objHtlFeatures->getFeatureInfoById($value['feature_id']);
|
||||
if ($htlFeatureInfo = $objHtlFeatures->getFeatureInfoById($value['feature_id'])) {
|
||||
$hotelFeatures[] = $htlFeatureInfo['name'];
|
||||
}
|
||||
//END
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount * $vart_quant;
|
||||
} else {
|
||||
$num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
|
||||
$total_rooms += 1;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = date('Y-m-d', strtotime($data_v['date_from']));
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = date('Y-m-d', strtotime($data_v['date_to']));
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
|
||||
|
||||
// By webkul New way to calculate product prices with feature Prices
|
||||
$roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice($type_value['id_product'], $data_v['date_from'], $data_v['date_to']);
|
||||
if (!$price_tax) {
|
||||
$amount = $roomTypeDateRangePrice['total_price_tax_excl'];
|
||||
} else {
|
||||
$amount = $roomTypeDateRangePrice['total_price_tax_incl'];
|
||||
}
|
||||
// END
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['link'] = $context->link->getPageLink('order-opc', null, $context->language->id, "id_product=".$type_value['id_product']."&deleteFromOrderLine=1&date_from=".$data_v['date_from']."&date_to=".$data_v['date_to']);
|
||||
}
|
||||
// product price after imposing feature prices...
|
||||
if ($price_tax) {
|
||||
$feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($type_value['id_product'], $data_v['date_from'], $data_v['date_to'], true);
|
||||
if ($hotelFeatures) {
|
||||
$hotelInfo['htl_features'] = $hotelFeatures;
|
||||
}
|
||||
}
|
||||
// append roomtype features
|
||||
$hotelInfo['room_features'] = $objProduct->getFrontFeatures($idLang);
|
||||
|
||||
$cartHotelData[$prodKey]['hotel_info'] = $hotelInfo;
|
||||
}
|
||||
if (isset($context->customer->id)) {
|
||||
$cartBookingDetails = $objCartBooking->getOnlyCartBookingData(
|
||||
$context->cart->id,
|
||||
$context->cart->id_guest,
|
||||
$product['id_product']
|
||||
);
|
||||
} else {
|
||||
$cartBookingDetails = $objCartBooking->getOnlyCartBookingData(
|
||||
$context->cart->id,
|
||||
$context->cart->id_guest,
|
||||
$product['id_product']
|
||||
);
|
||||
}
|
||||
if (isset($cartBookingDetails) && $cartBookingDetails) {
|
||||
foreach ($cartBookingDetails as $data_k => $data_v) {
|
||||
$dateJoin = strtotime($data_v['date_from']).strtotime($data_v['date_to']);
|
||||
if (isset($cartHotelData[$prodKey]['date_diff'][$dateJoin])) {
|
||||
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['num_rm'] += 1;
|
||||
$numDays = $cartHotelData[$prodKey]['date_diff'][$dateJoin]['num_days'];
|
||||
$varQty = (int) $cartHotelData[$prodKey]['date_diff'][$dateJoin]['num_rm'];
|
||||
$roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$product['id_product'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to']
|
||||
);
|
||||
if (!$price_tax) {
|
||||
$amount = $roomTypeDateRangePrice['total_price_tax_excl'];
|
||||
} else {
|
||||
$amount = $roomTypeDateRangePrice['total_price_tax_incl'];
|
||||
}
|
||||
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['amount'] = $amount * $varQty;
|
||||
} else {
|
||||
$feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($type_value['id_product'], $data_v['date_from'], $data_v['date_to'], false);
|
||||
$numDays = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
|
||||
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['num_rm'] = 1;
|
||||
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['data_form'] = date(
|
||||
'Y-m-d',
|
||||
strtotime($data_v['date_from'])
|
||||
);
|
||||
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['data_to'] = date(
|
||||
'Y-m-d',
|
||||
strtotime($data_v['date_to'])
|
||||
);
|
||||
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['num_days'] = $numDays;
|
||||
$roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$product['id_product'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to']
|
||||
);
|
||||
if (!$price_tax) {
|
||||
$amount = $roomTypeDateRangePrice['total_price_tax_excl'];
|
||||
} else {
|
||||
$amount = $roomTypeDateRangePrice['total_price_tax_incl'];
|
||||
}
|
||||
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['amount'] = $amount;
|
||||
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['link'] = $context->link->getPageLink(
|
||||
'order-opc',
|
||||
null,
|
||||
$idLang,
|
||||
"id_product=".$product['id_product']."&deleteFromOrderLine=1&date_from=".
|
||||
$data_v['date_from']."&date_to=".$data_v['date_to']
|
||||
);
|
||||
}
|
||||
if ($price_tax) {
|
||||
$feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
|
||||
$product['id_product'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
|
||||
$product['id_product'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
false
|
||||
);
|
||||
}
|
||||
$feature_price_diff = (float)($unitPriceWithoutReduction - $feature_price);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['feature_price'] = $feature_price;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff;
|
||||
|
||||
//enter hotel name
|
||||
$hotelInfo = $objHtlBranchInfo->hotelBranchesInfo(
|
||||
$context->language->id,
|
||||
2,
|
||||
0,
|
||||
$data_v['id_hotel']
|
||||
);
|
||||
$cart_htl_data[$type_key]['hotel_name'] = $hotelInfo['hotel_name'];
|
||||
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['feature_price'] = $feature_price;
|
||||
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['feature_price_diff'] = $feature_price_diff;
|
||||
}
|
||||
foreach ($cart_htl_data[$type_key]['date_diff'] as $key => $value) {
|
||||
$cart_htl_data[$type_key]['total_num_rooms'] += $value['num_rm'];
|
||||
foreach ($cartHotelData[$prodKey]['date_diff'] as $key => $value) {
|
||||
$cartHotelData[$prodKey]['total_num_rooms'] += $value['num_rm'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $cart_htl_data;
|
||||
return $cartHotelData;
|
||||
}
|
||||
|
||||
public function getHotelCartDistinctDateRangesByRoomType($id_cart, $id_product)
|
||||
@@ -805,4 +866,4 @@ class HotelCartBookingData extends ObjectModel
|
||||
{
|
||||
return Db::getInstance()->executeS("SELECT * FROM `"._DB_PREFIX_."htl_cart_booking_data` WHERE `id_cart`=".(int) $id_cart." AND `id_product`=".(int) $id_product);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ class HotelHelper
|
||||
}
|
||||
$obj_hotel_info->state_id = $state_id;
|
||||
$obj_hotel_info->country_id = $def_cont_id;
|
||||
$obj_hotel_info->zipcode = '263001';
|
||||
$obj_hotel_info->zipcode = self::getRandomZipcodeByForCountry($def_cont_id);
|
||||
$obj_hotel_info->address = 'Monticello Dr, Montgomery, AL 36117, USA';
|
||||
$obj_hotel_info->save();
|
||||
|
||||
@@ -502,7 +502,18 @@ class HotelHelper
|
||||
|
||||
Search::indexation(Tools::link_rewrite($value_prod), $product_id);
|
||||
|
||||
$product->addToCategories(2);
|
||||
// assign all the categories of hotel and its parent to the product
|
||||
if (Validate::isLoadedObject($objHotel = new HotelBranchInformation($id_hotel))) {
|
||||
if (Validate::isLoadedObject($objCategory = new Category($objHotel->id_category))) {
|
||||
if ($hotelCategories = $objCategory->getParentsCategories()) {
|
||||
$categoryIds = array();
|
||||
foreach ($hotelCategories as $rowCateg) {
|
||||
$categoryIds[] = $rowCateg['id_category'];
|
||||
}
|
||||
$product->addToCategories($categoryIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StockAvailable::updateQuantity($product_id, null, 999999999);
|
||||
|
||||
@@ -514,7 +525,11 @@ class HotelHelper
|
||||
if (is_dir($image_dir_path)) {
|
||||
if ($opendir = opendir($image_dir_path)) {
|
||||
while (($image = readdir($opendir)) !== false) {
|
||||
if ($this->validImageExt($image)) {
|
||||
$old_path = $image_dir_path.$image;
|
||||
|
||||
if (ImageManager::isRealImage($old_path)
|
||||
&& ImageManager::isCorrectImageFileExt($old_path)
|
||||
) {
|
||||
$image_obj = new Image();
|
||||
$image_obj->id_product = $product_id;
|
||||
$image_obj->position = Image::getHighestPosition($product_id) + 1;
|
||||
@@ -529,7 +544,6 @@ class HotelHelper
|
||||
$image_obj->cover = 0;
|
||||
}
|
||||
$image_obj->add();
|
||||
$old_path = $image_dir_path.$image;
|
||||
$new_path = $image_obj->getPathForCreation();
|
||||
foreach ($imagesTypes as $image_type) {
|
||||
ImageManager::resize(
|
||||
@@ -771,4 +785,21 @@ class HotelHelper
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getRandomZipcodeByForCountry($idCountry)
|
||||
{
|
||||
$randZipCode = '';
|
||||
$alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
if (Validate::isLoadedObject($objCountry = new Country($idCountry))) {
|
||||
if ($objCountry->need_zip_code) {
|
||||
if ($randZipCode = $objCountry->zip_code_format) {
|
||||
$randZipCode = str_replace('N', mt_rand(0, 9), $randZipCode);
|
||||
$randZipCode = str_replace('L', $alphabet[mt_rand(0, Tools::strlen($alphabet) - 1)], $randZipCode);
|
||||
$randZipCode = str_replace('C', $objCountry->iso_code, $randZipCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $randZipCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,6 +56,13 @@ class HotelImage extends ObjectModel
|
||||
return $delete;
|
||||
}
|
||||
|
||||
public static function getCover($idHotel)
|
||||
{
|
||||
return Db::getInstance()->getRow(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_image` WHERE `id_hotel` = '.(int)$idHotel.' AND `cover`=1'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* [validAddHotelMainImage :: To validate the image of the hotel before saving it]
|
||||
* @param [array] $image [variable having image information of the hotel]
|
||||
@@ -74,13 +81,6 @@ class HotelImage extends ObjectModel
|
||||
}
|
||||
}
|
||||
|
||||
public static function getCover($idHotel)
|
||||
{
|
||||
return Db::getInstance()->getRow(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_image` WHERE `id_hotel` = '.(int)$idHotel.' AND `cover`=1'
|
||||
);
|
||||
}
|
||||
|
||||
public function uploadHotelImages($images, $idHotel, $destPath)
|
||||
{
|
||||
if (isset($images) && $idHotel && $destPath) {
|
||||
|
||||
@@ -255,12 +255,6 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$this->errors[] = $this->l('Check Out Time is required field.');
|
||||
}
|
||||
|
||||
if ($zipcode == '') {
|
||||
$this->errors[] = $this->l('Postal Code is required field.');
|
||||
} elseif (!Validate::isPostCode($zipcode)) {
|
||||
$this->errors[] = $this->l('Enter a Valid Postal Code.');
|
||||
}
|
||||
|
||||
if (!$rating) {
|
||||
$this->errors[] = $this->l('Rating is required field.');
|
||||
}
|
||||
@@ -280,6 +274,15 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$this->errors[] = $this->l('State is required field.');
|
||||
}
|
||||
}
|
||||
/* Check zip code format */
|
||||
$objCountry = new Country($country);
|
||||
if ($objCountry->zip_code_format && !$objCountry->checkZipCode($zipcode)) {
|
||||
$this->errors[] = sprintf($this->l('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'), str_replace('C', $objCountry->iso_code, str_replace('N', '0', str_replace('L', 'A', $objCountry->zip_code_format))));
|
||||
} elseif (empty($zipcode) && $objCountry->need_zip_code) {
|
||||
$this->errors[] = $this->l('A Zip / Postal code is required.');
|
||||
} elseif ($zipcode && !Validate::isPostCode($zipcode)) {
|
||||
$this->errors[] = $this->l('The Zip / Postal code is invalid.');
|
||||
}
|
||||
}
|
||||
|
||||
if ($city == '') {
|
||||
@@ -381,6 +384,9 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$objHotelBranch->map_input_text = $map_input_text;
|
||||
$objHotelBranch->save();
|
||||
|
||||
// hotel categories before save categories
|
||||
$categsBeforeUpd = $objHotelBranch->getAllHotelCategories();
|
||||
|
||||
if ($newIdHotel = $objHotelBranch->id) {
|
||||
$groupIds = array();
|
||||
if ($dataGroupIds = Group::getGroups($this->context->language->id)) {
|
||||
@@ -389,10 +395,11 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
$objCountry = new Country();
|
||||
$countryName = $objCountry->getNameById($this->context->language->id, $country);
|
||||
$countryName = $objCountry->getNameById(Configuration::get('PS_LANG_DEFAULT'), $country);
|
||||
if ($catCountry = $objHotelBranch->addCategory($countryName, false, $groupIds)) {
|
||||
if ($state) {
|
||||
$stateName = (new State())->getNameById($state);
|
||||
$objState = new State();
|
||||
$stateName = $objState->getNameById($state);
|
||||
$catState = $objHotelBranch->addCategory($stateName, $catCountry, $groupIds);
|
||||
} else {
|
||||
$catState = $objHotelBranch->addCategory($city, $catCountry, $groupIds);
|
||||
@@ -411,6 +418,23 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
// hotel categories after save categories
|
||||
$categsAfterUpd = $objHotelBranch->getAllHotelCategories();
|
||||
|
||||
// delete categories which not in hotel categories and also unused
|
||||
if ($unusedCategs = array_diff($categsBeforeUpd, $categsAfterUpd)) {
|
||||
if ($hotelCategories = $objHotelBranch->getAllHotelCategories()) {
|
||||
foreach ($unusedCategs as $idCategory) {
|
||||
if (!in_array($idCategory, $hotelCategories)
|
||||
&& $idCategory != Configuration::get('PS_HOME_CATEGORY')
|
||||
) {
|
||||
$objCategory = new Category($idCategory);
|
||||
$objCategory->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
if ($idHotel) {
|
||||
Tools::redirectAdmin(
|
||||
@@ -465,7 +489,7 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
if ($idHotel) {
|
||||
$invalidImg = ImageManager::validateUpload(
|
||||
$_FILES['hotel_image'],
|
||||
Tools::getMaxUploadSize(Configuration::get('PS_LIMIT_UPLOAD_IMAGE_VALUE') * 1048576)
|
||||
Tools::getMaxUploadSize()
|
||||
);
|
||||
if (!$invalidImg) {
|
||||
// Add Hotel images
|
||||
|
||||
@@ -10,6 +10,7 @@ class AdminHotelConfigurationSettingController extends ModuleAdminController
|
||||
if (!($obj = $this->loadObject(true))) {
|
||||
return;
|
||||
}
|
||||
$this->toolbar_title = $this->l('Manage Hotel Settings');
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,9 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
|
||||
$objDefaultLanguage['name'];
|
||||
}
|
||||
if ($_FILES['htl_header_image']['name']) {
|
||||
$this->validateHotelHeaderImage($_FILES['htl_header_image']);
|
||||
if ($error = ImageManager::validateUpload($_FILES['htl_header_image'], Tools::getMaxUploadSize())) {
|
||||
$this->errors[] = $error;
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$img_path = _PS_IMG_DIR_.'hotel_header_image.jpg';
|
||||
@@ -349,20 +351,6 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function validateHotelHeaderImage($image)
|
||||
{
|
||||
if ($image['size'] > 0) {
|
||||
if ($image['tmp_name'] != '') {
|
||||
if (!ImageManager::isCorrectImageFileExt($image['name'])) {
|
||||
$this->errors[] = '<strong>'.$_FILES['htl_header_image']['name'].'</strong> : '.
|
||||
$this->l('Image format not recognized, allowed formats are: .gif, .jpg, .png');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
|
||||
@@ -26,6 +26,8 @@ class AdminHotelFeaturesController extends ModuleAdminController
|
||||
$this->table = 'htl_features';
|
||||
$this->className = 'HotelFeatures';
|
||||
$this->identifier = 'id';
|
||||
$this->toolbar_title = $this->l('Manage Hotel Features');
|
||||
|
||||
parent::__construct();
|
||||
$this->display = 'view';
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class hotelreservationsystem extends Module
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'hotelreservationsystem';
|
||||
$this->version = '1.2.1';
|
||||
$this->version = '1.2.2';
|
||||
$this->author = 'Webkul';
|
||||
$this->need_instance = 0;
|
||||
$this->bootstrap = true;
|
||||
|
||||
@@ -567,4 +567,7 @@ a.deleteHtlImage {
|
||||
.room_type_search_results_ul li:hover, .room_type_search_results_ul li:focus, .room_type_search_results_ul li:active {
|
||||
background-color: #379bf0;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
.setting-title {
|
||||
text-align: left;
|
||||
}
|
||||
@@ -1,62 +1,62 @@
|
||||
<div class="panel htl_conf_panel">
|
||||
<h3 class="tab"> <i class="icon-cogs"></i> {l s='Hotel Configuration' mod='hotelreservationsystem'}</h3>
|
||||
<div class="panel-body">
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$htl_reviews_conf_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-star"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Hotel Reviews Settings' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Hotel Reviews Settings' mod='hotelreservationsystem'}" data-content="{l s='Configure Reviews setting using this link.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$general_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-cogs"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Hotel General Settings' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Hotel General Settings' mod='hotelreservationsystem'}" data-content="{l s='Configure Your Hotel,s general Settings using this link.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$payment_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-money"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Payment Modules Setting' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Payment Modules Setting confi' mod='hotelreservationsystem'}" data-content="{l s='Configure your payment Modules settings using this link.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$order_restrict_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-list-alt"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Order Restrict Settings' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Order Restrict Settings' mod='hotelreservationsystem'}" data-content="{l s='Configure if you want to restrict orders till a specific date for your hotels.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$other_module_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-support"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Other Modules Settings' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Other Modules Settings' mod='hotelreservationsystem'}" data-content="{l s='Configure here settings of other modules of the software.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<!-- Setting to set prices for date range -->
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$feature_price_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-cog"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Feature Prices Settings' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Feature Prices Settings' mod='hotelreservationsystem'}" data-content="{l s='Here set specific prices for specific dates.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$general_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-cogs"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='General Settings' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Hotel General Settings' mod='hotelreservationsystem'}" data-content="{l s='Configure Your Hotel,s general Settings using this link.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$htl_reviews_conf_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-star"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Hotel Reviews' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Hotel Reviews Settings' mod='hotelreservationsystem'}" data-content="{l s='Configure Reviews setting using this link.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$payment_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-money"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Payment Modules' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Payment Modules Setting confi' mod='hotelreservationsystem'}" data-content="{l s='Configure your payment Modules settings using this link.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$order_restrict_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-list-alt"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Order Restrict' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Order Restrict Settings' mod='hotelreservationsystem'}" data-content="{l s='Configure if you want to restrict orders till a specific date for your hotels.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$other_module_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-support"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Other Modules' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Other Modules Settings' mod='hotelreservationsystem'}" data-content="{l s='Configure here settings of other modules of the software.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<!-- Setting to set prices for date range -->
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$feature_price_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-cog"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Feature Price' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Feature Prices Settings' mod='hotelreservationsystem'}" data-content="{l s='Here set specific prices for specific dates.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{hook h='displayAddModuleSettingLink'}
|
||||
{hook h='displayAddModuleSettingLink'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
36
modules/paypal/Readme.md
Normal file
36
modules/paypal/Readme.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# PayPal
|
||||
|
||||
## About
|
||||
|
||||
Let customer pay with PayPal Express Checkout or PayPal Integral Evolution.
|
||||
|
||||
## Contributing
|
||||
|
||||
PrestaShop modules are open-source extensions to the PrestaShop e-commerce solution. Everyone is welcome and even encouraged to contribute with their own improvements.
|
||||
|
||||
### Requirements
|
||||
|
||||
Contributors **must** follow the following rules:
|
||||
|
||||
* **Make your Pull Request on the "dev" branch**, NOT the "master" branch.
|
||||
* Do not update the module's version number.
|
||||
* Follow [the coding standards][1].
|
||||
|
||||
### Process in details
|
||||
|
||||
Contributors wishing to edit a module's files should follow the following process:
|
||||
|
||||
1. Create your GitHub account, if you do not have one already.
|
||||
2. Fork the bankwire project to your GitHub account.
|
||||
3. Clone your fork to your local machine in the ```/modules``` directory of your PrestaShop installation.
|
||||
4. Create a branch in your local clone of the module for your changes.
|
||||
5. Change the files in your branch. Be sure to follow [the coding standards][1]!
|
||||
6. Push your changed branch to your fork in your GitHub account.
|
||||
7. Create a pull request for your changes **on the _'dev'_ branch** of the module's project. Be sure to follow [the commit message norm][2] in your pull request. If you need help to make a pull request, read the [Github help page about creating pull requests][3].
|
||||
8. Wait for one of the core developers either to include your change in the codebase, or to comment on possible improvements you should make to your code.
|
||||
|
||||
That's it: you have contributed to this open-source project! Congratulations!
|
||||
|
||||
[1]: http://doc.prestashop.com/display/PS16/Coding+Standards
|
||||
[2]: http://doc.prestashop.com/display/PS16/How+to+write+a+commit+message
|
||||
[3]: https://help.github.com/articles/using-pull-requests
|
||||
44
modules/paypal/about.php
Normal file
44
modules/paypal/about.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* 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 PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__).'/../../config/config.inc.php';
|
||||
require_once dirname(__FILE__).'/../../init.php';
|
||||
|
||||
include_once dirname(__FILE__).'/paypal.php';
|
||||
include_once dirname(__FILE__).'/backward_compatibility/backward.php';
|
||||
|
||||
$paypal = new PayPal();
|
||||
|
||||
$context = Context::getContext();
|
||||
|
||||
$id_lang = (int) ($context->cookie->id_lang ? $context->cookie->id_lang : Configuration::get('PS_LANG_DEFAULT'));
|
||||
$iso_lang = Tools::strtolower(Language::getIsoById($id_lang));
|
||||
|
||||
$paypal->context->smarty->assign('iso_code', $iso_lang);
|
||||
|
||||
$display = new BWDisplay();
|
||||
$display->setTemplate(_PS_MODULE_DIR_.'paypal/views/templates/front/about.tpl');
|
||||
$display->run();
|
||||
2
modules/paypal/api/.htaccess
Normal file
2
modules/paypal/api/.htaccess
Normal file
@@ -0,0 +1,2 @@
|
||||
order allow,deny
|
||||
deny from all
|
||||
382
modules/paypal/api/ApiPaypalPlus.php
Normal file
382
modules/paypal/api/ApiPaypalPlus.php
Normal file
@@ -0,0 +1,382 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to 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 PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class ApiPaypalPlus
|
||||
{
|
||||
/* * ********************************************************* */
|
||||
/* * ******************** CONNECT METHODS ******************** */
|
||||
/* * ********************************************************* */
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (class_exists('Context')) {
|
||||
$this->context = Context::getContext();
|
||||
} else {
|
||||
global $smarty, $cookie;
|
||||
$this->context = new StdClass();
|
||||
$this->context->smarty = $smarty;
|
||||
$this->context->cookie = $cookie;
|
||||
}
|
||||
}
|
||||
|
||||
protected function sendByCURL($url, $body, $http_header = false, $identify = false, $customRequest = false)
|
||||
{
|
||||
$ch = curl_init();
|
||||
|
||||
if ($ch) {
|
||||
|
||||
if ((int) Configuration::get('PAYPAL_SANDBOX') == 1) {
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://api.sandbox.paypal.com'.$url);
|
||||
} else {
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://api.paypal.com'.$url);
|
||||
}
|
||||
|
||||
if ($identify) {
|
||||
curl_setopt($ch, CURLOPT_USERPWD, Configuration::get('PAYPAL_PLUS_CLIENT_ID').':'.Configuration::get('PAYPAL_PLUS_SECRET'));
|
||||
}
|
||||
|
||||
if ($http_header) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header);
|
||||
}
|
||||
if ($body) {
|
||||
if ($customRequest === false) {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
} else {
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $customRequest);
|
||||
}
|
||||
|
||||
if ($identify) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($body));
|
||||
} else {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
|
||||
}
|
||||
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
//curl_setopt($ch, CURLOPT_SSLVERSION, defined('CURL_SSLVERSION_TLSv1') ? CURL_SSLVERSION_TLSv1 : 1);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getToken($url, $body)
|
||||
{
|
||||
|
||||
|
||||
$result = $this->sendByCURL($url, $body, false, true);
|
||||
|
||||
/*
|
||||
* Init variable
|
||||
*/
|
||||
$oPayPalToken = Tools::jsonDecode($result);
|
||||
|
||||
if (isset($oPayPalToken->error)) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
if ($this->context->cookie->paypal_access_token_time_max > time()) {
|
||||
return $this->context->cookie->paypal_access_token_access_token;
|
||||
}
|
||||
|
||||
$time_max = time() + $oPayPalToken->expires_in;
|
||||
$access_token = $oPayPalToken->access_token;
|
||||
|
||||
/*
|
||||
* Set Token in Cookie
|
||||
*/
|
||||
$this->context->cookie->__set('paypal_access_token_time_max', $time_max);
|
||||
$this->context->cookie->__set('paypal_access_token_access_token', $access_token);
|
||||
$this->context->cookie->write();
|
||||
|
||||
return $access_token;
|
||||
}
|
||||
}
|
||||
|
||||
private function _createWebProfile()
|
||||
{
|
||||
|
||||
$presentation = new stdClass();
|
||||
$presentation->brand_name = Configuration::get('PS_SHOP_NAME');
|
||||
$presentation->logo_image = Tools::getHttpHost(true).__PS_BASE_URI__.'img/logo.jpg';
|
||||
$presentation->locale_code = Tools::strtoupper(Language::getIsoById($this->context->language->id));
|
||||
$input_fields = new stdClass();
|
||||
$input_fields->allow_note = false;
|
||||
$input_fields->no_shipping = 1;
|
||||
$input_fields->address_override = 1;
|
||||
|
||||
$flow_config = new stdClass();
|
||||
|
||||
$webProfile = new stdClass();
|
||||
$webProfile->name = Configuration::get('PS_SHOP_NAME');
|
||||
$webProfile->presentation = $presentation;
|
||||
$webProfile->input_fields = $input_fields;
|
||||
$webProfile->flow_config = $flow_config;
|
||||
|
||||
return $webProfile;
|
||||
}
|
||||
|
||||
public function getWebProfile()
|
||||
{
|
||||
$accessToken = $this->getToken(URL_PPP_CREATE_TOKEN, array('grant_type' => 'client_credentials'));
|
||||
|
||||
if ($accessToken) {
|
||||
|
||||
$data = $this->_createWebProfile();
|
||||
|
||||
$header = array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:Bearer '.$accessToken,
|
||||
);
|
||||
|
||||
$result = Tools::jsonDecode($this->sendByCURL(URL_PPP_WEBPROFILE, Tools::jsonEncode($data), $header));
|
||||
if (isset($result->id)) {
|
||||
return $result->id;
|
||||
} else {
|
||||
|
||||
$results = $this->getListProfile();
|
||||
|
||||
foreach ($results as $result) {
|
||||
if (isset($result->id) && $result->name == Configuration::get('PS_SHOP_NAME')) {
|
||||
return $result->id;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getListProfile()
|
||||
{
|
||||
|
||||
$accessToken = $this->getToken(URL_PPP_CREATE_TOKEN, array('grant_type' => 'client_credentials'));
|
||||
|
||||
if ($accessToken) {
|
||||
|
||||
$header = array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:Bearer '.$accessToken,
|
||||
);
|
||||
|
||||
return Tools::jsonDecode($this->sendByCURL(URL_PPP_WEBPROFILE, false, $header));
|
||||
}
|
||||
}
|
||||
|
||||
public function refreshToken()
|
||||
{
|
||||
if ($this->context->cookie->paypal_access_token_time_max < time()) {
|
||||
return $this->getToken(URL_PPP_CREATE_TOKEN, array('grant_type' => 'client_credentials'));
|
||||
} else {
|
||||
return $this->context->cookie->paypal_access_token_access_token;
|
||||
}
|
||||
}
|
||||
|
||||
private function _createObjectPayment($customer, $cart)
|
||||
{
|
||||
/*
|
||||
* Init Variable
|
||||
*/
|
||||
$oCurrency = new Currency($cart->id_currency);
|
||||
$address = new Address((int) $cart->id_address_invoice);
|
||||
|
||||
$country = new Country((int) $address->id_country);
|
||||
$iso_code = $country->iso_code;
|
||||
|
||||
if (version_compare(_PS_VERSION_, '1.5', '<')) {
|
||||
$totalShippingCostWithoutTax = $cart->getOrderShippingCost(null, false);
|
||||
} else {
|
||||
$totalShippingCostWithoutTax = $cart->getTotalShippingCost(null, false);
|
||||
}
|
||||
|
||||
$totalCartWithTax = $this->getCartPaymentTotal(true);
|
||||
$totalCartWithoutTax = $this->getCartPaymentTotal(false);
|
||||
|
||||
$total_tax = $totalCartWithTax - $totalCartWithoutTax;
|
||||
|
||||
if ($cart->gift) {
|
||||
if (version_compare(_PS_VERSION_, '1.5.3.0', '>=')) {
|
||||
$giftWithoutTax = $cart->getGiftWrappingPrice(false);
|
||||
} else {
|
||||
$giftWithoutTax = (float) (Configuration::get('PS_GIFT_WRAPPING_PRICE'));
|
||||
}
|
||||
|
||||
} else {
|
||||
$giftWithoutTax = 0;
|
||||
}
|
||||
|
||||
$shop_url = PayPal::getShopDomainSsl(true, true);
|
||||
|
||||
/*
|
||||
* Création de l'obj à envoyer à Paypal
|
||||
*/
|
||||
$state = new State($address->id_state);
|
||||
$shipping_address = new stdClass();
|
||||
$shipping_address->recipient_name = $address->alias;
|
||||
$shipping_address->type = 'residential';
|
||||
$shipping_address->line1 = $address->address1;
|
||||
$shipping_address->line2 = $address->address2;
|
||||
$shipping_address->city = $address->city;
|
||||
$shipping_address->country_code = $iso_code;
|
||||
$shipping_address->postal_code = $address->postcode;
|
||||
$shipping_address->state = ($state->iso_code == null) ? '' : $state->iso_code;
|
||||
$shipping_address->phone = $address->phone;
|
||||
|
||||
$payer_info = new stdClass();
|
||||
$payer_info->email = '"'.$customer->email.'"';
|
||||
$payer_info->first_name = $address->firstname;
|
||||
$payer_info->last_name = $address->lastname;
|
||||
$payer_info->country_code = '"'.$iso_code.'"';
|
||||
$payer_info->shipping_address = array($shipping_address);
|
||||
|
||||
$payer = new stdClass();
|
||||
$payer->payment_method = "paypal";
|
||||
//$payer->payer_info = $payer_info; // Objet set by PayPal
|
||||
|
||||
$aItems = array();
|
||||
/* Item */
|
||||
// ojects needed to get advance paid amount
|
||||
if ($cartItems = $cart->getProducts()) {
|
||||
$objCustomerAdv = new HotelCustomerAdvancedPayment();
|
||||
$objAdvPayment = new HotelAdvancedPayment();
|
||||
$objCartBooking = new HotelCartBookingData();
|
||||
foreach ($cartItems as $cartItem) {
|
||||
// set advance product price if customer chhoses advance payment
|
||||
if (Configuration::get('WK_ALLOW_ADVANCED_PAYMENT')
|
||||
&& $objCustomerAdv->getClientAdvPaymentDtl($this->context->cart->id, $this->context->cart->id_guest)
|
||||
) {
|
||||
$cartItem['price_wt'] = $cartItem['price'] = $objAdvPayment->getProductMinAdvPaymentAmountByIdCart(
|
||||
$this->context->cart->id,
|
||||
$cartItem['id_product']
|
||||
);
|
||||
$cartItem['quantity'] = 1;
|
||||
} elseif ($productRoomTypes = $objCartBooking->getCartInfoIdCartIdProduct(
|
||||
$this->context->cart->id,
|
||||
$cartItem['id_product']
|
||||
)) {
|
||||
$cartItem['price_wt'] = 0;
|
||||
foreach ($productRoomTypes as $cartRoomInfo) {
|
||||
if ($roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$cartRoomInfo['id_product'],
|
||||
$cartRoomInfo['date_from'],
|
||||
$cartRoomInfo['date_to']
|
||||
)) {
|
||||
$cartItem['price_wt'] += $roomTotalPrice['total_price_tax_incl'];
|
||||
$cartItem['price'] += $roomTotalPrice['total_price_tax_excl'];
|
||||
}
|
||||
}
|
||||
$cartItem['quantity'] = 1;
|
||||
}
|
||||
|
||||
$item = new stdClass();
|
||||
$item->name = $cartItem['name'];
|
||||
$item->currency = $oCurrency->iso_code;
|
||||
$item->quantity = $cartItem['quantity'];
|
||||
$item->price = number_format(round($cartItem['price'], 2), 2);
|
||||
$item->tax = number_format(round($cartItem['price_wt'] - $cartItem['price'], 2), 2);
|
||||
$aItems[] = $item;
|
||||
unset($item);
|
||||
}
|
||||
}
|
||||
|
||||
/* ItemList */
|
||||
$itemList = new stdClass();
|
||||
$itemList->items = $aItems;
|
||||
|
||||
/* Detail */
|
||||
$details = new stdClass();
|
||||
$details->shipping = number_format($totalShippingCostWithoutTax, 2);
|
||||
$details->tax = number_format($total_tax, 2);
|
||||
$details->handling_fee = number_format($giftWithoutTax, 2);
|
||||
$details->subtotal = number_format($totalCartWithoutTax - $totalShippingCostWithoutTax - $giftWithoutTax, 2);
|
||||
|
||||
/* Amount */
|
||||
$amount = new stdClass();
|
||||
$amount->total = number_format($totalCartWithTax, 2);
|
||||
$amount->currency = $oCurrency->iso_code;
|
||||
$amount->details = $details;
|
||||
|
||||
/* Transaction */
|
||||
$transaction = new stdClass();
|
||||
$transaction->amount = $amount;
|
||||
$transaction->item_list = $itemList;
|
||||
$transaction->description = "Payment description";
|
||||
$transaction->notify_url = $shop_url.'/modules/paypal/ipn.php';
|
||||
|
||||
/* Redirecte Url */
|
||||
|
||||
$redirectUrls = new stdClass();
|
||||
$redirectUrls->cancel_url = $shop_url._MODULE_DIR_.'paypal/paypal_plus/submit.php?id_cart='.(int) $cart->id;
|
||||
$redirectUrls->return_url = $shop_url._MODULE_DIR_.'paypal/paypal_plus/submit.php?id_cart='.(int) $cart->id;
|
||||
|
||||
/* Payment */
|
||||
$payment = new stdClass();
|
||||
$payment->transactions = array($transaction);
|
||||
$payment->payer = $payer;
|
||||
$payment->intent = "sale";
|
||||
if (Configuration::get('PAYPAL_WEB_PROFILE_ID')) {
|
||||
$payment->experience_profile_id = Configuration::get('PAYPAL_WEB_PROFILE_ID');
|
||||
}
|
||||
$payment->redirect_urls = $redirectUrls;
|
||||
return $payment;
|
||||
}
|
||||
|
||||
protected function createPayment($customer, $cart, $access_token)
|
||||
{
|
||||
|
||||
$data = $this->_createObjectPayment($customer, $cart);
|
||||
|
||||
$header = array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:Bearer '.$access_token,
|
||||
);
|
||||
|
||||
$result = $this->sendByCURL(URL_PPP_CREATE_PAYMENT, Tools::jsonEncode($data), $header);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getCartPaymentTotal($withTax = true)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
if (Configuration::get('WK_ALLOW_ADVANCED_PAYMENT')) {
|
||||
$objCustAdvPay = new HotelCustomerAdvancedPayment();
|
||||
$orderTotal = $objCustAdvPay->getOrdertTotal(
|
||||
$context->cart->id,
|
||||
$context->cart->id_guest
|
||||
);
|
||||
} else {
|
||||
$orderTotal = $cart->getOrderTotal($withTax, Cart::BOTH);
|
||||
}
|
||||
return $orderTotal;
|
||||
}
|
||||
}
|
||||
209
modules/paypal/api/CallApiPaypalPlus.php
Normal file
209
modules/paypal/api/CallApiPaypalPlus.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to 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 PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
require_once _PS_MODULE_DIR_.'paypal/api/ApiPaypalPlus.php';
|
||||
|
||||
define('URL_PPP_CREATE_TOKEN', '/v1/oauth2/token');
|
||||
define('URL_PPP_CREATE_PAYMENT', '/v1/payments/payment');
|
||||
define('URL_PPP_LOOK_UP', '/v1/payments/payment/');
|
||||
define('URL_PPP_WEBPROFILE', '/v1/payment-experience/web-profiles');
|
||||
define('URL_PPP_EXECUTE_PAYMENT', '/v1/payments/payment/');
|
||||
define('URL_PPP_EXECUTE_REFUND', '/v1/payments/sale/');
|
||||
|
||||
define('URL_PPP_PATCH', '/v1/payments/payment/');
|
||||
|
||||
|
||||
class CallApiPaypalPlus extends ApiPaypalPlus
|
||||
{
|
||||
protected $cart = null;
|
||||
protected $customer = null;
|
||||
public $id_payment;
|
||||
|
||||
public function setParams($params)
|
||||
{
|
||||
$this->cart = new Cart($params['cart']->id);
|
||||
$this->customer = new Customer($params['cookie']->id_customer);
|
||||
}
|
||||
|
||||
public function getApprovalUrl()
|
||||
{
|
||||
/*
|
||||
* Récupération du token
|
||||
*/
|
||||
$accessToken = $this->getToken(URL_PPP_CREATE_TOKEN, array('grant_type' => 'client_credentials'));
|
||||
|
||||
if ($accessToken != false) {
|
||||
|
||||
$result = Tools::jsonDecode($this->createPayment($this->customer, $this->cart, $accessToken));
|
||||
|
||||
if (isset($result->links)) {
|
||||
|
||||
foreach ($result->links as $link) {
|
||||
|
||||
if ($link->rel == 'approval_url') {
|
||||
$this->id_payment = $result->id;
|
||||
return $link->href;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function lookUpPayment($paymentId)
|
||||
{
|
||||
|
||||
if ($paymentId == 'NULL') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$accessToken = $this->refreshToken();
|
||||
|
||||
$header = array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:Bearer '.$accessToken,
|
||||
);
|
||||
|
||||
return $this->sendByCURL(URL_PPP_LOOK_UP.$paymentId, false, $header);
|
||||
}
|
||||
|
||||
public function executePayment($payer_id, $paymentId)
|
||||
{
|
||||
|
||||
if ($payer_id == 'NULL' || $paymentId == 'NULL') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$accessToken = $this->refreshToken();
|
||||
|
||||
$header = array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:Bearer '.$accessToken,
|
||||
);
|
||||
|
||||
$data = array('payer_id' => $payer_id);
|
||||
$response = $this->sendByCURL(URL_PPP_EXECUTE_PAYMENT.$paymentId.'/execute/', Tools::jsonEncode($data), $header);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function executeRefund($paymentId, $data)
|
||||
{
|
||||
|
||||
if ($paymentId == 'NULL' || !is_object($data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$accessToken = $this->refreshToken();
|
||||
|
||||
$header = array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:Bearer '.$accessToken,
|
||||
);
|
||||
|
||||
return $this->sendByCURL(URL_PPP_EXECUTE_REFUND.$paymentId.'/refund', Tools::jsonEncode($data), $header);
|
||||
}
|
||||
|
||||
public function patch($id_payment, $address)
|
||||
{
|
||||
/*
|
||||
$totalCartWithTax = $cart->getOrderTotal(true);
|
||||
$totalCartWithoutTax = $cart->getOrderTotal(false);
|
||||
$total_tax = $totalCartWithTax - $totalCartWithoutTax;
|
||||
if ($cart->gift) {
|
||||
if (version_compare(_PS_VERSION_, '1.5.3.0', '>=')) {
|
||||
$giftWithoutTax = $cart->getGiftWrappingPrice(false);
|
||||
} else {
|
||||
$giftWithoutTax = (float) (Configuration::get('PS_GIFT_WRAPPING_PRICE'));
|
||||
}
|
||||
|
||||
} else {
|
||||
$giftWithoutTax = 0;
|
||||
}
|
||||
if (version_compare(_PS_VERSION_, '1.5', '<')) {
|
||||
$totalShippingCostWithoutTax = $cart->getOrderShippingCost(null, false);
|
||||
} else {
|
||||
$totalShippingCostWithoutTax = $cart->getTotalShippingCost(null, false);
|
||||
}
|
||||
|
||||
$oCurrency = new Currency($cart->id_currency);
|
||||
$country = new Country((int) $address->id_country);
|
||||
$iso_code = $country->iso_code;
|
||||
|
||||
$state = new State($address->id_state);
|
||||
$shipping_address = new stdClass();
|
||||
$shipping_address->recipient_name = $address->alias;
|
||||
$shipping_address->type = 'residential';
|
||||
$shipping_address->line1 = $address->address1;
|
||||
$shipping_address->line2 = $address->address2;
|
||||
$shipping_address->city = $address->city;
|
||||
$shipping_address->country_code = $iso_code;
|
||||
$shipping_address->postal_code = $address->postcode;
|
||||
$shipping_address->state = ($state->iso_code == null) ? '' : $state->iso_code;
|
||||
$shipping_address->phone = $address->phone;
|
||||
|
||||
|
||||
$payment = new stdClass();
|
||||
|
||||
$payment->transactions = array();
|
||||
$payment->transactions[0] = new stdClass();
|
||||
$payment->transactions[0]->item_list = new stdClass();
|
||||
$payment->transactions[0]->item_list->shipping_address = $shipping_address;
|
||||
$payment->transactions[0]->amount = new stdClass();
|
||||
$payment->transactions[0]->amount->total = number_format($totalCartWithTax, 2);
|
||||
$payment->transactions[0]->amount->currency = $oCurrency->iso_code;
|
||||
$payment->transactions[0]->amount->details = new stdClass();;
|
||||
$payment->transactions[0]->amount->details->shipping = number_format($totalShippingCostWithoutTax, 2);
|
||||
$payment->transactions[0]->amount->details->tax = number_format($total_tax, 2);
|
||||
$payment->transactions[0]->amount->details->handling_fee = number_format($giftWithoutTax, 2);
|
||||
$payment->transactions[0]->amount->details->subtotal = number_format($totalCartWithoutTax - $totalShippingCostWithoutTax - $giftWithoutTax, 2);
|
||||
|
||||
*/
|
||||
|
||||
$country = new Country((int) $address->id_country);
|
||||
|
||||
$state = new State($address->id_state);
|
||||
|
||||
$payment = array(0 => new stdClass);
|
||||
$payment[0]->op = 'add';
|
||||
$payment[0]->path = '/transactions/0/item_list/shipping_address';
|
||||
$payment[0]->value = new stdClass();
|
||||
$payment[0]->value->line1 = $address->address1;
|
||||
$payment[0]->value->city = $address->city;
|
||||
$payment[0]->value->recipient_name = $address->firstname.' '.$address->lastname;//$address->alias;
|
||||
$payment[0]->value->state = ($state->iso_code == null) ? '' : $state->iso_code;
|
||||
$payment[0]->value->country_code = $country->iso_code;
|
||||
$payment[0]->value->postal_code = $address->postcode;
|
||||
|
||||
$accessToken = $this->refreshToken();
|
||||
$header = array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:Bearer '.$accessToken,
|
||||
);
|
||||
$body = str_replace('\/transactions\/0\/item_list\/shipping_address', '/transactions/0/item_list/shipping_address', Tools::jsonEncode($payment));
|
||||
return $this->sendByCURL(URL_PPP_PATCH.$id_payment, $body, $header, false, 'PATCH');
|
||||
}
|
||||
}
|
||||
33
modules/paypal/api/index.php
Normal file
33
modules/paypal/api/index.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to 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 PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
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;
|
||||
183
modules/paypal/api/paypal_connect.php
Normal file
183
modules/paypal/api/paypal_connect.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* 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 PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class PayPalConnect
|
||||
{
|
||||
private $_logs = array();
|
||||
private $paypal = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->paypal = new PayPal();
|
||||
}
|
||||
|
||||
public function makeConnection($host, $script, $body, $simple_mode = false, $http_header = false, $identify = false)
|
||||
{
|
||||
$this->_logs[] = $this->paypal->l('Making new connection to').' \''.$host.$script.'\'';
|
||||
|
||||
if (function_exists('curl_exec')) {
|
||||
$return = $this->_connectByCURL($host.$script, $body, $http_header, $identify);
|
||||
}
|
||||
|
||||
if (isset($return) && $return) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
$tmp = $this->_connectByFSOCK($host, $script, $body);
|
||||
|
||||
if (!$simple_mode || !preg_match('/[A-Z]+=/', $tmp, $result)) {
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
return Tools::substr($tmp, strpos($tmp, $result[0]));
|
||||
}
|
||||
|
||||
public function getLogs()
|
||||
{
|
||||
return $this->_logs;
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
/********************** CONNECT METHODS *********************/
|
||||
/************************************************************/
|
||||
private function _connectByCURL($url, $body, $http_header = false, $identify = false)
|
||||
{
|
||||
$ch = @curl_init();
|
||||
|
||||
if (!$ch) {
|
||||
$this->_logs[] = $this->paypal->l('Connect failed with CURL method');
|
||||
} else {
|
||||
$this->_logs[] = $this->paypal->l('Connect with CURL method successful');
|
||||
$this->_logs[] = '<b>'.$this->paypal->l('Sending this params:').'</b>';
|
||||
$this->_logs[] = $body;
|
||||
|
||||
@curl_setopt($ch, CURLOPT_URL, 'https://'.$url);
|
||||
|
||||
if ($identify) {
|
||||
@curl_setopt($ch, CURLOPT_USERPWD, Configuration::get('PAYPAL_LOGIN_CLIENT_ID').':'.Configuration::get('PAYPAL_LOGIN_SECRET'));
|
||||
}
|
||||
|
||||
@curl_setopt($ch, CURLOPT_POST, true);
|
||||
if ($body) {
|
||||
@curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
|
||||
}
|
||||
|
||||
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
@curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
@curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
//@curl_setopt($ch, CURLOPT_SSLVERSION, Configuration::get('PAYPAL_VERSION_TLS_CHECKED') == '1.2' ? 6 : 1);
|
||||
|
||||
@curl_setopt($ch, CURLOPT_VERBOSE, false);
|
||||
if ($http_header) {
|
||||
@curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header);
|
||||
}
|
||||
|
||||
$result = @curl_exec($ch);
|
||||
|
||||
if (!$result) {
|
||||
$this->_logs[] = $this->paypal->l('Send with CURL method failed ! Error:').' '.curl_error($ch);
|
||||
if (curl_errno($ch)) {
|
||||
$this->_logPaypal(curl_error($ch));
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->_logs[] = $this->paypal->l('Send with CURL method successful');
|
||||
}
|
||||
|
||||
@curl_close($ch);
|
||||
}
|
||||
return $result ? $result : false;
|
||||
}
|
||||
|
||||
private function _connectByFSOCK($host, $script, $body)
|
||||
{
|
||||
$fp = @fsockopen('tls://'.$host, 443, $errno, $errstr, 4);
|
||||
|
||||
if (!$fp) {
|
||||
$this->_logs[] = $this->paypal->l('Connect failed with fsockopen method');
|
||||
} else {
|
||||
$header = $this->_makeHeader($host, $script, Tools::strlen($body));
|
||||
$this->_logs[] = $this->paypal->l('Sending this params:').' '.$header.$body;
|
||||
|
||||
@fputs($fp, $header.$body);
|
||||
|
||||
$tmp = '';
|
||||
while (!feof($fp)) {
|
||||
$tmp .= trim(fgets($fp, 1024));
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
|
||||
if (!isset($tmp) || $tmp == false) {
|
||||
$this->_logs[] = $this->paypal->l('Send with fsockopen method failed !');
|
||||
} else {
|
||||
$this->_logs[] = $this->paypal->l('Send with fsockopen method successful');
|
||||
}
|
||||
|
||||
}
|
||||
return isset($tmp) ? $tmp : false;
|
||||
}
|
||||
|
||||
private function _makeHeader($host, $script, $lenght)
|
||||
{
|
||||
return 'POST '.(string) $script.' HTTP/1.1'."\r\n".
|
||||
'Host: '.(string) $host."\r\n".
|
||||
'Content-Type: application/x-www-form-urlencoded'."\r\n".
|
||||
'Content-Length: '.(int) $lenght."\r\n".
|
||||
'Connection: close'."\r\n\r\n";
|
||||
}
|
||||
|
||||
private function _logPaypal($message)
|
||||
{
|
||||
try {
|
||||
$date = date('Ymd');
|
||||
$path = _PS_MODULE_DIR_.'paypal/log/';
|
||||
$context = Context::getContext();
|
||||
// file_put_contents($path.$date.'_paypal_curl.log',date('d/m/Y H:i:s').' cart : '.$context->cart->id.' => '.$message.PHP_EOL,FILE_APPEND);
|
||||
$date_last_purge = Configuration::get('PAYPAL_PURGE_LOG_DATE');
|
||||
// if date not set : set at yesterday
|
||||
if (!$date_last_purge) {
|
||||
$date_last_purge = date('Ymd', strtotime('yesterday'));
|
||||
}
|
||||
if ($date_last_purge < $date) {
|
||||
$date_limit_purge = date('Ymd', strtotime('-1 month'));
|
||||
$dir = opendir($path);
|
||||
while ($file = readdir($dir)) {
|
||||
$date_file = Tools::substr($file, 0, 8);
|
||||
if ($file !='.' && $file != '..' && $date_file <= $date_limit_purge) {
|
||||
unlink($path.$file);
|
||||
}
|
||||
}
|
||||
Configuration::updateValue('PAYPAL_PURGE_LOG_DATE', $date);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
115
modules/paypal/api/paypal_lib.php
Normal file
115
modules/paypal/api/paypal_lib.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* 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 PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
include_once _PS_MODULE_DIR_.'paypal/api/paypal_connect.php';
|
||||
|
||||
define('PAYPAL_API_VERSION', '106.0');
|
||||
|
||||
class PaypalLib
|
||||
{
|
||||
|
||||
private $enable_log = false;
|
||||
private $_logs = array();
|
||||
protected $paypal = null;
|
||||
public function __construct()
|
||||
{
|
||||
$this->paypal = new PayPal();
|
||||
}
|
||||
|
||||
public function getLogs()
|
||||
{
|
||||
return $this->_logs;
|
||||
}
|
||||
|
||||
public function makeCall($host, $script, $method_name, $data, $method_version = '')
|
||||
{
|
||||
// Making request string
|
||||
$method_version = (!empty($method_version)) ? $method_version : PAYPAL_API_VERSION;
|
||||
|
||||
$params = array(
|
||||
'METHOD' => $method_name,
|
||||
'VERSION' => $method_version,
|
||||
'PWD' => Configuration::get('PAYPAL_API_PASSWORD'),
|
||||
'USER' => Configuration::get('PAYPAL_API_USER'),
|
||||
'SIGNATURE' => Configuration::get('PAYPAL_API_SIGNATURE'),
|
||||
);
|
||||
|
||||
$request = http_build_query($params, '', '&');
|
||||
$request .= '&'.(!is_array($data) ? $data : http_build_query($data, '', '&'));
|
||||
|
||||
// Making connection
|
||||
$result = $this->makeSimpleCall($host, $script, $request, true);
|
||||
$response = explode('&', $result);
|
||||
$logs_request = $this->_logs;
|
||||
$return = array();
|
||||
|
||||
if ($this->enable_log === true) {
|
||||
$handle = fopen(dirname(__FILE__).'/Results.txt', 'a+');
|
||||
fwrite($handle, 'Host : '.print_r($host, true)."\r\n");
|
||||
fwrite($handle, 'Request : '.print_r($request, true)."\r\n");
|
||||
fwrite($handle, 'Result : '.print_r($result, true)."\r\n");
|
||||
fwrite($handle, 'Logs : '.print_r($this->_logs, true."\r\n"));
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
foreach ($response as $value) {
|
||||
$tmp = explode('=', $value);
|
||||
$return[$tmp[0]] = urldecode(!isset($tmp[1]) ? $tmp[0] : $tmp[1]);
|
||||
}
|
||||
|
||||
if (!Configuration::get('PAYPAL_DEBUG_MODE')) {
|
||||
$this->_logs = array();
|
||||
}
|
||||
|
||||
$to_exclude = array('TOKEN', 'SUCCESSPAGEREDIRECTREQUESTED', 'VERSION', 'BUILD', 'ACK', 'CORRELATIONID');
|
||||
$this->_logs[] = '<b>'.$this->paypal->l('PayPal response:').'</b>';
|
||||
|
||||
foreach ($return as $key => $value) {
|
||||
if (!Configuration::get('PAYPAL_DEBUG_MODE') && in_array($key, $to_exclude)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->_logs[] = $key.' -> '.$value;
|
||||
}
|
||||
|
||||
// if (count($this->_logs) <= 2) {
|
||||
// $this->_logs = array_merge($this->_logs, $logs_request);
|
||||
// }
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function makeSimpleCall($host, $script, $request, $simple_mode = false)
|
||||
{
|
||||
// Making connection
|
||||
$paypal_connect = new PayPalConnect();
|
||||
|
||||
$result = $paypal_connect->makeConnection($host, $script, $request, $simple_mode);
|
||||
$this->_logs = $paypal_connect->getLogs();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
35
modules/paypal/api/sdk/braintree/index.php
Normal file
35
modules/paypal/api/sdk/braintree/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to 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 PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
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;
|
||||
25
modules/paypal/api/sdk/braintree/lib/Braintree.php
Normal file
25
modules/paypal/api/sdk/braintree/lib/Braintree.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Braintree PHP Library
|
||||
* Creates class_aliases for old class names replaced by PSR-4 Namespaces
|
||||
*
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*/
|
||||
|
||||
require_once('autoload.php');
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
|
||||
throw new Braintree_Exception('PHP version >= 5.4.0 required');
|
||||
}
|
||||
|
||||
|
||||
function requireDependencies() {
|
||||
$requiredExtensions = ['xmlwriter', 'openssl', 'dom', 'hash', 'curl'];
|
||||
foreach ($requiredExtensions AS $ext) {
|
||||
if (!extension_loaded($ext)) {
|
||||
throw new Braintree_Exception('The Braintree library requires the ' . $ext . ' extension.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
requireDependencies();
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Creates an instance of AccountUpdaterDailyReport
|
||||
*
|
||||
*
|
||||
* @package Braintree
|
||||
* @copyright 2016 Braintree, a division of PayPal, Inc.
|
||||
*
|
||||
* @property-read string $reportUrl
|
||||
* @property-read date $reportDate
|
||||
* @property-read date $receivedDate
|
||||
*/
|
||||
final class AccountUpdaterDailyReport extends Base
|
||||
{
|
||||
protected $_attributes = [];
|
||||
|
||||
protected function _initialize($disputeAttribs)
|
||||
{
|
||||
$this->_attributes = $disputeAttribs;
|
||||
}
|
||||
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$instance = new self();
|
||||
$instance->_initialize($attributes);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$display = [
|
||||
'reportDate', 'reportUrl'
|
||||
];
|
||||
|
||||
$displayAttributes = [];
|
||||
foreach ($display AS $attrib) {
|
||||
$displayAttributes[$attrib] = $this->$attrib;
|
||||
}
|
||||
return __CLASS__ . '[' .
|
||||
Util::attributesToString($displayAttributes) .']';
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\AccountUpdaterDailyReport', 'Braintree_AccountUpdaterDailyReport');
|
||||
29
modules/paypal/api/sdk/braintree/lib/Braintree/AddOn.php
Normal file
29
modules/paypal/api/sdk/braintree/lib/Braintree/AddOn.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
class AddOn extends Modification
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return AddOn
|
||||
*/
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$instance = new self();
|
||||
$instance->_initialize($attributes);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* static methods redirecting to gateway
|
||||
*
|
||||
* @return AddOn[]
|
||||
*/
|
||||
public static function all()
|
||||
{
|
||||
return Configuration::gateway()->addOn()->all();
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\AddOn', 'Braintree_AddOn');
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
class AddOnGateway
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var Gateway
|
||||
*/
|
||||
private $_gateway;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Configuration
|
||||
*/
|
||||
private $_config;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Http
|
||||
*/
|
||||
private $_http;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Gateway $gateway
|
||||
*/
|
||||
public function __construct($gateway)
|
||||
{
|
||||
$this->_gateway = $gateway;
|
||||
$this->_config = $gateway->config;
|
||||
$this->_config->assertHasAccessTokenOrKeys();
|
||||
$this->_http = new Http($gateway->config);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return AddOn[]
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
$path = $this->_config->merchantPath() . '/add_ons';
|
||||
$response = $this->_http->get($path);
|
||||
|
||||
$addOns = ["addOn" => $response['addOns']];
|
||||
|
||||
return Util::extractAttributeAsArray(
|
||||
$addOns,
|
||||
'addOn'
|
||||
);
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\AddOnGateway', 'Braintree_AddOnGateway');
|
||||
151
modules/paypal/api/sdk/braintree/lib/Braintree/Address.php
Normal file
151
modules/paypal/api/sdk/braintree/lib/Braintree/Address.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Braintree Address module
|
||||
* PHP Version 5
|
||||
* Creates and manages Braintree Addresses
|
||||
*
|
||||
* An Address belongs to a Customer. It can be associated to a
|
||||
* CreditCard as the billing address. It can also be used
|
||||
* as the shipping address when creating a Transaction.
|
||||
*
|
||||
* @package Braintree
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*
|
||||
* @property-read string $company
|
||||
* @property-read string $countryName
|
||||
* @property-read string $createdAt
|
||||
* @property-read string $customerId
|
||||
* @property-read string $extendedAddress
|
||||
* @property-read string $firstName
|
||||
* @property-read string $id
|
||||
* @property-read string $lastName
|
||||
* @property-read string $locality
|
||||
* @property-read string $postalCode
|
||||
* @property-read string $region
|
||||
* @property-read string $streetAddress
|
||||
* @property-read string $updatedAt
|
||||
*/
|
||||
class Address extends Base
|
||||
{
|
||||
/**
|
||||
* returns false if comparing object is not a Address,
|
||||
* or is a Address with a different id
|
||||
*
|
||||
* @param object $other address to compare against
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEqual($other)
|
||||
{
|
||||
return !($other instanceof self) ?
|
||||
false :
|
||||
($this->id === $other->id && $this->customerId === $other->customerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a printable representation of the object as:
|
||||
* ClassName[property=value, property=value]
|
||||
* @ignore
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return __CLASS__ . '[' .
|
||||
Util::attributesToString($this->_attributes) . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* sets instance properties from an array of values
|
||||
*
|
||||
* @ignore
|
||||
* @access protected
|
||||
* @param array $addressAttribs array of address data
|
||||
* @return void
|
||||
*/
|
||||
protected function _initialize($addressAttribs)
|
||||
{
|
||||
// set the attributes
|
||||
$this->_attributes = $addressAttribs;
|
||||
}
|
||||
|
||||
/**
|
||||
* factory method: returns an instance of Address
|
||||
* to the requesting method, with populated properties
|
||||
* @ignore
|
||||
* @return Address
|
||||
*/
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$instance = new self();
|
||||
$instance->_initialize($attributes);
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// static methods redirecting to gateway
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $attribs
|
||||
* @return Address
|
||||
*/
|
||||
public static function create($attribs)
|
||||
{
|
||||
return Configuration::gateway()->address()->create($attribs);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $attribs
|
||||
* @return Address
|
||||
*/
|
||||
public static function createNoValidate($attribs)
|
||||
{
|
||||
return Configuration::gateway()->address()->createNoValidate($attribs);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Customer|int $customerOrId
|
||||
* @param int $addressId
|
||||
* @throws InvalidArgumentException
|
||||
* @return Result\Successful
|
||||
*/
|
||||
public static function delete($customerOrId = null, $addressId = null)
|
||||
{
|
||||
return Configuration::gateway()->address()->delete($customerOrId, $addressId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Customer|int $customerOrId
|
||||
* @param int $addressId
|
||||
* @throws Exception\NotFound
|
||||
* @return Address
|
||||
*/
|
||||
public static function find($customerOrId, $addressId)
|
||||
{
|
||||
return Configuration::gateway()->address()->find($customerOrId, $addressId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Customer|int $customerOrId
|
||||
* @param int $addressId
|
||||
* @param array $attributes
|
||||
* @throws Exception\Unexpected
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
public static function update($customerOrId, $addressId, $attributes)
|
||||
{
|
||||
return Configuration::gateway()->address()->update($customerOrId, $addressId, $attributes);
|
||||
}
|
||||
|
||||
public static function updateNoValidate($customerOrId, $addressId, $attributes)
|
||||
{
|
||||
return Configuration::gateway()->address()->updateNoValidate($customerOrId, $addressId, $attributes);
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\Address', 'Braintree_Address');
|
||||
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Braintree AddressGateway module
|
||||
* PHP Version 5
|
||||
* Creates and manages Braintree Addresses
|
||||
*
|
||||
* An Address belongs to a Customer. It can be associated to a
|
||||
* CreditCard as the billing address. It can also be used
|
||||
* as the shipping address when creating a Transaction.
|
||||
*
|
||||
* @package Braintree
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*/
|
||||
class AddressGateway
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var Gateway
|
||||
*/
|
||||
private $_gateway;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Configuration
|
||||
*/
|
||||
private $_config;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Http
|
||||
*/
|
||||
private $_http;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Gateway $gateway
|
||||
*/
|
||||
public function __construct($gateway)
|
||||
{
|
||||
$this->_gateway = $gateway;
|
||||
$this->_config = $gateway->config;
|
||||
$this->_config->assertHasAccessTokenOrKeys();
|
||||
$this->_http = new Http($gateway->config);
|
||||
}
|
||||
|
||||
|
||||
/* public class methods */
|
||||
/**
|
||||
*
|
||||
* @access public
|
||||
* @param array $attribs
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
public function create($attribs)
|
||||
{
|
||||
Util::verifyKeys(self::createSignature(), $attribs);
|
||||
$customerId = isset($attribs['customerId']) ?
|
||||
$attribs['customerId'] :
|
||||
null;
|
||||
|
||||
$this->_validateCustomerId($customerId);
|
||||
unset($attribs['customerId']);
|
||||
return $this->_doCreate(
|
||||
'/customers/' . $customerId . '/addresses',
|
||||
['address' => $attribs]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* attempts the create operation assuming all data will validate
|
||||
* returns a Address object instead of a Result
|
||||
*
|
||||
* @access public
|
||||
* @param array $attribs
|
||||
* @return self
|
||||
* @throws Exception\ValidationError
|
||||
*/
|
||||
public function createNoValidate($attribs)
|
||||
{
|
||||
$result = $this->create($attribs);
|
||||
return Util::returnObjectOrThrowException(__CLASS__, $result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* delete an address by id
|
||||
*
|
||||
* @param mixed $customerOrId
|
||||
* @param string $addressId
|
||||
*/
|
||||
public function delete($customerOrId = null, $addressId = null)
|
||||
{
|
||||
$this->_validateId($addressId);
|
||||
$customerId = $this->_determineCustomerId($customerOrId);
|
||||
$path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
|
||||
$this->_http->delete($path);
|
||||
return new Result\Successful();
|
||||
}
|
||||
|
||||
/**
|
||||
* find an address by id
|
||||
*
|
||||
* Finds the address with the given <b>addressId</b> that is associated
|
||||
* to the given <b>customerOrId</b>.
|
||||
* If the address cannot be found, a NotFound exception will be thrown.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $customerOrId
|
||||
* @param string $addressId
|
||||
* @return Address
|
||||
* @throws Exception\NotFound
|
||||
*/
|
||||
public function find($customerOrId, $addressId)
|
||||
{
|
||||
|
||||
$customerId = $this->_determineCustomerId($customerOrId);
|
||||
$this->_validateId($addressId);
|
||||
|
||||
try {
|
||||
$path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
|
||||
$response = $this->_http->get($path);
|
||||
return Address::factory($response['address']);
|
||||
} catch (Exception\NotFound $e) {
|
||||
throw new Exception\NotFound(
|
||||
'address for customer ' . $customerId .
|
||||
' with id ' . $addressId . ' not found.'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* updates the address record
|
||||
*
|
||||
* if calling this method in context,
|
||||
* customerOrId is the 2nd attribute, addressId 3rd.
|
||||
* customerOrId & addressId are not sent in object context.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param array $attributes
|
||||
* @param mixed $customerOrId (only used in call)
|
||||
* @param string $addressId (only used in call)
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
public function update($customerOrId, $addressId, $attributes)
|
||||
{
|
||||
$this->_validateId($addressId);
|
||||
$customerId = $this->_determineCustomerId($customerOrId);
|
||||
Util::verifyKeys(self::updateSignature(), $attributes);
|
||||
|
||||
$path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
|
||||
$response = $this->_http->put($path, ['address' => $attributes]);
|
||||
|
||||
return $this->_verifyGatewayResponse($response);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* update an address record, assuming validations will pass
|
||||
*
|
||||
* if calling this method in context,
|
||||
* customerOrId is the 2nd attribute, addressId 3rd.
|
||||
* customerOrId & addressId are not sent in object context.
|
||||
*
|
||||
* @access public
|
||||
* @param array $transactionAttribs
|
||||
* @param string $customerId
|
||||
* @return Transaction
|
||||
* @throws Exception\ValidationsFailed
|
||||
* @see Address::update()
|
||||
*/
|
||||
public function updateNoValidate($customerOrId, $addressId, $attributes)
|
||||
{
|
||||
$result = $this->update($customerOrId, $addressId, $attributes);
|
||||
return Util::returnObjectOrThrowException(__CLASS__, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a full array signature of a valid create request
|
||||
* @return array gateway create request format
|
||||
*/
|
||||
public static function createSignature()
|
||||
{
|
||||
return [
|
||||
'company', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
|
||||
'countryName', 'customerId', 'extendedAddress', 'firstName',
|
||||
'lastName', 'locality', 'postalCode', 'region', 'streetAddress'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a full array signature of a valid update request
|
||||
* @return array gateway update request format
|
||||
*/
|
||||
public static function updateSignature()
|
||||
{
|
||||
// TODO: remove customerId from update signature
|
||||
return self::createSignature();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* verifies that a valid address id is being used
|
||||
* @ignore
|
||||
* @param string $id address id
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function _validateId($id = null)
|
||||
{
|
||||
if (empty($id) || trim($id) == "") {
|
||||
throw new InvalidArgumentException(
|
||||
'expected address id to be set'
|
||||
);
|
||||
}
|
||||
if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) {
|
||||
throw new InvalidArgumentException(
|
||||
$id . ' is an invalid address id.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* verifies that a valid customer id is being used
|
||||
* @ignore
|
||||
* @param string $id customer id
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function _validateCustomerId($id = null)
|
||||
{
|
||||
if (empty($id) || trim($id) == "") {
|
||||
throw new InvalidArgumentException(
|
||||
'expected customer id to be set'
|
||||
);
|
||||
}
|
||||
if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) {
|
||||
throw new InvalidArgumentException(
|
||||
$id . ' is an invalid customer id.'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* determines if a string id or Customer object was passed
|
||||
* @ignore
|
||||
* @param mixed $customerOrId
|
||||
* @return string customerId
|
||||
*/
|
||||
private function _determineCustomerId($customerOrId)
|
||||
{
|
||||
$customerId = ($customerOrId instanceof Customer) ? $customerOrId->id : $customerOrId;
|
||||
$this->_validateCustomerId($customerId);
|
||||
return $customerId;
|
||||
|
||||
}
|
||||
|
||||
/* private class methods */
|
||||
/**
|
||||
* sends the create request to the gateway
|
||||
* @ignore
|
||||
* @param string $subPath
|
||||
* @param array $params
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
private function _doCreate($subPath, $params)
|
||||
{
|
||||
$fullPath = $this->_config->merchantPath() . $subPath;
|
||||
$response = $this->_http->post($fullPath, $params);
|
||||
|
||||
return $this->_verifyGatewayResponse($response);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* generic method for validating incoming gateway responses
|
||||
*
|
||||
* creates a new Address object and encapsulates
|
||||
* it inside a Result\Successful object, or
|
||||
* encapsulates an Errors object inside a Result\Error
|
||||
* alternatively, throws an Unexpected exception if the response is invalid
|
||||
*
|
||||
* @ignore
|
||||
* @param array $response gateway response values
|
||||
* @return Result\Successful|Result\Error
|
||||
* @throws Exception\Unexpected
|
||||
*/
|
||||
private function _verifyGatewayResponse($response)
|
||||
{
|
||||
if (isset($response['address'])) {
|
||||
// return a populated instance of Address
|
||||
return new Result\Successful(
|
||||
Address::factory($response['address'])
|
||||
);
|
||||
} else if (isset($response['apiErrorResponse'])) {
|
||||
return new Result\Error($response['apiErrorResponse']);
|
||||
} else {
|
||||
throw new Exception\Unexpected(
|
||||
"Expected address or apiErrorResponse"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\AddressGateway', 'Braintree_AddressGateway');
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Braintree AmexExpressCheckoutCard module
|
||||
* Creates and manages Braintree Amex Express Checkout cards
|
||||
*
|
||||
* <b>== More information ==</b>
|
||||
*
|
||||
* See {@link https://developers.braintreepayments.com/javascript+php}<br />
|
||||
*
|
||||
* @package Braintree
|
||||
* @category Resources
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*
|
||||
* @property-read string $createdAt
|
||||
* @property-read string $default
|
||||
* @property-read string $updatedAt
|
||||
* @property-read string $customerId
|
||||
* @property-read string $cardType
|
||||
* @property-read string $bin
|
||||
* @property-read string $cardMemberExpiryDate
|
||||
* @property-read string $cardMemberNumber
|
||||
* @property-read string $cardType
|
||||
* @property-read string $sourceDescription
|
||||
* @property-read string $token
|
||||
* @property-read string $imageUrl
|
||||
* @property-read string $expirationMonth
|
||||
* @property-read string $expirationYear
|
||||
*/
|
||||
class AmexExpressCheckoutCard extends Base
|
||||
{
|
||||
/* instance methods */
|
||||
/**
|
||||
* returns false if default is null or false
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDefault()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* factory method: returns an instance of AmexExpressCheckoutCard
|
||||
* to the requesting method, with populated properties
|
||||
*
|
||||
* @ignore
|
||||
* @return AmexExpressCheckoutCard
|
||||
*/
|
||||
public static function factory($attributes)
|
||||
{
|
||||
|
||||
$instance = new self();
|
||||
$instance->_initialize($attributes);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets instance properties from an array of values
|
||||
*
|
||||
* @access protected
|
||||
* @param array $amexExpressCheckoutCardAttribs array of Amex Express Checkout card properties
|
||||
* @return void
|
||||
*/
|
||||
protected function _initialize($amexExpressCheckoutCardAttribs)
|
||||
{
|
||||
// set the attributes
|
||||
$this->_attributes = $amexExpressCheckoutCardAttribs;
|
||||
|
||||
$subscriptionArray = [];
|
||||
if (isset($amexExpressCheckoutCardAttribs['subscriptions'])) {
|
||||
foreach ($amexExpressCheckoutCardAttribs['subscriptions'] AS $subscription) {
|
||||
$subscriptionArray[] = Subscription::factory($subscription);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_set('subscriptions', $subscriptionArray);
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\AmexExpressCheckoutCard', 'Braintree_AmexExpressCheckoutCard');
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Braintree AndroidPayCard module
|
||||
* Creates and manages Braintree Android Pay cards
|
||||
*
|
||||
* <b>== More information ==</b>
|
||||
*
|
||||
* See {@link https://developers.braintreepayments.com/javascript+php}<br />
|
||||
*
|
||||
* @package Braintree
|
||||
* @category Resources
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*
|
||||
* @property-read string $bin
|
||||
* @property-read string $cardType
|
||||
* @property-read string $createdAt
|
||||
* @property-read string $customerId
|
||||
* @property-read string $default
|
||||
* @property-read string $expirationMonth
|
||||
* @property-read string $expirationYear
|
||||
* @property-read string $googleTransactionId
|
||||
* @property-read string $imageUrl
|
||||
* @property-read string $last4
|
||||
* @property-read string $sourceCardLast4
|
||||
* @property-read string $sourceCardType
|
||||
* @property-read string $sourceDescription
|
||||
* @property-read string $token
|
||||
* @property-read string $updatedAt
|
||||
* @property-read string $virtualCardLast4
|
||||
* @property-read string $virtualCardType
|
||||
*/
|
||||
class AndroidPayCard extends Base
|
||||
{
|
||||
/* instance methods */
|
||||
/**
|
||||
* returns false if default is null or false
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDefault()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* factory method: returns an instance of AndroidPayCard
|
||||
* to the requesting method, with populated properties
|
||||
*
|
||||
* @ignore
|
||||
* @return AndroidPayCard
|
||||
*/
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$defaultAttributes = [
|
||||
'expirationMonth' => '',
|
||||
'expirationYear' => '',
|
||||
'last4' => $attributes['virtualCardLast4'],
|
||||
'cardType' => $attributes['virtualCardType'],
|
||||
];
|
||||
|
||||
$instance = new self();
|
||||
$instance->_initialize(array_merge($defaultAttributes, $attributes));
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets instance properties from an array of values
|
||||
*
|
||||
* @access protected
|
||||
* @param array $androidPayCardAttribs array of Android Pay card properties
|
||||
* @return void
|
||||
*/
|
||||
protected function _initialize($androidPayCardAttribs)
|
||||
{
|
||||
// set the attributes
|
||||
$this->_attributes = $androidPayCardAttribs;
|
||||
|
||||
$subscriptionArray = [];
|
||||
if (isset($androidPayCardAttribs['subscriptions'])) {
|
||||
foreach ($androidPayCardAttribs['subscriptions'] AS $subscription) {
|
||||
$subscriptionArray[] = Subscription::factory($subscription);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_set('subscriptions', $subscriptionArray);
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\AndroidPayCard', 'Braintree_AndroidPayCard');
|
||||
100
modules/paypal/api/sdk/braintree/lib/Braintree/ApplePayCard.php
Normal file
100
modules/paypal/api/sdk/braintree/lib/Braintree/ApplePayCard.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Braintree ApplePayCard module
|
||||
* Creates and manages Braintree Apple Pay cards
|
||||
*
|
||||
* <b>== More information ==</b>
|
||||
*
|
||||
* See {@link https://developers.braintreepayments.com/javascript+php}<br />
|
||||
*
|
||||
* @package Braintree
|
||||
* @category Resources
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*
|
||||
* @property-read string $cardType
|
||||
* @property-read string $createdAt
|
||||
* @property-read string $customerId
|
||||
* @property-read string $expirationDate
|
||||
* @property-read string $expirationMonth
|
||||
* @property-read string $expirationYear
|
||||
* @property-read string $imageUrl
|
||||
* @property-read string $last4
|
||||
* @property-read string $token
|
||||
* @property-read string $paymentInstrumentName
|
||||
* @property-read string $sourceDescription
|
||||
* @property-read string $updatedAt
|
||||
*/
|
||||
class ApplePayCard extends Base
|
||||
{
|
||||
// Card Type
|
||||
const AMEX = 'Apple Pay - American Express';
|
||||
const MASTER_CARD = 'Apple Pay - MasterCard';
|
||||
const VISA = 'Apple Pay - Visa';
|
||||
|
||||
/* instance methods */
|
||||
/**
|
||||
* returns false if default is null or false
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDefault()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether the card is expired based on the current date
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isExpired()
|
||||
{
|
||||
return $this->expired;
|
||||
}
|
||||
|
||||
/**
|
||||
* factory method: returns an instance of ApplePayCard
|
||||
* to the requesting method, with populated properties
|
||||
*
|
||||
* @ignore
|
||||
* @return ApplePayCard
|
||||
*/
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$defaultAttributes = [
|
||||
'expirationMonth' => '',
|
||||
'expirationYear' => '',
|
||||
'last4' => '',
|
||||
];
|
||||
|
||||
$instance = new self();
|
||||
$instance->_initialize(array_merge($defaultAttributes, $attributes));
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets instance properties from an array of values
|
||||
*
|
||||
* @access protected
|
||||
* @param array $applePayCardAttribs array of Apple Pay card properties
|
||||
* @return void
|
||||
*/
|
||||
protected function _initialize($applePayCardAttribs)
|
||||
{
|
||||
// set the attributes
|
||||
$this->_attributes = $applePayCardAttribs;
|
||||
|
||||
$subscriptionArray = [];
|
||||
if (isset($applePayCardAttribs['subscriptions'])) {
|
||||
foreach ($applePayCardAttribs['subscriptions'] AS $subscription) {
|
||||
$subscriptionArray[] = Subscription::factory($subscription);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_set('subscriptions', $subscriptionArray);
|
||||
$this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\ApplePayCard', 'Braintree_ApplePayCard');
|
||||
77
modules/paypal/api/sdk/braintree/lib/Braintree/Base.php
Normal file
77
modules/paypal/api/sdk/braintree/lib/Braintree/Base.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Braintree PHP Library.
|
||||
*
|
||||
* Braintree base class and initialization
|
||||
* Provides methods to child classes. This class cannot be instantiated.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*/
|
||||
abstract class Base
|
||||
{
|
||||
protected $_attributes = [];
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* don't permit an explicit call of the constructor!
|
||||
* (like $t = new Transaction())
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable cloning of objects
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
protected function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor for instance properties stored in the private $_attributes property
|
||||
*
|
||||
* @ignore
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (array_key_exists($name, $this->_attributes)) {
|
||||
return $this->_attributes[$name];
|
||||
}
|
||||
else {
|
||||
trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the existance of a property stored in the private $_attributes property
|
||||
*
|
||||
* @ignore
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
return array_key_exists($name, $this->_attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutator for instance properties stored in the private $_attributes property
|
||||
*
|
||||
* @ignore
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function _set($key, $value)
|
||||
{
|
||||
$this->_attributes[$key] = $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
class ClientToken
|
||||
{
|
||||
const DEFAULT_VERSION = 2;
|
||||
|
||||
|
||||
// static methods redirecting to gateway
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public static function generate($params=[])
|
||||
{
|
||||
return Configuration::gateway()->clientToken()->generate($params);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type $params
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function conditionallyVerifyKeys($params)
|
||||
{
|
||||
return Configuration::gateway()->clientToken()->conditionallyVerifyKeys($params);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string client token retrieved from server
|
||||
*/
|
||||
public static function generateWithCustomerIdSignature()
|
||||
{
|
||||
return Configuration::gateway()->clientToken()->generateWithCustomerIdSignature();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string client token retrieved from server
|
||||
*/
|
||||
public static function generateWithoutCustomerIdSignature()
|
||||
{
|
||||
return Configuration::gateway()->clientToken()->generateWithoutCustomerIdSignature();
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\ClientToken', 'Braintree_ClientToken');
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
class ClientTokenGateway
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var Gateway
|
||||
*/
|
||||
private $_gateway;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Configuration
|
||||
*/
|
||||
private $_config;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Http
|
||||
*/
|
||||
private $_http;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Gateway $gateway
|
||||
*/
|
||||
public function __construct($gateway)
|
||||
{
|
||||
$this->_gateway = $gateway;
|
||||
$this->_config = $gateway->config;
|
||||
$this->_config->assertHasAccessTokenOrKeys();
|
||||
$this->_http = new Http($gateway->config);
|
||||
}
|
||||
|
||||
public function generate($params=[])
|
||||
{
|
||||
if (!array_key_exists("version", $params)) {
|
||||
$params["version"] = ClientToken::DEFAULT_VERSION;
|
||||
}
|
||||
|
||||
$this->conditionallyVerifyKeys($params);
|
||||
$generateParams = ["client_token" => $params];
|
||||
|
||||
return $this->_doGenerate('/client_token', $generateParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* sends the generate request to the gateway
|
||||
*
|
||||
* @ignore
|
||||
* @param var $url
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function _doGenerate($subPath, $params)
|
||||
{
|
||||
$fullPath = $this->_config->merchantPath() . $subPath;
|
||||
$response = $this->_http->post($fullPath, $params);
|
||||
|
||||
return $this->_verifyGatewayResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $params
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function conditionallyVerifyKeys($params)
|
||||
{
|
||||
if (array_key_exists("customerId", $params)) {
|
||||
Util::verifyKeys($this->generateWithCustomerIdSignature(), $params);
|
||||
} else {
|
||||
Util::verifyKeys($this->generateWithoutCustomerIdSignature(), $params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function generateWithCustomerIdSignature()
|
||||
{
|
||||
return [
|
||||
"version", "customerId", "proxyMerchantId",
|
||||
["options" => ["makeDefault", "verifyCard", "failOnDuplicatePaymentMethod"]],
|
||||
"merchantAccountId", "sepaMandateType", "sepaMandateAcceptanceLocation"];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function generateWithoutCustomerIdSignature()
|
||||
{
|
||||
return ["version", "proxyMerchantId", "merchantAccountId"];
|
||||
}
|
||||
|
||||
/**
|
||||
* generic method for validating incoming gateway responses
|
||||
*
|
||||
* If the request is successful, returns a client token string.
|
||||
* Otherwise, throws an InvalidArgumentException with the error
|
||||
* response from the Gateway or an HTTP status code exception.
|
||||
*
|
||||
* @ignore
|
||||
* @param array $response gateway response values
|
||||
* @return string client token
|
||||
* @throws InvalidArgumentException | HTTP status code exception
|
||||
*/
|
||||
private function _verifyGatewayResponse($response)
|
||||
{
|
||||
if (isset($response['clientToken'])) {
|
||||
return $response['clientToken']['value'];
|
||||
} elseif (isset($response['apiErrorResponse'])) {
|
||||
throw new InvalidArgumentException(
|
||||
$response['apiErrorResponse']['message']
|
||||
);
|
||||
} else {
|
||||
throw new Exception\Unexpected(
|
||||
"Expected clientToken or apiErrorResponse"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
class_alias('Braintree\ClientTokenGateway', 'Braintree_ClientTokenGateway');
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Braintree CoinbaseAccount module
|
||||
*
|
||||
* @package Braintree
|
||||
* @category Resources
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Manages Braintree CoinbaseAccounts
|
||||
*
|
||||
* <b>== More information ==</b>
|
||||
*
|
||||
*
|
||||
* @package Braintree
|
||||
* @category Resources
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*
|
||||
* @property-read string $customerId
|
||||
* @property-read string $token
|
||||
* @property-read string $userId
|
||||
* @property-read string $userName
|
||||
* @property-read string $userEmail
|
||||
*/
|
||||
class CoinbaseAccount extends Base
|
||||
{
|
||||
/**
|
||||
* factory method: returns an instance of CoinbaseAccount
|
||||
* to the requesting method, with populated properties
|
||||
*
|
||||
* @ignore
|
||||
* @return CoinbaseAccount
|
||||
*/
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$instance = new self();
|
||||
$instance->_initialize($attributes);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/* instance methods */
|
||||
|
||||
/**
|
||||
* returns false if default is null or false
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDefault()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets instance properties from an array of values
|
||||
*
|
||||
* @access protected
|
||||
* @param array $coinbaseAccountAttribs array of coinbaseAccount data
|
||||
* @return void
|
||||
*/
|
||||
protected function _initialize($coinbaseAccountAttribs)
|
||||
{
|
||||
// set the attributes
|
||||
$this->_attributes = $coinbaseAccountAttribs;
|
||||
|
||||
$subscriptionArray = [];
|
||||
if (isset($coinbaseAccountAttribs['subscriptions'])) {
|
||||
foreach ($coinbaseAccountAttribs['subscriptions'] AS $subscription) {
|
||||
$subscriptionArray[] = Subscription::factory($subscription);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_set('subscriptions', $subscriptionArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a printable representation of the object as:
|
||||
* ClassName[property=value, property=value]
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return __CLASS__ . '[' .
|
||||
Util::attributesToString($this->_attributes) .']';
|
||||
}
|
||||
|
||||
|
||||
// static methods redirecting to gateway
|
||||
|
||||
public static function find($token)
|
||||
{
|
||||
return Configuration::gateway()->coinbaseAccount()->find($token);
|
||||
}
|
||||
|
||||
public static function update($token, $attributes)
|
||||
{
|
||||
return Configuration::gateway()->coinbaseAccount()->update($token, $attributes);
|
||||
}
|
||||
|
||||
public static function delete($token)
|
||||
{
|
||||
return Configuration::gateway()->coinbaseAccount()->delete($token);
|
||||
}
|
||||
|
||||
public static function sale($token, $transactionAttribs)
|
||||
{
|
||||
return Configuration::gateway()->coinbaseAccount()->sale($token, $transactionAttribs);
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\CoinbaseAccount', 'Braintree_CoinbaseAccount');
|
||||
162
modules/paypal/api/sdk/braintree/lib/Braintree/Collection.php
Normal file
162
modules/paypal/api/sdk/braintree/lib/Braintree/Collection.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
use Countable;
|
||||
use IteratorAggregate;
|
||||
use ArrayAccess;
|
||||
use OutOfRangeException;
|
||||
use ArrayIterator;
|
||||
|
||||
/**
|
||||
* Braintree Generic collection
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Based on Generic Collection class from:
|
||||
* {@link http://codeutopia.net/code/library/CU/Collection.php}
|
||||
*
|
||||
* @package Braintree
|
||||
* @subpackage Utility
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*/
|
||||
|
||||
class Collection implements Countable, IteratorAggregate, ArrayAccess
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var array collection storage
|
||||
*/
|
||||
protected $_collection = [];
|
||||
|
||||
/**
|
||||
* Add a value into the collection
|
||||
* @param string $value
|
||||
*/
|
||||
public function add($value)
|
||||
{
|
||||
$this->_collection[] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set index's value
|
||||
* @param integer $index
|
||||
* @param mixed $value
|
||||
* @throws OutOfRangeException
|
||||
*/
|
||||
public function set($index, $value)
|
||||
{
|
||||
if($index >= $this->count())
|
||||
throw new OutOfRangeException('Index out of range');
|
||||
|
||||
$this->_collection[$index] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a value from the collection
|
||||
* @param integer $index index to remove
|
||||
* @throws OutOfRangeException if index is out of range
|
||||
*/
|
||||
public function remove($index)
|
||||
{
|
||||
if($index >= $this->count())
|
||||
throw new OutOfRangeException('Index out of range');
|
||||
|
||||
array_splice($this->_collection, $index, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return value at index
|
||||
* @param integer $index
|
||||
* @return mixed
|
||||
* @throws OutOfRangeException
|
||||
*/
|
||||
public function get($index)
|
||||
{
|
||||
if($index >= $this->count())
|
||||
throw new OutOfRangeException('Index out of range');
|
||||
|
||||
return $this->_collection[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if index exists
|
||||
* @param integer $index
|
||||
* @return boolean
|
||||
*/
|
||||
public function exists($index)
|
||||
{
|
||||
if($index >= $this->count())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Return count of items in collection
|
||||
* Implements countable
|
||||
* @return integer
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->_collection);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an iterator
|
||||
* Implements IteratorAggregate
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->_collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set offset to value
|
||||
* Implements ArrayAccess
|
||||
* @see set
|
||||
* @param integer $offset
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
$this->set($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset offset
|
||||
* Implements ArrayAccess
|
||||
* @see remove
|
||||
* @param integer $offset
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
$this->remove($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* get an offset's value
|
||||
* Implements ArrayAccess
|
||||
* @see get
|
||||
* @param integer $offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->get($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if offset exists
|
||||
* Implements ArrayAccess
|
||||
* @see exists
|
||||
* @param integer $offset
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return $this->exists($offset);
|
||||
}
|
||||
|
||||
}
|
||||
class_alias('Braintree\Collection', 'Braintree_Collection');
|
||||
500
modules/paypal/api/sdk/braintree/lib/Braintree/Configuration.php
Normal file
500
modules/paypal/api/sdk/braintree/lib/Braintree/Configuration.php
Normal file
@@ -0,0 +1,500 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
*
|
||||
* Configuration registry
|
||||
*
|
||||
* @package Braintree
|
||||
* @subpackage Utility
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*/
|
||||
|
||||
class Configuration
|
||||
{
|
||||
public static $global;
|
||||
|
||||
private $_environment = null;
|
||||
private $_merchantId = null;
|
||||
private $_publicKey = null;
|
||||
private $_privateKey = null;
|
||||
private $_clientId = null;
|
||||
private $_clientSecret = null;
|
||||
private $_accessToken = null;
|
||||
private $_proxyHost = null;
|
||||
private $_proxyPort = null;
|
||||
private $_proxyType = null;
|
||||
private $_timeout = 60;
|
||||
|
||||
/**
|
||||
* Braintree API version to use
|
||||
* @access public
|
||||
*/
|
||||
const API_VERSION = 4;
|
||||
|
||||
public function __construct($attribs = [])
|
||||
{
|
||||
foreach ($attribs as $kind => $value) {
|
||||
if ($kind == 'environment') {
|
||||
CredentialsParser::assertValidEnvironment($value);
|
||||
$this->_environment = $value;
|
||||
}
|
||||
if ($kind == 'merchantId') {
|
||||
$this->_merchantId = $value;
|
||||
}
|
||||
if ($kind == 'publicKey') {
|
||||
$this->_publicKey = $value;
|
||||
}
|
||||
if ($kind == 'privateKey') {
|
||||
$this->_privateKey = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($attribs['clientId']) || isset($attribs['accessToken'])) {
|
||||
if (isset($attribs['environment']) || isset($attribs['merchantId']) || isset($attribs['publicKey']) || isset($attribs['privateKey'])) {
|
||||
throw new Exception\Configuration('Cannot mix OAuth credentials (clientId, clientSecret, accessToken) with key credentials (publicKey, privateKey, environment, merchantId).');
|
||||
}
|
||||
$parsedCredentials = new CredentialsParser($attribs);
|
||||
|
||||
$this->_environment = $parsedCredentials->getEnvironment();
|
||||
$this->_merchantId = $parsedCredentials->getMerchantId();
|
||||
$this->_clientId = $parsedCredentials->getClientId();
|
||||
$this->_clientSecret = $parsedCredentials->getClientSecret();
|
||||
$this->_accessToken = $parsedCredentials->getAccessToken();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* resets configuration to default
|
||||
* @access public
|
||||
*/
|
||||
public static function reset()
|
||||
{
|
||||
self::$global = new Configuration();
|
||||
}
|
||||
|
||||
public static function gateway()
|
||||
{
|
||||
return new Gateway(self::$global);
|
||||
}
|
||||
|
||||
public static function environment($value=null)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return self::$global->getEnvironment();
|
||||
}
|
||||
CredentialsParser::assertValidEnvironment($value);
|
||||
self::$global->setEnvironment($value);
|
||||
}
|
||||
|
||||
public static function merchantId($value=null)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return self::$global->getMerchantId();
|
||||
}
|
||||
self::$global->setMerchantId($value);
|
||||
}
|
||||
|
||||
public static function publicKey($value=null)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return self::$global->getPublicKey();
|
||||
}
|
||||
self::$global->setPublicKey($value);
|
||||
}
|
||||
|
||||
public static function privateKey($value=null)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return self::$global->getPrivateKey();
|
||||
}
|
||||
self::$global->setPrivateKey($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or gets the read timeout to use for making requests.
|
||||
*
|
||||
* @param integer $value If provided, sets the read timeout
|
||||
* @return integer The read timeout used for connecting to Braintree
|
||||
*/
|
||||
public static function timeout($value=null)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return self::$global->getTimeout();
|
||||
}
|
||||
self::$global->setTimeout($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or gets the proxy host to use for connecting to Braintree
|
||||
*
|
||||
* @param string $value If provided, sets the proxy host
|
||||
* @return string The proxy host used for connecting to Braintree
|
||||
*/
|
||||
public static function proxyHost($value = null)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return self::$global->getProxyHost();
|
||||
}
|
||||
self::$global->setProxyHost($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or gets the port of the proxy to use for connecting to Braintree
|
||||
*
|
||||
* @param string $value If provided, sets the port of the proxy
|
||||
* @return string The port of the proxy used for connecting to Braintree
|
||||
*/
|
||||
public static function proxyPort($value = null)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return self::$global->getProxyPort();
|
||||
}
|
||||
self::$global->setProxyPort($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or gets the proxy type to use for connecting to Braintree. This value
|
||||
* can be any of the CURLOPT_PROXYTYPE options in PHP cURL.
|
||||
*
|
||||
* @param string $value If provided, sets the proxy type
|
||||
* @return string The proxy type used for connecting to Braintree
|
||||
*/
|
||||
public static function proxyType($value = null)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return self::$global->getProxyType();
|
||||
}
|
||||
self::$global->setProxyType($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether or not a proxy is properly configured
|
||||
*
|
||||
* @return bool true if a proxy is configured properly, false if not
|
||||
*/
|
||||
public static function isUsingProxy()
|
||||
{
|
||||
$proxyHost = self::$global->getProxyHost();
|
||||
$proxyPort = self::$global->getProxyPort();
|
||||
return !empty($proxyHost) && !empty($proxyPort);
|
||||
}
|
||||
|
||||
public static function assertGlobalHasAccessTokenOrKeys()
|
||||
{
|
||||
self::$global->assertHasAccessTokenOrKeys();
|
||||
}
|
||||
|
||||
public function assertHasAccessTokenOrKeys()
|
||||
{
|
||||
if (empty($this->_accessToken)) {
|
||||
if (empty($this->_merchantId)) {
|
||||
throw new Exception\Configuration('Braintree\\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\\Gateway).');
|
||||
} else if (empty($this->_environment)) {
|
||||
throw new Exception\Configuration('Braintree\\Configuration::environment needs to be set.');
|
||||
} else if (empty($this->_publicKey)) {
|
||||
throw new Exception\Configuration('Braintree\\Configuration::publicKey needs to be set.');
|
||||
} else if (empty($this->_privateKey)) {
|
||||
throw new Exception\Configuration('Braintree\\Configuration::privateKey needs to be set.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function assertHasClientCredentials()
|
||||
{
|
||||
$this->assertHasClientId();
|
||||
$this->assertHasClientSecret();
|
||||
}
|
||||
|
||||
public function assertHasClientId()
|
||||
{
|
||||
if (empty($this->_clientId)) {
|
||||
throw new Exception\Configuration('clientId needs to be passed to Braintree\\Gateway.');
|
||||
}
|
||||
}
|
||||
|
||||
public function assertHasClientSecret()
|
||||
{
|
||||
if (empty($this->_clientSecret)) {
|
||||
throw new Exception\Configuration('clientSecret needs to be passed to Braintree\\Gateway.');
|
||||
}
|
||||
}
|
||||
|
||||
public function getEnvironment()
|
||||
{
|
||||
return $this->_environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method directly. Pass in the environment to the constructor.
|
||||
*/
|
||||
public function setEnvironment($value)
|
||||
{
|
||||
$this->_environment = $value;
|
||||
}
|
||||
|
||||
public function getMerchantId()
|
||||
{
|
||||
return $this->_merchantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method directly. Pass in the merchantId to the constructor.
|
||||
*/
|
||||
public function setMerchantId($value)
|
||||
{
|
||||
$this->_merchantId = $value;
|
||||
}
|
||||
|
||||
public function getPublicKey()
|
||||
{
|
||||
return $this->_publicKey;
|
||||
}
|
||||
|
||||
public function getClientId()
|
||||
{
|
||||
return $this->_clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method directly. Pass in the publicKey to the constructor.
|
||||
*/
|
||||
public function setPublicKey($value)
|
||||
{
|
||||
$this->_publicKey = $value;
|
||||
}
|
||||
|
||||
public function getPrivateKey()
|
||||
{
|
||||
return $this->_privateKey;
|
||||
}
|
||||
|
||||
public function getClientSecret()
|
||||
{
|
||||
return $this->_clientSecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method directly. Pass in the privateKey to the constructor.
|
||||
*/
|
||||
public function setPrivateKey($value)
|
||||
{
|
||||
$this->_privateKey = $value;
|
||||
}
|
||||
|
||||
private function setProxyHost($value)
|
||||
{
|
||||
$this->_proxyHost = $value;
|
||||
}
|
||||
|
||||
public function getProxyHost()
|
||||
{
|
||||
return $this->_proxyHost;
|
||||
}
|
||||
|
||||
private function setProxyPort($value)
|
||||
{
|
||||
$this->_proxyPort = $value;
|
||||
}
|
||||
|
||||
public function getProxyPort()
|
||||
{
|
||||
return $this->_proxyPort;
|
||||
}
|
||||
|
||||
private function setProxyType($value)
|
||||
{
|
||||
$this->_proxyType = $value;
|
||||
}
|
||||
|
||||
public function getProxyType()
|
||||
{
|
||||
return $this->_proxyType;
|
||||
}
|
||||
|
||||
private function setTimeout($value)
|
||||
{
|
||||
$this->_timeout = $value;
|
||||
}
|
||||
|
||||
public function getTimeout()
|
||||
{
|
||||
return $this->_timeout;
|
||||
}
|
||||
|
||||
public function getAccessToken()
|
||||
{
|
||||
return $this->_accessToken;
|
||||
}
|
||||
|
||||
public function isAccessToken()
|
||||
{
|
||||
return !empty($this->_accessToken);
|
||||
}
|
||||
|
||||
public function isClientCredentials()
|
||||
{
|
||||
return !empty($this->_clientId);
|
||||
}
|
||||
/**
|
||||
* returns the base braintree gateway URL based on config values
|
||||
*
|
||||
* @access public
|
||||
* @param none
|
||||
* @return string braintree gateway URL
|
||||
*/
|
||||
public function baseUrl()
|
||||
{
|
||||
return sprintf('%s://%s:%d', $this->protocol(), $this->serverName(), $this->portNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the merchant path based on merchant ID
|
||||
*
|
||||
* @access protected
|
||||
* @param none
|
||||
* @return string merchant path uri
|
||||
*/
|
||||
public function merchantPath()
|
||||
{
|
||||
return '/merchants/' . $this->_merchantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the physical path for the location of the CA certs
|
||||
*
|
||||
* @access public
|
||||
* @param none
|
||||
* @return string filepath
|
||||
*/
|
||||
public function caFile($sslPath = NULL)
|
||||
{
|
||||
$sslPath = $sslPath ? $sslPath : DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .
|
||||
'ssl' . DIRECTORY_SEPARATOR;
|
||||
$caPath = __DIR__ . $sslPath . 'api_braintreegateway_com.ca.crt';
|
||||
|
||||
if (!file_exists($caPath))
|
||||
{
|
||||
throw new Exception\SSLCaFileNotFound();
|
||||
}
|
||||
|
||||
return $caPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the port number depending on environment
|
||||
*
|
||||
* @access public
|
||||
* @param none
|
||||
* @return int portnumber
|
||||
*/
|
||||
public function portNumber()
|
||||
{
|
||||
if ($this->sslOn()) {
|
||||
return 443;
|
||||
}
|
||||
return getenv("GATEWAY_PORT") ? getenv("GATEWAY_PORT") : 3000;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns http protocol depending on environment
|
||||
*
|
||||
* @access public
|
||||
* @param none
|
||||
* @return string http || https
|
||||
*/
|
||||
public function protocol()
|
||||
{
|
||||
return $this->sslOn() ? 'https' : 'http';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns gateway server name depending on environment
|
||||
*
|
||||
* @access public
|
||||
* @param none
|
||||
* @return string server domain name
|
||||
*/
|
||||
public function serverName()
|
||||
{
|
||||
switch($this->_environment) {
|
||||
case 'production':
|
||||
$serverName = 'api.braintreegateway.com';
|
||||
break;
|
||||
case 'qa':
|
||||
$serverName = 'gateway.qa.braintreepayments.com';
|
||||
break;
|
||||
case 'sandbox':
|
||||
$serverName = 'api.sandbox.braintreegateway.com';
|
||||
break;
|
||||
case 'development':
|
||||
case 'integration':
|
||||
default:
|
||||
$serverName = 'localhost';
|
||||
break;
|
||||
}
|
||||
|
||||
return $serverName;
|
||||
}
|
||||
|
||||
public function authUrl()
|
||||
{
|
||||
switch($this->_environment) {
|
||||
case 'production':
|
||||
$serverName = 'https://auth.venmo.com';
|
||||
break;
|
||||
case 'qa':
|
||||
$serverName = 'https://auth.qa.venmo.com';
|
||||
break;
|
||||
case 'sandbox':
|
||||
$serverName = 'https://auth.sandbox.venmo.com';
|
||||
break;
|
||||
case 'development':
|
||||
case 'integration':
|
||||
default:
|
||||
$serverName = 'http://auth.venmo.dev:9292';
|
||||
break;
|
||||
}
|
||||
|
||||
return $serverName;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns boolean indicating SSL is on or off for this session,
|
||||
* depending on environment
|
||||
*
|
||||
* @access public
|
||||
* @param none
|
||||
* @return boolean
|
||||
*/
|
||||
public function sslOn()
|
||||
{
|
||||
switch($this->_environment) {
|
||||
case 'integration':
|
||||
case 'development':
|
||||
$ssl = false;
|
||||
break;
|
||||
case 'production':
|
||||
case 'qa':
|
||||
case 'sandbox':
|
||||
default:
|
||||
$ssl = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return $ssl;
|
||||
}
|
||||
|
||||
/**
|
||||
* log message to default logger
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
*/
|
||||
public function logMessage($message)
|
||||
{
|
||||
error_log('[Braintree] ' . $message);
|
||||
}
|
||||
}
|
||||
Configuration::reset();
|
||||
class_alias('Braintree\Configuration', 'Braintree_Configuration');
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
*
|
||||
* CredentialsParser registry
|
||||
*
|
||||
* @package Braintree
|
||||
* @subpackage Utility
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*/
|
||||
|
||||
class CredentialsParser
|
||||
{
|
||||
private $_clientId;
|
||||
private $_clientSecret;
|
||||
private $_accessToken;
|
||||
private $_environment;
|
||||
private $_merchantId;
|
||||
|
||||
public function __construct($attribs)
|
||||
{
|
||||
foreach ($attribs as $kind => $value) {
|
||||
if ($kind == 'clientId') {
|
||||
$this->_clientId = $value;
|
||||
}
|
||||
if ($kind == 'clientSecret') {
|
||||
$this->_clientSecret = $value;
|
||||
}
|
||||
if ($kind == 'accessToken') {
|
||||
$this->_accessToken = $value;
|
||||
}
|
||||
}
|
||||
$this->parse();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @access protected
|
||||
* @static
|
||||
* @var array valid environments, used for validation
|
||||
*/
|
||||
private static $_validEnvironments = [
|
||||
'development',
|
||||
'integration',
|
||||
'sandbox',
|
||||
'production',
|
||||
'qa',
|
||||
];
|
||||
|
||||
|
||||
public function parse()
|
||||
{
|
||||
$environments = [];
|
||||
if (!empty($this->_clientId)) {
|
||||
$environments[] = ['clientId', $this->_parseClientCredential('clientId', $this->_clientId, 'client_id')];
|
||||
}
|
||||
if (!empty($this->_clientSecret)) {
|
||||
$environments[] = ['clientSecret', $this->_parseClientCredential('clientSecret', $this->_clientSecret, 'client_secret')];
|
||||
}
|
||||
if (!empty($this->_accessToken)) {
|
||||
$environments[] = ['accessToken', $this->_parseAccessToken()];
|
||||
}
|
||||
|
||||
$checkEnv = $environments[0];
|
||||
foreach ($environments as $env) {
|
||||
if ($env[1] !== $checkEnv[1]) {
|
||||
throw new Exception\Configuration(
|
||||
'Mismatched credential environments: ' . $checkEnv[0] . ' environment is ' . $checkEnv[1] .
|
||||
' and ' . $env[0] . ' environment is ' . $env[1]);
|
||||
}
|
||||
}
|
||||
|
||||
self::assertValidEnvironment($checkEnv[1]);
|
||||
$this->_environment = $checkEnv[1];
|
||||
}
|
||||
|
||||
public static function assertValidEnvironment($environment) {
|
||||
if (!in_array($environment, self::$_validEnvironments)) {
|
||||
throw new Exception\Configuration('"' .
|
||||
$environment . '" is not a valid environment.');
|
||||
}
|
||||
}
|
||||
|
||||
private function _parseClientCredential($credentialType, $value, $expectedValuePrefix)
|
||||
{
|
||||
$explodedCredential = explode('$', $value);
|
||||
if (sizeof($explodedCredential) != 3) {
|
||||
throw new Exception\Configuration('Incorrect ' . $credentialType . ' format. Expected: type$environment$token');
|
||||
}
|
||||
|
||||
$gotValuePrefix = $explodedCredential[0];
|
||||
$environment = $explodedCredential[1];
|
||||
$token = $explodedCredential[2];
|
||||
|
||||
if ($gotValuePrefix != $expectedValuePrefix) {
|
||||
throw new Exception\Configuration('Value passed for ' . $credentialType . ' is not a ' . $credentialType);
|
||||
}
|
||||
|
||||
return $environment;
|
||||
}
|
||||
|
||||
private function _parseAccessToken()
|
||||
{
|
||||
$accessTokenExploded = explode('$', $this->_accessToken);
|
||||
if (sizeof($accessTokenExploded) != 4) {
|
||||
throw new Exception\Configuration('Incorrect accessToken syntax. Expected: type$environment$merchant_id$token');
|
||||
}
|
||||
|
||||
$gotValuePrefix = $accessTokenExploded[0];
|
||||
$environment = $accessTokenExploded[1];
|
||||
$merchantId = $accessTokenExploded[2];
|
||||
$token = $accessTokenExploded[3];
|
||||
|
||||
if ($gotValuePrefix != 'access_token') {
|
||||
throw new Exception\Configuration('Value passed for accessToken is not an accessToken');
|
||||
}
|
||||
|
||||
$this->_merchantId = $merchantId;
|
||||
return $environment;
|
||||
}
|
||||
|
||||
public function getClientId()
|
||||
{
|
||||
return $this->_clientId;
|
||||
}
|
||||
|
||||
public function getClientSecret()
|
||||
{
|
||||
return $this->_clientSecret;
|
||||
}
|
||||
|
||||
public function getAccessToken()
|
||||
{
|
||||
return $this->_accessToken;
|
||||
}
|
||||
|
||||
public function getEnvironment()
|
||||
{
|
||||
return $this->_environment;
|
||||
}
|
||||
|
||||
public function getMerchantId()
|
||||
{
|
||||
return $this->_merchantId;
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\CredentialsParser', 'Braintree_CredentialsParser');
|
||||
315
modules/paypal/api/sdk/braintree/lib/Braintree/CreditCard.php
Normal file
315
modules/paypal/api/sdk/braintree/lib/Braintree/CreditCard.php
Normal file
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Braintree CreditCard module
|
||||
* Creates and manages Braintree CreditCards
|
||||
*
|
||||
* <b>== More information ==</b>
|
||||
*
|
||||
* For more detailed information on CreditCards, see {@link http://www.braintreepayments.com/gateway/credit-card-api http://www.braintreepaymentsolutions.com/gateway/credit-card-api}<br />
|
||||
* For more detailed information on CreditCard verifications, see {@link http://www.braintreepayments.com/gateway/credit-card-verification-api http://www.braintreepaymentsolutions.com/gateway/credit-card-verification-api}
|
||||
*
|
||||
* @package Braintree
|
||||
* @category Resources
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*
|
||||
* @property-read string $billingAddress
|
||||
* @property-read string $bin
|
||||
* @property-read string $cardType
|
||||
* @property-read string $cardholderName
|
||||
* @property-read string $createdAt
|
||||
* @property-read string $customerId
|
||||
* @property-read string $expirationDate
|
||||
* @property-read string $expirationMonth
|
||||
* @property-read string $expirationYear
|
||||
* @property-read string $imageUrl
|
||||
* @property-read string $last4
|
||||
* @property-read string $maskedNumber
|
||||
* @property-read string $token
|
||||
* @property-read string $updatedAt
|
||||
*/
|
||||
class CreditCard extends Base
|
||||
{
|
||||
// Card Type
|
||||
const AMEX = 'American Express';
|
||||
const CARTE_BLANCHE = 'Carte Blanche';
|
||||
const CHINA_UNION_PAY = 'China UnionPay';
|
||||
const DINERS_CLUB_INTERNATIONAL = 'Diners Club';
|
||||
const DISCOVER = 'Discover';
|
||||
const JCB = 'JCB';
|
||||
const LASER = 'Laser';
|
||||
const MAESTRO = 'Maestro';
|
||||
const MASTER_CARD = 'MasterCard';
|
||||
const SOLO = 'Solo';
|
||||
const SWITCH_TYPE = 'Switch';
|
||||
const VISA = 'Visa';
|
||||
const UNKNOWN = 'Unknown';
|
||||
|
||||
// Credit card origination location
|
||||
const INTERNATIONAL = "international";
|
||||
const US = "us";
|
||||
|
||||
const PREPAID_YES = 'Yes';
|
||||
const PREPAID_NO = 'No';
|
||||
const PREPAID_UNKNOWN = 'Unknown';
|
||||
|
||||
const PAYROLL_YES = 'Yes';
|
||||
const PAYROLL_NO = 'No';
|
||||
const PAYROLL_UNKNOWN = 'Unknown';
|
||||
|
||||
const HEALTHCARE_YES = 'Yes';
|
||||
const HEALTHCARE_NO = 'No';
|
||||
const HEALTHCARE_UNKNOWN = 'Unknown';
|
||||
|
||||
const DURBIN_REGULATED_YES = 'Yes';
|
||||
const DURBIN_REGULATED_NO = 'No';
|
||||
const DURBIN_REGULATED_UNKNOWN = 'Unknown';
|
||||
|
||||
const DEBIT_YES = 'Yes';
|
||||
const DEBIT_NO = 'No';
|
||||
const DEBIT_UNKNOWN = 'Unknown';
|
||||
|
||||
const COMMERCIAL_YES = 'Yes';
|
||||
const COMMERCIAL_NO = 'No';
|
||||
const COMMERCIAL_UNKNOWN = 'Unknown';
|
||||
|
||||
const COUNTRY_OF_ISSUANCE_UNKNOWN = "Unknown";
|
||||
const ISSUING_BANK_UNKNOWN = "Unknown";
|
||||
|
||||
/* instance methods */
|
||||
/**
|
||||
* returns false if default is null or false
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDefault()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether the card is expired based on the current date
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isExpired()
|
||||
{
|
||||
return $this->expired;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether the card is associated with venmo sdk
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVenmoSdk()
|
||||
{
|
||||
return $this->venmoSdk;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets instance properties from an array of values
|
||||
*
|
||||
* @access protected
|
||||
* @param array $creditCardAttribs array of creditcard data
|
||||
* @return void
|
||||
*/
|
||||
protected function _initialize($creditCardAttribs)
|
||||
{
|
||||
// set the attributes
|
||||
$this->_attributes = $creditCardAttribs;
|
||||
|
||||
// map each address into its own object
|
||||
$billingAddress = isset($creditCardAttribs['billingAddress']) ?
|
||||
Address::factory($creditCardAttribs['billingAddress']) :
|
||||
null;
|
||||
|
||||
$subscriptionArray = [];
|
||||
if (isset($creditCardAttribs['subscriptions'])) {
|
||||
foreach ($creditCardAttribs['subscriptions'] AS $subscription) {
|
||||
$subscriptionArray[] = Subscription::factory($subscription);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_set('subscriptions', $subscriptionArray);
|
||||
$this->_set('billingAddress', $billingAddress);
|
||||
$this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);
|
||||
$this->_set('maskedNumber', $this->bin . '******' . $this->last4);
|
||||
|
||||
if(isset($creditCardAttribs['verifications']) && count($creditCardAttribs['verifications']) > 0) {
|
||||
$verifications = $creditCardAttribs['verifications'];
|
||||
usort($verifications, [$this, '_compareCreatedAtOnVerifications']);
|
||||
|
||||
$this->_set('verification', CreditCardVerification::factory($verifications[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private function _compareCreatedAtOnVerifications($verificationAttrib1, $verificationAttrib2)
|
||||
{
|
||||
return ($verificationAttrib2['createdAt'] < $verificationAttrib1['createdAt']) ? -1 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false if comparing object is not a CreditCard,
|
||||
* or is a CreditCard with a different id
|
||||
*
|
||||
* @param object $otherCreditCard customer to compare against
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEqual($otherCreditCard)
|
||||
{
|
||||
return !($otherCreditCard instanceof self) ? false : $this->token === $otherCreditCard->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* create a printable representation of the object as:
|
||||
* ClassName[property=value, property=value]
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return __CLASS__ . '[' .
|
||||
Util::attributesToString($this->_attributes) .']';
|
||||
}
|
||||
|
||||
/**
|
||||
* factory method: returns an instance of CreditCard
|
||||
* to the requesting method, with populated properties
|
||||
*
|
||||
* @ignore
|
||||
* @return CreditCard
|
||||
*/
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$defaultAttributes = [
|
||||
'bin' => '',
|
||||
'expirationMonth' => '',
|
||||
'expirationYear' => '',
|
||||
'last4' => '',
|
||||
];
|
||||
|
||||
$instance = new self();
|
||||
$instance->_initialize(array_merge($defaultAttributes, $attributes));
|
||||
return $instance;
|
||||
}
|
||||
|
||||
|
||||
// static methods redirecting to gateway
|
||||
|
||||
public static function create($attribs)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->create($attribs);
|
||||
}
|
||||
|
||||
public static function createNoValidate($attribs)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->createNoValidate($attribs);
|
||||
}
|
||||
|
||||
public static function createFromTransparentRedirect($queryString)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->createFromTransparentRedirect($queryString);
|
||||
}
|
||||
|
||||
public static function createCreditCardUrl()
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->createCreditCardUrl();
|
||||
}
|
||||
|
||||
public static function expired()
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->expired();
|
||||
}
|
||||
|
||||
public static function fetchExpired($ids)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->fetchExpired($ids);
|
||||
}
|
||||
|
||||
public static function expiringBetween($startDate, $endDate)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->expiringBetween($startDate, $endDate);
|
||||
}
|
||||
|
||||
public static function fetchExpiring($startDate, $endDate, $ids)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->fetchExpiring($startDate, $endDate, $ids);
|
||||
}
|
||||
|
||||
public static function find($token)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->find($token);
|
||||
}
|
||||
|
||||
public static function fromNonce($nonce)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->fromNonce($nonce);
|
||||
}
|
||||
|
||||
public static function credit($token, $transactionAttribs)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->credit($token, $transactionAttribs);
|
||||
}
|
||||
|
||||
public static function creditNoValidate($token, $transactionAttribs)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->creditNoValidate($token, $transactionAttribs);
|
||||
}
|
||||
|
||||
public static function sale($token, $transactionAttribs)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->sale($token, $transactionAttribs);
|
||||
}
|
||||
|
||||
public static function saleNoValidate($token, $transactionAttribs)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->saleNoValidate($token, $transactionAttribs);
|
||||
}
|
||||
|
||||
public static function update($token, $attributes)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->update($token, $attributes);
|
||||
}
|
||||
|
||||
public static function updateNoValidate($token, $attributes)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->updateNoValidate($token, $attributes);
|
||||
}
|
||||
|
||||
public static function updateCreditCardUrl()
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->updateCreditCardUrl();
|
||||
}
|
||||
|
||||
public static function updateFromTransparentRedirect($queryString)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->updateFromTransparentRedirect($queryString);
|
||||
}
|
||||
|
||||
public static function delete($token)
|
||||
{
|
||||
return Configuration::gateway()->creditCard()->delete($token);
|
||||
}
|
||||
|
||||
/** @return array */
|
||||
public static function allCardTypes()
|
||||
{
|
||||
return [
|
||||
CreditCard::AMEX,
|
||||
CreditCard::CARTE_BLANCHE,
|
||||
CreditCard::CHINA_UNION_PAY,
|
||||
CreditCard::DINERS_CLUB_INTERNATIONAL,
|
||||
CreditCard::DISCOVER,
|
||||
CreditCard::JCB,
|
||||
CreditCard::LASER,
|
||||
CreditCard::MAESTRO,
|
||||
CreditCard::MASTER_CARD,
|
||||
CreditCard::SOLO,
|
||||
CreditCard::SWITCH_TYPE,
|
||||
CreditCard::VISA,
|
||||
CreditCard::UNKNOWN
|
||||
];
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\CreditCard', 'Braintree_CreditCard');
|
||||
@@ -0,0 +1,485 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Braintree CreditCardGateway module
|
||||
* Creates and manages Braintree CreditCards
|
||||
*
|
||||
* <b>== More information ==</b>
|
||||
*
|
||||
* For more detailed information on CreditCards, see {@link http://www.braintreepayments.com/gateway/credit-card-api http://www.braintreepaymentsolutions.com/gateway/credit-card-api}<br />
|
||||
* For more detailed information on CreditCard verifications, see {@link http://www.braintreepayments.com/gateway/credit-card-verification-api http://www.braintreepaymentsolutions.com/gateway/credit-card-verification-api}
|
||||
*
|
||||
* @package Braintree
|
||||
* @category Resources
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*/
|
||||
class CreditCardGateway
|
||||
{
|
||||
private $_gateway;
|
||||
private $_config;
|
||||
private $_http;
|
||||
|
||||
public function __construct($gateway)
|
||||
{
|
||||
$this->_gateway = $gateway;
|
||||
$this->_config = $gateway->config;
|
||||
$this->_config->assertHasAccessTokenOrKeys();
|
||||
$this->_http = new Http($gateway->config);
|
||||
}
|
||||
|
||||
public function create($attribs)
|
||||
{
|
||||
Util::verifyKeys(self::createSignature(), $attribs);
|
||||
return $this->_doCreate('/payment_methods', ['credit_card' => $attribs]);
|
||||
}
|
||||
|
||||
/**
|
||||
* attempts the create operation assuming all data will validate
|
||||
* returns a CreditCard object instead of a Result
|
||||
*
|
||||
* @access public
|
||||
* @param array $attribs
|
||||
* @return CreditCard
|
||||
* @throws Exception\ValidationError
|
||||
*/
|
||||
public function createNoValidate($attribs)
|
||||
{
|
||||
$result = $this->create($attribs);
|
||||
return Util::returnObjectOrThrowException(__CLASS__, $result);
|
||||
}
|
||||
/**
|
||||
* create a customer from a TransparentRedirect operation
|
||||
*
|
||||
* @deprecated since version 2.3.0
|
||||
* @access public
|
||||
* @param array $attribs
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
public function createFromTransparentRedirect($queryString)
|
||||
{
|
||||
trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
|
||||
$params = TransparentRedirect::parseAndValidateQueryString(
|
||||
$queryString
|
||||
);
|
||||
return $this->_doCreate(
|
||||
'/payment_methods/all/confirm_transparent_redirect_request',
|
||||
['id' => $params['id']]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated since version 2.3.0
|
||||
* @access public
|
||||
* @param none
|
||||
* @return string
|
||||
*/
|
||||
public function createCreditCardUrl()
|
||||
{
|
||||
trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
|
||||
return $this->_config->baseUrl() . $this->_config->merchantPath().
|
||||
'/payment_methods/all/create_via_transparent_redirect_request';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a ResourceCollection of expired credit cards
|
||||
* @return ResourceCollection
|
||||
*/
|
||||
public function expired()
|
||||
{
|
||||
$path = $this->_config->merchantPath() . '/payment_methods/all/expired_ids';
|
||||
$response = $this->_http->post($path);
|
||||
$pager = [
|
||||
'object' => $this,
|
||||
'method' => 'fetchExpired',
|
||||
'methodArgs' => []
|
||||
];
|
||||
|
||||
return new ResourceCollection($response, $pager);
|
||||
}
|
||||
|
||||
public function fetchExpired($ids)
|
||||
{
|
||||
$path = $this->_config->merchantPath() . "/payment_methods/all/expired";
|
||||
$response = $this->_http->post($path, ['search' => ['ids' => $ids]]);
|
||||
|
||||
return Util::extractattributeasarray(
|
||||
$response['paymentMethods'],
|
||||
'creditCard'
|
||||
);
|
||||
}
|
||||
/**
|
||||
* returns a ResourceCollection of credit cards expiring between start/end
|
||||
*
|
||||
* @return ResourceCollection
|
||||
*/
|
||||
public function expiringBetween($startDate, $endDate)
|
||||
{
|
||||
$queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring_ids?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate);
|
||||
$response = $this->_http->post($queryPath);
|
||||
$pager = [
|
||||
'object' => $this,
|
||||
'method' => 'fetchExpiring',
|
||||
'methodArgs' => [$startDate, $endDate]
|
||||
];
|
||||
|
||||
return new ResourceCollection($response, $pager);
|
||||
}
|
||||
|
||||
public function fetchExpiring($startDate, $endDate, $ids)
|
||||
{
|
||||
$queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate);
|
||||
$response = $this->_http->post($queryPath, ['search' => ['ids' => $ids]]);
|
||||
|
||||
return Util::extractAttributeAsArray(
|
||||
$response['paymentMethods'],
|
||||
'creditCard'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* find a creditcard by token
|
||||
*
|
||||
* @access public
|
||||
* @param string $token credit card unique id
|
||||
* @return CreditCard
|
||||
* @throws Exception\NotFound
|
||||
*/
|
||||
public function find($token)
|
||||
{
|
||||
$this->_validateId($token);
|
||||
try {
|
||||
$path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token;
|
||||
$response = $this->_http->get($path);
|
||||
return CreditCard::factory($response['creditCard']);
|
||||
} catch (Exception\NotFound $e) {
|
||||
throw new Exception\NotFound(
|
||||
'credit card with token ' . $token . ' not found'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a payment method nonce to a credit card
|
||||
*
|
||||
* @access public
|
||||
* @param string $nonce payment method nonce
|
||||
* @return CreditCard
|
||||
* @throws Exception\NotFound
|
||||
*/
|
||||
public function fromNonce($nonce)
|
||||
{
|
||||
$this->_validateId($nonce, "nonce");
|
||||
try {
|
||||
$path = $this->_config->merchantPath() . '/payment_methods/from_nonce/' . $nonce;
|
||||
$response = $this->_http->get($path);
|
||||
return CreditCard::factory($response['creditCard']);
|
||||
} catch (Exception\NotFound $e) {
|
||||
throw new Exception\NotFound(
|
||||
'credit card with nonce ' . $nonce . ' locked, consumed or not found'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* create a credit on the card for the passed transaction
|
||||
*
|
||||
* @access public
|
||||
* @param array $attribs
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
public function credit($token, $transactionAttribs)
|
||||
{
|
||||
$this->_validateId($token);
|
||||
return Transaction::credit(
|
||||
array_merge(
|
||||
$transactionAttribs,
|
||||
['paymentMethodToken' => $token]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a credit on this card, assuming validations will pass
|
||||
*
|
||||
* returns a Transaction object on success
|
||||
*
|
||||
* @access public
|
||||
* @param array $attribs
|
||||
* @return Transaction
|
||||
* @throws Exception\ValidationError
|
||||
*/
|
||||
public function creditNoValidate($token, $transactionAttribs)
|
||||
{
|
||||
$result = $this->credit($token, $transactionAttribs);
|
||||
return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new sale for the current card
|
||||
*
|
||||
* @param string $token
|
||||
* @param array $transactionAttribs
|
||||
* @return Result\Successful|Result\Error
|
||||
* @see Transaction::sale()
|
||||
*/
|
||||
public function sale($token, $transactionAttribs)
|
||||
{
|
||||
$this->_validateId($token);
|
||||
return Transaction::sale(
|
||||
array_merge(
|
||||
$transactionAttribs,
|
||||
['paymentMethodToken' => $token]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new sale using this card, assuming validations will pass
|
||||
*
|
||||
* returns a Transaction object on success
|
||||
*
|
||||
* @access public
|
||||
* @param array $transactionAttribs
|
||||
* @param string $token
|
||||
* @return Transaction
|
||||
* @throws Exception\ValidationsFailed
|
||||
* @see Transaction::sale()
|
||||
*/
|
||||
public function saleNoValidate($token, $transactionAttribs)
|
||||
{
|
||||
$result = $this->sale($token, $transactionAttribs);
|
||||
return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* updates the creditcard record
|
||||
*
|
||||
* if calling this method in context, $token
|
||||
* is the 2nd attribute. $token is not sent in object context.
|
||||
*
|
||||
* @access public
|
||||
* @param array $attributes
|
||||
* @param string $token (optional)
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
public function update($token, $attributes)
|
||||
{
|
||||
Util::verifyKeys(self::updateSignature(), $attributes);
|
||||
$this->_validateId($token);
|
||||
return $this->_doUpdate('put', '/payment_methods/credit_card/' . $token, ['creditCard' => $attributes]);
|
||||
}
|
||||
|
||||
/**
|
||||
* update a creditcard record, assuming validations will pass
|
||||
*
|
||||
* if calling this method in context, $token
|
||||
* is the 2nd attribute. $token is not sent in object context.
|
||||
* returns a CreditCard object on success
|
||||
*
|
||||
* @access public
|
||||
* @param array $attributes
|
||||
* @param string $token
|
||||
* @return CreditCard
|
||||
* @throws Exception\ValidationsFailed
|
||||
*/
|
||||
public function updateNoValidate($token, $attributes)
|
||||
{
|
||||
$result = $this->update($token, $attributes);
|
||||
return Util::returnObjectOrThrowException(__CLASS__, $result);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @access public
|
||||
* @param none
|
||||
* @return string
|
||||
*/
|
||||
public function updateCreditCardUrl()
|
||||
{
|
||||
trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
|
||||
return $this->_config->baseUrl() . $this->_config->merchantPath() .
|
||||
'/payment_methods/all/update_via_transparent_redirect_request';
|
||||
}
|
||||
|
||||
/**
|
||||
* update a customer from a TransparentRedirect operation
|
||||
*
|
||||
* @deprecated since version 2.3.0
|
||||
* @access public
|
||||
* @param array $attribs
|
||||
* @return object
|
||||
*/
|
||||
public function updateFromTransparentRedirect($queryString)
|
||||
{
|
||||
trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
|
||||
$params = TransparentRedirect::parseAndValidateQueryString(
|
||||
$queryString
|
||||
);
|
||||
return $this->_doUpdate(
|
||||
'post',
|
||||
'/payment_methods/all/confirm_transparent_redirect_request',
|
||||
['id' => $params['id']]
|
||||
);
|
||||
}
|
||||
|
||||
public function delete($token)
|
||||
{
|
||||
$this->_validateId($token);
|
||||
$path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token;
|
||||
$this->_http->delete($path);
|
||||
return new Result\Successful();
|
||||
}
|
||||
|
||||
private static function baseOptions()
|
||||
{
|
||||
return ['makeDefault', 'verificationMerchantAccountId', 'verifyCard', 'verificationAmount', 'venmoSdkSession'];
|
||||
}
|
||||
|
||||
private static function baseSignature($options)
|
||||
{
|
||||
return [
|
||||
'billingAddressId', 'cardholderName', 'cvv', 'number', 'deviceSessionId',
|
||||
'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode',
|
||||
'deviceData', 'fraudMerchantId', 'paymentMethodNonce',
|
||||
['options' => $options],
|
||||
[
|
||||
'billingAddress' => self::billingAddressSignature()
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public static function billingAddressSignature()
|
||||
{
|
||||
return [
|
||||
'firstName',
|
||||
'lastName',
|
||||
'company',
|
||||
'countryCodeAlpha2',
|
||||
'countryCodeAlpha3',
|
||||
'countryCodeNumeric',
|
||||
'countryName',
|
||||
'extendedAddress',
|
||||
'locality',
|
||||
'region',
|
||||
'postalCode',
|
||||
'streetAddress'
|
||||
];
|
||||
}
|
||||
|
||||
public static function createSignature()
|
||||
{
|
||||
$options = self::baseOptions();
|
||||
$options[] = "failOnDuplicatePaymentMethod";
|
||||
$signature = self::baseSignature($options);
|
||||
$signature[] = 'customerId';
|
||||
return $signature;
|
||||
}
|
||||
|
||||
public static function updateSignature()
|
||||
{
|
||||
$signature = self::baseSignature(self::baseOptions());
|
||||
|
||||
$updateExistingBillingSignature = [
|
||||
[
|
||||
'options' => [
|
||||
'updateExisting'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
foreach($signature AS $key => $value) {
|
||||
if(is_array($value) and array_key_exists('billingAddress', $value)) {
|
||||
$signature[$key]['billingAddress'] = array_merge_recursive($value['billingAddress'], $updateExistingBillingSignature);
|
||||
}
|
||||
}
|
||||
|
||||
return $signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* sends the create request to the gateway
|
||||
*
|
||||
* @ignore
|
||||
* @param string $subPath
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function _doCreate($subPath, $params)
|
||||
{
|
||||
$fullPath = $this->_config->merchantPath() . $subPath;
|
||||
$response = $this->_http->post($fullPath, $params);
|
||||
|
||||
return $this->_verifyGatewayResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* verifies that a valid credit card identifier is being used
|
||||
* @ignore
|
||||
* @param string $identifier
|
||||
* @param Optional $string $identifierType type of identifier supplied, default "token"
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function _validateId($identifier = null, $identifierType = "token")
|
||||
{
|
||||
if (empty($identifier)) {
|
||||
throw new InvalidArgumentException(
|
||||
'expected credit card id to be set'
|
||||
);
|
||||
}
|
||||
if (!preg_match('/^[0-9A-Za-z_-]+$/', $identifier)) {
|
||||
throw new InvalidArgumentException(
|
||||
$identifier . ' is an invalid credit card ' . $identifierType . '.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sends the update request to the gateway
|
||||
*
|
||||
* @ignore
|
||||
* @param string $url
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
private function _doUpdate($httpVerb, $subPath, $params)
|
||||
{
|
||||
$fullPath = $this->_config->merchantPath() . $subPath;
|
||||
$response = $this->_http->$httpVerb($fullPath, $params);
|
||||
return $this->_verifyGatewayResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* generic method for validating incoming gateway responses
|
||||
*
|
||||
* creates a new CreditCard object and encapsulates
|
||||
* it inside a Result\Successful object, or
|
||||
* encapsulates a Errors object inside a Result\Error
|
||||
* alternatively, throws an Unexpected exception if the response is invalid
|
||||
*
|
||||
* @ignore
|
||||
* @param array $response gateway response values
|
||||
* @return Result\Successful|Result\Error
|
||||
* @throws Exception\Unexpected
|
||||
*/
|
||||
private function _verifyGatewayResponse($response)
|
||||
{
|
||||
if (isset($response['creditCard'])) {
|
||||
// return a populated instance of Address
|
||||
return new Result\Successful(
|
||||
CreditCard::factory($response['creditCard'])
|
||||
);
|
||||
} elseif (isset($response['apiErrorResponse'])) {
|
||||
return new Result\Error($response['apiErrorResponse']);
|
||||
} else {
|
||||
throw new Exception\Unexpected(
|
||||
"Expected address or apiErrorResponse"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\CreditCardGateway', 'Braintree_CreditCardGateway');
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
class CreditCardVerification extends Result\CreditCardVerification
|
||||
{
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$instance = new self($attributes);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
// static methods redirecting to gateway
|
||||
//
|
||||
public static function create($attributes)
|
||||
{
|
||||
Util::verifyKeys(self::createSignature(), $attributes);
|
||||
return Configuration::gateway()->creditCardVerification()->create($attributes);
|
||||
}
|
||||
|
||||
public static function fetch($query, $ids)
|
||||
{
|
||||
return Configuration::gateway()->creditCardVerification()->fetch($query, $ids);
|
||||
}
|
||||
|
||||
public static function search($query)
|
||||
{
|
||||
return Configuration::gateway()->creditCardVerification()->search($query);
|
||||
}
|
||||
|
||||
public static function createSignature()
|
||||
{
|
||||
return [
|
||||
['options' => ['amount', 'merchantAccountId']],
|
||||
['creditCard' =>
|
||||
[
|
||||
'cardholderName', 'cvv', 'number',
|
||||
'expirationDate', 'expirationMonth', 'expirationYear',
|
||||
['billingAddress' => CreditCardGateway::billingAddressSignature()]
|
||||
]
|
||||
]];
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\CreditCardVerification', 'Braintree_CreditCardVerification');
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
class CreditCardVerificationGateway
|
||||
{
|
||||
private $_gateway;
|
||||
private $_config;
|
||||
private $_http;
|
||||
|
||||
public function __construct($gateway)
|
||||
{
|
||||
$this->_gateway = $gateway;
|
||||
$this->_config = $gateway->config;
|
||||
$this->_config->assertHasAccessTokenOrKeys();
|
||||
$this->_http = new Http($gateway->config);
|
||||
}
|
||||
|
||||
public function create($attributes)
|
||||
{
|
||||
$response = $this->_http->post($this->_config->merchantPath() . "/verifications", ['verification' => $attributes]);
|
||||
return $this->_verifyGatewayResponse($response);
|
||||
}
|
||||
|
||||
private function _verifyGatewayResponse($response)
|
||||
{
|
||||
|
||||
if(isset($response['verification'])){
|
||||
return new Result\Successful(
|
||||
CreditCardVerification::factory($response['verification'])
|
||||
);
|
||||
} else if (isset($response['apiErrorResponse'])) {
|
||||
return new Result\Error($response['apiErrorResponse']);
|
||||
} else {
|
||||
throw new Exception\Unexpected(
|
||||
"Expected transaction or apiErrorResponse"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function fetch($query, $ids)
|
||||
{
|
||||
$criteria = [];
|
||||
foreach ($query as $term) {
|
||||
$criteria[$term->name] = $term->toparam();
|
||||
}
|
||||
$criteria["ids"] = CreditCardVerificationSearch::ids()->in($ids)->toparam();
|
||||
$path = $this->_config->merchantPath() . '/verifications/advanced_search';
|
||||
$response = $this->_http->post($path, ['search' => $criteria]);
|
||||
|
||||
return Util::extractattributeasarray(
|
||||
$response['creditCardVerifications'],
|
||||
'verification'
|
||||
);
|
||||
}
|
||||
|
||||
public function search($query)
|
||||
{
|
||||
$criteria = [];
|
||||
foreach ($query as $term) {
|
||||
$criteria[$term->name] = $term->toparam();
|
||||
}
|
||||
|
||||
$path = $this->_config->merchantPath() . '/verifications/advanced_search_ids';
|
||||
$response = $this->_http->post($path, ['search' => $criteria]);
|
||||
$pager = [
|
||||
'object' => $this,
|
||||
'method' => 'fetch',
|
||||
'methodArgs' => [$query]
|
||||
];
|
||||
|
||||
return new ResourceCollection($response, $pager);
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\CreditCardVerificationGateway', 'Braintree_CreditCardVerificationGateway');
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
class CreditCardVerificationSearch
|
||||
{
|
||||
public static function id() {
|
||||
return new TextNode('id');
|
||||
}
|
||||
|
||||
public static function creditCardCardholderName() {
|
||||
return new TextNode('credit_card_cardholder_name');
|
||||
}
|
||||
|
||||
public static function billingAddressDetailsPostalCode() {
|
||||
return new TextNode('billing_address_details_postal_code');
|
||||
}
|
||||
|
||||
public static function customerEmail() {
|
||||
return new TextNode('customer_email');
|
||||
}
|
||||
|
||||
public static function customerId() {
|
||||
return new TextNode('customer_id');
|
||||
}
|
||||
|
||||
public static function paymentMethodToken(){
|
||||
return new TextNode('payment_method_token');
|
||||
}
|
||||
|
||||
public static function creditCardExpirationDate() {
|
||||
return new EqualityNode('credit_card_expiration_date');
|
||||
}
|
||||
|
||||
public static function creditCardNumber() {
|
||||
return new PartialMatchNode('credit_card_number');
|
||||
}
|
||||
|
||||
public static function ids() {
|
||||
return new MultipleValueNode('ids');
|
||||
}
|
||||
|
||||
public static function createdAt() {
|
||||
return new RangeNode("created_at");
|
||||
}
|
||||
|
||||
public static function creditCardCardType()
|
||||
{
|
||||
return new MultipleValueNode("credit_card_card_type", CreditCard::allCardTypes());
|
||||
}
|
||||
|
||||
public static function status()
|
||||
{
|
||||
return new MultipleValueNode("status", Result\CreditCardVerification::allStatuses());
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\CreditCardVerificationSearch', 'Braintree_CreditCardVerificationSearch');
|
||||
396
modules/paypal/api/sdk/braintree/lib/Braintree/Customer.php
Normal file
396
modules/paypal/api/sdk/braintree/lib/Braintree/Customer.php
Normal file
@@ -0,0 +1,396 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Braintree Customer module
|
||||
* Creates and manages Customers
|
||||
*
|
||||
* <b>== More information ==</b>
|
||||
*
|
||||
* For more detailed information on Customers, see {@link http://www.braintreepayments.com/gateway/customer-api http://www.braintreepaymentsolutions.com/gateway/customer-api}
|
||||
*
|
||||
* @package Braintree
|
||||
* @category Resources
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*
|
||||
* @property-read array $addresses
|
||||
* @property-read array $paymentMethods
|
||||
* @property-read string $company
|
||||
* @property-read string $createdAt
|
||||
* @property-read array $creditCards
|
||||
* @property-read array $paypalAccounts
|
||||
* @property-read array $applePayCards
|
||||
* @property-read array $androidPayCards
|
||||
* @property-read array $amexExpressCheckoutCards
|
||||
* @property-read array $venmoAccounts
|
||||
* @property-read array $coinbaseAccounts
|
||||
* @property-read array $customFields custom fields passed with the request
|
||||
* @property-read string $email
|
||||
* @property-read string $fax
|
||||
* @property-read string $firstName
|
||||
* @property-read string $id
|
||||
* @property-read string $lastName
|
||||
* @property-read string $phone
|
||||
* @property-read string $updatedAt
|
||||
* @property-read string $website
|
||||
*/
|
||||
class Customer extends Base
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @return Customer[]
|
||||
*/
|
||||
public static function all()
|
||||
{
|
||||
return Configuration::gateway()->customer()->all();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $query
|
||||
* @param int[] $ids
|
||||
* @return Customer|Customer[]
|
||||
*/
|
||||
public static function fetch($query, $ids)
|
||||
{
|
||||
return Configuration::gateway()->customer()->fetch($query, $ids);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $attribs
|
||||
* @return Customer
|
||||
*/
|
||||
public static function create($attribs = [])
|
||||
{
|
||||
return Configuration::gateway()->customer()->create($attribs);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $attribs
|
||||
* @return Customer
|
||||
*/
|
||||
public static function createNoValidate($attribs = [])
|
||||
{
|
||||
return Configuration::gateway()->customer()->createNoValidate($attribs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.3.0
|
||||
* @param string $queryString
|
||||
* @return Result\Successful
|
||||
*/
|
||||
public static function createFromTransparentRedirect($queryString)
|
||||
{
|
||||
return Configuration::gateway()->customer()->createFromTransparentRedirect($queryString);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.3.0
|
||||
* @return string
|
||||
*/
|
||||
public static function createCustomerUrl()
|
||||
{
|
||||
return Configuration::gateway()->customer()->createCustomerUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws Exception\NotFound
|
||||
* @param string $id customer id
|
||||
* @return Customer
|
||||
*/
|
||||
public static function find($id)
|
||||
{
|
||||
return Configuration::gateway()->customer()->find($id);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $customerId
|
||||
* @param array $transactionAttribs
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
public static function credit($customerId, $transactionAttribs)
|
||||
{
|
||||
return Configuration::gateway()->customer()->credit($customerId, $transactionAttribs);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws Exception\ValidationError
|
||||
* @param type $customerId
|
||||
* @param type $transactionAttribs
|
||||
* @return Transaction
|
||||
*/
|
||||
public static function creditNoValidate($customerId, $transactionAttribs)
|
||||
{
|
||||
return Configuration::gateway()->customer()->creditNoValidate($customerId, $transactionAttribs);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws Exception on invalid id or non-200 http response code
|
||||
* @param int $customerId
|
||||
* @return Result\Successful
|
||||
*/
|
||||
public static function delete($customerId)
|
||||
{
|
||||
return Configuration::gateway()->customer()->delete($customerId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $customerId
|
||||
* @param array $transactionAttribs
|
||||
* @return Transaction
|
||||
*/
|
||||
public static function sale($customerId, $transactionAttribs)
|
||||
{
|
||||
return Configuration::gateway()->customer()->sale($customerId, $transactionAttribs);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $customerId
|
||||
* @param array $transactionAttribs
|
||||
* @return Transaction
|
||||
*/
|
||||
public static function saleNoValidate($customerId, $transactionAttribs)
|
||||
{
|
||||
return Configuration::gateway()->customer()->saleNoValidate($customerId, $transactionAttribs);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @param string $query
|
||||
* @return ResourceCollection
|
||||
*/
|
||||
public static function search($query)
|
||||
{
|
||||
return Configuration::gateway()->customer()->search($query);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws Exception\Unexpected
|
||||
* @param int $customerId
|
||||
* @param array $attributes
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
public static function update($customerId, $attributes)
|
||||
{
|
||||
return Configuration::gateway()->customer()->update($customerId, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws Exception\Unexpected
|
||||
* @param int $customerId
|
||||
* @param array $attributes
|
||||
* @return CustomerGateway
|
||||
*/
|
||||
public static function updateNoValidate($customerId, $attributes)
|
||||
{
|
||||
return Configuration::gateway()->customer()->updateNoValidate($customerId, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated since version 2.3.0
|
||||
* @return string
|
||||
*/
|
||||
public static function updateCustomerUrl()
|
||||
{
|
||||
return Configuration::gateway()->customer()->updateCustomerUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated since version 2.3.0
|
||||
* @param string $queryString
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
public static function updateFromTransparentRedirect($queryString)
|
||||
{
|
||||
return Configuration::gateway()->customer()->updateFromTransparentRedirect($queryString);
|
||||
}
|
||||
|
||||
/* instance methods */
|
||||
|
||||
/**
|
||||
* sets instance properties from an array of values
|
||||
*
|
||||
* @ignore
|
||||
* @access protected
|
||||
* @param array $customerAttribs array of customer data
|
||||
*/
|
||||
protected function _initialize($customerAttribs)
|
||||
{
|
||||
$this->_attributes = $customerAttribs;
|
||||
|
||||
$addressArray = [];
|
||||
if (isset($customerAttribs['addresses'])) {
|
||||
|
||||
foreach ($customerAttribs['addresses'] AS $address) {
|
||||
$addressArray[] = Address::factory($address);
|
||||
}
|
||||
}
|
||||
$this->_set('addresses', $addressArray);
|
||||
|
||||
$creditCardArray = [];
|
||||
if (isset($customerAttribs['creditCards'])) {
|
||||
foreach ($customerAttribs['creditCards'] AS $creditCard) {
|
||||
$creditCardArray[] = CreditCard::factory($creditCard);
|
||||
}
|
||||
}
|
||||
$this->_set('creditCards', $creditCardArray);
|
||||
|
||||
$coinbaseAccountArray = [];
|
||||
if (isset($customerAttribs['coinbaseAccounts'])) {
|
||||
foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) {
|
||||
$coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount);
|
||||
}
|
||||
}
|
||||
$this->_set('coinbaseAccounts', $coinbaseAccountArray);
|
||||
|
||||
$paypalAccountArray = [];
|
||||
if (isset($customerAttribs['paypalAccounts'])) {
|
||||
foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) {
|
||||
$paypalAccountArray[] = PayPalAccount::factory($paypalAccount);
|
||||
}
|
||||
}
|
||||
$this->_set('paypalAccounts', $paypalAccountArray);
|
||||
|
||||
$applePayCardArray = [];
|
||||
if (isset($customerAttribs['applePayCards'])) {
|
||||
foreach ($customerAttribs['applePayCards'] AS $applePayCard) {
|
||||
$applePayCardArray[] = ApplePayCard::factory($applePayCard);
|
||||
}
|
||||
}
|
||||
$this->_set('applePayCards', $applePayCardArray);
|
||||
|
||||
$androidPayCardArray = [];
|
||||
if (isset($customerAttribs['androidPayCards'])) {
|
||||
foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) {
|
||||
$androidPayCardArray[] = AndroidPayCard::factory($androidPayCard);
|
||||
}
|
||||
}
|
||||
$this->_set('androidPayCards', $androidPayCardArray);
|
||||
|
||||
$amexExpressCheckoutCardArray = [];
|
||||
if (isset($customerAttribs['amexExpressCheckoutCards'])) {
|
||||
foreach ($customerAttribs['amexExpressCheckoutCards'] AS $amexExpressCheckoutCard) {
|
||||
$amexExpressCheckoutCardArray[] = AmexExpressCheckoutCard::factory($amexExpressCheckoutCard);
|
||||
}
|
||||
}
|
||||
$this->_set('amexExpressCheckoutCards', $amexExpressCheckoutCardArray);
|
||||
|
||||
$venmoAccountArray = array();
|
||||
if (isset($customerAttribs['venmoAccounts'])) {
|
||||
foreach ($customerAttribs['venmoAccounts'] AS $venmoAccount) {
|
||||
$venmoAccountArray[] = VenmoAccount::factory($venmoAccount);
|
||||
}
|
||||
}
|
||||
$this->_set('venmoAccounts', $venmoAccountArray);
|
||||
|
||||
$this->_set('paymentMethods', array_merge(
|
||||
$this->creditCards,
|
||||
$this->paypalAccounts,
|
||||
$this->applePayCards,
|
||||
$this->coinbaseAccounts,
|
||||
$this->androidPayCards,
|
||||
$this->amexExpressCheckoutCards,
|
||||
$this->venmoAccounts
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a string representation of the customer
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return __CLASS__ . '[' .
|
||||
Util::attributesToString($this->_attributes) .']';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false if comparing object is not a Customer,
|
||||
* or is a Customer with a different id
|
||||
*
|
||||
* @param object $otherCust customer to compare against
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEqual($otherCust)
|
||||
{
|
||||
return !($otherCust instanceof Customer) ? false : $this->id === $otherCust->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an array containt all of the customer's payment methods
|
||||
*
|
||||
* @deprecated since version 3.1.0 - use the paymentMethods property directly
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function paymentMethods()
|
||||
{
|
||||
return $this->paymentMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the customer's default payment method
|
||||
*
|
||||
* @return CreditCard|PayPalAccount
|
||||
*/
|
||||
public function defaultPaymentMethod()
|
||||
{
|
||||
$defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree\Customer::_defaultPaymentMethodFilter');
|
||||
return current($defaultPaymentMethods);
|
||||
}
|
||||
|
||||
public static function _defaultPaymentMethodFilter($paymentMethod)
|
||||
{
|
||||
return $paymentMethod->isDefault();
|
||||
}
|
||||
|
||||
/* private class properties */
|
||||
|
||||
/**
|
||||
* @access protected
|
||||
* @var array registry of customer data
|
||||
*/
|
||||
protected $_attributes = [
|
||||
'addresses' => '',
|
||||
'company' => '',
|
||||
'creditCards' => '',
|
||||
'email' => '',
|
||||
'fax' => '',
|
||||
'firstName' => '',
|
||||
'id' => '',
|
||||
'lastName' => '',
|
||||
'phone' => '',
|
||||
'createdAt' => '',
|
||||
'updatedAt' => '',
|
||||
'website' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* factory method: returns an instance of Customer
|
||||
* to the requesting method, with populated properties
|
||||
*
|
||||
* @ignore
|
||||
* @param array $attributes
|
||||
* @return Customer
|
||||
*/
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$instance = new Customer();
|
||||
$instance->_initialize($attributes);
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\Customer', 'Braintree_Customer');
|
||||
@@ -0,0 +1,623 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Braintree CustomerGateway module
|
||||
* Creates and manages Customers
|
||||
*
|
||||
* <b>== More information ==</b>
|
||||
*
|
||||
* For more detailed information on Customers, see {@link http://www.braintreepayments.com/gateway/customer-api http://www.braintreepaymentsolutions.com/gateway/customer-api}
|
||||
*
|
||||
* @package Braintree
|
||||
* @category Resources
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*/
|
||||
class CustomerGateway
|
||||
{
|
||||
private $_gateway;
|
||||
private $_config;
|
||||
private $_http;
|
||||
|
||||
public function __construct($gateway)
|
||||
{
|
||||
$this->_gateway = $gateway;
|
||||
$this->_config = $gateway->config;
|
||||
$this->_config->assertHasAccessTokenOrKeys();
|
||||
$this->_http = new Http($gateway->config);
|
||||
}
|
||||
|
||||
public function all()
|
||||
{
|
||||
$path = $this->_config->merchantPath() . '/customers/advanced_search_ids';
|
||||
$response = $this->_http->post($path);
|
||||
$pager = [
|
||||
'object' => $this,
|
||||
'method' => 'fetch',
|
||||
'methodArgs' => [[]]
|
||||
];
|
||||
|
||||
return new ResourceCollection($response, $pager);
|
||||
}
|
||||
|
||||
public function fetch($query, $ids)
|
||||
{
|
||||
$criteria = [];
|
||||
foreach ($query as $term) {
|
||||
$criteria[$term->name] = $term->toparam();
|
||||
}
|
||||
$criteria["ids"] = CustomerSearch::ids()->in($ids)->toparam();
|
||||
$path = $this->_config->merchantPath() . '/customers/advanced_search';
|
||||
$response = $this->_http->post($path, ['search' => $criteria]);
|
||||
|
||||
return Util::extractattributeasarray(
|
||||
$response['customers'],
|
||||
'customer'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a customer using the given +attributes+. If <tt>:id</tt> is not passed,
|
||||
* the gateway will generate it.
|
||||
*
|
||||
* <code>
|
||||
* $result = Customer::create(array(
|
||||
* 'first_name' => 'John',
|
||||
* 'last_name' => 'Smith',
|
||||
* 'company' => 'Smith Co.',
|
||||
* 'email' => 'john@smith.com',
|
||||
* 'website' => 'www.smithco.com',
|
||||
* 'fax' => '419-555-1234',
|
||||
* 'phone' => '614-555-1234'
|
||||
* ));
|
||||
* if($result->success) {
|
||||
* echo 'Created customer ' . $result->customer->id;
|
||||
* } else {
|
||||
* echo 'Could not create customer, see result->errors';
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @access public
|
||||
* @param array $attribs
|
||||
* @return Braintree_Result_Successful|Braintree_Result_Error
|
||||
*/
|
||||
public function create($attribs = [])
|
||||
{
|
||||
Util::verifyKeys(self::createSignature(), $attribs);
|
||||
return $this->_doCreate('/customers', ['customer' => $attribs]);
|
||||
}
|
||||
|
||||
/**
|
||||
* attempts the create operation assuming all data will validate
|
||||
* returns a Customer object instead of a Result
|
||||
*
|
||||
* @access public
|
||||
* @param array $attribs
|
||||
* @return Customer
|
||||
* @throws Exception\ValidationError
|
||||
*/
|
||||
public function createNoValidate($attribs = [])
|
||||
{
|
||||
$result = $this->create($attribs);
|
||||
return Util::returnObjectOrThrowException(__CLASS__, $result);
|
||||
}
|
||||
/**
|
||||
* create a customer from a TransparentRedirect operation
|
||||
*
|
||||
* @deprecated since version 2.3.0
|
||||
* @access public
|
||||
* @param array $attribs
|
||||
* @return Customer
|
||||
*/
|
||||
public function createFromTransparentRedirect($queryString)
|
||||
{
|
||||
trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
|
||||
$params = TransparentRedirect::parseAndValidateQueryString(
|
||||
$queryString
|
||||
);
|
||||
return $this->_doCreate(
|
||||
'/customers/all/confirm_transparent_redirect_request',
|
||||
['id' => $params['id']]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated since version 2.3.0
|
||||
* @access public
|
||||
* @param none
|
||||
* @return string
|
||||
*/
|
||||
public function createCustomerUrl()
|
||||
{
|
||||
trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
|
||||
return $this->_config->baseUrl() . $this->_config->merchantPath() .
|
||||
'/customers/all/create_via_transparent_redirect_request';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* creates a full array signature of a valid create request
|
||||
* @return array gateway create request format
|
||||
*/
|
||||
public static function createSignature()
|
||||
{
|
||||
|
||||
$creditCardSignature = CreditCardGateway::createSignature();
|
||||
unset($creditCardSignature[array_search('customerId', $creditCardSignature)]);
|
||||
$signature = [
|
||||
'id', 'company', 'email', 'fax', 'firstName',
|
||||
'lastName', 'phone', 'website', 'deviceData',
|
||||
'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce',
|
||||
['creditCard' => $creditCardSignature],
|
||||
['customFields' => ['_anyKey_']],
|
||||
];
|
||||
return $signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a full array signature of a valid update request
|
||||
* @return array update request format
|
||||
*/
|
||||
public static function updateSignature()
|
||||
{
|
||||
$creditCardSignature = CreditCardGateway::updateSignature();
|
||||
|
||||
foreach($creditCardSignature AS $key => $value) {
|
||||
if(is_array($value) and array_key_exists('options', $value)) {
|
||||
array_push($creditCardSignature[$key]['options'], 'updateExistingToken');
|
||||
}
|
||||
}
|
||||
|
||||
$signature = [
|
||||
'id', 'company', 'email', 'fax', 'firstName',
|
||||
'lastName', 'phone', 'website', 'deviceData',
|
||||
'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce',
|
||||
['creditCard' => $creditCardSignature],
|
||||
['customFields' => ['_anyKey_']],
|
||||
];
|
||||
return $signature;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* find a customer by id
|
||||
*
|
||||
* @access public
|
||||
* @param string id customer Id
|
||||
* @return Customer|boolean The customer object or false if the request fails.
|
||||
* @throws Exception\NotFound
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
$this->_validateId($id);
|
||||
try {
|
||||
$path = $this->_config->merchantPath() . '/customers/' . $id;
|
||||
$response = $this->_http->get($path);
|
||||
return Customer::factory($response['customer']);
|
||||
} catch (Exception\NotFound $e) {
|
||||
throw new Exception\NotFound(
|
||||
'customer with id ' . $id . ' not found'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* credit a customer for the passed transaction
|
||||
*
|
||||
* @access public
|
||||
* @param int $customerId
|
||||
* @param array $transactionAttribs
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
public function credit($customerId, $transactionAttribs)
|
||||
{
|
||||
$this->_validateId($customerId);
|
||||
return Transaction::credit(
|
||||
array_merge($transactionAttribs,
|
||||
['customerId' => $customerId]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* credit a customer, assuming validations will pass
|
||||
*
|
||||
* returns a Transaction object on success
|
||||
*
|
||||
* @access public
|
||||
* @param int $customerId
|
||||
* @param array $transactionAttribs
|
||||
* @return Transaction
|
||||
* @throws Exception\ValidationError
|
||||
*/
|
||||
public function creditNoValidate($customerId, $transactionAttribs)
|
||||
{
|
||||
$result = $this->credit($customerId, $transactionAttribs);
|
||||
return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a customer by id
|
||||
*
|
||||
* @param string $customerId
|
||||
*/
|
||||
public function delete($customerId)
|
||||
{
|
||||
$this->_validateId($customerId);
|
||||
$path = $this->_config->merchantPath() . '/customers/' . $customerId;
|
||||
$this->_http->delete($path);
|
||||
return new Result\Successful();
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new sale for a customer
|
||||
*
|
||||
* @param string $customerId
|
||||
* @param array $transactionAttribs
|
||||
* @return Result\Successful|Result\Error
|
||||
* @see Transaction::sale()
|
||||
*/
|
||||
public function sale($customerId, $transactionAttribs)
|
||||
{
|
||||
$this->_validateId($customerId);
|
||||
return Transaction::sale(
|
||||
array_merge($transactionAttribs,
|
||||
['customerId' => $customerId]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new sale for a customer, assuming validations will pass
|
||||
*
|
||||
* returns a Transaction object on success
|
||||
* @access public
|
||||
* @param string $customerId
|
||||
* @param array $transactionAttribs
|
||||
* @return Transaction
|
||||
* @throws Exception\ValidationsFailed
|
||||
* @see Transaction::sale()
|
||||
*/
|
||||
public function saleNoValidate($customerId, $transactionAttribs)
|
||||
{
|
||||
$result = $this->sale($customerId, $transactionAttribs);
|
||||
return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ResourceCollection of customers matching the search query.
|
||||
*
|
||||
* If <b>query</b> is a string, the search will be a basic search.
|
||||
* If <b>query</b> is a hash, the search will be an advanced search.
|
||||
* For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/customer-api#searching http://www.braintreepaymentsolutions.com/gateway/customer-api}
|
||||
*
|
||||
* @param mixed $query search query
|
||||
* @return ResourceCollection
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function search($query)
|
||||
{
|
||||
$criteria = [];
|
||||
foreach ($query as $term) {
|
||||
$result = $term->toparam();
|
||||
if(is_null($result) || empty($result)) {
|
||||
throw new InvalidArgumentException('Operator must be provided');
|
||||
}
|
||||
|
||||
$criteria[$term->name] = $term->toparam();
|
||||
}
|
||||
|
||||
$path = $this->_config->merchantPath() . '/customers/advanced_search_ids';
|
||||
$response = $this->_http->post($path, ['search' => $criteria]);
|
||||
$pager = [
|
||||
'object' => $this,
|
||||
'method' => 'fetch',
|
||||
'methodArgs' => [$query]
|
||||
];
|
||||
|
||||
return new ResourceCollection($response, $pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* updates the customer record
|
||||
*
|
||||
* if calling this method in static context, customerId
|
||||
* is the 2nd attribute. customerId is not sent in object context.
|
||||
*
|
||||
* @access public
|
||||
* @param string $customerId (optional)
|
||||
* @param array $attributes
|
||||
* @return Result\Successful|Result\Error
|
||||
*/
|
||||
public function update($customerId, $attributes)
|
||||
{
|
||||
Util::verifyKeys(self::updateSignature(), $attributes);
|
||||
$this->_validateId($customerId);
|
||||
return $this->_doUpdate(
|
||||
'put',
|
||||
'/customers/' . $customerId,
|
||||
['customer' => $attributes]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* update a customer record, assuming validations will pass
|
||||
*
|
||||
* if calling this method in static context, customerId
|
||||
* is the 2nd attribute. customerId is not sent in object context.
|
||||
* returns a Customer object on success
|
||||
*
|
||||
* @access public
|
||||
* @param string $customerId
|
||||
* @param array $attributes
|
||||
* @return Customer
|
||||
* @throws Exception\ValidationsFailed
|
||||
*/
|
||||
public function updateNoValidate($customerId, $attributes)
|
||||
{
|
||||
$result = $this->update($customerId, $attributes);
|
||||
return Util::returnObjectOrThrowException(__CLASS__, $result);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @deprecated since version 2.3.0
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function updateCustomerUrl()
|
||||
{
|
||||
trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
|
||||
return $this->_config->baseUrl() . $this->_config->merchantPath() .
|
||||
'/customers/all/update_via_transparent_redirect_request';
|
||||
}
|
||||
|
||||
/**
|
||||
* update a customer from a TransparentRedirect operation
|
||||
*
|
||||
* @deprecated since version 2.3.0
|
||||
* @access public
|
||||
* @param string $queryString
|
||||
* @return object
|
||||
*/
|
||||
public function updateFromTransparentRedirect($queryString)
|
||||
{
|
||||
trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
|
||||
$params = TransparentRedirect::parseAndValidateQueryString(
|
||||
$queryString
|
||||
);
|
||||
return $this->_doUpdate(
|
||||
'post',
|
||||
'/customers/all/confirm_transparent_redirect_request',
|
||||
['id' => $params['id']]
|
||||
);
|
||||
}
|
||||
|
||||
/* instance methods */
|
||||
|
||||
/**
|
||||
* sets instance properties from an array of values
|
||||
*
|
||||
* @ignore
|
||||
* @access protected
|
||||
* @param array $customerAttribs array of customer data
|
||||
* @return void
|
||||
*/
|
||||
protected function _initialize($customerAttribs)
|
||||
{
|
||||
// set the attributes
|
||||
$this->_attributes = $customerAttribs;
|
||||
|
||||
// map each address into its own object
|
||||
$addressArray = [];
|
||||
if (isset($customerAttribs['addresses'])) {
|
||||
|
||||
foreach ($customerAttribs['addresses'] AS $address) {
|
||||
$addressArray[] = Address::factory($address);
|
||||
}
|
||||
}
|
||||
$this->_set('addresses', $addressArray);
|
||||
|
||||
// map each creditCard into its own object
|
||||
$creditCardArray = [];
|
||||
if (isset($customerAttribs['creditCards'])) {
|
||||
foreach ($customerAttribs['creditCards'] AS $creditCard) {
|
||||
$creditCardArray[] = CreditCard::factory($creditCard);
|
||||
}
|
||||
}
|
||||
$this->_set('creditCards', $creditCardArray);
|
||||
|
||||
// map each coinbaseAccount into its own object
|
||||
$coinbaseAccountArray = [];
|
||||
if (isset($customerAttribs['coinbaseAccounts'])) {
|
||||
foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) {
|
||||
$coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount);
|
||||
}
|
||||
}
|
||||
$this->_set('coinbaseAccounts', $coinbaseAccountArray);
|
||||
|
||||
// map each paypalAccount into its own object
|
||||
$paypalAccountArray = [];
|
||||
if (isset($customerAttribs['paypalAccounts'])) {
|
||||
foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) {
|
||||
$paypalAccountArray[] = PayPalAccount::factory($paypalAccount);
|
||||
}
|
||||
}
|
||||
$this->_set('paypalAccounts', $paypalAccountArray);
|
||||
|
||||
// map each applePayCard into its own object
|
||||
$applePayCardArray = [];
|
||||
if (isset($customerAttribs['applePayCards'])) {
|
||||
foreach ($customerAttribs['applePayCards'] AS $applePayCard) {
|
||||
$applePayCardArray[] = ApplePayCard::factory($applePayCard);
|
||||
}
|
||||
}
|
||||
$this->_set('applePayCards', $applePayCardArray);
|
||||
|
||||
// map each androidPayCard into its own object
|
||||
$androidPayCardArray = [];
|
||||
if (isset($customerAttribs['androidPayCards'])) {
|
||||
foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) {
|
||||
$androidPayCardArray[] = AndroidPayCard::factory($androidPayCard);
|
||||
}
|
||||
}
|
||||
$this->_set('androidPayCards', $androidPayCardArray);
|
||||
|
||||
$this->_set('paymentMethods', array_merge($this->creditCards, $this->paypalAccounts, $this->applePayCards, $this->coinbaseAccounts, $this->androidPayCards));
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a string representation of the customer
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return __CLASS__ . '[' .
|
||||
Util::attributesToString($this->_attributes) .']';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false if comparing object is not a Customer,
|
||||
* or is a Customer with a different id
|
||||
*
|
||||
* @param object $otherCust customer to compare against
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEqual($otherCust)
|
||||
{
|
||||
return !($otherCust instanceof Customer) ? false : $this->id === $otherCust->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an array containt all of the customer's payment methods
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function paymentMethods()
|
||||
{
|
||||
return $this->paymentMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the customer's default payment method
|
||||
*
|
||||
* @return CreditCard|PayPalAccount|ApplePayCard|AndroidPayCard
|
||||
*/
|
||||
public function defaultPaymentMethod()
|
||||
{
|
||||
$defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree\\Customer::_defaultPaymentMethodFilter');
|
||||
return current($defaultPaymentMethods);
|
||||
}
|
||||
|
||||
public static function _defaultPaymentMethodFilter($paymentMethod)
|
||||
{
|
||||
return $paymentMethod->isDefault();
|
||||
}
|
||||
|
||||
/* private class properties */
|
||||
|
||||
/**
|
||||
* @access protected
|
||||
* @var array registry of customer data
|
||||
*/
|
||||
protected $_attributes = [
|
||||
'addresses' => '',
|
||||
'company' => '',
|
||||
'creditCards' => '',
|
||||
'email' => '',
|
||||
'fax' => '',
|
||||
'firstName' => '',
|
||||
'id' => '',
|
||||
'lastName' => '',
|
||||
'phone' => '',
|
||||
'createdAt' => '',
|
||||
'updatedAt' => '',
|
||||
'website' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* sends the create request to the gateway
|
||||
*
|
||||
* @ignore
|
||||
* @param string $subPath
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function _doCreate($subPath, $params)
|
||||
{
|
||||
$fullPath = $this->_config->merchantPath() . $subPath;
|
||||
$response = $this->_http->post($fullPath, $params);
|
||||
|
||||
return $this->_verifyGatewayResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* verifies that a valid customer id is being used
|
||||
* @ignore
|
||||
* @param string customer id
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function _validateId($id = null) {
|
||||
if (is_null($id)) {
|
||||
throw new InvalidArgumentException(
|
||||
'expected customer id to be set'
|
||||
);
|
||||
}
|
||||
if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) {
|
||||
throw new InvalidArgumentException(
|
||||
$id . ' is an invalid customer id.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private class methods */
|
||||
|
||||
/**
|
||||
* sends the update request to the gateway
|
||||
*
|
||||
* @ignore
|
||||
* @param string $subPath
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
private function _doUpdate($httpVerb, $subPath, $params)
|
||||
{
|
||||
$fullPath = $this->_config->merchantPath() . $subPath;
|
||||
$response = $this->_http->$httpVerb($fullPath, $params);
|
||||
|
||||
return $this->_verifyGatewayResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* generic method for validating incoming gateway responses
|
||||
*
|
||||
* creates a new Customer object and encapsulates
|
||||
* it inside a Result\Successful object, or
|
||||
* encapsulates a Errors object inside a Result\Error
|
||||
* alternatively, throws an Unexpected exception if the response is invalid.
|
||||
*
|
||||
* @ignore
|
||||
* @param array $response gateway response values
|
||||
* @return Result\Successful|Result\Error
|
||||
* @throws Exception\Unexpected
|
||||
*/
|
||||
private function _verifyGatewayResponse($response)
|
||||
{
|
||||
if (isset($response['customer'])) {
|
||||
// return a populated instance of Customer
|
||||
return new Result\Successful(
|
||||
Customer::factory($response['customer'])
|
||||
);
|
||||
} else if (isset($response['apiErrorResponse'])) {
|
||||
return new Result\Error($response['apiErrorResponse']);
|
||||
} else {
|
||||
throw new Exception\Unexpected(
|
||||
"Expected customer or apiErrorResponse"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\CustomerGateway', 'Braintree_CustomerGateway');
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
class CustomerSearch
|
||||
{
|
||||
public static function addressCountryName() { return new TextNode('address_country_name'); }
|
||||
public static function addressExtendedAddress() { return new TextNode('address_extended_address'); }
|
||||
public static function addressFirstName() { return new TextNode('address_first_name'); }
|
||||
public static function addressLastName() { return new TextNode('address_last_name'); }
|
||||
public static function addressLocality() { return new TextNode('address_locality'); }
|
||||
public static function addressPostalCode() { return new TextNode('address_postal_code'); }
|
||||
public static function addressRegion() { return new TextNode('address_region'); }
|
||||
public static function addressStreetAddress() { return new TextNode('address_street_address'); }
|
||||
public static function cardholderName() { return new TextNode('cardholder_name'); }
|
||||
public static function company() { return new TextNode('company'); }
|
||||
public static function email() { return new TextNode('email'); }
|
||||
public static function fax() { return new TextNode('fax'); }
|
||||
public static function firstName() { return new TextNode('first_name'); }
|
||||
public static function id() { return new TextNode('id'); }
|
||||
public static function lastName() { return new TextNode('last_name'); }
|
||||
public static function paymentMethodToken() { return new TextNode('payment_method_token'); }
|
||||
public static function paymentMethodTokenWithDuplicates() { return new IsNode('payment_method_token_with_duplicates'); }
|
||||
public static function paypalAccountEmail() { return new IsNode('paypal_account_email'); }
|
||||
public static function phone() { return new TextNode('phone'); }
|
||||
public static function website() { return new TextNode('website'); }
|
||||
|
||||
public static function creditCardExpirationDate() { return new EqualityNode('credit_card_expiration_date'); }
|
||||
public static function creditCardNumber() { return new PartialMatchNode('credit_card_number'); }
|
||||
|
||||
public static function ids() { return new MultipleValueNode('ids'); }
|
||||
|
||||
public static function createdAt() { return new RangeNode("created_at"); }
|
||||
}
|
||||
class_alias('Braintree\CustomerSearch', 'Braintree_CustomerSearch');
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
class Descriptor extends Instance
|
||||
{
|
||||
}
|
||||
class_alias('Braintree\Descriptor', 'Braintree_Descriptor');
|
||||
62
modules/paypal/api/sdk/braintree/lib/Braintree/Digest.php
Normal file
62
modules/paypal/api/sdk/braintree/lib/Braintree/Digest.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Digest encryption module
|
||||
* Digest creates an HMAC-SHA1 hash for encrypting messages
|
||||
*
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*/
|
||||
class Digest
|
||||
{
|
||||
public static function hexDigestSha1($key, $string)
|
||||
{
|
||||
if(function_exists('hash_hmac')) {
|
||||
return self::_builtInHmacSha1($string, $key);
|
||||
} else {
|
||||
return self::_hmacSha1($string, $key);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hexDigestSha256($key, $string)
|
||||
{
|
||||
return hash_hmac('sha256', $string, hash('sha256', $key, true));
|
||||
}
|
||||
|
||||
public static function secureCompare($left, $right)
|
||||
{
|
||||
if (strlen($left) != strlen($right)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$leftBytes = unpack("C*", $left);
|
||||
$rightBytes = unpack("C*", $right);
|
||||
|
||||
$result = 0;
|
||||
for ($i = 1; $i <= count($leftBytes); $i++) {
|
||||
$result = $result | ($leftBytes[$i] ^ $rightBytes[$i]);
|
||||
}
|
||||
return $result == 0;
|
||||
}
|
||||
|
||||
public static function _builtInHmacSha1($message, $key)
|
||||
{
|
||||
return hash_hmac('sha1', $message, sha1($key, true));
|
||||
}
|
||||
|
||||
public static function _hmacSha1($message, $key)
|
||||
{
|
||||
$pack = 'H40';
|
||||
$keyDigest = sha1($key,true);
|
||||
$innerPad = str_repeat(chr(0x36), 64);
|
||||
$outerPad = str_repeat(chr(0x5C), 64);
|
||||
|
||||
for ($i = 0; $i < 20; $i++) {
|
||||
$innerPad{$i} = $keyDigest{$i} ^ $innerPad{$i};
|
||||
$outerPad{$i} = $keyDigest{$i} ^ $outerPad{$i};
|
||||
}
|
||||
|
||||
return sha1($outerPad.pack($pack, sha1($innerPad.$message)));
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\Digest', 'Braintree_Digest');
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
final class Disbursement extends Base
|
||||
{
|
||||
private $_merchantAccount;
|
||||
|
||||
protected function _initialize($disbursementAttribs)
|
||||
{
|
||||
$this->_attributes = $disbursementAttribs;
|
||||
$this->merchantAccountDetails = $disbursementAttribs['merchantAccount'];
|
||||
|
||||
if (isset($disbursementAttribs['merchantAccount'])) {
|
||||
$this->_set('merchantAccount',
|
||||
MerchantAccount::factory($disbursementAttribs['merchantAccount'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
$collection = Transaction::search([
|
||||
TransactionSearch::ids()->in($this->transactionIds),
|
||||
]);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$instance = new self();
|
||||
$instance->_initialize($attributes);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$display = [
|
||||
'id', 'merchantAccountDetails', 'exceptionMessage', 'amount',
|
||||
'disbursementDate', 'followUpAction', 'retry', 'success',
|
||||
'transactionIds'
|
||||
];
|
||||
|
||||
$displayAttributes = [];
|
||||
foreach ($display AS $attrib) {
|
||||
$displayAttributes[$attrib] = $this->$attrib;
|
||||
}
|
||||
return __CLASS__ . '[' .
|
||||
Util::attributesToString($displayAttributes) .']';
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\Disbursement', 'Braintree_Disbursement');
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Disbursement details from a transaction
|
||||
* Creates an instance of DisbursementDetails as returned from a transaction
|
||||
*
|
||||
*
|
||||
* @package Braintree
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*
|
||||
* @property-read string $settlementAmount
|
||||
* @property-read string $settlementCurrencyIsoCode
|
||||
* @property-read string $settlementCurrencyExchangeRate
|
||||
* @property-read string $fundsHeld
|
||||
* @property-read string $success
|
||||
* @property-read string $disbursementDate
|
||||
*/
|
||||
class DisbursementDetails extends Instance
|
||||
{
|
||||
public function isValid() {
|
||||
return !is_null($this->disbursementDate);
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\DisbursementDetails', 'Braintree_DisbursementDetails');
|
||||
21
modules/paypal/api/sdk/braintree/lib/Braintree/Discount.php
Normal file
21
modules/paypal/api/sdk/braintree/lib/Braintree/Discount.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
class Discount extends Modification
|
||||
{
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$instance = new self();
|
||||
$instance->_initialize($attributes);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
|
||||
// static methods redirecting to gateway
|
||||
|
||||
public static function all()
|
||||
{
|
||||
return Configuration::gateway()->discount()->all();
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\Discount', 'Braintree_Discount');
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
class DiscountGateway
|
||||
{
|
||||
private $_gateway;
|
||||
private $_config;
|
||||
private $_http;
|
||||
|
||||
public function __construct($gateway)
|
||||
{
|
||||
$this->_gateway = $gateway;
|
||||
$this->_config = $gateway->config;
|
||||
$this->_config->assertHasAccessTokenOrKeys();
|
||||
$this->_http = new Http($gateway->config);
|
||||
}
|
||||
|
||||
public function all()
|
||||
{
|
||||
$path = $this->_config->merchantPath() . '/discounts';
|
||||
$response = $this->_http->get($path);
|
||||
|
||||
$discounts = ["discount" => $response['discounts']];
|
||||
|
||||
return Util::extractAttributeAsArray(
|
||||
$discounts,
|
||||
'discount'
|
||||
);
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\DiscountGateway', 'Braintree_DiscountGateway');
|
||||
82
modules/paypal/api/sdk/braintree/lib/Braintree/Dispute.php
Normal file
82
modules/paypal/api/sdk/braintree/lib/Braintree/Dispute.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
/**
|
||||
* Creates an instance of Dispute as returned from a transaction
|
||||
*
|
||||
*
|
||||
* @package Braintree
|
||||
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
||||
*
|
||||
* @property-read string $amount
|
||||
* @property-read string $currencyIsoCode
|
||||
* @property-read date $receivedDate
|
||||
* @property-read string $reason
|
||||
* @property-read string $status
|
||||
* @property-read string $disbursementDate
|
||||
* @property-read object $transactionDetails
|
||||
*/
|
||||
final class Dispute extends Base
|
||||
{
|
||||
protected $_attributes = [];
|
||||
|
||||
/* Dispute Status */
|
||||
const OPEN = 'open';
|
||||
const WON = 'won';
|
||||
const LOST = 'lost';
|
||||
|
||||
/* deprecated; for backwards compatibilty */
|
||||
const Open = 'open';
|
||||
|
||||
/* Dispute Reason */
|
||||
const CANCELLED_RECURRING_TRANSACTION = "cancelled_recurring_transaction";
|
||||
const CREDIT_NOT_PROCESSED = "credit_not_processed";
|
||||
const DUPLICATE = "duplicate";
|
||||
const FRAUD = "fraud";
|
||||
const GENERAL = "general";
|
||||
const INVALID_ACCOUNT = "invalid_account";
|
||||
const NOT_RECOGNIZED = "not_recognized";
|
||||
const PRODUCT_NOT_RECEIVED = "product_not_received";
|
||||
const PRODUCT_UNSATISFACTORY = "product_unsatisfactory";
|
||||
const TRANSACTION_AMOUNT_DIFFERS = "transaction_amount_differs";
|
||||
const RETRIEVAL = "retrieval";
|
||||
|
||||
/* Dispute Kind */
|
||||
const CHARGEBACK = 'chargeback';
|
||||
const PRE_ARBITRATION = 'pre_arbitration';
|
||||
// RETRIEVAL for kind already defined under Dispute Reason
|
||||
|
||||
protected function _initialize($disputeAttribs)
|
||||
{
|
||||
$this->_attributes = $disputeAttribs;
|
||||
|
||||
if (isset($disputeAttribs['transaction'])) {
|
||||
$this->_set('transactionDetails',
|
||||
new Dispute\TransactionDetails($disputeAttribs['transaction'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function factory($attributes)
|
||||
{
|
||||
$instance = new self();
|
||||
$instance->_initialize($attributes);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$display = [
|
||||
'amount', 'reason', 'status',
|
||||
'replyByDate', 'receivedDate', 'currencyIsoCode'
|
||||
];
|
||||
|
||||
$displayAttributes = [];
|
||||
foreach ($display AS $attrib) {
|
||||
$displayAttributes[$attrib] = $this->$attrib;
|
||||
}
|
||||
return __CLASS__ . '[' .
|
||||
Util::attributesToString($displayAttributes) .']';
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\Dispute', 'Braintree_Dispute');
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Braintree\Dispute;
|
||||
|
||||
use Braintree\Instance;
|
||||
|
||||
/**
|
||||
* Transaction details for a dispute
|
||||
*
|
||||
* @package Braintree
|
||||
* @copyright 2010 Braintree Payment Solutions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates an instance of DisbursementDetails as returned from a transaction
|
||||
*
|
||||
*
|
||||
* @package Braintree
|
||||
* @copyright 2010 Braintree Payment Solutions
|
||||
*
|
||||
* @property-read string $amount
|
||||
* @property-read string $id
|
||||
*/
|
||||
class TransactionDetails extends Instance
|
||||
{
|
||||
}
|
||||
|
||||
class_alias('Braintree\Dispute\TransactionDetails', 'Braintree_Dispute_TransactionDetails');
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to 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 PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
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;
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace Braintree;
|
||||
|
||||
class EqualityNode extends IsNode
|
||||
{
|
||||
function isNot($value)
|
||||
{
|
||||
$this->searchTerms['is_not'] = strval($value);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
class_alias('Braintree\EqualityNode', 'Braintree_EqualityNode');
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user