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