first commit

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

View File

@@ -0,0 +1,94 @@
<?php
/**
* 2007-2020 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\services;
require_once dirname(__FILE__) . '/../classes/PaypalIpn.php';
class ServicePaypalIpn
{
/**
* @param $idTransaction string
* @param $status string
* @return bool
*/
public function exists($idTransaction, $status)
{
$collection = new \PrestaShopCollection(\PaypalIpn::class);
$collection->where('id_transaction', '=', pSQL($idTransaction));
$collection->where('status', '=', pSQL($status));
return (bool)$collection->count();
}
/**
* @param $idTransaction string
* @return array of the Prestashop Order objects
*/
public function getOrdersPsByTransaction($idTransaction)
{
$cart = $this->getCartByTransaction($idTransaction);
if (\Validate::isLoadedObject($cart) == false) {
return array();
}
$orderCollection = new \PrestaShopCollection(\Order::class);
$orderCollection->where('id_cart', '=', (int)$cart->id);
return $orderCollection->getResults();
}
/**
* @param $idTransaction string
* @return \Cart
*/
public function getCartByTransaction($idTransaction)
{
if ($idCart = $this->getIdCartByTransaction($idTransaction)) {
$cart = new \Cart((int)$idCart);
if (\Validate::isLoadedObject($cart)) {
return $cart;
}
}
return false;
}
/**
* @param $idTransaction string
* @return int
*/
public function getIdCartByTransaction($idTransaction)
{
$query = new \DbQuery();
$query->from('paypal_order');
$query->select('id_cart');
$query->where('id_transaction = "' . pSQL($idTransaction) . '"');
return (int) \Db::getInstance()->getValue($query);
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* 2007-2020 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\services;
use PaypalPPBTlib\Extensions\ProcessLogger\Classes\ProcessLoggerObjectModel;
use PaypalAddons\classes\AbstractMethodPaypal;
require_once dirname(__FILE__) . '/../classes/PaypalOrder.php';
class ServicePaypalLog
{
/**
* @param $log ProcessLoggerObjectModel
* @return url
*/
public function getLinkToTransaction($log)
{
if ($log->id_transaction == false || $log->id_order == false) {
return '';
}
/** @var $paypalOrder \PaypalOrder object*/
$paypalOrder = $this->getPaypalOrderByLog($log);
if (\Validate::isLoadedObject($paypalOrder) == false || $paypalOrder->method == 'BT') {
return '';
}
$method = AbstractMethodPaypal::load($paypalOrder->method);
return $method->getLinkToTransaction($log);
}
public function getPaypalOrderByLog($log)
{
return \PaypalOrder::loadByOrderId($log->id_order);
}
}

View File

@@ -0,0 +1,104 @@
<?php
/**
* 2007-2020 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\services;
use PrestaShopBundle\Security\Admin\Employee;
require_once dirname(__FILE__) . '/../classes/PaypalOrder.php';
require_once dirname(__FILE__) . '/../classes/PaypalCapture.php';
use PaypalAddons\classes\AbstractMethodPaypal;
class ServicePaypalOrder
{
/**
* @param $paypalOrder \PaypalOrder object
* @param $idStatus integer id of the order status
* @return bool
*/
public function setOrderStatus($paypalOrder, $idStatus)
{
$psOrders = $this->getPsOrders($paypalOrder);
if (empty($psOrders)) {
return false;
}
/* @var $psOrder \Order*/
foreach ($psOrders as $psOrder) {
if (empty($psOrder->getHistory(\Context::getContext()->language->id, $idStatus)) == false) {
continue;
}
if (in_array($idStatus, array((int)\Configuration::get('PS_OS_REFUND'), (int)\Configuration::get('PAYPAL_OS_REFUNDED_PAYPAL')))) {
$paypalOrder->payment_status = 'refunded';
$paypalOrder->save();
}
$psOrder->setCurrentState($idStatus);
}
return true;
}
/**
* @param $paypalOrder \PaypalOrder object
* @return \PaypalCapture object
*/
public function getCapture($paypalOrder)
{
$collection = new \PrestaShopCollection('PaypalCapture');
$collection->where('id_paypal_order', '=', $paypalOrder->id);
return $collection->getFirst();
}
/**
* @param $transactionId string id of the Prestashop Customer object
* @return \PaypalOrder
*/
public function getPaypalOrderByTransaction($transactionId)
{
$collection = new \PrestaShopCollection('PaypalOrder');
$collection->where('id_transaction', '=', $transactionId);
return $collection->getFirst();
}
/**
* @param $paypalOrder \PaypalOrder object
* @return array of the Order objects
*/
public function getPsOrders($paypalOrder)
{
$collection = new \PrestaShopCollection('Order');
$collection->where('id_cart', '=', $paypalOrder->id_cart);
return $collection->getResults();
}
}

