diff --git a/Controller/PaymentController.php b/Controller/PaymentController.php index 94fde70..ba46fcb 100644 --- a/Controller/PaymentController.php +++ b/Controller/PaymentController.php @@ -52,10 +52,10 @@ public function newAction(Request $request, $order) return $this->render( 'AppVentusMangopayBundle::cardPayment.html.twig', - array( - 'form' => $form->createView(), + [ + 'form' => $form->createView(), 'order' => $order, - ) + ] ); } @@ -87,13 +87,13 @@ public function paymentFinalizeAction(Request $request, $orderId, $cardId) // Handle error if ((property_exists($updatedCardRegister, 'ResultCode') && $updatedCardRegister->ResultCode !== '000000') - || $updatedCardRegister->Status == 'ERROR') { + || $updatedCardRegister->Status == 'ERROR') { $errorMessage = $this->get('translator')->trans('mangopay.error.'.$updatedCardRegister->ResultCode); - return new JsonResponse(array( + return new JsonResponse([ 'success' => false, 'message' => $errorMessage, - )); + ]); } // Create a PayIn @@ -103,17 +103,17 @@ public function paymentFinalizeAction(Request $request, $orderId, $cardId) if ((property_exists($preAuth, 'Code') && $preAuth->Code !== 200) || $preAuth->Status == 'FAILED') { $errorMessage = $this->get('translator')->trans('mangopay.error.'.$preAuth->ResultCode); - return new JsonResponse(array( + return new JsonResponse([ 'success' => false, 'message' => $errorMessage, - )); + ]); } // Handle secure mode if (property_exists($preAuth, 'SecureModeNeeded') && $preAuth->SecureModeNeeded == 1) { - return new JsonResponse(array( - 'success' => true, + return new JsonResponse([ + 'success' => true, 'redirect' => $preAuth->SecureModeRedirectURL, - )); + ]); } // store payin transaction @@ -134,9 +134,9 @@ public function paymentFinalizeAction(Request $request, $orderId, $cardId) $this->get('translator')->trans('appventus_mangopay.alert.pre_authorisation.success') ); - return new JsonResponse(array( + return new JsonResponse([ 'success' => true, - )); + ]); } /** @@ -198,18 +198,19 @@ public function paymentFinalizeSecureAction(Request $request, $orderId) /** * @param Request $request The request - * @param int $orderId + * @param int $orderId * * This method shows the congratulations * * @Route("/success/{orderId}", name="appventus_mangopaybundle_payment_success") + * * @return Response */ public function successAction(Request $request, $orderId) { return $this->render( 'AppVentusMangopayBundle::success.html.twig', - [ 'orderId' => $orderId ] + ['orderId' => $orderId] ); } } diff --git a/Helper/PaymentHelper.php b/Helper/PaymentHelper.php index 7781f73..ad811f1 100644 --- a/Helper/PaymentHelper.php +++ b/Helper/PaymentHelper.php @@ -53,15 +53,15 @@ public function prepareCardRegistrationCallback(User $user, Order $order) $redirect = $this->router->generate( 'appventus_mangopaybundle_payment_finalize', - array( + [ 'orderId' => $order->getId(), - 'cardId' => $mangoCardRegistration->Id, - ) + 'cardId' => $mangoCardRegistration->Id, + ] ); $successRedirect = $this->generateSuccessUrl($order->getId()); - return array( + return [ 'callback' => 'payAjaxOrRedirect("' .$redirect.'", "' .$redirect.'", "' @@ -69,7 +69,7 @@ public function prepareCardRegistrationCallback(User $user, Order $order) .$preregistrationData.'", "' .$accessKey.'", "' .$successRedirect.'")', - ); + ]; } /** @@ -110,9 +110,9 @@ public function createPreAuthorisation(CardRegistration $updatedCardRegister, Us $cardPreAuthorisation->SecureMode = 'DEFAULT'; $cardPreAuthorisation->SecureModeReturnURL = $this->router->generate( 'appventus_mangopaybundle_payment_finalize_secure', - array( + [ 'orderId' => $order->getId(), - ), + ], true ); @@ -125,6 +125,7 @@ public function createPreAuthorisation(CardRegistration $updatedCardRegister, Us return $preAuth; } + /** * execute a pre authorisation. * @@ -199,5 +200,4 @@ public function generateSuccessUrl($orderId) { return $this->router->generate('appventus_mangopaybundle_payment_success', ['orderId' => $orderId]); } - }