/**
  * @View()
  * @Route("/payment/done", name="app_payment_done")
  * @param Request $request
  * @return JsonResponse
  */
 public function paymentDoneAction(Request $request)
 {
     $token = $this->get('payum.security.http_request_verifier')->verify($request);
     $identity = $token->getDetails();
     $model = $this->get('payum')->getStorage($identity->getClass())->find($identity);
     $gateway = $this->get('payum')->getGateway($token->getGatewayName());
     // or Payum can fetch the model for you while executing a request (Preferred).
     $gateway->execute($status = new GetHumanStatus($token));
     $payment = $status->getFirstModel();
     $paymentSuccess = false;
     $mailSent = false;
     $order = null;
     if ($status->isAuthorized()) {
         $entityManager = $this->getDoctrine()->getEntityManager();
         $order = $entityManager->getRepository('AppBundle:TicketsOrder')->find($payment->getOrderId());
         $order->setValidate(true);
         $entityManager->flush();
         $ticketsSender = $this->get('app.tickets_sender');
         try {
             $ticketsSender->sendTickets($order);
             $mailSent = true;
         } catch (\Swift_TransportException $e) {
             // the mail is not sent
         }
         $paymentSuccess = true;
     }
     return array('paymentSuccess' => $paymentSuccess, 'mailSent' => $mailSent, 'order' => $order);
 }
 /**
  * @Route("/donePayment", name="payment_done" )
  */
 public function doneAction(Request $request)
 {
     $token = $this->get('payum.security.http_request_verifier')->verify($request);
     $gateway = $this->get('payum')->getGateway($token->getGatewayName());
     // you can invalidate the token. The url could not be requested any more.
     // $this->get('payum.security.http_request_verifier')->invalidate($token);
     // Once you have token you can get the model from the storage directly.
     //$identity = $token->getDetails();
     //$payment = $payum->getStorage($identity->getClass())->find($identity);
     // or Payum can fetch the model for you while executing a request (Preferred).
     $gateway->execute($status = new GetHumanStatus($token));
     $payment = $status->getFirstModel();
     // you have order and payment status
     // so you can do whatever you want for example you can just print status and payment details.
     if ($status->getValue() === "pending" || $status->getValue() === "success" || $status->getValue() === "captured") {
         $em = $this->getDoctrine()->getManager();
         $usr = $this->get('security.context')->getToken()->getUser()->getUser();
         $usr->setPremium(true);
         $em->persist($usr);
         $em->flush();
         return $this->redirect($this->generateUrl('profile'));
     } else {
         //var_dump($status->getValue());
         return $this->redirect($this->generateUrl('get_premium'));
     }
 }
Exemplo n.º 3
0
 public function verifyRequest(VerifyRequestCommand $command)
 {
     $token = $this->requestVerifier->verify($command->getRequest());
     $gateway = $this->registry->getGateway($token->getGatewayName());
     $gateway->execute($status = new GetHumanStatus($token));
     $payment = $status->getFirstModel();
     $this->requestVerifier->invalidate($token);
     $event = new RequestVerifiedEvent($status, $payment);
     $this->eventBus->handle($event);
 }
 public function done($payum_token)
 {
     /** @var Request $request */
     $request = \App::make('request');
     $request->attributes->set('payum_token', $payum_token);
     $token = $this->getHttpRequestVerifier()->verify($request);
     $payment = $this->getPayum()->getPayment($token->getPaymentName());
     $payment->execute($status = new GetHumanStatus($token));
     return \Response::json(array('status' => $status->getValue(), 'details' => iterator_to_array($status->getFirstModel())));
 }
 public function viewOrderAction(Request $request)
 {
     $token = $this->getHttpRequestVerifier()->verify($request);
     $gateway = $this->getPayum()->getGateway($token->getGatewayName());
     try {
         $gateway->execute(new Sync($token));
     } catch (RequestNotSupportedException $e) {
     }
     $gateway->execute($status = new GetHumanStatus($token));
     /** @var PaymentInterface $payment */
     $payment = $status->getFirstModel();
     return $this->render('AcmePaymentBundle:Details:viewOrder.html.twig', array('status' => $status->getValue(), 'payment' => htmlspecialchars(json_encode(array('client' => array('id' => $payment->getClientId(), 'email' => $payment->getClientEmail()), 'number' => $payment->getNumber(), 'description' => $payment->getCurrencyCode(), 'total_amount' => $payment->getTotalAmount(), 'currency_code' => $payment->getCurrencyCode(), 'details' => $payment->getDetails()), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)), 'gatewayTitle' => ucwords(str_replace(array('_', '-'), ' ', $token->getGatewayName()))));
 }
