fix: missing trad and clear payment session on error (#744)

This commit is contained in:
JacquesDurand 2024-10-01 09:15:11 +02:00 committed by Hugo Nicolas
parent 5a370bc9aa
commit 06a76374bc
No known key found for this signature in database
GPG key ID: 09CB3D93EB8B0E61
7 changed files with 25 additions and 11 deletions

View file

@ -2,7 +2,7 @@
apiVersion: batch/v1 apiVersion: batch/v1
kind: CronJob kind: CronJob
metadata: metadata:
name: {{ include "plateforme-ebs" . }}-cronjob-end-membership name: {{ include "plateforme-ebs" . }}-cronjob-end-p-membership
labels: labels:
{{- include "plateforme-ebs.labels" . | nindent 4 }} {{- include "plateforme-ebs.labels" . | nindent 4 }}
spec: spec:
@ -23,7 +23,7 @@ spec:
serviceAccountName: {{ include "plateforme-ebs.serviceAccountName" . }} serviceAccountName: {{ include "plateforme-ebs.serviceAccountName" . }}
restartPolicy: Never restartPolicy: Never
containers: containers:
- name: {{ .Chart.Name }}-cronjob-end-membership - name: {{ .Chart.Name }}-cronjob-end-p-membership
image: "{{ .Values.php.image.repository }}:{{ .Values.php.image.tag | default .Chart.AppVersion }}" image: "{{ .Values.php.image.repository }}:{{ .Values.php.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.php.image.pullPolicy }} imagePullPolicy: {{ .Values.php.image.pullPolicy }}
command: ['/bin/sh', '-c'] command: ['/bin/sh', '-c']

View file

@ -2,7 +2,7 @@
apiVersion: batch/v1 apiVersion: batch/v1
kind: CronJob kind: CronJob
metadata: metadata:
name: {{ include "plateforme-ebs" . }}-cronjob-notify-ms-e-1 name: {{ include "plateforme-ebs" . }}-cronjob-notify-pms-e-1
labels: labels:
{{- include "plateforme-ebs.labels" . | nindent 4 }} {{- include "plateforme-ebs.labels" . | nindent 4 }}
spec: spec:
@ -23,7 +23,7 @@ spec:
serviceAccountName: {{ include "plateforme-ebs.serviceAccountName" . }} serviceAccountName: {{ include "plateforme-ebs.serviceAccountName" . }}
restartPolicy: Never restartPolicy: Never
containers: containers:
- name: {{ .Chart.Name }}-cronjob-notify-ms-e-1 - name: {{ .Chart.Name }}-cronjob-notify-pms-e-1
image: "{{ .Values.php.image.repository }}:{{ .Values.php.image.tag | default .Chart.AppVersion }}" image: "{{ .Values.php.image.repository }}:{{ .Values.php.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.php.image.pullPolicy }} imagePullPolicy: {{ .Values.php.image.pullPolicy }}
command: ['/bin/sh', '-c'] command: ['/bin/sh', '-c']

View file

@ -2,7 +2,7 @@
apiVersion: batch/v1 apiVersion: batch/v1
kind: CronJob kind: CronJob
metadata: metadata:
name: {{ include "plateforme-ebs" . }}-cronjob-notify-ms-e-7 name: {{ include "plateforme-ebs" . }}-cronjob-notify-pms-e-7
labels: labels:
{{- include "plateforme-ebs.labels" . | nindent 4 }} {{- include "plateforme-ebs.labels" . | nindent 4 }}
spec: spec:
@ -23,7 +23,7 @@ spec:
serviceAccountName: {{ include "plateforme-ebs.serviceAccountName" . }} serviceAccountName: {{ include "plateforme-ebs.serviceAccountName" . }}
restartPolicy: Never restartPolicy: Never
containers: containers:
- name: {{ .Chart.Name }}-cronjob-notify-ms-e-7 - name: {{ .Chart.Name }}-cronjob-notify-pms-e-7
image: "{{ .Values.php.image.repository }}:{{ .Values.php.image.tag | default .Chart.AppVersion }}" image: "{{ .Values.php.image.repository }}:{{ .Values.php.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.php.image.pullPolicy }} imagePullPolicy: {{ .Values.php.image.pullPolicy }}
command: ['/bin/sh', '-c'] command: ['/bin/sh', '-c']

View file

@ -359,7 +359,7 @@ abstract class AbstractUserCrudController extends AbstractCrudController impleme
$vacationModeField = BooleanField::new('vacationMode'); $vacationModeField = BooleanField::new('vacationMode');
$addressField = AssociationField::new('address'); $addressField = AssociationField::new('address');
$groupsCountField = AssociationField::new('userGroups')->setLabel('Groups number'); $groupsCountField = AssociationField::new('userGroups')->setLabel('Groups number');
$membershipPaidField = BooleanField::new('membershipPaid'); $membershipPaidField = $this->getSimpleBooleanField('membershipPaid');
$startAt = DateField::new('startAt'); $startAt = DateField::new('startAt');
$endAt = DateField::new('endAt'); $endAt = DateField::new('endAt');
$expiresInField = IntegerField::new('expiresIn') $expiresInField = IntegerField::new('expiresIn')

View file

@ -62,6 +62,7 @@ final class DoneAction extends AbstractController
/** @var GetHumanStatus $status */ /** @var GetHumanStatus $status */
$status = $this->commandBus->dispatch(new PlatformMembershipPaidCommand($platformOffer->getId(), $user->getId(), $token)); $status = $this->commandBus->dispatch(new PlatformMembershipPaidCommand($platformOffer->getId(), $user->getId(), $token));
$request->getSession()->remove('payment_in_progress');
// Not captured // Not captured
if (!$status->isCaptured()) { if (!$status->isCaptured()) {
$this->addFlashWarning($this->translator->trans($this->getI18nPrefix().'.status.'.$status->getValue())); $this->addFlashWarning($this->translator->trans($this->getI18nPrefix().'.status.'.$status->getValue()));
@ -73,8 +74,6 @@ final class DoneAction extends AbstractController
'%platform%' => $platformOffer->getConfiguration()?->getPlatformName()], '%platform%' => $platformOffer->getConfiguration()?->getPlatformName()],
)); ));
$request->getSession()->remove('payment_in_progress');
$group = $user->getMyGroupsAsInvited()->first(); $group = $user->getMyGroupsAsInvited()->first();
if ($group !== false) { if ($group !== false) {
return $this->redirectToRoute('app_group_show_logged', $group->getRoutingParameters()); return $this->redirectToRoute('app_group_show_logged', $group->getRoutingParameters());

View file

@ -84,7 +84,7 @@ class DoneActionTest extends TestCase
$comandBus->method('dispatch')->willReturn(new GetHumanStatus(new PaymentToken())); $comandBus->method('dispatch')->willReturn(new GetHumanStatus(new PaymentToken()));
$doneAction = new DoneAction( $doneAction = new DoneAction(
$this->getCommandBus(), $comandBus,
$payum, $payum,
$translator, $translator,
$this->getLogger(), $this->getLogger(),
@ -95,6 +95,7 @@ class DoneActionTest extends TestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$session->method('getFlashBag')->willReturn(new FlashBag()); $session->method('getFlashBag')->willReturn(new FlashBag());
$session->method('remove')->with('payment_in_progress')->willReturn(true);
$requesStack = $this->getMockBuilder(RequestStack::class) $requesStack = $this->getMockBuilder(RequestStack::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -106,9 +107,13 @@ class DoneActionTest extends TestCase
$container->method('get')->willReturn($requesStack); $container->method('get')->willReturn($requesStack);
$doneAction->setContainer($container); $doneAction->setContainer($container);
$request = new Request();
$request->setSession($session);
$requesStack->push($request);
$this->expectException(\Error::class); // or more mock are needed. To clean up later $this->expectException(\Error::class); // or more mock are needed. To clean up later
$doneAction->__invoke(new Request(), $this->getPlatformOffer(), $this->getUser()); $doneAction->__invoke($request, $this->getPlatformOffer(), $this->getUser());
} }
/** /**

View file

@ -327,6 +327,11 @@
<target>Informations</target> <target>Informations</target>
</trans-unit> </trans-unit>
<trans-unit id="n4CnzfH" resname="panel.payment_information">
<source>panel.payment_information</source>
<target>Informations sur l'abonnement</target>
</trans-unit>
<!-- Files and images --> <!-- Files and images -->
<trans-unit id="AHzY4cd" resname="images.help"> <trans-unit id="AHzY4cd" resname="images.help">
<source>images.help</source> <source>images.help</source>
@ -378,6 +383,11 @@
<target>Abonnement à la plateforme payé</target> <target>Abonnement à la plateforme payé</target>
</trans-unit> </trans-unit>
<trans-unit id="hgruegV" resname="Platform Offer">
<source>Platform Offer</source>
<target>Tarif d'adhésion</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>