Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     ini_set('memory_limit', '2048M');
     for ($i = 1; $i <= 6000; $i++) {
         $customer = new Customer();
         $customer->setCreatedAt(self::getRandomDate());
         $customer->setFirstName(self::getRandomFirstname());
         $customer->setLastName(self::getRandomLastname());
         $customer->setCivility(self::getRandomCivility());
         $customer->setEmail(self::getRandomEmail($customer->getLastName()));
         $customer->setAddressStreet(self::getRandomAddressStreet());
         $customer->setBirthday(self::getRandomDate());
         $customer->setPhone(self::getRandomPhone());
         $customer->setCompany(self::getRandomCompany());
         $customer->setRemoteId(self::getRandomRemoteId());
         $customer->setWebsite(self::getRandomWebsite());
         $customer->setAddressZipcode(self::getRandomZipCode());
         $customer->setAddressCity(self::getRandomCity());
         $customer->setAddressCountry(self::getRandomCountry());
         $CustomerOgoneID = $customer->getLastName() . '_OGONE_' . self::getRandomRemoteId();
         $manager->persist($customer);
         $jmax = rand(1, 3);
         $j = 1;
         if ($i % 1000 == 0) {
             $manager->flush();
         }
         for ($j = 1; $j <= $jmax; $j++) {
             $amount = self::getRandomAmount();
             $paymentMethod = self::getRandomPaymentMethod();
             $campaign = self::getRandomCampaign();
             $intent = new Intent($amount, $paymentMethod, 'EUR', $campaign);
             $intent->setCustomer($customer);
             $intent->setCreatedAt(self::getRandomDate());
             $intent->setType(self::getRandomType());
             $intent->setStatus(self::getRandomStatus());
             $intent->setFiscalReceipt(self::getRandomFiscalReceipt());
             $manager->persist($intent);
             $pmax = 1;
             if ($intent->getType() == Intent::TYPE_RECURING) {
                 $pmax = rand(1, 15);
             }
             for ($p = 1; $p <= $pmax; $p++) {
                 $payment = new Payment();
                 $payment->setIntent($intent);
                 if ($pmax == 1 && $p == $pmax) {
                     $payment->setStatus(self::getRandomPaymentStatus());
                 } else {
                     $payment->setStatus(Payment::STATUS_PAYED);
                 }
                 $payment->setAlias($CustomerOgoneID);
                 $payment->setTransaction(self::getRandomTransactionId());
                 $payment->setAutorisation(self::getRandomAutorisationId());
                 $manager->persist($payment);
             }
         }
     }
     $manager->flush();
 }
Esempio n. 3
0
 /**
  * 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.');
 }