Exemplo n.º 6
0
 public function doneAction(Request $request)
 {
     $storage = $this->get('payum')->getStorage('challenge\\PaymentBundle\\Entity\\Orders');
     $em = $this->getDoctrine()->getManager();
     $token = $this->get('payum.security.http_request_verifier')->verify($request);
     $payment = $this->get('payum')->getGateway($token->getGatewayName());
     $payment->execute($status = new GetHumanStatus($token));
     if ($status->isCaptured()) {
         $order = $status->getFirstModel();
         $order->setPayer(true);
         $storage->update($order);
     }
     return $this->redirect($this->generateUrl('user_lobby_acheter'));
 }
Exemplo n.º 7
0
 public function done(Request $request, $payum_token)
 {
     $request->attributes->set('payum_token', $payum_token);
     $token = $this->getPayum()->getHttpRequestVerifier()->verify($request);
     $gateway = $this->getPayum()->getGateway($token->getGatewayName());
     $gateway->execute($status = new GetHumanStatus($token));
     $status_txt = $status->getValue();
     $details = iterator_to_array($status->getFirstModel());
     if ($status_txt == "captured") {
         if ($details['approved'] == true && $details['declined'] == false) {
             $request->session()->put("payment_data", serialize($details));
             return redirect()->route("cart_done");
         } else {
             return redirect()->route("cart")->with("error", "Payment error , validation error ");
         }
     } else {
         return redirect()->route("cart")->with("error", "Payment error , statut not captured " . $status_txt);
     }
 }
Exemplo n.º 8
0
 /**
  * @Security("has_role('ROLE_STUDENT')")
  */
 public function paymentDoneAction(Request $request)
 {
     $token = $this->get('payum.security.http_request_verifier')->verify($request);
     $identity = $token->getDetails();
     $model = $this->get('payum')->getStorage($identity->getClass())->find($identity);
     $gateway = $this->get('payum')->getGateway($token->getGatewayName());
     // you can invalidate the token. The url could not be requested any more.
     // $this->get('payum.security.http_request_verifier')->invalidate($token);
     // Once you have token you can get the model from the storage directly.
     //$identity = $token->getDetails();
     //$details = $payum->getStorage($identity->getClass())->find($identity);
     // or Payum can fetch the model for you while executing a request (Preferred).
     $gateway->execute($status = new GetHumanStatus($token));
     $details = $status->getFirstModel();
     // you have order and payment status
     // so you can do whatever you want for example you can just print status and payment details.
     if ($status->isAuthorized() || $status->isCaptured()) {
         $request->getSession()->getFlashBag()->add('success', 'offer.flash.canceled');
     }
     return new JsonResponse(array('status' => $status->getValue(), 'details' => iterator_to_array($details)));
 }
Exemplo n.º 9
0
 /**
  * done.
  *
  * @method done
  *
  * @param \Illuminate\Http\Request $request
  * @param string                   $payumToken
  * @param callable                 $closure
  *
  * @return mixed
  */
 public function done(Request $request, $payumToken, callable $closure)
 {
     return $this->send($request, $payumToken, function ($gateway, $token, $httpRequestVerifier) use($closure) {
         $gateway->execute($status = new GetHumanStatus($token));
         $payment = $status->getFirstModel();
         return $closure($status, $payment, $gateway, $token, $httpRequestVerifier);
     });
 }
Exemplo n.º 10
0
 public function doneAction(Request $request)
 {
     $token = $this->get('payum.security.http_request_verifier')->verify($request);
     $identity = $token->getDetails();
     $model = $this->get('payum')->getStorage($identity->getClass())->find($identity);
     $gateway = $this->get('payum')->getGateway($token->getGatewayName());
     // you can invalidate the token. The url could not be requested any more.
     // $this->get('payum.security.http_request_verifier')->invalidate($token);
     // Once you have token you can get the model from the storage directly.
     //$identity = $token->getDetails();
     //$details = $payum->getStorage($identity->getClass())->find($identity);
     // or Payum can fetch the model for you while executing a request (Preferred).
     $gateway->execute($status = new GetHumanStatus($token));
     $details = $status->getFirstModel();
     if ($status == true) {
         // Validation email
         $message = \Swift_Message::newInstance()->setSubject('Validation de votre commande')->setFrom(array('*****@*****.**' => 'Apx Trade'))->setTo($this->container->get('security.context')->getToken()->getUser()->getEmailCanonical())->setCharset('utf-8')->setContentType('text/html')->setBody($this->renderView('EcommerceBundle:Default:SwiftLayout/validationOrder.html.twig', array('user' => $this->container->get('security.context')->getToken()->getUser())));
         $this->get('mailer')->send($message);
         $this->get('session')->getFlashBag()->add('success', 'Votre commande est valider avec success');
         return $this->redirect($this->generateUrl('invoices'));
     }
     $this->get('session')->getFlashBag()->add('warning', 'Une erreur est survenue lors du paiement');
     return $this->redirect($this->generateUrl('cart'));
     // you have order and payment status
     // so you can do whatever you want for example you can just print status and payment details.
     //return new JsonResponse(array(
     //    'status' => $status->getValue(),
     //    'details' => iterator_to_array($details),
     //));
 }
