Use isModEnabled

This commit is contained in:
Alexandre SPANGARO 2022-09-25 21:59:46 +02:00
parent da55ed782c
commit a7a39cba97
5 changed files with 37 additions and 37 deletions

View File

@ -247,7 +247,7 @@ $urlko = preg_replace('/&$/', '', $urlko); // Remove last &
// Make special controls
if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) {
if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) {
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
@ -273,10 +273,10 @@ if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypa
return -1;
}
}
if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) {
if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) {
// No specific test for the moment
}
if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled)) {
if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) {
require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'; // This include also /stripe/lib/stripe.lib.php, /includes/stripe/stripe-php/init.php, ...
}
@ -481,7 +481,7 @@ if ($action == 'dopayment') {
// Called when choosing Stripe mode.
// When using the old Charge API architecture, this code is called after clicking the 'dopayment' with the Charge API architecture.
// When using the PaymentIntent API architecture, the Stripe customer was already created when creating PaymentIntent when showing payment page, and the payment is already ok when action=charge.
if ($action == 'charge' && !empty($conf->stripe->enabled)) {
if ($action == 'charge' && isModEnabled('stripe')) {
$amountstripe = $amount;
// Correct the amount according to unit of currency
@ -844,10 +844,10 @@ if ($source && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_r
// Show sandbox warning
if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled) && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'int'))) { // We can force sand box with param 'forcesandbox'
if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal') && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'int'))) { // We can force sand box with param 'forcesandbox'
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Paypal'), '', 'warning');
}
if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'int'))) {
if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'int'))) {
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
}
@ -911,14 +911,14 @@ if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) {
print '<!-- Form to send a payment -->'."\n";
print '<!-- creditor = '.dol_escape_htmltag($creditor).' -->'."\n";
// Additionnal information for each payment system
if (!empty($conf->paypal->enabled)) {
if (isModEnabled('paypal')) {
print '<!-- PAYPAL_API_SANDBOX = '.getDolGlobalString('PAYPAL_API_SANDBOX').' -->'."\n";
print '<!-- PAYPAL_API_INTEGRAL_OR_PAYPALONLY = '.getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY').' -->'."\n";
}
if (!empty($conf->paybox->enabled)) {
if (isModEnabled('paybox')) {
print '<!-- PAYBOX_CGI_URL = '.getDolGlobalString('PAYBOX_CGI_URL_V2').' -->'."\n";
}
if (!empty($conf->stripe->enabled)) {
if (isModEnabled('stripe')) {
print '<!-- STRIPE_LIVE = '.getDolGlobalString('STRIPE_LIVE').' -->'."\n";
}
print '<!-- urlok = '.$urlok.' -->'."\n";
@ -2043,7 +2043,7 @@ if ($action != 'dopayment') {
'paymentmethod' => $paymentmethod
];
$reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action);
if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) {
if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) {
print '<div class="button buttonpayment" id="div_dopayment_paybox"><span class="fa fa-credit-card"></span> <input class="" type="submit" id="dopayment_paybox" name="dopayment_paybox" value="'.$langs->trans("PayBoxDoPayment").'">';
print '<br>';
print '<span class="buttonpaymentsmall">'.$langs->trans("CreditOrDebitCard").'</span>';
@ -2062,7 +2062,7 @@ if ($action != 'dopayment') {
';
}
if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled)) {
if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) {
print '<div class="button buttonpayment" id="div_dopayment_stripe"><span class="fa fa-credit-card"></span> <input class="" type="submit" id="dopayment_stripe" name="dopayment_stripe" value="'.$langs->trans("StripeDoPayment").'">';
print '<input type="hidden" name="noidempotency" value="'.GETPOST('noidempotency', 'int').'">';
print '<br>';
@ -2083,7 +2083,7 @@ if ($action != 'dopayment') {
';
}
if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) {
if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) {
if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) {
$conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral';
}

View File

@ -51,14 +51,14 @@ 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 (isModEnabled('paypal')) {
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
}
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal", "stripe"));
if (!empty($conf->paypal->enabled)) {
if (isModEnabled('paypal')) {
$PAYPALTOKEN = GETPOST('TOKEN');
if (empty($PAYPALTOKEN)) {
$PAYPALTOKEN = GETPOST('token');
@ -68,9 +68,9 @@ if (!empty($conf->paypal->enabled)) {
$PAYPALPAYERID = GETPOST('PayerID');
}
}
if (!empty($conf->paybox->enabled)) {
if (isModEnabled('paybox')) {
}
if (!empty($conf->stripe->enabled)) {
if (isModEnabled('stripe')) {
}
$FULLTAG = GETPOST('FULLTAG');
@ -96,13 +96,13 @@ if (empty($paymentmethod)) {
$validpaymentmethod = array();
if (!empty($conf->paypal->enabled)) {
if (isModEnabled('paypal')) {
$validpaymentmethod['paypal'] = 'paypal';
}
if (!empty($conf->paybox->enabled)) {
if (isModEnabled('paybox')) {
$validpaymentmethod['paybox'] = 'paybox';
}
if (!empty($conf->stripe->enabled)) {
if (isModEnabled('stripe')) {
$validpaymentmethod['stripe'] = 'stripe';
}

View File

@ -57,7 +57,7 @@ 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 (!empty($conf->paypal->enabled)) {
if (isModEnabled('paypal')) {
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
}
@ -65,7 +65,7 @@ if (!empty($conf->paypal->enabled)) {
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal"));
// Clean parameters
if (!empty($conf->paypal->enabled)) {
if (isModEnabled('paypal')) {
$PAYPAL_API_USER = "";
if (!empty($conf->global->PAYPAL_API_USER)) {
$PAYPAL_API_USER = $conf->global->PAYPAL_API_USER;
@ -127,13 +127,13 @@ dol_syslog("***** paymentok.php is called paymentmethod=".$paymentmethod." FULLT
$validpaymentmethod = array();
if (!empty($conf->paypal->enabled)) {
if (isModEnabled('paypal')) {
$validpaymentmethod['paypal'] = 'paypal';
}
if (!empty($conf->paybox->enabled)) {
if (isModEnabled('paybox')) {
$validpaymentmethod['paybox'] = 'paybox';
}
if (!empty($conf->stripe->enabled)) {
if (isModEnabled('stripe')) {
$validpaymentmethod['stripe'] = 'stripe';
}
@ -236,7 +236,7 @@ if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) {
print '<br><br><br>';
if (!empty($conf->paypal->enabled)) {
if (isModEnabled('paypal')) {
if ($paymentmethod == 'paypal') { // We call this page only if payment is ok on payment system
if ($PAYPALTOKEN) {
// Get on url call
@ -316,14 +316,14 @@ if (!empty($conf->paypal->enabled)) {
}
}
if (!empty($conf->paybox->enabled)) {
if (isModEnabled('paybox')) {
if ($paymentmethod == 'paybox') {
// TODO Add a check to validate that payment is ok.
$ispaymentok = true; // We call this page only if payment is ok on payment system
}
}
if (!empty($conf->stripe->enabled)) {
if (isModEnabled('stripe')) {
if ($paymentmethod == 'stripe') {
// TODO Add a check to validate that payment is ok. We can request Stripe with payment_intent and payment_intent_client_secret
$ispaymentok = true; // We call this page only if payment is ok on payment system

View File

@ -84,7 +84,7 @@ $permissiontoadd = $user->rights->societe->creer; // Used by the include of acti
$permissiontoaddupdatepaymentinformation = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $permissiontoadd) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->societe->thirdparty_paymentinformation_advance->write)));
if (!empty($conf->stripe->enabled)) {
if (isModEnabled('stripe')) {
$service = 'StripeTest';
$servicestatus = 0;
if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) {
@ -493,7 +493,7 @@ if (empty($reshook)) {
$id = $savid;
// Action for stripe
if (!empty($conf->stripe->enabled) && class_exists('Stripe')) {
if (isModEnabled('stripe') && class_exists('Stripe')) {
if ($action == 'synccustomertostripe') {
if ($object->client == 0) {
$error++;
@ -782,11 +782,11 @@ llxHeader('', $title, $help_url);
$head = societe_prepare_head($object);
// Show sandbox warning
/*if (!empty($conf->paypal->enabled) && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))) // We can force sand box with param 'forcesandbox'
/*if (isModEnabled('paypal') && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))) // We can force sand box with param 'forcesandbox'
{
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Paypal'),'','warning');
}*/
if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
}
@ -885,13 +885,13 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
$elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
}
if (!empty($conf->stripe->enabled)) {
if (isModEnabled('stripe')) {
// Stripe customer key 'cu_....' stored into llx_societe_account
print '<tr><td class="titlefield">';
print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid');
print '</td><td>';
print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid');
if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') {
if (isModEnabled('stripe') && $stripecu && $action != 'editkey_account') {
$connect = '';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
@ -947,7 +947,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
}
}
if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
$stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here)
// Stripe customer key 'cu_....' stored into llx_societe_account
@ -955,7 +955,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid');
print '</td><td>';
print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid');
if (!empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') {
if (isModEnabled('stripe') && $stripesupplieracc && $action != 'editkey_account_supplier') {
$connect = '';
$url = 'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
@ -1338,7 +1338,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
}
// List of Stripe connect accounts
if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s');
$balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc));
print '<table class="liste centpercent">'."\n";

View File

@ -399,7 +399,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
if (!empty($site_account)) {
\Stripe\Stripe::setApiKey($site_account);
}
if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
$service = 'StripeTest';
$servicestatus = '0';
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');