Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,27 @@ public function __invoke(Request $request): Response
$etat = MembershipFeePaymentStatus::Rejected;
}

$cmd = $payboxResponse->getCmd();

$cleanedCmd = $cmd;
// cf payboxfactory, on a un suffixe pour gérer l'unicité et éviter une erreur "An error occurred while creating or updating row in fappel"
$suffixPos = strpos($cleanedCmd, '__');
if (false !== $suffixPos) {
$cleanedCmd = substr($cleanedCmd, 0, $suffixPos);
}

if ($etat == MembershipFeePaymentStatus::Paid) {
$account = $this->onlinePaymentHandler->getAccountFromCmd($payboxResponse->getCmd());
$account = $this->onlinePaymentHandler->getAccountFromCmd($cleanedCmd);
$lastCotisation = $this->membershipFeeService->getLatestByUserTypeAndId(MemberType::from($account['type']), $account['id']);

if (!$lastCotisation instanceof MembershipFee && $account['type'] == MemberType::MemberPhysical->value) {
$user = $this->userRepository->get($account['id']);
$this->eventDispatcher->dispatch(new NewMemberEvent($user));
}

$this->onlinePaymentHandler->validerReglementEnLigne($payboxResponse->getCmd(), round($payboxResponse->getTotal() / 100, 2), $payboxResponse->getAuthorizationId(), $payboxResponse->getTransactionId());
$this->membershipFeeMailer->notifierReglementEnLigneAuTresorier($payboxResponse->getCmd(), round($payboxResponse->getTotal() / 100, 2), $payboxResponse->getAuthorizationId(), $payboxResponse->getTransactionId());
$this->audit->log("Ajout de la cotisation " . $payboxResponse->getCmd() . " via Paybox.");
$this->onlinePaymentHandler->validerReglementEnLigne($cleanedCmd, round($payboxResponse->getTotal() / 100, 2), $payboxResponse->getAuthorizationId(), $payboxResponse->getTransactionId());
$this->membershipFeeMailer->notifierReglementEnLigneAuTresorier($cleanedCmd, round($payboxResponse->getTotal() / 100, 2), $payboxResponse->getAuthorizationId(), $payboxResponse->getTransactionId());
$this->audit->log("Ajout de la cotisation " . $cleanedCmd . " via Paybox.");
}
return new Response();
}
Expand Down
2 changes: 1 addition & 1 deletion sources/AppBundle/Payment/PayboxFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function createPayboxForSubscription($facture, $montant, $email, PayboxBi

$paybox
->setTotal((int) $montant * 100) // Total de la commande, en centimes d'euros
->setCmd($facture) // Référence de la commande
->setCmd($facture . '__' . uniqid()) // Référence de la commande + un suffixe pour gérer l'unicité et éviter une erreur "An error occurred while creating or updating row in fappel" sur paybox notamment en environnement de test
->setPorteur($email) // Email du client final (Le porteur de la carte)
->setUrlRetourEffectue($this->router->generate('membership_payment_redirect', ['type' => 'success'], RouterInterface::ABSOLUTE_URL))
->setUrlRetourRefuse($this->router->generate('membership_payment_redirect', ['type' => 'refused'], RouterInterface::ABSOLUTE_URL))
Expand Down
15 changes: 15 additions & 0 deletions tests/behat/bootstrap/FormContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ public function submitFormWithName(string $formName): void
$form->submit();
}

#[Then('I submit the form with id :formId')]
public function submitFormWithId(string $formId): void
{
$form = $this->minkContext->getSession()->getPage()->find('xpath', "//form[@id='$formId']");

if (null === $form) {
throw new ExpectationException(
sprintf('The form of id "%s" not found', $formId),
$this->minkContext->getSession()->getDriver(),
);
}

$form->submit();
}

#[Then('The :field field should only contain the follow values :expectedValuesJson')]
public function selectHasValues(string $field, string $expectedValuesJson): void
{
Expand Down
1 change: 1 addition & 0 deletions tests/behat/features/EventPages/Ticketing.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Feature: Event pages - Ticketing
When I press "Régler par carte"
# Pour suivre la redirection POST de Paybox
And I submit the form with name "PAYBOX"
And I submit the form with id "payment_page_redirect_form"
When I fill in "NUMERO_CARTE" with "1111222233334444"
And I select "12" from "MOIS_VALIDITE"
And I select "26" from "AN_VALIDITE"
Expand Down
2 changes: 2 additions & 0 deletions tests/behat/features/PublicSite/Register.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Feature: Site Public - Register
When I press "Régler par carte"
# Pour suivre la redirection POST de Paybox
And I submit the form with name "PAYBOX"
And I submit the form with id "payment_page_redirect_form"
When I fill in "NUMERO_CARTE" with "1111222233334444"
And I select "12" from "MOIS_VALIDITE"
And I select "26" from "AN_VALIDITE"
Expand Down Expand Up @@ -85,6 +86,7 @@ Feature: Site Public - Register
When I press "Régler par carte"
# Pour suivre la redirection POST de Paybox
And I submit the form with name "PAYBOX"
And I submit the form with id "payment_page_redirect_form"
When I fill in "NUMERO_CARTE" with "1111222233334444"
And I select "12" from "MOIS_VALIDITE"
And I select "26" from "AN_VALIDITE"
Expand Down
Loading