2013-12-25 02:40:42 +01:00
|
|
|
<?php
|
|
|
|
|
/**
|
2018-10-14 10:56:03 +02:00
|
|
|
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
|
2024-03-07 21:39:29 +01:00
|
|
|
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
2020-09-29 02:26:18 +02:00
|
|
|
* Copyright (C) 2020 Abbes Bahfir <bafbes@gmail.com>
|
2021-05-04 21:55:19 +02:00
|
|
|
* Copyright (C) 2021 Waël Almoman <info@almoman.com>
|
2024-10-14 01:59:44 +02:00
|
|
|
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
2013-12-25 02:40:42 +01:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-09-23 21:55:30 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
* or see https://www.gnu.org/
|
2013-12-25 02:40:42 +01:00
|
|
|
*/
|
|
|
|
|
|
2013-12-28 23:13:32 +01:00
|
|
|
/**
|
|
|
|
|
* Returns an array with the tabs for the "Payment" section
|
|
|
|
|
* It loads tabs from modules looking for the entity payment
|
2017-09-09 10:03:09 +02:00
|
|
|
*
|
2014-01-02 16:41:23 +01:00
|
|
|
* @param Paiement $object Current payment object
|
2024-10-14 01:59:44 +02:00
|
|
|
* @return array<array{0:string,1:string,2:string}> Array of tabs for the payment section
|
2013-12-28 23:13:32 +01:00
|
|
|
*/
|
2021-05-04 22:59:32 +02:00
|
|
|
function payment_prepare_head(Paiement $object)
|
|
|
|
|
{
|
2024-05-21 20:19:57 +02:00
|
|
|
global $langs, $conf, $db;
|
2017-09-09 10:03:09 +02:00
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
$h = 0;
|
|
|
|
|
$head = array();
|
2013-12-25 02:40:42 +01:00
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$object->id;
|
|
|
|
|
$head[$h][1] = $langs->trans("Payment");
|
|
|
|
|
$head[$h][2] = 'payment';
|
|
|
|
|
$h++;
|
2013-12-25 02:40:42 +01:00
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
// Show more tabs from modules
|
|
|
|
|
// Entries must be declared in modules descriptor with line
|
|
|
|
|
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
|
|
|
|
// $this->tabs = array('entity:-tabname); to remove a tab
|
|
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment');
|
2013-12-25 02:40:42 +01:00
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$object->id;
|
|
|
|
|
$head[$h][1] = $langs->trans("Info");
|
|
|
|
|
$head[$h][2] = 'info';
|
|
|
|
|
$h++;
|
2020-09-29 02:26:18 +02:00
|
|
|
|
2024-05-21 20:19:57 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
|
|
|
|
$upload_dir = $conf->compta->payment->dir_output.'/'.$object->ref;
|
|
|
|
|
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
|
|
|
|
$nbLinks = Link::count($db, $object->element, $object->id);
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/document.php?id='.$object->id;
|
|
|
|
|
$head[$h][1] = $langs->trans('Documents');
|
|
|
|
|
if (($nbFiles + $nbLinks) > 0) {
|
|
|
|
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
|
|
|
|
|
}
|
|
|
|
|
$head[$h][2] = 'documents';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment', 'remove');
|
2020-09-29 02:26:18 +02:00
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
return $head;
|
2020-09-29 02:26:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns an array with the tabs for the "Bannkline" section
|
|
|
|
|
* It loads tabs from modules looking for the entity payment
|
|
|
|
|
*
|
2020-10-02 01:14:43 +02:00
|
|
|
* @param int $id ID of bank line
|
2024-10-14 01:59:44 +02:00
|
|
|
* @return array<array{0:string,1:string,2:string}> Array of tabs for the Banline section
|
2020-09-29 02:26:18 +02:00
|
|
|
*/
|
2021-05-04 22:59:32 +02:00
|
|
|
function bankline_prepare_head($id)
|
|
|
|
|
{
|
2020-10-07 15:01:28 +02:00
|
|
|
global $langs, $conf;
|
2020-09-29 02:26:18 +02:00
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
$h = 0;
|
|
|
|
|
$head = array();
|
2020-09-29 02:26:18 +02:00
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$id;
|
|
|
|
|
$head[$h][1] = $langs->trans('BankTransaction');
|
|
|
|
|
$head[$h][2] = 'bankline';
|
|
|
|
|
$h++;
|
2020-09-29 02:26:18 +02:00
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
// Show more tabs from modules
|
|
|
|
|
// Entries must be declared in modules descriptor with line
|
|
|
|
|
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
|
|
|
|
// $this->tabs = array('entity:-tabname); to remove a tab
|
|
|
|
|
complete_head_from_modules($conf, $langs, null, $head, $h, 'bankline');
|
2020-09-29 02:26:18 +02:00
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$id;
|
|
|
|
|
$head[$h][1] = $langs->trans("Info");
|
|
|
|
|
$head[$h][2] = 'info';
|
|
|
|
|
$h++;
|
2013-12-25 02:40:42 +01:00
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
complete_head_from_modules($conf, $langs, null, $head, $h, 'bankline', 'remove');
|
2013-12-25 02:40:42 +01:00
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
return $head;
|
2013-12-25 02:40:42 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-28 23:13:32 +01:00
|
|
|
/**
|
|
|
|
|
* Returns an array with the tabs for the "Supplier payment" section
|
|
|
|
|
* It loads tabs from modules looking for the entity payment_supplier
|
2017-09-09 10:03:09 +02:00
|
|
|
*
|
2014-01-02 16:41:23 +01:00
|
|
|
* @param Paiement $object Current payment object
|
2024-10-14 01:59:44 +02:00
|
|
|
* @return array<array{0:string,1:string,2:string}> Tabs for the payment section
|
2013-12-28 23:13:32 +01:00
|
|
|
*/
|
2021-05-04 22:59:32 +02:00
|
|
|
function payment_supplier_prepare_head(Paiement $object)
|
|
|
|
|
{
|
2021-10-18 00:48:33 +02:00
|
|
|
global $db, $langs, $conf;
|
2017-09-09 10:03:09 +02:00
|
|
|
|
2013-12-25 02:40:42 +01:00
|
|
|
$h = 0;
|
|
|
|
|
$head = array();
|
|
|
|
|
|
2014-09-18 21:18:25 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$object->id;
|
2020-05-17 13:34:16 +02:00
|
|
|
$head[$h][1] = $langs->trans("Payment");
|
2013-12-25 02:40:42 +01:00
|
|
|
$head[$h][2] = 'payment';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2020-10-07 15:01:28 +02:00
|
|
|
// Show more tabs from modules
|
|
|
|
|
// Entries must be declared in modules descriptor with line
|
|
|
|
|
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
|
|
|
|
// $this->tabs = array('entity:-tabname); to remove a tab
|
|
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_supplier');
|
2017-09-09 10:03:09 +02:00
|
|
|
|
2013-12-25 02:40:42 +01:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$object->id;
|
|
|
|
|
$head[$h][1] = $langs->trans('Info');
|
|
|
|
|
$head[$h][2] = 'info';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2021-10-18 00:48:33 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
|
|
|
|
$upload_dir = $conf->fournisseur->payment->dir_output.'/'.$object->ref;
|
|
|
|
|
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
|
|
|
|
$nbLinks = Link::count($db, $object->element, $object->id);
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/document.php?id='.$object->id;
|
|
|
|
|
$head[$h][1] = $langs->trans('Documents');
|
|
|
|
|
if (($nbFiles + $nbLinks) > 0) {
|
|
|
|
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
|
|
|
|
|
}
|
|
|
|
|
$head[$h][2] = 'documents';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_supplier', 'remove');
|
2013-12-25 02:40:42 +01:00
|
|
|
|
|
|
|
|
return $head;
|
2017-05-13 14:03:09 +02:00
|
|
|
}
|
|
|
|
|
|
2018-06-27 11:34:40 +02:00
|
|
|
/**
|
|
|
|
|
* Return array of valid payment mode
|
|
|
|
|
*
|
2024-05-24 14:49:33 +02:00
|
|
|
* @param string $paymentmethod Filter on this payment method (''=none, 'paypal', 'stripe', ...)
|
2024-11-04 12:32:13 +01:00
|
|
|
* @return array<string,string> Array of valid payment method
|
2018-06-27 11:34:40 +02:00
|
|
|
*/
|
2021-05-04 22:59:32 +02:00
|
|
|
function getValidOnlinePaymentMethods($paymentmethod = '')
|
|
|
|
|
{
|
2023-03-13 10:05:00 +01:00
|
|
|
global $langs, $hookmanager, $action;
|
2018-06-27 11:34:40 +02:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$validpaymentmethod = array();
|
2018-06-27 11:34:40 +02:00
|
|
|
|
2022-09-25 21:58:40 +02:00
|
|
|
if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) {
|
2019-11-08 10:24:03 +01:00
|
|
|
$langs->load("paypal");
|
2020-04-10 10:59:32 +02:00
|
|
|
$validpaymentmethod['paypal'] = 'valid';
|
2018-06-27 11:34:40 +02:00
|
|
|
}
|
2022-09-25 21:58:40 +02:00
|
|
|
if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) {
|
2024-04-04 11:00:35 +02:00
|
|
|
$langs->loadLangs(array("paybox", "stripe"));
|
2020-04-10 10:59:32 +02:00
|
|
|
$validpaymentmethod['paybox'] = 'valid';
|
2018-06-27 11:34:40 +02:00
|
|
|
}
|
2022-09-25 21:58:40 +02:00
|
|
|
if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) {
|
2019-11-08 10:24:03 +01:00
|
|
|
$langs->load("stripe");
|
2020-04-10 10:59:32 +02:00
|
|
|
$validpaymentmethod['stripe'] = 'valid';
|
2018-06-27 11:34:40 +02:00
|
|
|
}
|
2019-11-08 10:24:03 +01:00
|
|
|
|
2022-12-31 16:24:32 +01:00
|
|
|
// This hook is used to complete the $validpaymentmethod array so an external payment modules
|
2024-05-24 14:49:33 +02:00
|
|
|
// can add its own key (ie 'payzen' for Payzen, 'helloasso' for HelloAsso...)
|
2022-12-31 16:24:32 +01:00
|
|
|
$parameters = [
|
|
|
|
|
'paymentmethod' => $paymentmethod,
|
|
|
|
|
'validpaymentmethod' => &$validpaymentmethod
|
|
|
|
|
];
|
|
|
|
|
$tmpobject = new stdClass();
|
2023-01-30 03:01:13 +01:00
|
|
|
$reshook = $hookmanager->executeHooks('getValidPayment', $parameters, $tmpobject, $action);
|
|
|
|
|
if ($reshook < 0) {
|
|
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
|
|
|
} elseif (!empty($hookmanager->resArray['validpaymentmethod'])) {
|
|
|
|
|
if ($reshook == 0) {
|
|
|
|
|
$validpaymentmethod = array_merge($validpaymentmethod, $hookmanager->resArray['validpaymentmethod']);
|
|
|
|
|
} else {
|
|
|
|
|
$validpaymentmethod = $hookmanager->resArray['validpaymentmethod'];
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-08 10:24:03 +01:00
|
|
|
|
2018-06-27 11:34:40 +02:00
|
|
|
return $validpaymentmethod;
|
|
|
|
|
}
|
2017-05-13 14:03:09 +02:00
|
|
|
|
2017-09-12 12:18:26 +02:00
|
|
|
/**
|
2021-05-04 21:55:19 +02:00
|
|
|
* Return string with full online payment Url
|
2017-09-12 12:18:26 +02:00
|
|
|
*
|
2023-04-05 16:03:14 +02:00
|
|
|
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...)
|
|
|
|
|
* @param string $ref Ref of object
|
|
|
|
|
* @param int|float $amount Amount of money to request for
|
|
|
|
|
* @return string Url string
|
2017-09-12 12:18:26 +02:00
|
|
|
*/
|
2023-04-05 16:03:14 +02:00
|
|
|
function showOnlinePaymentUrl($type, $ref, $amount = 0)
|
2021-05-04 22:59:32 +02:00
|
|
|
{
|
2019-10-05 19:28:00 +02:00
|
|
|
global $langs;
|
2017-09-12 12:18:26 +02:00
|
|
|
|
2018-09-11 10:36:39 +02:00
|
|
|
// Load translation files required by the page
|
2020-10-07 15:01:28 +02:00
|
|
|
$langs->loadLangs(array('payment', 'stripe'));
|
2018-09-11 10:36:39 +02:00
|
|
|
|
2022-06-27 10:53:03 +02:00
|
|
|
$servicename = ''; // Link is a generic link for all payments services (paypal, stripe, ...)
|
2017-09-12 12:18:26 +02:00
|
|
|
|
2021-03-26 17:58:00 +01:00
|
|
|
$out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'</span><br>';
|
2022-07-11 11:44:00 +02:00
|
|
|
$url = getOnlinePaymentUrl(0, $type, $ref, $amount);
|
2024-08-26 15:33:48 +02:00
|
|
|
$out .= '<div class="urllink"><input type="text" id="onlinepaymenturl" spellcheck="false" class="quatrevingtpercentminusx" value="'.$url.'">';
|
2021-11-22 02:35:55 +01:00
|
|
|
$out .= '<a class="" href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
|
2021-10-18 20:46:28 +02:00
|
|
|
$out .= '</div>';
|
2024-09-05 16:05:37 +02:00
|
|
|
$out .= ajax_autoselect("onlinepaymenturl", '');
|
2017-09-12 12:18:26 +02:00
|
|
|
return $out;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-04 21:55:19 +02:00
|
|
|
/**
|
|
|
|
|
* Return string with HTML link for online payment
|
|
|
|
|
*
|
2023-04-05 16:03:14 +02:00
|
|
|
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...)
|
|
|
|
|
* @param string $ref Ref of object
|
|
|
|
|
* @param string $label Text or HTML tag to display, if empty it display the URL
|
|
|
|
|
* @param int|float $amount Amount of money to request for
|
|
|
|
|
* @return string Url string
|
2021-05-04 21:55:19 +02:00
|
|
|
*/
|
2023-04-05 16:03:14 +02:00
|
|
|
function getHtmlOnlinePaymentLink($type, $ref, $label = '', $amount = 0)
|
2021-05-04 22:59:32 +02:00
|
|
|
{
|
2022-07-11 11:44:00 +02:00
|
|
|
$url = getOnlinePaymentUrl(0, $type, $ref, $amount);
|
2021-05-04 21:55:19 +02:00
|
|
|
$label = $label ? $label : $url;
|
2021-11-22 02:35:55 +01:00
|
|
|
return '<a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$label.'</a>';
|
2021-05-04 21:55:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-09-12 12:18:26 +02:00
|
|
|
/**
|
|
|
|
|
* Return string with full Url
|
|
|
|
|
*
|
2024-01-13 19:48:20 +01:00
|
|
|
* @param int $mode 0=True url, 1=Url formatted with colors
|
2023-04-05 16:03:14 +02:00
|
|
|
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member', 'boothlocation', ...)
|
|
|
|
|
* @param string $ref Ref of object
|
|
|
|
|
* @param int|float $amount Amount of money to request for
|
|
|
|
|
* @param string $freetag Free tag (required and used for $type='free' only)
|
2025-01-08 23:29:04 +01:00
|
|
|
* @param int|string $localorexternal 0=Url of current browsing, 1=Url for external access, or string with virtual host url
|
2023-04-05 16:03:14 +02:00
|
|
|
* @return string Url string
|
2017-09-12 12:18:26 +02:00
|
|
|
*/
|
2023-04-05 16:03:14 +02:00
|
|
|
function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = 0, $freetag = 'your_tag', $localorexternal = 1)
|
2021-05-04 22:59:32 +02:00
|
|
|
{
|
2020-10-07 15:01:28 +02:00
|
|
|
global $conf, $dolibarr_main_url_root;
|
2017-09-12 12:18:26 +02:00
|
|
|
|
2019-11-13 19:35:39 +01:00
|
|
|
$out = '';
|
2017-09-12 12:18:26 +02:00
|
|
|
|
2019-04-24 18:47:11 +02:00
|
|
|
// Define $urlwithroot
|
2019-11-13 19:35:39 +01:00
|
|
|
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
|
|
|
|
|
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
2019-04-24 18:47:11 +02:00
|
|
|
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
|
|
|
|
|
2023-03-03 20:55:07 +01:00
|
|
|
$urltouse = DOL_MAIN_URL_ROOT; // Should be "https://www.mydomain.com/mydolibarr" for example
|
|
|
|
|
//dol_syslog("getOnlinePaymentUrl DOL_MAIN_URL_ROOT=".DOL_MAIN_URL_ROOT);
|
2023-03-03 19:58:04 +01:00
|
|
|
|
2025-01-08 23:29:04 +01:00
|
|
|
if ((string) $localorexternal == '1') {
|
2021-02-23 22:03:23 +01:00
|
|
|
$urltouse = $urlwithroot;
|
2025-01-08 23:29:04 +01:00
|
|
|
} elseif ((string) $localorexternal != '0') {
|
|
|
|
|
$urltouse = $localorexternal;
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
2019-04-24 18:47:11 +02:00
|
|
|
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($type == 'free') {
|
2024-11-29 15:11:36 +01:00
|
|
|
$out = $urltouse.'/public/payment/newpayment.php?amount='.($mode ? '<span style="color: #666666">' : '').price2num($amount, 'MT').($mode ? '</span>' : '').'&tag='.($mode ? '<span style="color: #666666">' : '').$freetag.($mode ? '</span>' : '');
|
2023-11-27 11:39:32 +01:00
|
|
|
if (getDolGlobalString('PAYMENT_SECURITY_TOKEN')) {
|
|
|
|
|
if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
|
2024-01-05 04:18:53 +01:00
|
|
|
$out .= '&securekey='.urlencode(getDolGlobalString('PAYMENT_SECURITY_TOKEN'));
|
2021-02-23 22:03:23 +01:00
|
|
|
} else {
|
2024-11-29 15:11:36 +01:00
|
|
|
$out .= '&securekey='.urlencode(dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 'sha1md5'));
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
2017-09-12 12:18:26 +02:00
|
|
|
}
|
2019-11-08 10:24:03 +01:00
|
|
|
//if ($mode) $out.='&noidempotency=1';
|
2021-02-23 22:03:23 +01:00
|
|
|
} elseif ($type == 'order') {
|
2022-01-04 12:56:08 +01:00
|
|
|
$out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($mode == 1) {
|
|
|
|
|
$out .= 'order_ref';
|
|
|
|
|
}
|
|
|
|
|
if ($mode == 0) {
|
|
|
|
|
$out .= urlencode($ref);
|
|
|
|
|
}
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= ($mode ? '</span>' : '');
|
2023-11-27 11:39:32 +01:00
|
|
|
if (getDolGlobalString('PAYMENT_SECURITY_TOKEN')) {
|
|
|
|
|
if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
|
2024-01-05 04:18:53 +01:00
|
|
|
$out .= '&securekey='.urlencode(getDolGlobalString('PAYMENT_SECURITY_TOKEN'));
|
2021-02-23 22:03:23 +01:00
|
|
|
} else {
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($mode == 1) {
|
2023-10-15 15:32:35 +02:00
|
|
|
$out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$type."' + order_ref)";
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
|
|
|
|
if ($mode == 0) {
|
2024-11-29 15:11:36 +01:00
|
|
|
$out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN').$type.$ref, 'sha1md5');
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= ($mode ? '</span>' : '');
|
2017-09-12 12:18:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-02-23 22:03:23 +01:00
|
|
|
} elseif ($type == 'invoice') {
|
2022-01-04 12:56:08 +01:00
|
|
|
$out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($mode == 1) {
|
|
|
|
|
$out .= 'invoice_ref';
|
|
|
|
|
}
|
|
|
|
|
if ($mode == 0) {
|
|
|
|
|
$out .= urlencode($ref);
|
|
|
|
|
}
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= ($mode ? '</span>' : '');
|
2023-11-27 11:39:32 +01:00
|
|
|
if (getDolGlobalString('PAYMENT_SECURITY_TOKEN')) {
|
|
|
|
|
if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
|
2024-01-05 04:18:53 +01:00
|
|
|
$out .= '&securekey='.urlencode(getDolGlobalString('PAYMENT_SECURITY_TOKEN'));
|
2021-02-23 22:03:23 +01:00
|
|
|
} else {
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($mode == 1) {
|
2023-10-15 15:32:35 +02:00
|
|
|
$out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$type."' + invoice_ref)";
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
|
|
|
|
if ($mode == 0) {
|
2024-11-29 15:11:36 +01:00
|
|
|
$out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN').$type.$ref, 'sha1md5');
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= ($mode ? '</span>' : '');
|
2017-09-12 12:18:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-02-23 22:03:23 +01:00
|
|
|
} elseif ($type == 'contractline') {
|
2022-01-04 12:56:08 +01:00
|
|
|
$out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($mode == 1) {
|
|
|
|
|
$out .= 'contractline_ref';
|
|
|
|
|
}
|
|
|
|
|
if ($mode == 0) {
|
|
|
|
|
$out .= urlencode($ref);
|
|
|
|
|
}
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= ($mode ? '</span>' : '');
|
2023-11-27 11:39:32 +01:00
|
|
|
if (getDolGlobalString('PAYMENT_SECURITY_TOKEN')) {
|
|
|
|
|
if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
|
2024-01-05 04:18:53 +01:00
|
|
|
$out .= '&securekey='.urlencode(getDolGlobalString('PAYMENT_SECURITY_TOKEN'));
|
2021-02-23 22:03:23 +01:00
|
|
|
} else {
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($mode == 1) {
|
2023-10-15 15:32:35 +02:00
|
|
|
$out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$type."' + contractline_ref)";
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
|
|
|
|
if ($mode == 0) {
|
2024-11-29 15:11:36 +01:00
|
|
|
$out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN').$type.$ref, 'sha1md5');
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= ($mode ? '</span>' : '');
|
2017-09-12 12:18:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-02-23 22:03:23 +01:00
|
|
|
} elseif ($type == 'member' || $type == 'membersubscription') {
|
2021-04-12 16:37:43 +02:00
|
|
|
$newtype = 'member';
|
2022-06-28 02:33:17 +02:00
|
|
|
$out = $urltouse.'/public/payment/newpayment.php?source=member';
|
2024-11-29 15:11:36 +01:00
|
|
|
$out .= '&amount='.price2num($amount, 'MT');
|
2022-06-28 02:33:17 +02:00
|
|
|
$out .= '&ref='.($mode ? '<span style="color: #666666">' : '');
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($mode == 1) {
|
|
|
|
|
$out .= 'member_ref';
|
|
|
|
|
}
|
|
|
|
|
if ($mode == 0) {
|
|
|
|
|
$out .= urlencode($ref);
|
|
|
|
|
}
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= ($mode ? '</span>' : '');
|
2023-11-27 11:39:32 +01:00
|
|
|
if (getDolGlobalString('PAYMENT_SECURITY_TOKEN')) {
|
|
|
|
|
if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
|
2024-01-05 04:18:53 +01:00
|
|
|
$out .= '&securekey='.urlencode(getDolGlobalString('PAYMENT_SECURITY_TOKEN'));
|
2021-02-23 22:03:23 +01:00
|
|
|
} else {
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
|
2024-11-29 15:11:36 +01:00
|
|
|
if ($mode == 1) { // mode tuto
|
2023-10-15 15:32:35 +02:00
|
|
|
$out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$newtype."' + member_ref)";
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
2024-11-29 15:11:36 +01:00
|
|
|
if ($mode == 0) { // mode real
|
|
|
|
|
$out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN').$newtype.$ref, 'sha1md5');
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= ($mode ? '</span>' : '');
|
2017-09-12 12:18:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-01-04 12:56:08 +01:00
|
|
|
} elseif ($type == 'donation') {
|
|
|
|
|
$out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($mode == 1) {
|
|
|
|
|
$out .= 'donation_ref';
|
|
|
|
|
}
|
|
|
|
|
if ($mode == 0) {
|
|
|
|
|
$out .= urlencode($ref);
|
|
|
|
|
}
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= ($mode ? '</span>' : '');
|
2023-11-27 11:39:32 +01:00
|
|
|
if (getDolGlobalString('PAYMENT_SECURITY_TOKEN')) {
|
|
|
|
|
if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
|
2024-01-05 04:18:53 +01:00
|
|
|
$out .= '&securekey='.urlencode(getDolGlobalString('PAYMENT_SECURITY_TOKEN'));
|
2021-02-23 22:03:23 +01:00
|
|
|
} else {
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($mode == 1) {
|
2023-10-15 15:32:35 +02:00
|
|
|
$out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$type."' + donation_ref)";
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
|
|
|
|
if ($mode == 0) {
|
2024-11-29 15:11:36 +01:00
|
|
|
$out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN').$type.$ref, 'sha1md5');
|
2021-02-23 22:03:23 +01:00
|
|
|
}
|
2021-10-05 09:41:03 +02:00
|
|
|
$out .= ($mode ? '</span>' : '');
|
2018-09-05 17:40:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-01-04 12:56:08 +01:00
|
|
|
} elseif ($type == 'boothlocation') {
|
|
|
|
|
$out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
|
|
|
|
|
if ($mode == 1) {
|
|
|
|
|
$out .= 'invoice_ref';
|
|
|
|
|
}
|
|
|
|
|
if ($mode == 0) {
|
|
|
|
|
$out .= urlencode($ref);
|
|
|
|
|
}
|
|
|
|
|
$out .= ($mode ? '</span>' : '');
|
2023-11-27 11:39:32 +01:00
|
|
|
if (getDolGlobalString('PAYMENT_SECURITY_TOKEN')) {
|
|
|
|
|
if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
|
2024-01-05 04:18:53 +01:00
|
|
|
$out .= '&securekey='.urlencode(getDolGlobalString('PAYMENT_SECURITY_TOKEN'));
|
2022-01-04 12:56:08 +01:00
|
|
|
} else {
|
|
|
|
|
$out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
|
|
|
|
|
if ($mode == 1) {
|
2023-10-15 15:32:35 +02:00
|
|
|
$out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$type."' + invoice_ref)";
|
2022-01-04 12:56:08 +01:00
|
|
|
}
|
|
|
|
|
if ($mode == 0) {
|
2024-11-29 15:11:36 +01:00
|
|
|
$out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN').$type.$ref, 'sha1md5');
|
2022-01-04 12:56:08 +01:00
|
|
|
}
|
|
|
|
|
$out .= ($mode ? '</span>' : '');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-12 18:23:58 +02:00
|
|
|
}
|
2017-09-12 12:18:26 +02:00
|
|
|
|
|
|
|
|
// For multicompany
|
2022-08-28 13:57:34 +02:00
|
|
|
if (!empty($out) && isModEnabled('multicompany')) {
|
2021-02-23 22:03:23 +01:00
|
|
|
$out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities
|
|
|
|
|
}
|
2017-09-12 12:18:26 +02:00
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
|
}
|