Beispiel #1
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();
 }
 /**
  * return anything that can be managed as a response
  */
 public function pay(Intent $intent)
 {
     if ($intent->getStatus() === Intent::STATUS_NEW) {
         $intent->setStatus(Intent::STATUS_PENDING);
         $entityMgr = $this->getDoctrine()->getManager();
         $entityMgr->persist($intent);
         $entityMgr->flush();
         return new RedirectResponse($this->getRouter()->generate('donate_ogone_pay'));
     }
     return new Response('', 500);
 }
 public function pay(Intent $intent)
 {
     if ($intent->getStatus() === Intent::STATUS_NEW) {
         //le payement est immédiatement terminé,
         $intent->setStatus(Intent::STATUS_DONE);
         $em = $this->doctrine->getManager();
         //TODO should we dispatch an event or something?
         $em->persist($intent);
         $em->flush();
         return new RedirectResponse($this->router->generate('donate_payment_check_promise_completed'));
     }
     $response = new Response();
     $response->setStatusCode(500);
     return $response;
 }
 /**
  * Set status as pending
  * @since  1.0.0
  * @todo  should not flush here, flush should be in controller
  * @todo  i'm not even sure this method should stay, should probably move to entity class
  * @param  Intent an intent
  * @return current object for chainability
  * @deprecated Deprecated since version 2.2.0, to be removed in 2.4.0. Use $intent->setStatus(Intent::STATUS_PENDING) directly instead.
  */
 public function pending(Intent $intent)
 {
     $intent->setStatus(Intent::STATUS_PENDING);
     $em = $this->getDoctrine()->getManager();
     $em->persist($intent);
     $em->flush();
     trigger_error('pending() is deprecated since version 2.2.0, to be removed in 2.4.0. Use $intent->setStatus(Intent::STATUS_PENDING) directly instead.', E_USER_DEPRECATED);
     return $this;
 }