Try to fix regression

This commit is contained in:
Laurent Destailleur 2018-03-11 01:23:06 +01:00
parent 06689bb79f
commit 5b0dd0e31b
2 changed files with 25 additions and 27 deletions

View File

@ -48,7 +48,8 @@ if (isset($_GET['connect'])){
$endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY; $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY;
$service = 'StripeLive'; $service = 'StripeLive';
} }
}else { }
else {
if (isset($_GET['test'])) if (isset($_GET['test']))
{ {
$endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY; $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY;
@ -90,7 +91,7 @@ $user->getrights();
if (! empty($conf->multicompany->enabled) && ! empty($conf->stripeconnect->enabled)) { if (! empty($conf->multicompany->enabled) && ! empty($conf->stripeconnect->enabled)) {
$sql = "SELECT entity"; $sql = "SELECT entity";
$sql.= " FROM ".MAIN_DB_PREFIX."oauth_token"; $sql.= " FROM ".MAIN_DB_PREFIX."oauth_token";
$sql.= " WHERE service = '$service' and tokenstring = '%".$event->account."%'"; $sql.= " WHERE service = '".$db->escape($service)."' and tokenstring = '%".$db->escape($event->account)."%'";
dol_syslog(get_class($db) . "::fetch", LOG_DEBUG); dol_syslog(get_class($db) . "::fetch", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
@ -120,6 +121,7 @@ if ($event->type == 'payout.created') {
if ($result > 0) if ($result > 0)
{ {
// TODO Use CMail and translation
$body = "Un virement de ".price2num($event->data->object->amount/100)." ".$event->data->object->currency." est attendu sur votre compte le ".date('d-m-Y H:i:s',$event->data->object->arrival_date); $body = "Un virement de ".price2num($event->data->object->amount/100)." ".$event->data->object->currency." est attendu sur votre compte le ".date('d-m-Y H:i:s',$event->data->object->arrival_date);
$subject = '[NOTIFICATION] Virement programmée'; $subject = '[NOTIFICATION] Virement programmée';
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; // TODO convert in dolibarr standard $headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; // TODO convert in dolibarr standard
@ -180,9 +182,10 @@ elseif ($event->type == 'payout.paid') {
if (! ($result > 0)) $error++; if (! ($result > 0)) $error++;
} }
// TODO Use CMail and translation
$body = "Un virement de ".price2num($event->data->object->amount/100)." ".$event->data->object->currency." a ete effectue sur votre compte le ".date('d-m-Y H:i:s',$event->data->object->arrival_date); $body = "Un virement de ".price2num($event->data->object->amount/100)." ".$event->data->object->currency." a ete effectue sur votre compte le ".date('d-m-Y H:i:s',$event->data->object->arrival_date);
$subject = '[NOTIFICATION] Virement effectué'; $subject = '[NOTIFICATION] Virement effectué';
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; // TODO convert in dolibarr standard $headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
mail(''.$conf->global->MAIN_INFO_SOCIETE_MAIL.'', $subject, $body, $headers); mail(''.$conf->global->MAIN_INFO_SOCIETE_MAIL.'', $subject, $body, $headers);
return 1; return 1;

View File

@ -150,24 +150,17 @@ print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="titlefield">'; print '<td class="titlefield">';
print $langs->trans("StripeLiveEnabled").'</td><td>'; print $langs->trans("StripeLiveEnabled").'</td><td>';
if (empty($conf->global->STRIPECONNECT_LIVE) && ! empty($conf->stripeconnect->enabled)) {
if (!empty($conf->global->STRIPE_LIVE))
print '<A href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=0">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</A>';
}
else {
if (!empty($conf->global->STRIPE_LIVE)) if (!empty($conf->global->STRIPE_LIVE))
{ {
print '<A href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=0">'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=0">';
print img_picto($langs->trans("Activated"),'switch_on'); print img_picto($langs->trans("Activated"),'switch_on');
print '</a>';
} }
else else
{ {
print '<A href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=1">'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=1">';
print img_picto($langs->trans("Disabled"),'switch_off'); print img_picto($langs->trans("Disabled"),'switch_off');
} print '</a>';
print '</A>';
} }
print '</td></tr>'; print '</td></tr>';
@ -207,6 +200,8 @@ if (empty($conf->stripeconnect->enabled))
print '</td></tr>'; print '</td></tr>';
} }
if (empty($conf->stripeconnect->enabled))
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_SECRET_KEY").'</span></td><td>'; print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_SECRET_KEY").'</span></td><td>';
print '<input class="minwidth300" type="text" name="STRIPE_LIVE_SECRET_KEY" value="'.$conf->global->STRIPE_LIVE_SECRET_KEY.'">'; print '<input class="minwidth300" type="text" name="STRIPE_LIVE_SECRET_KEY" value="'.$conf->global->STRIPE_LIVE_SECRET_KEY.'">';
@ -233,7 +228,7 @@ print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("UsageParameter").'</td>'; print '<td class="titlefield">'.$langs->trans("UsageParameter").'</td>';
print '<td>'.$langs->trans("Value").'</td>'; print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n"; print "</tr>\n";