Confirmation payment OK

@param Request $request

@return stdClass
557073
public function confirmation(Request $request)
    {
        if( $request->get('paypal') != '' && $request->get('paymentId') != '' && $request->get('PayerID') != '')
        {
            $this->getToken();
            $em = $this->container->get('doctrine')->getManager();
            //Search on transaction paymentDetails the $paymentId
            $paymentId = $request->get('paymentId');
            $transaction = $em->getRepository('EcommerceBundle:Transaction')->findOnPaymentDetails($paymentId);

            $payerId = $request->get('PayerID');
            $payment_execute = array(
                            'payer_id' => $payerId
                           );
            $json = json_encode($payment_execute);

            //Search 'payment_execute_url' in paymentDetails transaction
            $paymentDetails = json_decode($transaction->getPaymentDetails());
            foreach ($paymentDetails->links as $link) {
                if($link->rel == 'execute'){
                        $payment_execute_url = $link->href;
                }
            }
            $json_resp = $this->call('POST', $payment_execute_url, $json);
            //$html  = "Payment Execute processed " . $json_resp['id'] ." with state '". $json_resp['state']."'";

            //UPDATE TRANSACTION
            $transaction->setStatus(Transaction::STATUS_PAID);
            $transaction->setPaymentDetails($transaction->getPaymentDetails().json_encode($json_resp));
            $em->flush();

        }
        //check recurring paypal
        elseif($request->get('paypal') != '' &&  $request->get('token') != ''){
            
            $this->getToken();
            $em = $this->container->get('doctrine')->getManager();

            if($this->get('session')->has('agreement')){
                $sessionAgreement = json_decode($this->get('session')->get('agreement'));
                $agreement = $em->getRepository('EcommerceBundle:Agreement')->findOneByPaypalId($sessionAgreement->id);

                if(!$agreement){
                    throw $this->createNotFoundException('Unable to find Agreement entity.');
                }

                $checkoutManager->cleanSession();
                if($agreement instanceof Agreement){
                    return array('agreement_id' => $agreement->getId());
                }
            }else{
                return $this->redirect($this->generateUrl('ecommerce_checkout_detail'));
            }

            //Search 'payment_execute_url' in paymentDetails transaction
            $paymentDetails = json_decode($this->get('session')->get('agreement'));
            foreach ($paymentDetails->links as $link) {
                if($link->rel == 'execute'){
                    $payment_execute_url = $link->href;
                }
            }
           
            $json_resp = $this->call('POST', $payment_execute_url, '{}');
            //Recurring payment_method = paypal (agreement execute)
            if(isset($json_resp['state']) && $json_resp['state'] == 'Active'){
                $agreement->setStatus($json_resp['state']);
                $agreement->setPaypalId($json_resp['id']);
                $agreement->setOutstandingAmount($json_resp['agreement_details']['outstanding_balance']['value']);
                $agreement->setCyclesRemaining($json_resp['agreement_details']['cycles_remaining']);
                $agreement->setNextBillingDate($json_resp['agreement_details']['next_billing_date']);
                $agreement->setFinalPaymentDate($json_resp['agreement_details']['final_payment_date']);
                $agreement->setFailedPaymentCount($json_resp['agreement_details']['failed_payment_count']);
                $em->flush();
            }elseif(isset($json_resp['status']) && $json_resp['status'] == 'error'){
                $agreement->setStatus($json_resp['state']);
                $em->flush();
                throw $this->createNotFoundException('Error on confirmation payment:'. json_encode($json_resp));
            }

            if($agreement instanceof Agreement){
                return array('agreement_id' => $agreement->getId());
            }
        }
        
    }
823237
public function orderConfirmationAction(Request $request, $id)
    {
        $locale = $this->getLocaleManager()->retrieveLocale($this->getUser(), $request->get('locale'));

        $this->get('translator')->setLocale($locale);

        try {
            $orderApiEntity = $this->getOrderManager()->findByIdAndLocale($id, $locale, false);
            $order = $orderApiEntity->getEntity();
        } catch (OrderNotFoundException $exc) {
            throw new OrderNotFoundException($id);
        }

        $pdf = $this->getOrderPdfManager()->createOrderConfirmation($orderApiEntity);

        // Get pdf name with function parameter isSubmitted = true.
        $pdfName = $this->getOrderPdfManager()->getPdfName($order, true);
        $responseType = $this->container->getParameter('sulu_sales_order.pdf_response_type');

        return new Response(
            $pdf,
            200,
            [
                'Content-Type' => 'application/pdf',
                'Content-Disposition' => sprintf('%s; filename="%s"', $responseType, $pdfName),
            ]
        );
    }
