From d6e8872af4a37b985481507b0a499c6c3060abdf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Mar 2018 14:14:33 +0100 Subject: [PATCH] Update interface_99_modStripe_Stripe.class.php --- .../interface_99_modStripe_Stripe.class.php | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/core/triggers/interface_99_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_99_modStripe_Stripe.class.php index e75d87c36f6..0fff7b6a58e 100644 --- a/htdocs/core/triggers/interface_99_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_99_modStripe_Stripe.class.php @@ -121,18 +121,27 @@ $langs->load("mails"); $langs->load('other'); /** Users */ $ok=0; -$stripe=new Stripe($db); +$stripe=new Stripe($db); +if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || empty($conf->global->STRIPECONNECT_LIVE) || GETPOST('forcesandbox','alpha'))) +{ + $service = 'StripeTest'; +} +else +{ + $service = 'StripeLive'; +} + if ($action == 'COMPANY_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); -if ($stripe->GetStripeAccount($conf->entity)&&$object->client!=0) { -$cu=$stripe->CustomerStripe($object->id,$stripe->GetStripeAccount($conf->entity)); +if ($stripe->getStripeAccount($service) && $object->client!=0) { +$cu=$stripe->CustomerStripe($object->id,$stripe->getStripeAccount($service)); if ($cu) { if ($conf->entity=='1'){ $customer = \Stripe\Customer::retrieve("$cu->id"); }else{ -$customer = \Stripe\Customer::retrieve("$cu->id",array("stripe_account" => $stripe->GetStripeAccount($conf->entity))); +$customer = \Stripe\Customer::retrieve("$cu->id",array("stripe_account" => $stripe->getStripeAccount($service))); } if (!empty($object->email)) {$customer->email = "$object->email";} $customer->description = "$object->name"; @@ -143,12 +152,12 @@ elseif ($action == 'COMPANY_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); -$cu=$stripe->CustomerStripe($object->id,$stripe->GetStripeAccount($conf->entity)); +$cu=$stripe->CustomerStripe($object->id,$stripe->getStripeAccount($service)); if ($cu) { if ($conf->entity==1){ $customer = \Stripe\Customer::retrieve("$cu->id"); }else{ - $customer = \Stripe\Customer::retrieve("$cu->id",array("stripe_account" => $stripe->GetStripeAccount($conf->entity))); + $customer = \Stripe\Customer::retrieve("$cu->id",array("stripe_account" => $stripe->getStripeAccount($service))); } $customer->delete(); }