From 869e497a48732a877fab9907a2cf4353adfff7fb Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 21 Aug 2019 16:41:36 +0200 Subject: [PATCH 1/4] NEW : Platforme compliance with Stripe Connect --- htdocs/install/mysql/tables/llx_oauth_token.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_oauth_token.sql b/htdocs/install/mysql/tables/llx_oauth_token.sql index 81ae99c6ce6..6698335c07e 100644 --- a/htdocs/install/mysql/tables/llx_oauth_token.sql +++ b/htdocs/install/mysql/tables/llx_oauth_token.sql @@ -20,6 +20,7 @@ CREATE TABLE llx_oauth_token ( service varchar(36), token text, -- token in serialize() format, of an object StdOAuth2Token of library phpoauth2 tokenstring text, -- token in json format '{"access_token": "sk_test_cccc", "refresh_token": "rt_aaa", "token_type": "bearer", ..., "scope": "read_write"} + fk_soc integer, fk_user integer, fk_adherent integer, entity integer DEFAULT 1 From e43d9967805df72f4493af82f091a2306d66cd4c Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 21 Aug 2019 16:45:53 +0200 Subject: [PATCH 2/4] Update 10.0.0-11.0.0.sql --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 4f70af3b566..9ffda1e9132 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -76,3 +76,5 @@ ALTER TABLE llx_c_price_expression MODIFY COLUMN expression varchar(255) NOT NUL UPDATE llx_bank_url set url = REPLACE( url, 'compta/salaries/', 'salaries/'); ALTER TABLE llx_stock_mouvement ADD COLUMN fk_projet INTEGER NOT NULL DEFAULT 0 AFTER model_pdf; + +ALTER TABLE llx_oauth_token ADD COLUMN fk_soc integer DEFAULT NULL after token; From 074ea37664b3b7e2d918e358fdba6ad4eb175f77 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 21 Aug 2019 17:09:26 +0200 Subject: [PATCH 3/4] Update stripe.class.php --- htdocs/stripe/class/stripe.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index c6df1206d0f..d24a51cdb03 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -78,9 +78,10 @@ class Stripe extends CommonObject * Return main company OAuth Connect stripe account * * @param string $mode 'StripeTest' or 'StripeLive' + * @param int $fk_soc Id of thirdparty * @return string Stripe account 'acc_....' or '' if no OAuth token found */ - public function getStripeAccount($mode = 'StripeTest') + public function getStripeAccount($mode = 'StripeTest', $fk_soc = null) { global $conf; @@ -88,6 +89,10 @@ class Stripe extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."oauth_token"; $sql.= " WHERE entity = ".$conf->entity; $sql.= " AND service = '".$mode."'"; + if ($fk_soc) { + $sql.= " AND fk_soc = '".$fk_soc."'"; + } else { $sql.= " AND ISNULL(fk_soc)"; } + $sql.= " AND ISNULL(fk_user) AND ISNULL(fk_adherent)"; dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); From 5983f08d731b52c69e10e1870f1650647bb886b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Aug 2019 12:52:30 +0200 Subject: [PATCH 4/4] Update stripe.class.php --- htdocs/stripe/class/stripe.class.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index d24a51cdb03..5dda24a763e 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -81,7 +81,7 @@ class Stripe extends CommonObject * @param int $fk_soc Id of thirdparty * @return string Stripe account 'acc_....' or '' if no OAuth token found */ - public function getStripeAccount($mode = 'StripeTest', $fk_soc = null) + public function getStripeAccount($mode = 'StripeTest', $fk_soc = 0) { global $conf; @@ -89,10 +89,13 @@ class Stripe extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."oauth_token"; $sql.= " WHERE entity = ".$conf->entity; $sql.= " AND service = '".$mode."'"; - if ($fk_soc) { - $sql.= " AND fk_soc = '".$fk_soc."'"; - } else { $sql.= " AND ISNULL(fk_soc)"; } - $sql.= " AND ISNULL(fk_user) AND ISNULL(fk_adherent)"; + 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); $result = $this->db->query($sql);