1123829
public function resultAction(Request $request)
    {
        try {
            $this
                ->gestpayManager
                ->processResult($request->query->all());
        } catch (PaymentException $e) {
            $this
                ->logger
                ->log(
                    'error',
                    'Gestpay error "'.$e->getMessage(),
                    GestpayMethod::METHOD_NAME
                );
        }

        return new Response('OK');
    }
244956
public function statusUpdateAction(Request $request)
    {
        //Payone always sends status updates in ISO-8859-1. We transform them to utf8.
        $requestParameters = $request->request->all();

        $map = [
            // TransferObject (internal) => POST request (external)
            'key' => 'key',
            'aid' => 'aid',
            'mode' => 'mode',
            'customerid' => null,
            'portalid' => 'portalid',
            'sequencenumber' => 'sequencenumber',
            'txaction' => 'txaction',
            'receivable' => 'receivable',
            'price' => 'price',
            'balance' => 'balance',
            'currency' => 'currency',
            'txid' => 'txid',
            'userid' => 'userid',
            'txtime' => 'txtime',
            'clearingtype' => 'clearingtype',
            'reference' => 'reference',
            'reminderlevel' => 'reminderlevel',
        ];

        $dataArray = [];
        foreach ($map as $transferObjectKey => $postDataKey) {
            if (!isset($requestParameters[$postDataKey])) {
                continue;
            }
            $dataArray[$transferObjectKey] = utf8_encode($requestParameters[$postDataKey]);
        }

        $payoneTransactionStatusUpdateTransfer = new PayoneTransactionStatusUpdateTransfer();
        $payoneTransactionStatusUpdateTransfer->fromArray($dataArray);

        $payoneTransactionStatusUpdateTransfer = $this->getFacade()->processTransactionStatusUpdate($payoneTransactionStatusUpdateTransfer);

        $this->triggerEventsOnSuccess($payoneTransactionStatusUpdateTransfer);

        $callback = function () use ($payoneTransactionStatusUpdateTransfer) {
            echo $payoneTransactionStatusUpdateTransfer->getResponse();
        };

        return $this->streamedResponse($callback);
    }
1245700
public function supportRequestToken(Request $request)
    {
        $clientExist = $request->getUser() && $request->getPassword();
        $oauthParams = $request->get('grant_type') === 'client_credentials';

        return $oauthParams && $clientExist;
    }
934611
public function isValid (Request $request)
		{
			$parsed = $this->parseRouteRequest($request);

			return $this->getBaseUri($request) !== null
				&& preg_match('#^' . preg_quote(rtrim($this->getBaseUri($request), '/'), '#') . '#', rtrim($request->getUri(false), '/'))
				&& $this->getController($request)->respondsTo($parsed['method'], $parsed['arguments']);
		}
1332466
public function developPaymentGatewayAction(Request $request)
    {
        $paymentName = 'foo_bar_gateway';

        $form = $this->createPurchaseForm();
        $form->handleRequest($request);
        if ($form->isValid()) {
            $data = $form->getData();

            $storage = $this->getPayum()->getStorage('Acme\PaymentBundle\Model\PaymentDetails');

            $paymentDetails = $storage->createModel();
            $paymentDetails['amount'] = (float) $data['amount'];
            $paymentDetails['currency'] = $data['currency'];
            $storage->updateModel($paymentDetails);

            $captureToken = $this->getTokenFactory()->createCaptureToken(
                $paymentName,
                $paymentDetails,
                'acme_payment_details_view'
            );

            return $this->redirect($captureToken->getTargetUrl());
        }

        return array(
            'form' => $form->createView()
        );
    }
1093032
public function payment(Request $request)
    {
        $payment = (new Processor($request))->process();

        Session::put('tzsk_payu_data.payment', $payment);

        return redirect()->to(base64_decode($request->callback));
    }
242476
protected function isDonateAlreadyAdded(Request $request)
    {
        /** @var \PServerCore\Entity\Repository\DonateLog $donateEntity */
        $donateEntity = $this->entityManager->getRepository($this->collectionOptions->getEntityOptions()->getDonateLog());

        return $donateEntity->isDonateAlreadyAdded($request->getTransactionId(),
            $this->mapPaymentProvider2DonateType($request));
    }