Exemplo n.º 11
0
<?php

require '../vendor/autoload.php';
require 'config.php';
use Payum\Core\Request\GetHumanStatus;
$token = $requestVerifier->verify($_REQUEST);
$payment = $payum->getPayment($token->getPaymentName());
// you can invalidate the token. The url could not be requested any more.
// $requestVerifier->invalidate($token);
// Once you have token you can get the model from the storage directly.
//$identity = $token->getDetails();
//$order = $payum->getStorage($identity->getClass())->find($identity);
// or Payum can fetch the model for you while executing a request (Preferred).
$payment->execute($status = new GetHumanStatus($token));
$order = $status->getFirstModel();
header('Content-Type: application/json');
print_r(array('status' => $status->getValue(), 'order' => array('total_amount' => $order->getTotalAmount(), 'currency_code' => $order->getCurrencyCode(), 'details' => $order->getDetails())));
Exemplo n.º 12
0
<?php

// done.php
include_once __DIR__ . '/config.php';
use Payum\Core\Request\GetHumanStatus;
use Payum\Core\Security\TokenInterface;
/**
 * @var TokenInterface
 */
$token = $payum->getHttpRequestVerifier()->verify($_REQUEST);
$gateway = $payum->getGateway($token->getGatewayName());
$gateway->execute($status = new GetHumanStatus($token));
$payment = $status->getFirstModel();
header('Content-Type: application/json');
echo json_encode(array('status' => $status->getValue(), 'order' => array('total_amount' => $payment->getTotalAmount(), 'currency_code' => $payment->getCurrencyCode(), 'details' => $payment->getDetails())));
Exemplo n.º 13
0
 /**
  * @Route("/payment/done", name="done")
  */
 public function doneAction(Request $request)
 {
     $token = $this->get('payum.security.http_request_verifier')->verify($request);
     $gateway = $this->get('payum')->getGateway($token->getGatewayName());
     // Once you have token you can get the model from the storage directly.
     //$identity = $token->getDetails();
     //$payment = $payum->getStorage($identity->getClass())->find($identity);
     // or Payum can fetch the model for you while executing a request (Preferred).
     $gateway->execute($status = new GetHumanStatus($token));
     $payment = $status->getFirstModel();
     //invalidate the token. The url cannot be requested any more.
     $this->get('payum.security.http_request_verifier')->invalidate($token);
     //if payment is successful
     if ($status->isCaptured()) {
         $manager = $this->get('oneup_uploader.orphanage_manager')->get('gallery');
         if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
             throw $this->createAccessDeniedException();
         }
         $logger = $this->get('logger');
         try {
             $originalNames = $this->renameFiles();
             $files = $manager->uploadFiles();
             $files = $this->stampFiles($files);
             $protectedFiles = array();
             foreach ($files as $file) {
                 $protected = new ProtectedFile();
                 $protected->setUserID($this->getUser()->getId());
                 $protected->setFileName($file->getFilename());
                 $protected->setOriginalName($originalNames[pathinfo($file->getFilename(), PATHINFO_FILENAME)]);
                 $protected->setExtension($file->getExtension());
                 $protected->setDateProtected(new \DateTime('now'));
                 $protected->setRegistrationNumber(pathinfo($file->getFilename(), PATHINFO_FILENAME));
                 $protected->setFile($file);
                 $em = $this->getDoctrine()->getManager();
                 $em->persist($protected);
                 $em->flush();
                 $protectedFiles[] = $protected;
             }
             //send certification email
             $this->get('email.sender')->sendCertificationEmail($protectedFiles);
             $response = $this->render('payment/success.html.twig');
         } catch (\Exception $e) {
             $logger->critical($e->getMessage());
             $response = $this->render('payment/unsuccess.html.twig');
         }
     } else {
         $response = $this->render('payment/unsuccess.html.twig');
     }
     //after 3 seconds redirect to user's profile
     $response->headers->set('Refresh', '3; ' . $this->get('router')->generate('fos_user_profile_show'));
     return $response;
     //to be used for debugging purposes
     /*return new JsonResponse(array(
           'status' => $status->getValue(),
           'payment' => array(
               'total_amount' => $payment->getTotalAmount(),
               'currency_code' => $payment->getCurrencyCode(),
               'details' => $payment->getDetails(),
           ),
       ));*/
 }