Merge pull request #14886 from ptibogxiv/patch-367

FIX stripe for connect mode
This commit is contained in:
Laurent Destailleur 2020-10-01 16:38:30 +02:00 committed by GitHub
commit aaad3c3b75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 12 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2018 Thibault FOUCART <support@ptibogxiv.net> /* Copyright (C) 2018-2020 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -115,7 +115,7 @@ 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 = '".$db->escape($service)."' and tokenstring = '%".$db->escape($event->account)."%'"; $sql .= " WHERE service = '".$db->escape($service)."' and tokenstring LIKE '%".$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);
@ -134,8 +134,6 @@ if (!empty($conf->multicompany->enabled) && !empty($conf->stripeconnect->enabled
$key = 1; $key = 1;
} }
$ret = $mc->switchEntity($key); $ret = $mc->switchEntity($key);
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res) die("Include of main fails");
} }
// list of action // list of action

View File

@ -1329,7 +1329,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
} }
// List of Stripe payment modes // List of Stripe payment modes
if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $object->fournisseur && !empty($stripesupplieracc)) if (!empty($conf->stripe->enabled) && !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'); 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)); $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc));

View File

@ -90,15 +90,12 @@ class Stripe extends CommonObject
global $conf; global $conf;
$sql = "SELECT tokenstring"; $sql = "SELECT tokenstring";
$sql .= " FROM ".MAIN_DB_PREFIX."oauth_token"; $sql .= " FROM ".MAIN_DB_PREFIX."oauth_token WHERE";
$sql .= " WHERE entity = ".$conf->entity; if (empty($fk_soc)) $sql .= " entity = ".$conf->entity. " AND";
$sql .= " AND service = '".$mode."'"; $sql .= " service = '".$mode."'";
if ($fk_soc > 0) { if ($fk_soc > 0) {
$sql .= " AND fk_soc = ".$fk_soc; $sql .= " AND fk_soc = ".$fk_soc;
} }
else {
$sql .= " AND fk_soc IS NULL";
}
$sql .= " AND fk_user IS NULL AND fk_adherent IS NULL"; $sql .= " AND fk_user IS NULL AND fk_adherent IS NULL";
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);