Commit 86b5fdbe by Kohinos Cooperatic

fix bugs and improve interface showing status of currently ongoing recurring payments

parent 489e4b18
...@@ -211,29 +211,28 @@ class Payment extends BasePayment ...@@ -211,29 +211,28 @@ class Payment extends BasePayment
} }
$day = $this->getRecurrenceMonthDay() ? $this->getRecurrenceMonthDay() - 1 : 0; //if not set assume first day of month (not a big deal anyway) $day = $this->getRecurrenceMonthDay() ? $this->getRecurrenceMonthDay() - 1 : 0; //if not set assume first day of month (not a big deal anyway)
$dateOfFirstOccurenceAfterInitialPayment = $firstDayOfCreationMonth->modify( $dateOfFirstOccurenceAfterInitialPayment = $firstDayOfCreationMonth->modify(
$day . " days next month" "+" . $day . " days next month"
); );
$paymentEndDate = $this->getRecurrenceMonthsCount() ? $paymentEndDate = $this->getRecurrenceMonthsCount() ?
$dateOfFirstOccurenceAfterInitialPayment->modify( $dateOfFirstOccurenceAfterInitialPayment->modify(
"+" . ($this->getRecurrenceMonthsCount() - 1) //minus one because initial payment is not considered by payzen as the first occurence "+" . ($this->getRecurrenceMonthsCount() - 1) . " months" //minus one because initial payment is not considered by payzen as the first occurence
) )
: null; //assume no end date if recurrenceMonthsCount not set : null; //assume no end date if recurrenceMonthsCount not set
//Now check expiry date //Now check expiry date
$expiryDate = DateTime::createFromFormat( $paymentEndDateDueToExpiry = new DateTime();
'Ym',$this->details['vads_expiry_year'] . $this->details['vads_expiry_month'] $paymentEndDateDueToExpiry->setDate($this->details['vads_expiry_year'],$this->details['vads_expiry_month'],$day+1);
);
$now = new DateTime(); $now = new DateTime();
if($paymentEndDate && $paymentEndDate < $expiryDate) { if($paymentEndDate && $paymentEndDate < $paymentEndDateDueToExpiry) {
//Compare now with payment end date //Compare now with payment end date
$reason = "Dernière échéance le : " . $paymentEndDate->format('d/m/Y'); $reason = "Paiement récurrent en cours jusqu'à dernière échéance le " . $paymentEndDate->format('d/m/Y') . ".";
return $now >= $paymentEndDate; return $now >= $paymentEndDate;
} else { } else {
//Compare now with expiry date //Compare now with expiry date
$reason = "Expiration du moyen de paiement le : " . $expiryDate->format('d/m/Y'); $reason = "Paiement récurrent en cours jusqu'à dernière échéance le " . $paymentEndDateDueToExpiry->format('d/m/Y') . " en raison de l'expiration du moyen de paiement.";
return $now >= $expiryDate; return $now >= $paymentEndDateDueToExpiry;
} }
} }
} }
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