Skip to content

Commit

Permalink
FIX return of the error code
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 2, 2025
1 parent 4fb1232 commit bd666f4
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions htdocs/core/class/commoninvoice.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,8 @@ public function makeStripeSepaRequest($fuser, $did, $type = 'direct-debit', $sou
$error++;
$errorforinvoice++;
dol_syslog("makeStripeSepaRequest Error no bank account defined for Stripe payments", LOG_ERR);
$this->errors[] = "Error bank account for Stripe payments not defined into Stripe module";
$this->error = "Error bank account for Stripe payments not defined into Stripe module";
$this->errors[] = $this->error;
}

$this->db->begin();
Expand All @@ -1359,7 +1360,8 @@ public function makeStripeSepaRequest($fuser, $did, $type = 'direct-debit', $sou
$error++;
$errorforinvoice++;
dol_syslog("makeStripeSepaRequest Error on BonPrelevement creation", LOG_ERR);
$this->errors[] = "Error on BonPrelevement creation";
$this->error = "Error on BonPrelevement creation";
$this->errors[] = $this->error;
}
/*
if (!$error) {
Expand All @@ -1371,15 +1373,17 @@ public function makeStripeSepaRequest($fuser, $did, $type = 'direct-debit', $sou
$result = $this->db->query($sql);
if ($result < 0) {
$error++;
$this->errors[] = "Error on updating fk_prelevement_bons to ".$bon->id;
$this->error = "Error on updating fk_prelevement_bons to ".$bon->id;
$this->errors[] = $this->error;
}
}
*/
} else {
$error++;
$errorforinvoice++;
dol_syslog("makeStripeSepaRequest Error Line already part of a bank payment order", LOG_ERR);
$this->errors[] = "The line is already included into a bank payment order. Delete the bank payment order first.";
$this->error = "The line is already included into a bank payment order. Delete the bank payment order first.";
$this->errors[] = $this->error;
}
}

Expand Down Expand Up @@ -1458,11 +1462,13 @@ public function makeStripeSepaRequest($fuser, $did, $type = 'direct-debit', $sou
} else {
$customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
if (empty($customer) && ! empty($stripe->error)) {
$this->errors[] = $stripe->error;
$this->error = $stripe->error;
$this->errors[] = $this->error;
}
/*if (!empty($customer) && empty($customer->sources)) {
$customer = null;
$this->errors[] = '\Stripe\Customer::retrieve did not returned the sources';
$this->error = '\Stripe\Customer::retrieve did not returned the sources';
$this->errors[] = $this->error;
}*/
}

Expand Down Expand Up @@ -1572,7 +1578,9 @@ public function makeStripeSepaRequest($fuser, $did, $type = 'direct-debit', $sou

$description = 'Stripe payment ERROR from makeStripeSepaRequest: ' . $FULLTAG;
$postactionmessages[] = $errmsg . ' (' . $stripearrayofkeys['publishable_key'] . ')';
$this->errors[] = $errmsg;

$this->error = $errmsg;
$this->errors[] = $this->error;
} else {
dol_syslog('Successfuly request '.$type.' '.$stripecard->id);

Expand Down Expand Up @@ -1602,7 +1610,9 @@ public function makeStripeSepaRequest($fuser, $did, $type = 'direct-debit', $sou
$error++;
$errorforinvoice++;
dol_syslog("No ban payment method found for this stripe customer " . $customer->id, LOG_WARNING);
$this->errors[] = 'Failed to get direct debit payment method for stripe customer = ' . $customer->id;

$this->error = 'Failed to get direct debit payment method for stripe customer = ' . $customer->id;
$this->errors[] = $this->error;

$description = 'Failed to find or use the payment mode - no ban defined for the thirdparty account';
$stripefailurecode = 'BADPAYMENTMODE';
Expand All @@ -1628,10 +1638,12 @@ public function makeStripeSepaRequest($fuser, $did, $type = 'direct-debit', $sou
} else { // Else of the if ($resultthirdparty > 0 && ! empty($customer)) {
if ($resultthirdparty <= 0) {
dol_syslog('SellYourSaasUtils Failed to load customer for thirdparty_id = ' . $thirdparty->id, LOG_WARNING);
$this->errors[] = 'Failed to load Stripe account for thirdparty_id = ' . $thirdparty->id;
$this->error = 'Failed to load Stripe account for thirdparty_id = ' . $thirdparty->id;
$this->errors[] = $this->error;
} else { // $customer stripe not found
dol_syslog('SellYourSaasUtils Failed to get Stripe customer id for thirdparty_id = ' . $thirdparty->id . " in mode " . $servicestatus . " in Stripe env " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key'], LOG_WARNING);
$this->errors[] = 'Failed to get Stripe account id for thirdparty_id = ' . $thirdparty->id . " in mode " . $servicestatus . " in Stripe env " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key'];
$this->error = 'Failed to get Stripe account id for thirdparty_id = ' . $thirdparty->id . " in mode " . $servicestatus . " in Stripe env " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key'];
$this->errors[] = $this->error;
}
$error++;
$errorforinvoice++;
Expand Down Expand Up @@ -1688,13 +1700,15 @@ public function makeStripeSepaRequest($fuser, $did, $type = 'direct-debit', $sou
$error++;
$errorforinvoice++;
dol_syslog('Error ' . $e->getMessage(), LOG_ERR);
$this->errors[] = 'Error ' . $e->getMessage();
$this->error = 'Error ' . $e->getMessage();
$this->errors[] = $this->error;
}
} else { // If remain to pay is null
$error++;
$errorforinvoice++;
dol_syslog("Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?", LOG_WARNING);
$this->errors[] = "Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?";
$this->error = "Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?";
$this->errors[] = $this->error;
}
}

Expand All @@ -1705,7 +1719,8 @@ public function makeStripeSepaRequest($fuser, $did, $type = 'direct-debit', $sou
$error++;
$errorforinvoice++;
dol_syslog("Error on BonPrelevement creation", LOG_ERR);
$this->errors[] = "Error on BonPrelevement creation";
$this->error = "Error on BonPrelevement creation";
$this->errors[] = $this->error;
}
}

Expand Down

0 comments on commit bd666f4

Please sign in to comment.