Skip to content

Commit

Permalink
Fix deletion of credit card when no Oauth set
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 2, 2018
1 parent 75b1cac commit e83149a
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions htdocs/core/triggers/interface_80_modStripe_Stripe.class.php
Expand Up @@ -138,7 +138,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
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
Expand Down Expand Up @@ -167,7 +167,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
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)
Expand All @@ -191,15 +191,10 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf

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
Expand Down Expand Up @@ -231,14 +226,10 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf

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
Expand Down

0 comments on commit e83149a

Please sign in to comment.