From 76f5d5384026848f98d67a823a062e186ba95dfa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Oct 2018 22:34:41 +0200 Subject: [PATCH] Fix deletion of credit card when no Oauth set --- .../interface_80_modStripe_Stripe.class.php | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index c1cf1bfd936..3c86dc805ff 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -140,7 +140,7 @@ class InterfaceStripe if ($action == 'COMPANY_MODIFY') { dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. if ($object->client != 0) { $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); // This make a network request @@ -169,7 +169,7 @@ class InterfaceStripe if ($action == 'COMPANY_DELETE') { dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); if ($customer) @@ -193,15 +193,10 @@ class InterfaceStripe if (! empty($object->stripe_card_ref)) { - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this - if (empty($stripeacc)) - { - $ok = -1; - $this->error = "Stripe API keys are not defined into Stripe module setup for mode ".$service; - } - elseif ($stripecu) + if ($stripecu) { // Get customer (required to get a card) if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage @@ -233,14 +228,10 @@ class InterfaceStripe if (! empty($object->stripe_card_ref)) { - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this - if (empty($stripeacc)) - { - $ok = -1; - $this->error = "Stripe API keys are not defined into Stripe module setup for mode ".$service; - } - elseif ($stripecu) + + if ($stripecu) { // Get customer (required to get a card) if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage