Fix syntax

This commit is contained in:
Laurent Destailleur 2018-03-13 14:48:01 +01:00
parent f7dd7e89de
commit 9c92e09295

View File

@ -109,7 +109,6 @@ class InterfaceStripe
* @param Conf $conf Object conf * @param Conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK * @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/ */
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
{ {
// Put here code you want to execute when a Dolibarr business events occurs. // Put here code you want to execute when a Dolibarr business events occurs.
@ -119,12 +118,12 @@ $langs->load("members");
$langs->load("users"); $langs->load("users");
$langs->load("mails"); $langs->load("mails");
$langs->load('other'); $langs->load('other');
/** Users */
$ok = 0; $ok = 0;
$stripe = new Stripe($db); $stripe = new Stripe($db);
if (empty($conf->stripe->enabled)) return 0; if (empty($conf->stripe->enabled)) return 0;
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha'))) if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
{ {
$service = 'StripeTest'; $service = 'StripeTest';
} }
@ -134,32 +133,34 @@ else
} }
if ($action == 'COMPANY_MODIFY') { if ($action == 'COMPANY_MODIFY') {
dol_syslog( dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
if ($stripe->getStripeAccount($service) && $object->client != 0) { if ($stripe->getStripeAccount($service) && $object->client != 0) {
$cu=$stripe->CustomerStripe($object->id,$stripe->getStripeAccount($service)); $cu = $stripe->customerStripe($object->id, $stripe->getStripeAccount($service));
if ($cu) { if ($cu) {
if ($conf->entity == '1') { if ($conf->entity == '1') {
$customer = \Stripe\Customer::retrieve("$cu->id"); $customer = \Stripe\Customer::retrieve("$cu->id");
} else { } else {
$customer = \Stripe\Customer::retrieve("$cu->id",array("stripe_account" => $stripe->getStripeAccount($service))); $customer = \Stripe\Customer::retrieve("$cu->id", array(
"stripe_account" => $stripe->getStripeAccount($service)
));
}
if (! empty($object->email)) {
$customer->email = "$object->email";
} }
if (!empty($object->email)) {$customer->email = "$object->email";}
$customer->description = "$object->name"; $customer->description = "$object->name";
$customer->save(); $customer->save();
}}
} }
elseif ($action == 'COMPANY_DELETE') { }
dol_syslog( } elseif ($action == 'COMPANY_DELETE') {
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
); $cu = $stripe->customerStripe($object->id, $stripe->getStripeAccount($service));
$cu=$stripe->CustomerStripe($object->id,$stripe->getStripeAccount($service));
if ($cu) { if ($cu) {
if ($conf->entity == 1) { if ($conf->entity == 1) {
$customer = \Stripe\Customer::retrieve("$cu->id"); $customer = \Stripe\Customer::retrieve("$cu->id");
} else { } else {
$customer = \Stripe\Customer::retrieve("$cu->id",array("stripe_account" => $stripe->getStripeAccount($service))); $customer = \Stripe\Customer::retrieve("$cu->id", array(
"stripe_account" => $stripe->getStripeAccount($service)
));
} }
$customer->delete(); $customer->delete();
} }