/** * traitement réel du paiement * * @param Ecedi\Donate\OgoneBundle\Ogone\Response $response * @return Payment the payment instance */ protected function doHandle(Response $response) { //initialize payment $payment = new Payment(); $payment->setAutorisation($response->getAcceptance())->setTransaction($response->getPayId())->setResponseCode($response->getStatus())->setResponse($response); $normalizer = $this->container->get('donate_ogone.status_normalizer'); $payment->setStatus($normalizer->normalize($response->getStatus())); try { //validate response $this->validate($response); $this->logger->debug('Payment Status : ' . $payment->getStatus()); } catch (UnauthorizedPostSaleException $e) { $this->logger->warning('Incorrectly signed post-sale received'); $payment->setStatus(Payment::STATUS_INVALID); } //add payment to intent try { $intentId = $this->getIntentId($response); $this->logger->debug('found intent id ' . $intentId); } catch (CannotDetermineOrderIdException $e) { $this->logger->warning('CannotDetermineOrderIdException'); $intentId = false; //TODO le payment p-e ok, mais il est orphelin } $this->intentManager->attachPayment($intentId, $payment); return $payment; }
protected function send(Payment $payment) { //si on a pas associé l'intent alors pas d'email if ($payment->getIntent()) { $body = $this->templating->render('DonateFrontBundle:Mail:thanks.txt.twig', array('intent' => $payment->getIntent(), 'payment' => $payment)); $message = \Swift_Message::newInstance()->setSubject($this->translator->trans('Thank you for your generosity'))->setFrom($this->noreply)->setTo($payment->getIntent()->getCustomer()->getEmail())->setBody($body, 'text/html'); $this->mailer->send($message); } }
/** * Handle paybox Response listener * * @param PayboxResponseEvent $event */ public function onPayboxIpnResponse(PayboxResponseEvent $event) { if ($event->isVerified()) { $this->logger->info('Verified Ipn received, payment is stored.'); $ipnData = new IpnData($event->getData()); $payment = new Payment(); $payment->setAutorisation($ipnData->getAuthorisationId())->setTransaction($ipnData->getTransactionId())->setResponseCode($ipnData->getErrorCode())->setResponse($ipnData->getData())->setStatus($this->normalizer->normalize($ipnData->getErrorCode())); // On attache le paiement à l'intent $this->intentManager->attachPayment($ipnData->getIntentId(), $payment); return; } //unverified ipn... we just log it as warning //@TODO do something smartter to keep track of thoses $this->logger->warning('Unverified Ipn received, content is ignored.'); }
public function paymentStatus() { return $this->getOne(Payment::getAllowedStatus()); }
/** * Add payments * * @param \Ecedi\Donate\CoreBundle\Entity\Payment $payments * @return Intent */ public function addPayment(Payment $payments) { $this->payments[] = $payments; $payments->setIntent($this); return $this; }
public function it_should_add_payment_to_intent(Intent $intent, Payment $payment) { $this->intentRepository->find(10)->willReturn($intent); $payment->getStatus()->willReturn(Payment::STATUS_PAYED); $intent->getType()->willReturn(Intent::TYPE_SPOT); $intent->getStatus()->willReturn(Intent::STATUS_PENDING); //on ajoute bien le payment a l'intent $intent->addPayment($payment)->shouldBeCalled(); //on change le status de l'intent $intent->setStatus(Intent::STATUS_DONE)->shouldBeCalled(); $this->attachPayment(10, $payment); //on persist les deux entity $this->manager->persist($intent)->shouldHaveBeenCalled(); $this->manager->persist($payment)->shouldHaveBeenCalled(); }
private static function getRandomPaymentStatus() { return self::getRandomString(Payment::getAllowedStatus()); }