|
@@ -25,23 +25,32 @@
|
|
|
* This token can be used to get more informations.
|
|
|
*/
|
|
|
|
|
|
-if (!defined('NOLOGIN')) define("NOLOGIN", 1); // This means this output page does not require to be logged.
|
|
|
-if (!defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
|
|
|
-if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
|
|
|
-if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1');
|
|
|
+if (!defined('NOLOGIN')) {
|
|
|
+ define("NOLOGIN", 1); // This means this output page does not require to be logged.
|
|
|
+}
|
|
|
+if (!defined('NOCSRFCHECK')) {
|
|
|
+ define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
|
|
|
+}
|
|
|
+if (!defined('NOIPCHECK')) {
|
|
|
+ define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
|
|
|
+}
|
|
|
+if (!defined('NOBROWSERNOTIF')) {
|
|
|
+ define('NOBROWSERNOTIF', '1');
|
|
|
+}
|
|
|
|
|
|
// For MultiCompany module.
|
|
|
// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
|
|
|
// TODO This should be useless. Because entity must be retrieve from object ref and not from url.
|
|
|
$entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1));
|
|
|
-if (is_numeric($entity)) define("DOLENTITY", $entity);
|
|
|
+if (is_numeric($entity)) {
|
|
|
+ define("DOLENTITY", $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';
|
|
|
|
|
|
-if (!empty($conf->paypal->enabled))
|
|
|
-{
|
|
|
+if (!empty($conf->paypal->enabled)) {
|
|
|
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
|
|
|
}
|
|
@@ -49,29 +58,46 @@ if (!empty($conf->paypal->enabled))
|
|
|
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal"));
|
|
|
|
|
|
// Clean parameters
|
|
|
-if (!empty($conf->paypal->enabled))
|
|
|
-{
|
|
|
+if (!empty($conf->paypal->enabled)) {
|
|
|
$PAYPAL_API_USER = "";
|
|
|
- if (!empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER;
|
|
|
+ if (!empty($conf->global->PAYPAL_API_USER)) {
|
|
|
+ $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER;
|
|
|
+ }
|
|
|
$PAYPAL_API_PASSWORD = "";
|
|
|
- if (!empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD;
|
|
|
+ if (!empty($conf->global->PAYPAL_API_PASSWORD)) {
|
|
|
+ $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD;
|
|
|
+ }
|
|
|
$PAYPAL_API_SIGNATURE = "";
|
|
|
- if (!empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE;
|
|
|
+ if (!empty($conf->global->PAYPAL_API_SIGNATURE)) {
|
|
|
+ $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE;
|
|
|
+ }
|
|
|
$PAYPAL_API_SANDBOX = "";
|
|
|
- if (!empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX;
|
|
|
+ if (!empty($conf->global->PAYPAL_API_SANDBOX)) {
|
|
|
+ $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX;
|
|
|
+ }
|
|
|
$PAYPAL_API_OK = "";
|
|
|
- if ($urlok) $PAYPAL_API_OK = $urlok;
|
|
|
+ if ($urlok) {
|
|
|
+ $PAYPAL_API_OK = $urlok;
|
|
|
+ }
|
|
|
$PAYPAL_API_KO = "";
|
|
|
- if ($urlko) $PAYPAL_API_KO = $urlko;
|
|
|
+ if ($urlko) {
|
|
|
+ $PAYPAL_API_KO = $urlko;
|
|
|
+ }
|
|
|
|
|
|
$PAYPALTOKEN = GETPOST('TOKEN');
|
|
|
- if (empty($PAYPALTOKEN)) $PAYPALTOKEN = GETPOST('token');
|
|
|
+ if (empty($PAYPALTOKEN)) {
|
|
|
+ $PAYPALTOKEN = GETPOST('token');
|
|
|
+ }
|
|
|
$PAYPALPAYERID = GETPOST('PAYERID');
|
|
|
- if (empty($PAYPALPAYERID)) $PAYPALPAYERID = GETPOST('PayerID');
|
|
|
+ if (empty($PAYPALPAYERID)) {
|
|
|
+ $PAYPALPAYERID = GETPOST('PayerID');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$FULLTAG = GETPOST('FULLTAG');
|
|
|
-if (empty($FULLTAG)) $FULLTAG = GETPOST('fulltag');
|
|
|
+if (empty($FULLTAG)) {
|
|
|
+ $FULLTAG = GETPOST('fulltag');
|
|
|
+}
|
|
|
$source = GETPOST('s', 'alpha') ?GETPOST('s', 'alpha') : GETPOST('source', 'alpha');
|
|
|
$ref = GETPOST('ref');
|
|
|
|
|
@@ -81,12 +107,10 @@ $suffix = GETPOST("suffix", 'aZ09');
|
|
|
// Detect $paymentmethod
|
|
|
$paymentmethod = '';
|
|
|
$reg = array();
|
|
|
-if (preg_match('/PM=([^\.]+)/', $FULLTAG, $reg))
|
|
|
-{
|
|
|
+if (preg_match('/PM=([^\.]+)/', $FULLTAG, $reg)) {
|
|
|
$paymentmethod = $reg[1];
|
|
|
}
|
|
|
-if (empty($paymentmethod))
|
|
|
-{
|
|
|
+if (empty($paymentmethod)) {
|
|
|
dol_print_error(null, 'The back url does not contains a parameter fulltag that should help us to find the payment method used');
|
|
|
exit;
|
|
|
}
|
|
@@ -95,12 +119,20 @@ dol_syslog("***** paymentok.php is called paymentmethod=".$paymentmethod." FULLT
|
|
|
|
|
|
|
|
|
$validpaymentmethod = array();
|
|
|
-if (!empty($conf->paypal->enabled)) $validpaymentmethod['paypal'] = 'paypal';
|
|
|
-if (!empty($conf->paybox->enabled)) $validpaymentmethod['paybox'] = 'paybox';
|
|
|
-if (!empty($conf->stripe->enabled)) $validpaymentmethod['stripe'] = 'stripe';
|
|
|
+if (!empty($conf->paypal->enabled)) {
|
|
|
+ $validpaymentmethod['paypal'] = 'paypal';
|
|
|
+}
|
|
|
+if (!empty($conf->paybox->enabled)) {
|
|
|
+ $validpaymentmethod['paybox'] = 'paybox';
|
|
|
+}
|
|
|
+if (!empty($conf->stripe->enabled)) {
|
|
|
+ $validpaymentmethod['stripe'] = 'stripe';
|
|
|
+}
|
|
|
|
|
|
// Security check
|
|
|
-if (empty($validpaymentmethod)) accessforbidden('', 0, 0, 1);
|
|
|
+if (empty($validpaymentmethod)) {
|
|
|
+ accessforbidden('', 0, 0, 1);
|
|
|
+}
|
|
|
|
|
|
|
|
|
$ispaymentok = false;
|
|
@@ -130,11 +162,15 @@ $now = dol_now();
|
|
|
dol_syslog("Callback url when a payment was done. query_string=".(dol_escape_htmltag($_SERVER["QUERY_STRING"]) ?dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '')." script_uri=".(dol_escape_htmltag($_SERVER["SCRIPT_URI"]) ?dol_escape_htmltag($_SERVER["SCRIPT_URI"]) : ''), LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
$tracepost = "";
|
|
|
-foreach ($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n";
|
|
|
+foreach ($_POST as $k => $v) {
|
|
|
+ $tracepost .= "{$k} - {$v}\n";
|
|
|
+}
|
|
|
dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
$head = '';
|
|
|
-if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
|
|
|
+if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
|
|
|
+ $head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
|
|
|
+}
|
|
|
|
|
|
$conf->dol_hide_topmenu = 1;
|
|
|
$conf->dol_hide_leftmenu = 1;
|
|
@@ -153,25 +189,25 @@ print '<div id="dolpaymentdiv" class="center">'."\n";
|
|
|
$logosmall = $mysoc->logo_small;
|
|
|
$logo = $mysoc->logo;
|
|
|
$paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix;
|
|
|
-if (!empty($conf->global->$paramlogo)) $logosmall = $conf->global->$paramlogo;
|
|
|
-elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
|
|
|
+if (!empty($conf->global->$paramlogo)) {
|
|
|
+ $logosmall = $conf->global->$paramlogo;
|
|
|
+} elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) {
|
|
|
+ $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
|
|
|
+}
|
|
|
//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
|
|
|
// Define urllogo
|
|
|
$urllogo = '';
|
|
|
$urllogofull = '';
|
|
|
-if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall))
|
|
|
-{
|
|
|
+if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
|
|
|
$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
|
|
|
$urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
|
|
|
-} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo))
|
|
|
-{
|
|
|
+} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
|
|
|
$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
|
|
|
$urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
|
|
|
}
|
|
|
|
|
|
// Output html code for logo
|
|
|
-if ($urllogo)
|
|
|
-{
|
|
|
+if ($urllogo) {
|
|
|
print '<div class="backgreypublicpayment">';
|
|
|
print '<div class="logopublicpayment">';
|
|
|
print '<img id="dolpaymentlogo" src="'.$urllogo.'"';
|
|
@@ -187,12 +223,9 @@ if ($urllogo)
|
|
|
print '<br><br><br>';
|
|
|
|
|
|
|
|
|
-if (!empty($conf->paypal->enabled))
|
|
|
-{
|
|
|
- if ($paymentmethod == 'paypal') // We call this page only if payment is ok on payment system
|
|
|
- {
|
|
|
- if ($PAYPALTOKEN)
|
|
|
- {
|
|
|
+if (!empty($conf->paypal->enabled)) {
|
|
|
+ if ($paymentmethod == 'paypal') { // We call this page only if payment is ok on payment system
|
|
|
+ if ($PAYPALTOKEN) {
|
|
|
// Get on url call
|
|
|
$onlinetoken = $PAYPALTOKEN;
|
|
|
$fulltag = $FULLTAG;
|
|
@@ -207,15 +240,13 @@ if (!empty($conf->paypal->enabled))
|
|
|
dol_syslog("Call paymentok with token=".$onlinetoken." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
// Validate record
|
|
|
- if (!empty($paymentType))
|
|
|
- {
|
|
|
+ if (!empty($paymentType)) {
|
|
|
dol_syslog("We call GetExpressCheckoutDetails", LOG_DEBUG, 0, '_payment');
|
|
|
$resArray = getDetails($onlinetoken);
|
|
|
//var_dump($resarray);
|
|
|
|
|
|
$ack = strtoupper($resArray["ACK"]);
|
|
|
- if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING")
|
|
|
- {
|
|
|
+ if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
|
|
|
// Nothing to do
|
|
|
dol_syslog("Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0, '_payment');
|
|
|
} else {
|
|
@@ -227,8 +258,7 @@ if (!empty($conf->paypal->enabled))
|
|
|
//var_dump($resarray);
|
|
|
|
|
|
$ack = strtoupper($resArray2["ACK"]);
|
|
|
- if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING")
|
|
|
- {
|
|
|
+ if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
|
|
|
dol_syslog("Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
$object->source = $source;
|
|
@@ -263,22 +293,32 @@ if (!empty($conf->paypal->enabled))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-if (!empty($conf->paybox->enabled))
|
|
|
-{
|
|
|
- if ($paymentmethod == 'paybox') $ispaymentok = true; // We call this page only if payment is ok on payment system
|
|
|
+if (!empty($conf->paybox->enabled)) {
|
|
|
+ if ($paymentmethod == 'paybox') {
|
|
|
+ $ispaymentok = true; // We call this page only if payment is ok on payment system
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-if (!empty($conf->stripe->enabled))
|
|
|
-{
|
|
|
- if ($paymentmethod == 'stripe') $ispaymentok = true; // We call this page only if payment is ok on payment system
|
|
|
+if (!empty($conf->stripe->enabled)) {
|
|
|
+ if ($paymentmethod == 'stripe') {
|
|
|
+ $ispaymentok = true; // We call this page only if payment is ok on payment system
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
// If data not provided from back url, search them into the session env
|
|
|
-if (empty($ipaddress)) $ipaddress = $_SESSION['ipaddress'];
|
|
|
-if (empty($TRANSACTIONID)) $TRANSACTIONID = $_SESSION['TRANSACTIONID'];
|
|
|
-if (empty($FinalPaymentAmt)) $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"];
|
|
|
-if (empty($paymentType)) $paymentType = $_SESSION["paymentType"];
|
|
|
+if (empty($ipaddress)) {
|
|
|
+ $ipaddress = $_SESSION['ipaddress'];
|
|
|
+}
|
|
|
+if (empty($TRANSACTIONID)) {
|
|
|
+ $TRANSACTIONID = $_SESSION['TRANSACTIONID'];
|
|
|
+}
|
|
|
+if (empty($FinalPaymentAmt)) {
|
|
|
+ $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"];
|
|
|
+}
|
|
|
+if (empty($paymentType)) {
|
|
|
+ $paymentType = $_SESSION["paymentType"];
|
|
|
+}
|
|
|
|
|
|
$fulltag = $FULLTAG;
|
|
|
$tmptag = dolExplodeIntoArray($fulltag, '.', '=');
|
|
@@ -290,18 +330,22 @@ dol_syslog("ispaymentok=".$ispaymentok." tmptag=".var_export($tmptag, true), LOG
|
|
|
// Make complementary actions
|
|
|
$ispostactionok = 0;
|
|
|
$postactionmessages = array();
|
|
|
-if ($ispaymentok)
|
|
|
-{
|
|
|
+if ($ispaymentok) {
|
|
|
// Set permission for the anonymous user
|
|
|
- if (empty($user->rights->societe)) $user->rights->societe = new stdClass();
|
|
|
- if (empty($user->rights->facture)) $user->rights->facture = new stdClass();
|
|
|
- if (empty($user->rights->adherent)) { $user->rights->adherent = new stdClass(); $user->rights->adherent->cotisation = new stdClass(); }
|
|
|
+ if (empty($user->rights->societe)) {
|
|
|
+ $user->rights->societe = new stdClass();
|
|
|
+ }
|
|
|
+ if (empty($user->rights->facture)) {
|
|
|
+ $user->rights->facture = new stdClass();
|
|
|
+ }
|
|
|
+ if (empty($user->rights->adherent)) {
|
|
|
+ $user->rights->adherent = new stdClass(); $user->rights->adherent->cotisation = new stdClass();
|
|
|
+ }
|
|
|
$user->rights->societe->creer = 1;
|
|
|
$user->rights->facture->creer = 1;
|
|
|
$user->rights->adherent->cotisation->creer = 1;
|
|
|
|
|
|
- if (array_key_exists('MEM', $tmptag) && $tmptag['MEM'] > 0)
|
|
|
- {
|
|
|
+ if (array_key_exists('MEM', $tmptag) && $tmptag['MEM'] > 0) {
|
|
|
// Validate member
|
|
|
// Create subscription
|
|
|
// Create complementary actions (this include creation of thirdparty)
|
|
@@ -322,16 +366,22 @@ if ($ispaymentok)
|
|
|
|
|
|
dol_syslog("We have to process member with id=".$tmptag['MEM']." result1=".$result1." result2=".$result2, LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
- if ($result1 > 0 && $result2 > 0)
|
|
|
- {
|
|
|
+ if ($result1 > 0 && $result2 > 0) {
|
|
|
$paymentTypeId = 0;
|
|
|
- if ($paymentmethod == 'paybox') $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
- if ($paymentmethod == 'paypal') $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
- if ($paymentmethod == 'stripe') $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
- if (empty($paymentTypeId))
|
|
|
- {
|
|
|
+ if ($paymentmethod == 'paybox') {
|
|
|
+ $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
+ }
|
|
|
+ if ($paymentmethod == 'paypal') {
|
|
|
+ $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
+ }
|
|
|
+ if ($paymentmethod == 'stripe') {
|
|
|
+ $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
+ }
|
|
|
+ if (empty($paymentTypeId)) {
|
|
|
$paymentType = $_SESSION["paymentType"];
|
|
|
- if (empty($paymentType)) $paymentType = 'CB';
|
|
|
+ if (empty($paymentType)) {
|
|
|
+ $paymentType = 'CB';
|
|
|
+ }
|
|
|
$paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1);
|
|
|
}
|
|
|
|
|
@@ -340,11 +390,9 @@ if ($ispaymentok)
|
|
|
dol_syslog("FinalPaymentAmt=".$FinalPaymentAmt." paymentTypeId=".$paymentTypeId, LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
// Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)
|
|
|
- if (!empty($FinalPaymentAmt) && $paymentTypeId > 0)
|
|
|
- {
|
|
|
+ if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
|
|
|
$result = $object->validate($user);
|
|
|
- if ($result < 0 || empty($object->datevalid))
|
|
|
- {
|
|
|
+ if ($result < 0 || empty($object->datevalid)) {
|
|
|
$error++;
|
|
|
$errmsg = $object->error;
|
|
|
$postactionmessages[] = $errmsg;
|
|
@@ -355,13 +403,14 @@ if ($ispaymentok)
|
|
|
|
|
|
// Subscription informations
|
|
|
$datesubscription = $object->datevalid;
|
|
|
- if ($object->datefin > 0)
|
|
|
- {
|
|
|
+ if ($object->datefin > 0) {
|
|
|
$datesubscription = dol_time_plus_duree($object->datefin, 1, 'd');
|
|
|
}
|
|
|
|
|
|
$datesubend = null;
|
|
|
- if ($datesubscription && $defaultdelay && $defaultdelayunit) $datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd');
|
|
|
+ if ($datesubscription && $defaultdelay && $defaultdelayunit) {
|
|
|
+ $datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd');
|
|
|
+ }
|
|
|
|
|
|
$paymentdate = $now;
|
|
|
$amount = $FinalPaymentAmt;
|
|
@@ -369,11 +418,16 @@ if ($ispaymentok)
|
|
|
|
|
|
// Payment informations
|
|
|
$accountid = 0;
|
|
|
- if ($paymentmethod == 'paybox') $accountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
- if ($paymentmethod == 'paypal') $accountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
- if ($paymentmethod == 'stripe') $accountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
- if ($accountid < 0)
|
|
|
- {
|
|
|
+ if ($paymentmethod == 'paybox') {
|
|
|
+ $accountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
+ }
|
|
|
+ if ($paymentmethod == 'paypal') {
|
|
|
+ $accountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
+ }
|
|
|
+ if ($paymentmethod == 'stripe') {
|
|
|
+ $accountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
+ }
|
|
|
+ if ($accountid < 0) {
|
|
|
$error++;
|
|
|
$errmsg = 'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
|
|
|
$postactionmessages[] = $errmsg;
|
|
@@ -387,23 +441,27 @@ if ($ispaymentok)
|
|
|
$emetteur_banque = '';
|
|
|
// Define default choice for complementary actions
|
|
|
$option = '';
|
|
|
- if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $option = 'bankviainvoice';
|
|
|
- elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && !empty($conf->banque->enabled)) $option = 'bankdirect';
|
|
|
- elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $option = 'invoiceonly';
|
|
|
- if (empty($option)) $option = 'none';
|
|
|
+ if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) {
|
|
|
+ $option = 'bankviainvoice';
|
|
|
+ } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && !empty($conf->banque->enabled)) {
|
|
|
+ $option = 'bankdirect';
|
|
|
+ } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) {
|
|
|
+ $option = 'invoiceonly';
|
|
|
+ }
|
|
|
+ if (empty($option)) {
|
|
|
+ $option = 'none';
|
|
|
+ }
|
|
|
$sendalsoemail = 1;
|
|
|
|
|
|
// Record the subscription then complementary actions
|
|
|
$db->begin();
|
|
|
|
|
|
// Create subscription
|
|
|
- if (!$error)
|
|
|
- {
|
|
|
+ if (!$error) {
|
|
|
dol_syslog("Call ->subscription to create subscription", LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
$crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
|
|
|
- if ($crowid <= 0)
|
|
|
- {
|
|
|
+ if ($crowid <= 0) {
|
|
|
$error++;
|
|
|
$errmsg = $object->error;
|
|
|
$postactionmessages[] = $errmsg;
|
|
@@ -414,15 +472,13 @@ if ($ispaymentok)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!$error)
|
|
|
- {
|
|
|
+ if (!$error) {
|
|
|
dol_syslog("Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
$autocreatethirdparty = 1; // will create thirdparty if member not yet linked to a thirdparty
|
|
|
|
|
|
$result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty);
|
|
|
- if ($result < 0)
|
|
|
- {
|
|
|
+ if ($result < 0) {
|
|
|
dol_syslog("Error ".$object->error." ".join(',', $object->errors), LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
$error++;
|
|
@@ -430,18 +486,15 @@ if ($ispaymentok)
|
|
|
$postactionmessages = array_merge($postactionmessages, $object->errors);
|
|
|
$ispostactionok = -1;
|
|
|
} else {
|
|
|
- if ($option == 'bankviainvoice')
|
|
|
- {
|
|
|
+ if ($option == 'bankviainvoice') {
|
|
|
$postactionmessages[] = 'Invoice, payment and bank record created';
|
|
|
dol_syslog("Invoice, payment and bank record created", LOG_DEBUG, 0, '_payment');
|
|
|
}
|
|
|
- if ($option == 'bankdirect')
|
|
|
- {
|
|
|
+ if ($option == 'bankdirect') {
|
|
|
$postactionmessages[] = 'Bank record created';
|
|
|
dol_syslog("Bank record created", LOG_DEBUG, 0, '_payment');
|
|
|
}
|
|
|
- if ($option == 'invoiceonly')
|
|
|
- {
|
|
|
+ if ($option == 'invoiceonly') {
|
|
|
$postactionmessages[] = 'Invoice recorded';
|
|
|
dol_syslog("Invoice recorded", LOG_DEBUG, 0, '_payment');
|
|
|
}
|
|
@@ -451,18 +504,15 @@ if ($ispaymentok)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!$error)
|
|
|
- {
|
|
|
- if ($paymentmethod == 'stripe' && $autocreatethirdparty && $option == 'bankviainvoice')
|
|
|
- {
|
|
|
+ if (!$error) {
|
|
|
+ if ($paymentmethod == 'stripe' && $autocreatethirdparty && $option == 'bankviainvoice') {
|
|
|
$thirdparty_id = $object->fk_soc;
|
|
|
|
|
|
dol_syslog("Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
$service = 'StripeTest';
|
|
|
$servicestatus = 0;
|
|
|
- if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha'))
|
|
|
- {
|
|
|
+ if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) {
|
|
|
$service = 'StripeLive';
|
|
|
$servicestatus = 1;
|
|
|
}
|
|
@@ -477,8 +527,7 @@ if ($ispaymentok)
|
|
|
|
|
|
$customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
|
|
|
|
|
|
- if (!$customer && $TRANSACTIONID) // Not linked to a stripe customer, we make the link
|
|
|
- {
|
|
|
+ if (!$customer && $TRANSACTIONID) { // Not linked to a stripe customer, we make the link
|
|
|
dol_syslog("No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
try {
|
|
@@ -541,13 +590,11 @@ if ($ispaymentok)
|
|
|
}
|
|
|
|
|
|
// Send email to member
|
|
|
- if (!$error)
|
|
|
- {
|
|
|
+ if (!$error) {
|
|
|
dol_syslog("Send email to customer to ".$object->email." if we have to (sendalsoemail = ".$sendalsoemail.")", LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
// Send confirmation Email
|
|
|
- if ($object->email && $sendalsoemail)
|
|
|
- {
|
|
|
+ if ($object->email && $sendalsoemail) {
|
|
|
$subject = '';
|
|
|
$msg = '';
|
|
|
|
|
@@ -563,10 +610,11 @@ if ($ispaymentok)
|
|
|
$arraydefaultmessage = null;
|
|
|
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
|
|
|
|
|
|
- if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
|
|
+ if (!empty($labeltouse)) {
|
|
|
+ $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
|
|
+ }
|
|
|
|
|
|
- if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
|
|
|
- {
|
|
|
+ if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
|
|
$subject = $arraydefaultmessage->topic;
|
|
|
$msg = $arraydefaultmessage->content;
|
|
|
}
|
|
@@ -581,8 +629,7 @@ if ($ispaymentok)
|
|
|
$listofpaths = array();
|
|
|
$listofnames = array();
|
|
|
$listofmimes = array();
|
|
|
- if (is_object($object->invoice))
|
|
|
- {
|
|
|
+ if (is_object($object->invoice)) {
|
|
|
$invoicediroutput = $conf->facture->dir_output;
|
|
|
$fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+');
|
|
|
$file = $fileparams['fullname'];
|
|
@@ -596,14 +643,16 @@ if ($ispaymentok)
|
|
|
|
|
|
$result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, "", $moreinheader);
|
|
|
|
|
|
- if ($result < 0)
|
|
|
- {
|
|
|
+ if ($result < 0) {
|
|
|
$errmsg = $object->error;
|
|
|
$postactionmessages[] = $errmsg;
|
|
|
$ispostactionok = -1;
|
|
|
} else {
|
|
|
- if ($file) $postactionmessages[] = 'Email sent to member (with invoice document attached)';
|
|
|
- else $postactionmessages[] = 'Email sent to member (without any attached document)';
|
|
|
+ if ($file) {
|
|
|
+ $postactionmessages[] = 'Email sent to member (with invoice document attached)';
|
|
|
+ } else {
|
|
|
+ $postactionmessages[] = 'Email sent to member (without any attached document)';
|
|
|
+ }
|
|
|
|
|
|
// TODO Add actioncomm event
|
|
|
}
|
|
@@ -617,40 +666,43 @@ if ($ispaymentok)
|
|
|
$postactionmessages[] = 'Member '.$tmptag['MEM'].' for subscription paid was not found';
|
|
|
$ispostactionok = -1;
|
|
|
}
|
|
|
- } elseif (array_key_exists('INV', $tmptag) && $tmptag['INV'] > 0)
|
|
|
- {
|
|
|
+ } elseif (array_key_exists('INV', $tmptag) && $tmptag['INV'] > 0) {
|
|
|
// Record payment
|
|
|
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
|
|
$object = new Facture($db);
|
|
|
$result = $object->fetch($tmptag['INV']);
|
|
|
- if ($result)
|
|
|
- {
|
|
|
+ if ($result) {
|
|
|
$FinalPaymentAmt = $_SESSION["FinalPaymentAmt"];
|
|
|
|
|
|
$paymentTypeId = 0;
|
|
|
- if ($paymentmethod == 'paybox') $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
- if ($paymentmethod == 'paypal') $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
- if ($paymentmethod == 'stripe') $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
- if (empty($paymentTypeId))
|
|
|
- {
|
|
|
+ if ($paymentmethod == 'paybox') {
|
|
|
+ $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
+ }
|
|
|
+ if ($paymentmethod == 'paypal') {
|
|
|
+ $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
+ }
|
|
|
+ if ($paymentmethod == 'stripe') {
|
|
|
+ $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
|
|
|
+ }
|
|
|
+ if (empty($paymentTypeId)) {
|
|
|
$paymentType = $_SESSION["paymentType"];
|
|
|
- if (empty($paymentType)) $paymentType = 'CB';
|
|
|
+ if (empty($paymentType)) {
|
|
|
+ $paymentType = 'CB';
|
|
|
+ }
|
|
|
$paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1);
|
|
|
}
|
|
|
|
|
|
$currencyCodeType = $_SESSION['currencyCodeType'];
|
|
|
|
|
|
// Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)
|
|
|
- if (!empty($FinalPaymentAmt) && $paymentTypeId > 0)
|
|
|
- {
|
|
|
+ if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
|
|
|
$db->begin();
|
|
|
|
|
|
// Creation of payment line
|
|
|
include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
|
|
$paiement = new Paiement($db);
|
|
|
$paiement->datepaye = $now;
|
|
|
- if ($currencyCodeType == $conf->currency)
|
|
|
- {
|
|
|
+ if ($currencyCodeType == $conf->currency) {
|
|
|
$paiement->amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching with invoice id
|
|
|
} else {
|
|
|
$paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching
|
|
@@ -665,11 +717,9 @@ if ($ispaymentok)
|
|
|
$paiement->ext_payment_id = $TRANSACTIONID;
|
|
|
$paiement->ext_payment_site = $service;
|
|
|
|
|
|
- if (!$error)
|
|
|
- {
|
|
|
+ if (!$error) {
|
|
|
$paiement_id = $paiement->create($user, 1); // This include closing invoices and regenerating documents
|
|
|
- if ($paiement_id < 0)
|
|
|
- {
|
|
|
+ if ($paiement_id < 0) {
|
|
|
$postactionmessages[] = $paiement->error.' '.join("<br>\n", $paiement->errors);
|
|
|
$ispostactionok = -1;
|
|
|
$error++;
|
|
@@ -679,20 +729,23 @@ if ($ispaymentok)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!$error && !empty($conf->banque->enabled))
|
|
|
- {
|
|
|
+ if (!$error && !empty($conf->banque->enabled)) {
|
|
|
$bankaccountid = 0;
|
|
|
- if ($paymentmethod == 'paybox') $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
- elseif ($paymentmethod == 'paypal') $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
- elseif ($paymentmethod == 'stripe') $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
+ if ($paymentmethod == 'paybox') {
|
|
|
+ $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
+ } elseif ($paymentmethod == 'paypal') {
|
|
|
+ $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
+ } elseif ($paymentmethod == 'stripe') {
|
|
|
+ $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
|
|
|
+ }
|
|
|
|
|
|
- if ($bankaccountid > 0)
|
|
|
- {
|
|
|
+ if ($bankaccountid > 0) {
|
|
|
$label = '(CustomerInvoicePayment)';
|
|
|
- if ($object->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
|
|
|
+ if ($object->type == Facture::TYPE_CREDIT_NOTE) {
|
|
|
+ $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
|
|
|
+ }
|
|
|
$result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', '');
|
|
|
- if ($result < 0)
|
|
|
- {
|
|
|
+ if ($result < 0) {
|
|
|
$postactionmessages[] = $paiement->error.' '.join("<br>\n", $paiement->errors);
|
|
|
$ispostactionok = -1;
|
|
|
$error++;
|
|
@@ -707,8 +760,7 @@ if ($ispaymentok)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!$error)
|
|
|
- {
|
|
|
+ if (!$error) {
|
|
|
$db->commit();
|
|
|
} else {
|
|
|
$db->rollback();
|
|
@@ -726,8 +778,7 @@ if ($ispaymentok)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-if ($ispaymentok)
|
|
|
-{
|
|
|
+if ($ispaymentok) {
|
|
|
// Get on url call
|
|
|
$onlinetoken = empty($PAYPALTOKEN) ? $_SESSION['onlinetoken'] : $PAYPALTOKEN;
|
|
|
$payerID = empty($PAYPALPAYERID) ? $_SESSION['payerID'] : $PAYPALPAYERID;
|
|
@@ -739,26 +790,33 @@ if ($ispaymentok)
|
|
|
if (is_object($object) && method_exists($object, 'call_trigger')) {
|
|
|
// Call trigger
|
|
|
$result = $object->call_trigger('PAYMENTONLINE_PAYMENT_OK', $user);
|
|
|
- if ($result < 0) $error++;
|
|
|
+ if ($result < 0) {
|
|
|
+ $error++;
|
|
|
+ }
|
|
|
// End call triggers
|
|
|
}
|
|
|
|
|
|
print $langs->trans("YourPaymentHasBeenRecorded")."<br>\n";
|
|
|
- if ($TRANSACTIONID) print $langs->trans("ThisIsTransactionId", $TRANSACTIONID)."<br><br>\n";
|
|
|
+ if ($TRANSACTIONID) {
|
|
|
+ print $langs->trans("ThisIsTransactionId", $TRANSACTIONID)."<br><br>\n";
|
|
|
+ }
|
|
|
|
|
|
$key = 'ONLINE_PAYMENT_MESSAGE_OK';
|
|
|
- if (!empty($conf->global->$key)) print $conf->global->$key;
|
|
|
+ if (!empty($conf->global->$key)) {
|
|
|
+ print $conf->global->$key;
|
|
|
+ }
|
|
|
|
|
|
$sendemail = '';
|
|
|
- if (!empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) $sendemail = $conf->global->ONLINE_PAYMENT_SENDEMAIL;
|
|
|
+ if (!empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) {
|
|
|
+ $sendemail = $conf->global->ONLINE_PAYMENT_SENDEMAIL;
|
|
|
+ }
|
|
|
|
|
|
$tmptag = dolExplodeIntoArray($fulltag, '.', '=');
|
|
|
|
|
|
dol_syslog("Send email to admins if we have to (sendemail = ".$sendemail.")", LOG_DEBUG, 0, '_payment');
|
|
|
|
|
|
// Send an email to admins
|
|
|
- if ($sendemail)
|
|
|
- {
|
|
|
+ if ($sendemail) {
|
|
|
$companylangs = new Translate('', $conf);
|
|
|
$companylangs->setDefaultLang($mysoc->default_lang);
|
|
|
$companylangs->loadLangs(array('main', 'members', 'bills', 'paypal', 'paybox'));
|
|
@@ -772,26 +830,28 @@ if ($ispaymentok)
|
|
|
|
|
|
// Define link to login card
|
|
|
$appli = constant('DOL_APPLICATION_TITLE');
|
|
|
- if (!empty($conf->global->MAIN_APPLICATION_TITLE))
|
|
|
- {
|
|
|
+ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
|
|
|
$appli = $conf->global->MAIN_APPLICATION_TITLE;
|
|
|
- if (preg_match('/\d\.\d/', $appli))
|
|
|
- {
|
|
|
- if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
|
|
|
- } else $appli .= " ".DOL_VERSION;
|
|
|
- } else $appli .= " ".DOL_VERSION;
|
|
|
+ if (preg_match('/\d\.\d/', $appli)) {
|
|
|
+ if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
|
|
|
+ $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $appli .= " ".DOL_VERSION;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $appli .= " ".DOL_VERSION;
|
|
|
+ }
|
|
|
|
|
|
$urlback = $_SERVER["REQUEST_URI"];
|
|
|
$topic = '['.$appli.'] '.$companylangs->transnoentitiesnoconv("NewOnlinePaymentReceived");
|
|
|
$content = "";
|
|
|
- if (array_key_exists('MEM', $tmptag))
|
|
|
- {
|
|
|
+ if (array_key_exists('MEM', $tmptag)) {
|
|
|
$url = $urlwithroot."/adherents/subscription.php?rowid=".$tmptag['MEM'];
|
|
|
$content .= '<strong>'.$companylangs->trans("PaymentSubscription")."</strong><br><br>\n";
|
|
|
$content .= $companylangs->trans("MemberId").': <strong>'.$tmptag['MEM']."</strong><br>\n";
|
|
|
$content .= $companylangs->trans("Link").': <a href="'.$url.'">'.$url.'</a>'."<br>\n";
|
|
|
- } elseif (array_key_exists('INV', $tmptag))
|
|
|
- {
|
|
|
+ } elseif (array_key_exists('INV', $tmptag)) {
|
|
|
$url = $urlwithroot."/compta/facture/card.php?id=".$tmptag['INV'];
|
|
|
$content .= '<strong>'.$companylangs->trans("Payment")."</strong><br><br>\n";
|
|
|
$content .= $companylangs->trans("InvoiceId").': <strong>'.$tmptag['INV']."</strong><br>\n";
|
|
@@ -801,24 +861,20 @@ if ($ispaymentok)
|
|
|
$content .= $companylangs->transnoentitiesnoconv("NewOnlinePaymentReceived")."<br>\n";
|
|
|
}
|
|
|
$content .= $companylangs->transnoentities("PostActionAfterPayment").' : ';
|
|
|
- if ($ispostactionok > 0)
|
|
|
- {
|
|
|
+ if ($ispostactionok > 0) {
|
|
|
//$topic.=' ('.$companylangs->transnoentitiesnoconv("Status").' '.$companylangs->transnoentitiesnoconv("OK").')';
|
|
|
$content .= '<font color="green">'.$companylangs->transnoentitiesnoconv("OK").'</font>';
|
|
|
- } elseif ($ispostactionok == 0)
|
|
|
- {
|
|
|
+ } elseif ($ispostactionok == 0) {
|
|
|
$content .= $companylangs->transnoentitiesnoconv("None");
|
|
|
} else {
|
|
|
$topic .= ($ispostactionok ? '' : ' ('.$companylangs->trans("WarningPostActionErrorAfterPayment").')');
|
|
|
$content .= '<font color="red">'.$companylangs->transnoentitiesnoconv("Error").'</font>';
|
|
|
}
|
|
|
$content .= '<br>'."\n";
|
|
|
- foreach ($postactionmessages as $postactionmessage)
|
|
|
- {
|
|
|
+ foreach ($postactionmessages as $postactionmessage) {
|
|
|
$content .= ' * '.$postactionmessage.'<br>'."\n";
|
|
|
}
|
|
|
- if ($ispostactionok < 0)
|
|
|
- {
|
|
|
+ if ($ispostactionok < 0) {
|
|
|
$content .= $langs->transnoentities("ARollbackWasPerformedOnPostActions");
|
|
|
}
|
|
|
$content .= '<br>'."\n";
|
|
@@ -831,10 +887,18 @@ if ($ispaymentok)
|
|
|
$content .= "<br>\n";
|
|
|
$content .= "tag=".$fulltag."<br>\ntoken=".$onlinetoken."<br>\npaymentType=".$paymentType."<br>\ncurrencycodeType=".$currencyCodeType."<br>\npayerId=".$payerID."<br>\nipaddress=".$ipaddress."<br>\nFinalPaymentAmt=".$FinalPaymentAmt."<br>\n";
|
|
|
|
|
|
- if (!empty($ErrorCode)) $content .= "ErrorCode = ".$ErrorCode."<br>\n";
|
|
|
- if (!empty($ErrorShortMsg)) $content .= "ErrorShortMsg = ".$ErrorShortMsg."<br>\n";
|
|
|
- if (!empty($ErrorLongMsg)) $content .= "ErrorLongMsg = ".$ErrorLongMsg."<br>\n";
|
|
|
- if (!empty($ErrorSeverityCode)) $content .= "ErrorSeverityCode = ".$ErrorSeverityCode."<br>\n";
|
|
|
+ if (!empty($ErrorCode)) {
|
|
|
+ $content .= "ErrorCode = ".$ErrorCode."<br>\n";
|
|
|
+ }
|
|
|
+ if (!empty($ErrorShortMsg)) {
|
|
|
+ $content .= "ErrorShortMsg = ".$ErrorShortMsg."<br>\n";
|
|
|
+ }
|
|
|
+ if (!empty($ErrorLongMsg)) {
|
|
|
+ $content .= "ErrorLongMsg = ".$ErrorLongMsg."<br>\n";
|
|
|
+ }
|
|
|
+ if (!empty($ErrorSeverityCode)) {
|
|
|
+ $content .= "ErrorSeverityCode = ".$ErrorSeverityCode."<br>\n";
|
|
|
+ }
|
|
|
|
|
|
$ishtml = dol_textishtml($content); // May contain urls
|
|
|
|
|
@@ -842,8 +906,7 @@ if ($ispaymentok)
|
|
|
$mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml);
|
|
|
|
|
|
$result = $mailfile->sendfile();
|
|
|
- if ($result)
|
|
|
- {
|
|
|
+ if ($result) {
|
|
|
dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment');
|
|
|
//dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0);
|
|
|
} else {
|
|
@@ -863,7 +926,9 @@ if ($ispaymentok)
|
|
|
if (is_object($object) && method_exists($object, 'call_trigger')) {
|
|
|
// Call trigger
|
|
|
$result = $object->call_trigger('PAYMENTONLINE_PAYMENT_KO', $user);
|
|
|
- if ($result < 0) $error++;
|
|
|
+ if ($result < 0) {
|
|
|
+ $error++;
|
|
|
+ }
|
|
|
// End call triggers
|
|
|
}
|
|
|
|
|
@@ -873,18 +938,25 @@ if ($ispaymentok)
|
|
|
print $langs->trans('ErrorCode').": ".$ErrorCode."<br>\n";
|
|
|
print $langs->trans('ErrorSeverityCode').": ".$ErrorSeverityCode."<br>\n";
|
|
|
|
|
|
- if ($mysoc->email) print "\nPlease, send a screenshot of this page to ".$mysoc->email."<br>\n";
|
|
|
+ if ($mysoc->email) {
|
|
|
+ print "\nPlease, send a screenshot of this page to ".$mysoc->email."<br>\n";
|
|
|
+ }
|
|
|
|
|
|
$sendemail = '';
|
|
|
- if (!empty($conf->global->PAYMENTONLINE_SENDEMAIL)) $sendemail = $conf->global->PAYMENTONLINE_SENDEMAIL;
|
|
|
+ if (!empty($conf->global->PAYMENTONLINE_SENDEMAIL)) {
|
|
|
+ $sendemail = $conf->global->PAYMENTONLINE_SENDEMAIL;
|
|
|
+ }
|
|
|
// TODO Remove local option to keep only the generic one ?
|
|
|
- if ($paymentmethod == 'paypal' && !empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) $sendemail = $conf->global->PAYPAL_PAYONLINE_SENDEMAIL;
|
|
|
- elseif ($paymentmethod == 'paybox' && !empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) $sendemail = $conf->global->PAYBOX_PAYONLINE_SENDEMAIL;
|
|
|
- elseif ($paymentmethod == 'stripe' && !empty($conf->global->STRIPE_PAYONLINE_SENDEMAIL)) $sendemail = $conf->global->STRIPE_PAYONLINE_SENDEMAIL;
|
|
|
+ if ($paymentmethod == 'paypal' && !empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) {
|
|
|
+ $sendemail = $conf->global->PAYPAL_PAYONLINE_SENDEMAIL;
|
|
|
+ } elseif ($paymentmethod == 'paybox' && !empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) {
|
|
|
+ $sendemail = $conf->global->PAYBOX_PAYONLINE_SENDEMAIL;
|
|
|
+ } elseif ($paymentmethod == 'stripe' && !empty($conf->global->STRIPE_PAYONLINE_SENDEMAIL)) {
|
|
|
+ $sendemail = $conf->global->STRIPE_PAYONLINE_SENDEMAIL;
|
|
|
+ }
|
|
|
|
|
|
// Send warning of error to administrator
|
|
|
- if ($sendemail)
|
|
|
- {
|
|
|
+ if ($sendemail) {
|
|
|
$companylangs = new Translate('', $conf);
|
|
|
$companylangs->setDefaultLang($mysoc->default_lang);
|
|
|
$companylangs->loadLangs(array('main', 'members', 'bills', 'paypal', 'paybox'));
|
|
@@ -898,14 +970,18 @@ if ($ispaymentok)
|
|
|
|
|
|
// Define link to login card
|
|
|
$appli = constant('DOL_APPLICATION_TITLE');
|
|
|
- if (!empty($conf->global->MAIN_APPLICATION_TITLE))
|
|
|
- {
|
|
|
+ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
|
|
|
$appli = $conf->global->MAIN_APPLICATION_TITLE;
|
|
|
- if (preg_match('/\d\.\d/', $appli))
|
|
|
- {
|
|
|
- if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
|
|
|
- } else $appli .= " ".DOL_VERSION;
|
|
|
- } else $appli .= " ".DOL_VERSION;
|
|
|
+ if (preg_match('/\d\.\d/', $appli)) {
|
|
|
+ if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
|
|
|
+ $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $appli .= " ".DOL_VERSION;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $appli .= " ".DOL_VERSION;
|
|
|
+ }
|
|
|
|
|
|
$urlback = $_SERVER["REQUEST_URI"];
|
|
|
$topic = '['.$appli.'] '.$companylangs->transnoentitiesnoconv("ValidationOfPaymentFailed");
|
|
@@ -926,8 +1002,7 @@ if ($ispaymentok)
|
|
|
$mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml);
|
|
|
|
|
|
$result = $mailfile->sendfile();
|
|
|
- if ($result)
|
|
|
- {
|
|
|
+ if ($result) {
|
|
|
dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment');
|
|
|
} else {
|
|
|
dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment');
|