From 676d70d86dc71aa9b878b8b6c437eafafaff2086 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 1 Oct 2020 12:14:50 +0200 Subject: [PATCH 1/3] FIX stripe for connect mode --- htdocs/public/stripe/ipn.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 4291cb6f834..16160e94200 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018 Frédéric France +/* Copyright (C) 2018-2020 Thibault FOUCART + * Copyright (C) 2018 Frédéric France * * 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 @@ -115,7 +115,7 @@ if (!empty($conf->multicompany->enabled) && !empty($conf->stripeconnect->enabled { $sql = "SELECT entity"; $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); $result = $db->query($sql); @@ -134,8 +134,6 @@ if (!empty($conf->multicompany->enabled) && !empty($conf->stripeconnect->enabled $key = 1; } $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 From 3f78d8fe258f43d3e4716663f86d8b291b78e9b4 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 1 Oct 2020 12:19:12 +0200 Subject: [PATCH 2/3] Update stripe.class.php --- htdocs/stripe/class/stripe.class.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index a72e5291f58..2ac8193a71e 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -90,15 +90,12 @@ class Stripe extends CommonObject global $conf; $sql = "SELECT tokenstring"; - $sql .= " FROM ".MAIN_DB_PREFIX."oauth_token"; - $sql .= " WHERE entity = ".$conf->entity; - $sql .= " AND service = '".$mode."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."oauth_token WHERE"; + if (empty($fk_soc)) $sql .= " entity = ".$conf->entity. " AND"; + $sql .= " service = '".$mode."'"; if ($fk_soc > 0) { $sql .= " AND fk_soc = ".$fk_soc; } - else { - $sql .= " AND fk_soc IS NULL"; - } $sql .= " AND fk_user IS NULL AND fk_adherent IS NULL"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); From 4e16db1e5f71dfe1f2ca416f222ed24a2b5dea83 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 1 Oct 2020 12:22:53 +0200 Subject: [PATCH 3/3] Update paymentmodes.php --- htdocs/societe/paymentmodes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index b29a3073c85..5894c3245a9 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1329,7 +1329,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // 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'); $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc));