Commit 15b362e3 by Yvon Kerdoncuff

Merge branch '6260-faux-positif-dans-detection-paiement-recurrent-en-cours' into 'develop'

6260 faux positif dans detection paiement recurrent en cours

See merge request cooperatic/kohinos-tav!85
parents 9c5c2b85 496b7a54
......@@ -192,21 +192,23 @@ class Payment extends BasePayment
*/
public function isRecurringPaymentEndedOrExpired(&$reason)
{
if(!$this->details
|| !array_key_exists('vads_effective_creation_date',$this->details)
|| !array_key_exists('vads_expiry_year',$this->details)
|| !array_key_exists('vads_effective_creation_date',$this->details)
if (
!$this->details
|| !array_key_exists('vads_effective_creation_date', $this->details)
|| !array_key_exists('vads_expiry_year', $this->details)
|| !array_key_exists('vads_effective_creation_date', $this->details)
) {
$reason = "Attribut détails vide ou clés absentes.";
return null;
}
$firstDayOfCreationMonth = DateTime::createFromFormat(
'Ymd',substr($this->details['vads_effective_creation_date'],0,6) . "01"
'Ymd',
substr($this->details['vads_effective_creation_date'], 0, 6) . "01"
);
if(!$firstDayOfCreationMonth) {
$reason = "Error parsing vads_effective_creation_date : " . $this->details['vads_effective_creation_date'];
return null;
}
if (!$firstDayOfCreationMonth) {
$reason = "Error parsing vads_effective_creation_date : " . $this->details['vads_effective_creation_date'];
return null;
}
$day = $this->getRecurrenceMonthDay() ? $this->getRecurrenceMonthDay() - 1 : 0; //if not set assume first day of month (not a big deal anyway)
$dateOfFirstOccurenceAfterInitialPayment = $firstDayOfCreationMonth->modify(
"+" . $day . " days next month"
......@@ -219,11 +221,11 @@ class Payment extends BasePayment
: null; //assume no end date if recurrenceMonthsCount not set
//Now check expiry date
$paymentEndDateDueToExpiry = new DateTime();
$paymentEndDateDueToExpiry->setDate($this->details['vads_expiry_year'],$this->details['vads_expiry_month'],$day+1);
$paymentEndDateDueToExpiry = new DateTime();
$paymentEndDateDueToExpiry->setDate($this->details['vads_expiry_year'], $this->details['vads_expiry_month'], $day + 1);
$now = new DateTime();
if($paymentEndDate && $paymentEndDate < $paymentEndDateDueToExpiry) {
if ($paymentEndDate && $paymentEndDate < $paymentEndDateDueToExpiry) {
//Compare now with payment end date
$reason = "Paiement récurrent en cours jusqu'à dernière échéance le " . $paymentEndDate->format('d/m/Y') . ".";
return $now >= $paymentEndDate;
......
......@@ -10,6 +10,7 @@ use App\Entity\CotisationTavReversement;
use App\Entity\CotisationTavPrelevement;
use App\Enum\MoyenEnum;
use App\Utils\CustomEntityManager;
use Payum\Core\Request\GetHumanStatus;
use Symfony\Component\Security\Core\Security;
class TAVCotisationUtils
......@@ -54,9 +55,19 @@ class TAVCotisationUtils
$res = "";
foreach($recurringPayments as $p) {
$reason = "";
if($p->isRecurringPaymentEndedOrExpired($reason) !== true) {
$res .= ($reason . " ");
if (
$p->getStatus() !== GetHumanStatus::STATUS_FAILED
&& $p->getStatus() !== GetHumanStatus::STATUS_CANCELED
&& $p->getStatus() !== GetHumanStatus::STATUS_EXPIRED
) {
//Everytime payzen sends a recurring payment notification, notification is
//caught by notifyRecurringPaymentAction, which does not update payment status.
//This is why we can not rely on $p->getStatus to decide if a recurring
//payment is still active or ended or expired.
$reason = "";
if($p->isRecurringPaymentEndedOrExpired($reason) !== true) {
$res .= ($reason . " ");
}
}
}
return $res;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment