Add a better error message when payment link is not valid.

This commit is contained in:
Laurent Destailleur 2017-06-02 09:13:04 +02:00
parent b4f1df03de
commit 5c58ed8ca7
7 changed files with 217 additions and 173 deletions

View File

@ -3235,15 +3235,19 @@ function dol_print_error($db='',$error='',$errors=null)
* Show a public email and error code to contact if technical error * Show a public email and error code to contact if technical error
* *
* @param string $prefixcode Prefix of public error code * @param string $prefixcode Prefix of public error code
* @param string $errormessage Complete error message
* @return void * @return void
*/ */
function dol_print_error_email($prefixcode) function dol_print_error_email($prefixcode, $errormessage='')
{ {
global $langs,$conf; global $langs,$conf;
$langs->load("errors"); $langs->load("errors");
$now=dol_now(); $now=dol_now();
print '<br><div class="error">'.$langs->trans("ErrorContactEMail", $conf->global->MAIN_INFO_SOCIETE_MAIL, $prefixcode.dol_print_date($now,'%Y%m%d')).'</div>'; print '<br><div class="center login_main_message"><div class="error">';
print $langs->trans("ErrorContactEMail", $conf->global->MAIN_INFO_SOCIETE_MAIL, $prefixcode.dol_print_date($now,'%Y%m%d'));
if ($errormessage) print '<br><br>'.$errormessage;
print '</div></div>';
} }
/** /**

View File

@ -190,6 +190,7 @@ ErrorModuleFileSeemsToHaveAWrongFormat=The module package seems to have a wrong
ErrorFilenameDosNotMatchDolibarrPackageRules=The name of the module package (<strong>%s</strong>) does not match expected name syntax: <strong>%s</strong> ErrorFilenameDosNotMatchDolibarrPackageRules=The name of the module package (<strong>%s</strong>) does not match expected name syntax: <strong>%s</strong>
ErrorDuplicateTrigger=Error, duplicate trigger name %s. Already loaded from %s. ErrorDuplicateTrigger=Error, duplicate trigger name %s. Already loaded from %s.
ErrorNoWarehouseDefined=Error, no warehouses defined. ErrorNoWarehouseDefined=Error, no warehouses defined.
ErrorBadLinkSourceSetButBadValueForRef=The link you use is not valid. A 'source' for payment is defined, but value for 'ref' is not valid.
# Warnings # Warnings
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.

View File

@ -169,13 +169,22 @@ $conf->dol_hide_leftmenu=1;
llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody');
// Common variables // Common variables
$creditor=$mysoc->name; $creditor=$mysoc->name;
$paramcreditor='PAYBOX_CREDITOR_'.$suffix; $paramcreditor='PAYBOX_CREDITOR_'.$suffix;
if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor; if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor;
else if (! empty($conf->global->PAYBOX_CREDITOR)) $creditor=$conf->global->PAYBOX_CREDITOR; else if (! empty($conf->global->PAYBOX_CREDITOR)) $creditor=$conf->global->PAYBOX_CREDITOR;
// Check link validity
if (! empty($SOURCE) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', '')))
{
$langs->load("errors");
dol_print_error_email('BADREFINPAYMENTFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $SOURCE, $ref));
llxFooter();
$db->close();
exit;
}
print '<span id="dolpaymentspan"></span>'."\n"; print '<span id="dolpaymentspan"></span>'."\n";
print '<div class="center">'; print '<div class="center">';
print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">';

View File

@ -335,19 +335,28 @@ $conf->dol_hide_leftmenu=1;
llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody');
// Check link validity
if (! empty($SOURCE) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', '')))
{
$langs->load("errors");
dol_print_error_email('BADREFINPAYMENTFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $SOURCE, $ref));
llxFooter();
$db->close();
exit;
}
if (! empty($conf->paypal->enabled)) if (! empty($conf->paypal->enabled))
{ {
if (! empty($PAYPAL_API_SANDBOX))
{
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning');
}
// Common variables // Common variables
$creditor=$mysoc->name; $creditor=$mysoc->name;
$paramcreditor='PAYPAL_CREDITOR_'.$suffix; $paramcreditor='PAYPAL_CREDITOR_'.$suffix;
if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor; if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor;
else if (! empty($conf->global->PAYPAL_CREDITOR)) $creditor=$conf->global->PAYPAL_CREDITOR; else if (! empty($conf->global->PAYPAL_CREDITOR)) $creditor=$conf->global->PAYPAL_CREDITOR;
if (! empty($PAYPAL_API_SANDBOX))
{
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning');
}
} }
print '<span id="dolpaymentspan"></span>'."\n"; print '<span id="dolpaymentspan"></span>'."\n";

View File

@ -265,17 +265,27 @@ $conf->dol_hide_leftmenu=1;
llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody');
if (! empty($conf->global->PAYPAL_API_SANDBOX))
{
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning');
}
// Common variables // Common variables
$creditor=$mysoc->name; $creditor=$mysoc->name;
$paramcreditor='PAYPAL_CREDITOR_'.$suffix; $paramcreditor='PAYPAL_CREDITOR_'.$suffix;
if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor; if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor;
else if (! empty($conf->global->PAYPAL_CREDITOR)) $creditor=$conf->global->PAYPAL_CREDITOR; else if (! empty($conf->global->PAYPAL_CREDITOR)) $creditor=$conf->global->PAYPAL_CREDITOR;
// Check link validity
if (! empty($SOURCE) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', '')))
{
$langs->load("errors");
dol_print_error_email('BADREFINPAYMENTFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $SOURCE, $ref));
llxFooter();
$db->close();
exit;
}
if (! empty($conf->global->PAYPAL_API_SANDBOX))
{
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning');
}
print '<span id="dopaymentspan"></span>'."\n"; print '<span id="dopaymentspan"></span>'."\n";
print '<div class="center">'."\n"; print '<div class="center">'."\n";
print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n"; print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
@ -824,6 +834,7 @@ if (GETPOST("source") == 'membersubscription')
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
$member=new Adherent($db); $member=new Adherent($db);
$result=$member->fetch('',$ref); $result=$member->fetch('',$ref);
if ($result < 0) if ($result < 0)

View File

@ -335,6 +335,16 @@ $conf->dol_hide_leftmenu=1;
llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody');
// Check link validity
if (! empty($SOURCE) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', '')))
{
$langs->load("errors");
dol_print_error_email('BADREFINPAYMENTFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $SOURCE, $ref));
llxFooter();
$db->close();
exit;
}
if (empty($conf->global->STRIPE_LIVE)) if (empty($conf->global->STRIPE_LIVE))
{ {
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning'); dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning');