From 523b03e1324984a073b84666dd1149b6ec7655ed Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 28 Aug 2018 13:32:38 +0200 Subject: [PATCH 1/6] Fix for new stripe API 2018-08-23 Fix break with change API --- .../triggers/interface_80_modStripe_Stripe.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index ab0cd62eb82..f9985461df8 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -136,7 +136,6 @@ class InterfaceStripe $service = 'StripeLive'; $servicestatus = 1; } - // If customer is linked to Strip, we update/delete Stripe too if ($action == 'COMPANY_MODIFY') { dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); @@ -148,19 +147,22 @@ class InterfaceStripe if ($customer) { $namecleaned = $object->name ? $object->name : null; - $vatcleaned = $object->tva_intra ? $object->tva_intra : null; // We force data to "null" if empty as expected by Stripe + $vatcleaned = array( + "tax_id" => $object->tva_intra ? $object->tva_intra : null, // We force data to "null" if empty as expected by Stripe + "type" => 'vat', + ); // Detect if we change a Stripe info (email, description, vat id) $changerequested = 0; if (! empty($object->email) && $object->email != $customer->email) $changerequested++; if ($namecleaned != $customer->description) $changerequested++; - if ($vatcleaned != $customer->business_vat_id) $changerequested++; + if ($vatcleaned != $customer->tax_info) $changerequested++; if ($changerequested) { if (! empty($object->email)) $customer->email = $object->email; $customer->description = $namecleaned; - $customer->business_vat_id = $vatcleaned; + $customer->tax_info = $vatcleaned; $customer->save(); } From 90de2698c3668bc50e75eb34a5b3597963b39748 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 28 Aug 2018 13:34:59 +0200 Subject: [PATCH 2/6] Fix for new stripe API 2018-08-23 Fix break of change API --- htdocs/stripe/class/stripe.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index b8472d0b821..bf4103e51a8 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -166,7 +166,10 @@ class Stripe extends CommonObject { $dataforcustomer = array( "email" => $object->email, - "business_vat_id" => $object->tva_intra, + "tax_info" => array( + "tax_id" => $object->tva_intra ? $object->tva_intra : null, // We force data to "null" if empty as expected by Stripe + "type" => 'vat', + ), "description" => $object->name, "metadata" => array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])) ); From 289dfc7fbeeab2c5269324f81fa0c9357c57ceac Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 28 Aug 2018 13:37:17 +0200 Subject: [PATCH 3/6] update API version We need to downgrade this change to V8 because some breaks occur if Stripe API is updated in dashboard to 2018-08-23 --- htdocs/stripe/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index 7aa22678d7a..802dad47737 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -55,4 +55,4 @@ else \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); \Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version -\Stripe\Stripe::setApiVersion("2018-07-27"); // force version API +\Stripe\Stripe::setApiVersion("2018-08-23"); // force version API From 25be9f59896ebe323a034abd0255a2db87580cc3 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 29 Aug 2018 13:19:03 +0200 Subject: [PATCH 4/6] fix if null --- htdocs/stripe/class/stripe.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index bf4103e51a8..e8c0d7a3f12 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -166,13 +166,16 @@ class Stripe extends CommonObject { $dataforcustomer = array( "email" => $object->email, - "tax_info" => array( - "tax_id" => $object->tva_intra ? $object->tva_intra : null, // We force data to "null" if empty as expected by Stripe - "type" => 'vat', - ), "description" => $object->name, "metadata" => array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])) ); + + if ($object->tva_intra!=null) + { + $dataforcustomer["tax_info"] = array( + "tax_id" => $object->tva_intra, + "type" => 'vat'); + } //$a = \Stripe\Stripe::getApiKey(); //var_dump($a);var_dump($key);exit; From ff44e65c38c640f5097e5570791af6d759e46995 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 10 Sep 2018 12:31:34 +0200 Subject: [PATCH 5/6] update api changelog 2018-09-06 introduce no change for dolibarr with 2018-08-23 --- htdocs/stripe/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index 802dad47737..1c15b547fad 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -55,4 +55,4 @@ else \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); \Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version -\Stripe\Stripe::setApiVersion("2018-08-23"); // force version API +\Stripe\Stripe::setApiVersion("2018-09-06"); // force version API From 95989019335d08499c8b33e1e1ca7d78e12d49b6 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 27 Sep 2018 09:43:43 +0200 Subject: [PATCH 6/6] Update config.php --- htdocs/stripe/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index 1c15b547fad..6141c2a32f8 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -55,4 +55,4 @@ else \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); \Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version -\Stripe\Stripe::setApiVersion("2018-09-06"); // force version API +\Stripe\Stripe::setApiVersion("2018-09-24"); // force version API