/**
  * @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'));
     }
 }
 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())));
 }
Exemplo n.º 3
0
 protected function _actionDone(KControllerContextInterface $context)
 {
     $token = $this->getHttpRequestVerifier()->verify($context->getRequest()->getQuery()->toArray());
     $identity = $token->getDetails();
     $model = $this->getPayum()->getStorage($identity->getClass())->find($identity);
     $this->setGateway($token->getGatewayName());
     $gateway = $this->getPayum()->getGateway($token->getGatewayName());
     $gateway->execute($status = new GetHumanStatus($model));
     $context->params = array('status' => $status, 'token' => $token);
     $this->getHttpRequestVerifier()->invalidate($token);
     $this->execute($status->getValue(), $context);
 }
 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.º 5
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);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function onPostExecute(Context $context)
 {
     if ($context->getPrevious()) {
         return;
     }
     /** @var Generic $request */
     $request = $context->getRequest();
     if (false == $request instanceof Generic) {
         return;
     }
     if ($request instanceof GetStatusInterface) {
         return;
     }
     if ($request->getFirstModel() instanceof Payment) {
         /** @var Payment $payment */
         $payment = $request->getFirstModel();
         $context->getGateway()->execute($status = new GetHumanStatus($payment));
         $payment->setStatus($status->getValue());
     }
 }
Exemplo n.º 7
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.º 8
0
 /**
  * @test
  * 
  * @dataProvider provideMarkXXXMethods
  */
 public function shouldAllowGetMarkedStatus($markXXXMethod)
 {
     $statusRequest = new GetHumanStatus(new \stdClass());
     $statusRequest->{$markXXXMethod}();
     $this->assertNotEmpty($statusRequest->getValue());
 }
Exemplo n.º 9
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.º 10
0
 /**
  * Offline Payment done
  */
 public function doneOfflineAction(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 = $this->get('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));
     $orderManager = $this->get('hecommerce.order.manager');
     $order = $orderManager->loadOrderForConnectedUser();
     $paymentMethod = $this->get('hecommerce.paymentmethod.manager')->loadByName('offline');
     //$payment = $status->getFirstModel();
     if ($status->getValue() == 'captured') {
         //$order->setPaymentDate(new \DateTime());
         $order->setPaymentMethod($paymentMethod);
         $order->setPaymentDetails($payment);
         $orderManager->save($order);
         try {
             $confirmationEmailManager = $this->get('hecommerce.confirmationemail.manager');
             $confirmationEmail = $confirmationEmailManager->create();
             $confirmationEmail->setOrder($order);
             $confirmationEmail->setSendAt();
             $confirmationEmailManager->save($confirmationEmail);
             throw new Exception('Some Error Message');
         } catch (\Exception $e) {
             //send an email to the admin
             //var_dump($e->getMessage());
         }
         return $this->render('HeadooEcommerceBundle:Store:confirmation.html.twig');
     } else {
         return $this->render('HeadooEcommerceBundle:Store:fail.html.twig');
     }
 }
Exemplo n.º 11
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.º 12
0
 public function doneAction()
 {
     //error_reporting(E_ALL);
     //ini_set('display_errors', 1);
     $token = $this->getServiceLocator()->get('payum.security.http_request_verifier')->verify($this);
     $gateway = $this->getServiceLocator()->get('payum')->getGateway($token->getGatewayName());
     $gateway->execute($status = new GetHumanStatus($token));
     //return new JsonModel(array('status' => $status->getValue()) + iterator_to_array($status->getModel()));
     if ($status->getValue() == "captured") {
         $order = new Container('order');
         //create transaction sucessfull
         $transaction = new Transaction();
         $transaction->setData(['intrans_no' => "", 'fapiao_no' => "", 'total' => round($order->offsetGet('total'), 2), 'subtotal' => round($order->offsetGet('total'), 2), 'fee' => 0, 'bank' => $this->getReference('Admin\\Entity\\ProfileBank', 1), 'is_deleted' => 0, 'client' => $this->getReference('User\\Entity\\User', $order->offsetGet('client')), 'payDate' => new \DateTime('NOW'), 'createDate' => new \DateTime('NOW'), 'typeStatus' => 1, 'currency' => $order->offsetGet('currency'), 'items' => $data['items'] ? $data['items'] : null]);
         $transaction->save($this->getEntityManager());
         //update status project to pay
         $project = $this->find('\\User\\Entity\\Project', $order->offsetGet('project'));
         $project->setData(['payStatus' => 2]);
         $project->save($this->getEntityManager());
         //go to sucessful page
         return new ViewModel(['success' => true, 'total' => round($order->offsetGet('total'), 2), 'currency' => $order->offsetGet('currency'), 'project_no' => $order->offsetGet('project_no'), 'project' => $order->offsetGet('project')]);
     } else {
         //go to fail page
         return new ViewModel(['success' => false]);
     }
 }