147 lines
5.4 KiB
PHP
147 lines
5.4 KiB
PHP
<?php
|
||
/**
|
||
* 1997-2016 Quadra Informatique
|
||
*
|
||
* NOTICE OF LICENSE
|
||
*
|
||
* This source file is subject to the Open Software License (OSL 3.0) that is available
|
||
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
|
||
* If you are unable to obtain it through the world-wide-web, please send an email
|
||
* to modules@quadra-informatique.fr so we can send you a copy immediately.
|
||
*
|
||
* @author Quadra Informatique <modules@quadra-informatique.fr>
|
||
* @copyright 1997-2016 Quadra Informatique
|
||
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||
*/
|
||
|
||
class Be2billExeccode extends ObjectModel
|
||
{
|
||
|
||
/**
|
||
* Be2bill Execcode ID
|
||
* Same value as the EXECCODE parameter sent by the payment platform
|
||
* @var string
|
||
*/
|
||
public $id_b2b_execcode;
|
||
|
||
/**
|
||
* Message associated to the EXECCODE parameter sent by
|
||
* the payment platform
|
||
* @var string
|
||
*/
|
||
public $message;
|
||
|
||
/**
|
||
* @see ObjectModel::$definition
|
||
*/
|
||
public static $definition = array(
|
||
'table' => 'b2b_execcode',
|
||
'primary' => 'id_b2b_execcode',
|
||
'multilang' => true,
|
||
'fields' => array(
|
||
'message' => array(
|
||
'type' => self::TYPE_STRING,
|
||
'lang' => true,
|
||
'validate' => 'isString',
|
||
'required' => true
|
||
)
|
||
)
|
||
);
|
||
|
||
/**
|
||
* Create Execcode table
|
||
* @return boolean
|
||
*/
|
||
public static function createBe2billExeccodeTable()
|
||
{
|
||
$sql = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'b2b_execcode` (
|
||
`id_b2b_execcode` VARCHAR(10) NOT NULL,
|
||
`message` VARCHAR(255) NOT NULL,
|
||
PRIMARY KEY (`id_b2b_execcode`)
|
||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8';
|
||
|
||
return Db::getInstance()->execute($sql);
|
||
}
|
||
|
||
/**
|
||
* Insert in Be2bill Execcode table the default values of EXECCODE
|
||
* and messages associated
|
||
* @return boolean
|
||
*/
|
||
public static function insertBe2billExeccodeDefaultValues()
|
||
{
|
||
$data = array(
|
||
'0000' => 'Transaction Successfull',
|
||
'0001' => '3DSecure Identification required',
|
||
'0002' => 'Redirection to alternative payment required',
|
||
'1001' => 'Missing parameters',
|
||
'1002' => 'Invalid parameters',
|
||
'1003' => 'HASH Error',
|
||
'1004' => 'Protocol Not supported',
|
||
'1005' => 'REST ERROR',
|
||
'1006' => 'GET parameters forbidden',
|
||
'2001' => 'ALIAS not found',
|
||
'2002' => 'Reference transaction failed',
|
||
'2003' => 'Reference transaction not refundable',
|
||
'2004' => 'Reference transaction not found',
|
||
'2005' => 'Reference transaction not capturable',
|
||
'2006' => 'Reference transaction not finished',
|
||
'2007' => 'Invalid capture amount',
|
||
'2008' => 'The refund amount is invalid',
|
||
'2009' => 'The authorization has expired',
|
||
'2010' => 'Timetable not found',
|
||
'2011' => 'Timetable already interupt',
|
||
'2012' => 'Timetable already over',
|
||
'3001' => 'Acount disactivated',
|
||
'3002' => 'Server IP not known by BE2BILL',
|
||
'3003' => 'Transaction not allowed',
|
||
'4001' => 'Transaction refused by the banking network',
|
||
'4002' => 'insufficient funds',
|
||
'4003' => 'Card refused by the banking network',
|
||
'4004' => 'Transaction aborted',
|
||
'4005' => 'Fraud suspected',
|
||
'4006' => 'Card lost',
|
||
'4007' => 'Card stolen',
|
||
'4008' => '3DSecure Authentication failed',
|
||
'4009' => '3DSecure Authentication expired',
|
||
'4010' => 'Invalid transaction',
|
||
'4011' => 'Transaction duplicated',
|
||
'4012' => 'Invalid Card data',
|
||
'4013' => 'Transaction unauthorized by the banking network for this person',
|
||
'4014' => '3D secure card non enroled',
|
||
'4015' => 'Transaction expired',
|
||
'4016' => 'Transaction refused by payment terminal',
|
||
'4017' => 'Exceeding the expiry date of the form ( filled in by the merchant )',
|
||
'5001' => 'Protocol error',
|
||
'5002' => 'Banking network error',
|
||
'5003' => 'Maintenance active',
|
||
'5004' => 'Time out, the response will arrive by the notification url',
|
||
'5005' => 'Error displaying 3D Secure Module',
|
||
'6001' => 'Transaction declined by merchant',
|
||
'6002' => 'Transaction declined',
|
||
'6003' => 'Cardholder has already disputed a transaction',
|
||
'6004' => 'Transaction declined by merchant’s rules'
|
||
);
|
||
|
||
foreach ($data as $execcode => $message) {
|
||
Db::getInstance()->insert('b2b_execcode', array(
|
||
'id_b2b_execcode' => pSQL($execcode),
|
||
'message' => pSQL($message)
|
||
), false, true, Db::INSERT_IGNORE);
|
||
}
|
||
return (Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'b2b_execcode`') >= count($data));
|
||
}
|
||
|
||
/**
|
||
* Return the associated message to the given EXECCODE
|
||
* @param string $execcode
|
||
* @return string|boolean
|
||
*/
|
||
public static function getMessageByExeccode($execcode)
|
||
{
|
||
return Db::getInstance()->getValue('SELECT `message`
|
||
FROM `'._DB_PREFIX_.'b2b_execcode`
|
||
WHERE `id_b2b_execcode` = \''.pSQL($execcode).'\'');
|
||
}
|
||
}
|