808764
public function form(Request $request)
    {
        //Renders form payment
        $paymentData = $this->paymentService->setDataFromSession('stripe');
        if (is_array($paymentData)) {
            return $this->render('@c975LPayment/pages/payment.html.twig', $paymentData);
        }

        //No current payment
        return $this->render('@c975LPayment/pages/noPayment.html.twig');
    }
1095475
public function informationsAction(Request $request)
    {
        if (null !== $redirect = $this->validateStep('information')) {
            return $redirect;
        }

        $cart = $this->getCart();

        /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
        $user = $this->getUser();
        if (null !== $user) {
            $cart
                ->setUser($user)
                ->setGender($user->getGender())
                ->setFirstName($user->getFirstName())
                ->setLastName($user->getLastName())
                ->setEmail($user->getEmail())
            ;
        }

        $form = $this->createForm('ekyna_cart_step_information', $cart);

        $form->handleRequest($request);
        if ($form->isValid()) {
            $event = new OrderEvent($cart);
            $this->getDispatcher()->dispatch(OrderEvents::CONTENT_CHANGE, $event);
            if (!$event->isPropagationStopped()) {
                if ($cart->requiresShipment()) {
                    return $this->redirect($this->generateUrl('ekyna_cart_shipment'));
                }
                return $this->redirect($this->generateUrl('ekyna_cart_payment'));
            } else {
                $event->toFlashes($this->getFlashBag());
            }
            return $this->redirect($this->generateUrl('ekyna_cart_informations'));
        }

        return $this->render('EkynaCartBundle:Cart:informations.html.twig', [
            'form' => $form->createView(),
            'cart' => $cart,
         	'user' => $user,
        ]);
    }
325686
public function process(Request $request, Transaction $transaction, Delivery $delivery)
    {
        //UPDATE TRANSACTION
        $em = $this->container->get('doctrine')->getManager();
        $pm = $em->getRepository('EcommerceBundle:PaymentMethod')->findOneBySlug('bank-transfer-test');
        $transaction->setStatus(Transaction::STATUS_PAID);
        $transaction->setPaymentMethod($pm);
        $em->persist($transaction);
        $em->flush();
        //confirmation payment
        $answer = new stdClass();
        $answer->redirectUrl = $this->container->get('router')->generate('ecommerce_checkout_confirmationpayment');

        return $answer;
    }
778385
public function viewAction(Request $request)
    {
        $token = $this->getHttpRequestVerifier()->verify($request);

        $status = new BinaryMaskStatusRequest($token);

        $this->getPayum()->getPayment($token->getPaymentName())->execute($status);

        return array(
            'status' => $status,
        );
    }
221346
public function sendConfirmMail(Request $request)
    {
        if (null === $usrId = $request->query->get('usr_id')) {
            $this->app->abort(400, 'Missing usr_id parameter.');
        }

        $user = $this->getUserRepository()->find((int) $usrId);
        if (!$user instanceof User) {
            $this->app->addFlash('error', $this->app->trans('Invalid link.'));

            return $this->app->redirectPath('homepage');
        }

        try {
            $this->sendAccountUnlockEmail($user, $request);
            $this->app->addFlash('success', $this->app->trans('login::notification: demande de confirmation par mail envoyee'));
        } catch (InvalidArgumentException $e) {
            // todo, log this failure
            $this->app->addFlash('error', $this->app->trans('Unable to send your account unlock email.'));
        }

        return $this->app->redirectPath('homepage');
    }
1338207
public function edit(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Media', 'update')) {
            return $this->noPermission();
        }
        $media = Media::find($request->mediaID);
        $media->title = $request->title;
        $media->description = $request->description;
        $media->credit = $request->credit;

        if ($media->save()) {
            return "OK";
        }
        return "ERR";
    }
723538
public function check(Request $request)
    {
        $this->response = $this->verify($request->input('g-recaptcha-response'), $request->ip());

        return $this;
    }
833995
public function delete(Request $request)
    {
        $this->validate(request(), [//@todo create custom Request class for page validation
            'page_id' => 'required',
        ]);
        
        $status = $this->page->deleteById($request->get('page_id'));
        return $status;
    }