/** * {@inheritdoc} */ public function sendConfirmationReceipt(TransactionInterface $transaction) { $parameters = $transaction->getParameters(); if (!array_key_exists('action', $parameters)) { throw new \RuntimeException('"action" parameter is missing from Transaction.'); } switch ($parameters['action']) { case 'accept': $transaction->setState(TransactionInterface::STATE_OK); $transaction->setStatusCode(TransactionInterface::STATUS_VALIDATED); $transaction->getOrder()->setValidatedAt(new \DateTime()); $transaction->getOrder()->setStatus(OrderInterface::STATUS_VALIDATED); $transaction->getOrder()->setPaymentStatus(TransactionInterface::STATUS_VALIDATED); return new Response('ok', 200, array('Content-Type' => 'text/plain')); case 'refuse': $transaction->setState(TransactionInterface::STATE_KO); $transaction->setStatusCode(TransactionInterface::STATUS_ERROR_VALIDATION); return false; default: $transaction->setState(TransactionInterface::STATE_KO); $transaction->setStatusCode(TransactionInterface::STATUS_ERROR_VALIDATION); return false; } }
/** * {@inheritdoc} */ public function sendConfirmationReceipt(TransactionInterface $transaction) { $transaction->setState(TransactionInterface::STATE_OK); $transaction->setStatusCode(TransactionInterface::STATUS_VALIDATED); $transaction->getOrder()->setValidatedAt(new \DateTime()); $transaction->getOrder()->setStatus(OrderInterface::STATUS_VALIDATED); $transaction->getOrder()->setPaymentStatus(TransactionInterface::STATUS_VALIDATED); return new RedirectResponse($this->router->generate($this->getOption('url_return_ok'), $transaction->getParameters())); }
/** * {@inheritdoc} */ public function sendConfirmationReceipt(TransactionInterface $transaction) { if (!$transaction->isValid()) { return new \Symfony\Component\HttpFoundation\Response(''); } $params = $transaction->getParameters(); $params['cmd'] = '_notify-validate'; //$this->getLogger()-> // retrieve the client $client = $this->getWebConnectorProvider()->getNamedClient($this->getOption('web_connector_name', 'default')); $client->request('POST', $this->getOption('url_action'), $params); if ($client->getResponse()->getContent() == 'VERIFIED') { $transaction->setState(TransactionInterface::STATE_OK); $transaction->setStatusCode(TransactionInterface::STATUS_VALIDATED); $transaction->getOrder()->setValidatedAt(new \DateTime()); $transaction->getOrder()->setStatus(OrderInterface::STATUS_VALIDATED); $transaction->getOrder()->setPaymentStatus(TransactionInterface::STATUS_VALIDATED); } else { $transaction->setState(TransactionInterface::STATE_KO); $transaction->setStatusCode(TransactionInterface::STATUS_ERROR_VALIDATION); // TODO error in status -> setting payment status to an order status value $transaction->getOrder()->setPaymentStatus(OrderInterface::STATUS_ERROR); if ($this->getLogger()) { $this->getLogger()->emergency('[Paypal::sendAccuseReception] Paypal failed to check the postback'); } } return new \Symfony\Component\HttpFoundation\Response(''); }