MAJ Module Paypal vers 5.1.1 (comme en prod)
This commit is contained in:
@@ -20,29 +20,23 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2019 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PaypalVaulting.
|
||||
* Class PaypalOrder.
|
||||
*/
|
||||
class PaypalVaulting extends ObjectModel
|
||||
{
|
||||
/** @var string Token received from BT */
|
||||
public $token;
|
||||
/** @var integer id of the Prestashop Customer object*/
|
||||
public $id_customer;
|
||||
|
||||
/** @var int BT Customer ID */
|
||||
public $id_paypal_customer;
|
||||
/** @var string hash of the remembered card ids*/
|
||||
public $rememberedCards;
|
||||
|
||||
/** @var string client can set card name in prestashop account */
|
||||
public $name;
|
||||
|
||||
/** @var string Card or paypal account short info like last 4 numbers/exp. date */
|
||||
public $info;
|
||||
|
||||
/** @var string card ou paypal, etc... */
|
||||
public $payment_tool;
|
||||
/** @var bool mode of payment (sandbox or live) */
|
||||
public $sandbox;
|
||||
|
||||
/** @var string Object creation date */
|
||||
public $date_add;
|
||||
@@ -50,6 +44,9 @@ class PaypalVaulting extends ObjectModel
|
||||
/** @var string Object last modification date */
|
||||
public $date_upd;
|
||||
|
||||
/** @var string */
|
||||
public $profile_key;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
@@ -58,70 +55,14 @@ class PaypalVaulting extends ObjectModel
|
||||
'primary' => 'id_paypal_vaulting',
|
||||
'multilang' => false,
|
||||
'fields' => array(
|
||||
'token' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
|
||||
'id_paypal_customer' => array('type' => self::TYPE_INT),
|
||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
|
||||
'info' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
|
||||
'payment_tool' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
|
||||
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'rememberedCards' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
|
||||
'profile_key' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
|
||||
'sandbox' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Checking if vault was created already for this card/pp account
|
||||
* @return boolean
|
||||
*/
|
||||
public static function vaultingExist($token, $customer)
|
||||
{
|
||||
$db = Db::getInstance();
|
||||
$query = new DbQuery();
|
||||
$query->select('id_paypal_vaulting');
|
||||
$query->from('paypal_vaulting');
|
||||
$query->where('token = "'.pSQL($token).'" AND id_paypal_customer = '.(int)$customer);
|
||||
$result = $db->getValue($query);
|
||||
return $result ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all vaulted methods (cards, accounts) for this customer
|
||||
* @param integer $customer PrestaShop Customer ID
|
||||
* @param string $method payment tool (card or paypal account)
|
||||
* @return array PaypalVaulting
|
||||
*/
|
||||
public static function getCustomerMethods($customer, $method)
|
||||
{
|
||||
$db = Db::getInstance();
|
||||
$query = new DbQuery();
|
||||
$query->select('*');
|
||||
$query->from('paypal_vaulting', 'pv');
|
||||
$query->leftJoin('paypal_customer', 'pc', 'pv.id_paypal_customer = pc.id_paypal_customer');
|
||||
$query->where('pc.id_customer = '.(int)$customer);
|
||||
$query->where('pv.payment_tool = "'.pSQL($method).'"');
|
||||
$query->where('pc.sandbox = ' . (int)Configuration::get('PAYPAL_SANDBOX'));
|
||||
$result = $db->executeS($query);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vaulted methods grouped by tools (card or paypal account)
|
||||
* @param integer $customer PrestaShop Customer ID
|
||||
* @return array PaypalVaulting
|
||||
*/
|
||||
public static function getCustomerGroupedMethods($customer)
|
||||
{
|
||||
$db = Db::getInstance();
|
||||
$methods = array();
|
||||
$query = new DbQuery();
|
||||
$query->select('*');
|
||||
$query->from('paypal_vaulting', 'pv');
|
||||
$query->leftJoin('paypal_customer', 'pc', 'pv.id_paypal_customer = pc.id_paypal_customer');
|
||||
$query->where('pc.id_customer = '.(int)$customer);
|
||||
$query->where('pc.sandbox = ' . (int)Configuration::get('PAYPAL_SANDBOX'));
|
||||
$results = $db->query($query);
|
||||
while ($result = $db->nextRow($results)) {
|
||||
$methods[$result['payment_tool']][] = $result;
|
||||
}
|
||||
return $methods;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user