Fix deletion of credit card when no Oauth set

This commit is contained in:
Laurent Destailleur 2018-10-02 22:34:41 +02:00
parent 56cb0763d1
commit 76f5d53840

View File

@ -140,7 +140,7 @@ class InterfaceStripe
if ($action == 'COMPANY_MODIFY') { if ($action == 'COMPANY_MODIFY') {
dol_syslog("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);
$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) { if ($object->client != 0) {
$customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); // This make a network request $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); // This make a network request
@ -169,7 +169,7 @@ class InterfaceStripe
if ($action == 'COMPANY_DELETE') { if ($action == 'COMPANY_DELETE') {
dol_syslog("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);
$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); $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus);
if ($customer) if ($customer)
@ -193,15 +193,10 @@ class InterfaceStripe
if (! empty($object->stripe_card_ref)) 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 $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this
if (empty($stripeacc)) if ($stripecu)
{
$ok = -1;
$this->error = "Stripe API keys are not defined into Stripe module setup for mode ".$service;
}
elseif ($stripecu)
{ {
// Get customer (required to get a card) // Get customer (required to get a card)
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage 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)) 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 $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this
if (empty($stripeacc))
{ if ($stripecu)
$ok = -1;
$this->error = "Stripe API keys are not defined into Stripe module setup for mode ".$service;
}
elseif ($stripecu)
{ {
// Get customer (required to get a card) // Get customer (required to get a card)
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage