Work on generic payment module

This commit is contained in:
Laurent Destailleur 2017-09-01 18:49:55 +02:00
parent 30eefb34aa
commit 796684713f
3 changed files with 77 additions and 5 deletions

View File

@ -71,17 +71,17 @@ if (! $action)
{
if (! GETPOST("amount",'alpha') && ! GETPOST("source",'alpha'))
{
dol_print_error('',$langs->trans('ErrorBadParameters')." - amount or source");
print $langs->trans('ErrorBadParameters')." - amount or source";
exit;
}
if (is_numeric($amount) && ! GETPOST("tag",'alpha') && ! GETPOST("source",'alpha'))
{
dol_print_error('',$langs->trans('ErrorBadParameters')." - tag or source");
print $langs->trans('ErrorBadParameters')." - tag or source";
exit;
}
if (GETPOST("source",'alpha') && ! GETPOST("ref",'alpha'))
{
dol_print_error('',$langs->trans('ErrorBadParameters')." - ref");
print $langs->trans('ErrorBadParameters')." - ref";
exit;
}
}
@ -117,6 +117,11 @@ $FULLTAG=GETPOST("fulltag",'alpha'); // fulltag is tag with more informations
$SECUREKEY=GETPOST("securekey"); // Secure key
if ($paymentmethod && ! preg_match('/'.preg_quote('PM='.$paymentmethod,'/').'/', $FULLTAG)) $FULLTAG.=($FULLTAG?'.':'').'PM='.$paymentmethod;
if (! empty($suffix))
{
$urlok.='suffix='.urlencode($suffix).'&';
$urlko.='suffix='.urlencode($suffix).'&';
}
if (! empty($SOURCE))
{
$urlok.='source='.urlencode($SOURCE).'&';
@ -560,12 +565,12 @@ $urllogo='';
if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('thumbs/'.$logosmall);
$width=128;
$width=150;
}
elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode($logo);
$width=128;
$width=150;
}
// Output html code for logo
if ($urllogo)

View File

@ -70,6 +70,8 @@ if (! empty($conf->stripe->enabled))
$FULLTAG=GETPOST('FULLTAG');
if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag');
$suffix=GETPOST("suffix",'aZ09');
// Detect $paymentmethod
$paymentmethod='';
@ -202,6 +204,38 @@ llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'online
// Show ko message
print '<span id="dolpaymentspan"></span>'."\n";
print '<div id="dolpaymentdiv" align="center">'."\n";
// Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo)
$width=0;
// Define logo and logosmall
$logosmall=$mysoc->logo_small;
$logo=$mysoc->logo;
$paramlogo='ONLINE_PAYMENT_LOGO_'.$suffix;
if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo;
else if (! empty($conf->global->ONLINE_PAYMENT_LOGO)) $logosmall=$conf->global->ONLINE_PAYMENT_LOGO;
//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
// Define urllogo
$urllogo='';
if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('thumbs/'.$logosmall);
$width=150;
}
elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode($logo);
$width=150;
}
// Output html code for logo
if ($urllogo)
{
print '<center><img id="dolpaymentlogo" title="'.$title.'" src="'.$urllogo.'"';
if ($width) print ' width="'.$width.'"';
print '></center>';
print '<br>';
}
print $langs->trans("YourPaymentHasNotBeenRecorded")."<br><br>";
if (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_KO)) print $conf->global->ONLINE_PAYMENT_MESSAGE_KO;

View File

@ -79,6 +79,8 @@ if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag');
$source=GETPOST('source');
$ref=GETPOST('ref');
$suffix=GETPOST("suffix",'aZ09');
// Detect $paymentmethod
$paymentmethod='';
@ -149,6 +151,37 @@ print '<span id="dolpaymentspan"></span>'."\n";
print '<div id="dolpaymentdiv" align="center">'."\n";
// Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo)
$width=0;
// Define logo and logosmall
$logosmall=$mysoc->logo_small;
$logo=$mysoc->logo;
$paramlogo='ONLINE_PAYMENT_LOGO_'.$suffix;
if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo;
else if (! empty($conf->global->ONLINE_PAYMENT_LOGO)) $logosmall=$conf->global->ONLINE_PAYMENT_LOGO;
//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
// Define urllogo
$urllogo='';
if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('thumbs/'.$logosmall);
$width=150;
}
elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode($logo);
$width=150;
}
// Output html code for logo
if ($urllogo)
{
print '<center><img id="dolpaymentlogo" title="'.$title.'" src="'.$urllogo.'"';
if ($width) print ' width="'.$width.'"';
print '></center>';
print '<br>';
}
if (! empty($conf->paypal->enabled))
{
if ($paymentmethod == 'paypal')