View File

@@ -0,0 +1,115 @@
<?php
/**
* 2007-2020 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PaypalAddons\services;
require_once dirname(__FILE__) . '/../classes/PaypalVaulting.php';
use PaypalAddons\classes\AbstractMethodPaypal;
class ServicePaypalVaulting
{
/**
* @param $idCustomer integer id of the Prestashop Customer object
* @param $rememberedCards string hash of the remembered card ids
* @param $mode bool mode of the payment (sandbox or live)
* @return bool
*/
public function createOrUpdatePaypalVaulting($idCustomer, $rememberedCards, $mode = null)
{
if ($mode === null) {
$mode = (int)\Configuration::get('PAYPAL_SANDBOX');
}
$paypalVaultingObject = $this->getPaypalVaultingByIdCustomer($idCustomer, $mode);
if (is_object($paypalVaultingObject) == false || \Validate::isLoadedObject($paypalVaultingObject) == false) {
$paypalVaultingObject = new \PaypalVaulting();
$paypalVaultingObject->id_customer = $idCustomer;
$paypalVaultingObject->sandbox = (int)$mode;
if ((int)$mode) {
$profileKey = md5(\Configuration::get('PAYPAL_MB_SANDBOX_CLIENTID'));
} else {
$profileKey = md5(\Configuration::get('PAYPAL_MB_LIVE_CLIENTID'));
}
$paypalVaultingObject->profile_key = $profileKey;
}
$paypalVaultingObject->rememberedCards = $rememberedCards;
try {
return $paypalVaultingObject->save();
} catch (\Exception $e) {
return false;
}
}
/**
* @param $idCustomer integer id of the Prestashop Customer object
* @param $mode bool mode of the payment (sandbox or live)
* @return string
*/
public function getRememberedCardsByIdCustomer($idCustomer, $mode = null)
{
if ($mode === null) {
$mode = (int)\Configuration::get('PAYPAL_SANDBOX');
}
$paypalVaultingObject = $this->getPaypalVaultingByIdCustomer($idCustomer, $mode);
if (is_object($paypalVaultingObject) == false || \Validate::isLoadedObject($paypalVaultingObject) == false) {
return '';
}
return $paypalVaultingObject->rememberedCards;
}
/**
* @param $idCustomer integer id of the Prestashop Customer object
* @param $mode bool mode of the payment (sandbox or live)
* @return \PaypalVaulting object or false
*/
public function getPaypalVaultingByIdCustomer($idCustomer, $mode = null)
{
if ($mode === null) {
$mode = (int)\Configuration::get('PAYPAL_SANDBOX');
}
if ((int)$mode) {
$profileKey = md5(\Configuration::get('PAYPAL_MB_SANDBOX_CLIENTID'));
} else {
$profileKey = md5(\Configuration::get('PAYPAL_MB_LIVE_CLIENTID'));
}
$collection = new \PrestaShopCollection(\PaypalVaulting::class);
$collection->where('id_customer', '=', (int)$idCustomer);
$collection->where('sandbox', '=', (int)$mode);
$collection->where('profile_key', '=', $profileKey);
return $collection->getFirst();
}
}

View File

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