Add hooks on payment pages
This commit is contained in:
parent
cbda0e6197
commit
7d433e43fa
@ -197,6 +197,7 @@ class HookManager
|
||||
'getFormatedSupplierRef',
|
||||
'getIdProfUrl',
|
||||
'getInputIdProf',
|
||||
'isPaymentOK',
|
||||
'menuDropdownQuickaddItems',
|
||||
'menuLeftMenuItems',
|
||||
'moveUploadedFile',
|
||||
|
||||
@ -146,7 +146,7 @@ function payment_supplier_prepare_head(Paiement $object)
|
||||
*/
|
||||
function getValidOnlinePaymentMethods($paymentmethod = '')
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $conf, $langs, $hookmanager, $action;
|
||||
|
||||
$validpaymentmethod = array();
|
||||
|
||||
@ -162,8 +162,15 @@ function getValidOnlinePaymentMethods($paymentmethod = '')
|
||||
$langs->load("stripe");
|
||||
$validpaymentmethod['stripe'] = 'valid';
|
||||
}
|
||||
// TODO Add trigger
|
||||
|
||||
// This hook is used to complete the $validpaymentmethod array so an external payment modules
|
||||
// can add its own key (ie 'payzen' for Payzen, ...)
|
||||
$parameters = [
|
||||
'paymentmethod' => $paymentmethod,
|
||||
'validpaymentmethod' => &$validpaymentmethod
|
||||
];
|
||||
$tmpobject = new stdClass();
|
||||
$hookmanager->executeHooks('doValidatePayment', $parameters, $tmpobject, $action);
|
||||
|
||||
return $validpaymentmethod;
|
||||
}
|
||||
|
||||
@ -281,15 +281,9 @@ if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('strip
|
||||
}
|
||||
|
||||
// Initialize $validpaymentmethod
|
||||
// The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods()
|
||||
$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
|
||||
|
||||
// This hook is used to push to $validpaymentmethod by external payment modules (ie Payzen, ...)
|
||||
$parameters = [
|
||||
'paymentmethod' => $paymentmethod,
|
||||
'validpaymentmethod' => &$validpaymentmethod
|
||||
];
|
||||
$reshook = $hookmanager->executeHooks('doValidatePayment', $parameters, $object, $action);
|
||||
|
||||
// Check security token
|
||||
$tmpsource = $source;
|
||||
if ($tmpsource == 'membersubscription') {
|
||||
|
||||
@ -54,13 +54,14 @@ if (is_numeric($entity)) {
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
|
||||
|
||||
if (isModEnabled('paypal')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
|
||||
}
|
||||
// Hook to be used by external payment modules (ie Payzen, ...)
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($db);
|
||||
$hookmanager->initHooks(array('newpayment'));
|
||||
|
||||
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal"));
|
||||
|
||||
@ -337,6 +338,16 @@ if (isModEnabled('stripe')) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check status of the object to verify if it is paid by external payment modules
|
||||
$action = '';
|
||||
$parameters = [
|
||||
'paymentmethod' => $paymentmethod,
|
||||
];
|
||||
$reshook = $hookmanager->executeHooks('isPaymentOK', $parameters, $object, $action);
|
||||
if ($reshook >= 0) {
|
||||
$ispaymentok = $hookmanager->resArray['ispaymentok'];
|
||||
}
|
||||
|
||||
|
||||
// If data not provided from back url, search them into the session env
|
||||
if (empty($ipaddress)) {
|
||||
@ -1142,6 +1153,8 @@ if ($ispaymentok) {
|
||||
// (we need first that the donation module is able to generate a pdf document for the cerfa with pre filled content)
|
||||
} elseif (array_key_exists('ATT', $tmptag) && $tmptag['ATT'] > 0) {
|
||||
// Record payment for registration to an event for an attendee
|
||||
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$object = new Facture($db);
|
||||
$result = $object->fetch($ref);
|
||||
@ -1355,6 +1368,8 @@ if ($ispaymentok) {
|
||||
}
|
||||
} elseif (array_key_exists('BOO', $tmptag) && $tmptag['BOO'] > 0) {
|
||||
// Record payment for booth or conference
|
||||
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$object = new Facture($db);
|
||||
$result = $object->fetch($ref);
|
||||
@ -1461,6 +1476,8 @@ if ($ispaymentok) {
|
||||
|
||||
if (!$error) {
|
||||
// Putting the booth to "suggested" state
|
||||
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
|
||||
$booth = new ConferenceOrBooth($db);
|
||||
$resultbooth = $booth->fetch((int) $tmptag['BOO']);
|
||||
if ($resultbooth < 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user