Fix for new stripe API 2018-08-23
Fix break with change API
This commit is contained in:
parent
50d50c2e10
commit
523b03e132
@ -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();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user