Commit 87c7feeb by Damien Moulard

Merge branch '6366-authorized-vs-authorised-and-another-detail' into ssa-gironde

parents c5192036 8414ff8a
......@@ -200,6 +200,9 @@ class PaymentController extends AbstractController
* Voie 3 : le traitement de la requête se fait finalement simplement dans notifyRecurringPaymentAction sans utiliser
* les mécanismes complexes de Payum.
*
* Pour d'autres problèmes avec Payum, voir aussi les commentaires liés à
* l'utilisation de GetHumanStatus::STATUS_AUTHORIZED.
*
* Yvon KERDONCUFF
* 26/03/2024
*/
......@@ -240,15 +243,14 @@ class PaymentController extends AbstractController
&& array_key_exists('vads_identifier', $payment->getDetails())
&& $payment->getDetails()['vads_identifier'] == $vads_identifier
) {
if (
GetHumanStatus::STATUS_CAPTURED == $new_status
|| GetHumanStatus::STATUS_AUTHORIZED == $new_status
) {
// Payum GetHumanStatus constants don't match Payzen vads_trans_status here
// e.g. GetHumanStatus::STATUS_AUTHORIZED does not match 'authorised' value sent by Payzen
if (in_array($new_status, ['captured', 'authorised', GetHumanStatus::STATUS_CAPTURED, GetHumanStatus::STATUS_AUTHORIZED])) {
$this->paymentUtils->handlePayzenNotificationCore($payment);
$this->em->flush();
}
return new Response('Recurring payment occurence taken into account.', 200);
//for debug purpose, display vads_trans_status in payzen backoffice
return new Response('Recurring payment occurence taken into account. vads_trans_status = ' . $new_status, 200);
}
}
//return error
......@@ -281,7 +283,16 @@ class PaymentController extends AbstractController
}
// Set flash message according to payment status
if (GetHumanStatus::STATUS_CAPTURED == $payment->getStatus() || GetHumanStatus::STATUS_AUTHORIZED == $payment->getStatus()) {
/* WARNING : THIS PIECE OF CODE IS USING INAPPROPRIATE GetHumanStatus::STATUS_AUTHORIZED :
*
* This is (another) issue here with Payum.
* current_payment_status will never match STATUS_AUTHORIZED
* on the opposite, we have no chance to detect 'authorised' value here
* because Payzen vads_trans_status is written 'authorised' and not 'authorized'
*
* @see comment above notifyRecurringPaymentAction for more Payum weird stuff
*/
if (in_array($payment->getStatus(), ['captured', 'authorised', GetHumanStatus::STATUS_CAPTURED, GetHumanStatus::STATUS_AUTHORIZED])) {
$type = $payment->getDescription();
if (Payment::TYPE_ACHAT_MONNAIE_ADHERENT == $type || Payment::TYPE_ACHAT_MONNAIE_PRESTA == $type) {
......
......@@ -84,14 +84,17 @@ class PaymentStatusExtension implements ExtensionInterface
$current_payment_status = $payment->getStatus();
$new_status = $status->getValue();
if (
GetHumanStatus::STATUS_CAPTURED !== $current_payment_status
&& GetHumanStatus::STATUS_AUTHORIZED != $current_payment_status
) {
if (
GetHumanStatus::STATUS_CAPTURED == $new_status
|| GetHumanStatus::STATUS_AUTHORIZED == $new_status
) {
/* WARNING : THIS PIECE OF CODE IS USING INAPPROPRIATE GetHumanStatus::STATUS_AUTHORIZED :
*
* This is (another) issue here with Payum.
* current_payment_status will never match STATUS_AUTHORIZED
* on the opposite, we have no chance to detect 'authorised' value here
* because Payzen vads_trans_status is written 'authorised' and not 'authorized'
*
* @see comment above notifyRecurringPaymentAction for more Payum weird stuff
*/
if (!in_array($current_payment_status, ['captured', 'authorised', GetHumanStatus::STATUS_CAPTURED, GetHumanStatus::STATUS_AUTHORIZED])) {
if (in_array($new_status, ['captured', 'authorised', GetHumanStatus::STATUS_CAPTURED, GetHumanStatus::STATUS_AUTHORIZED]) ) {
$this->paymentUtils->handlePayzenNotificationCore($payment);
// Invalidate (delete) notify token after payment is captured
$this->em->remove($token);
......
......@@ -212,7 +212,7 @@ class PaymentUtils
$payment->setClientId($user->getId());
$payment->setExtraData('');
$this->em->persist($payment);
} else if (Payment::TYPE_PAIEMENT_COTISATION_TAV == $type || Payment::TYPE_PAIEMENT_RECURRENT_COTISATION_TAV) {
} else if (Payment::TYPE_PAIEMENT_COTISATION_TAV == $type || Payment::TYPE_PAIEMENT_RECURRENT_COTISATION_TAV == $type) {
$flux = $this->serializer->deserialize(
$payment->getFluxData(),
AchatMonnaieAdherent::class,
......@@ -247,7 +247,7 @@ class PaymentUtils
$this->em->persist($flux);
$this->operationUtils->executeOperations($flux);
if (Payment::TYPE_PAIEMENT_COTISATION_TAV == $type || Payment::TYPE_PAIEMENT_RECURRENT_COTISATION_TAV) {
if (Payment::TYPE_PAIEMENT_COTISATION_TAV == $type || Payment::TYPE_PAIEMENT_RECURRENT_COTISATION_TAV == $type) {
// Create new flux for cotisation, depending on process
if ($this->container->getParameter('household_based_allowance')) {
$this->tavCotisationsUtils->applyHouseholdAllowance($flux);
......
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