示例#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();
 }
 /**
  * We use the autorize tunnel as it is for a recurring payment
  *
  * payment won't be tracked
  *
  * @param  Intent $intent [description]
  * @return [type] [description]
  */
 public function autorize(Intent $intent)
 {
     if ($intent->getStatus() === Intent::STATUS_NEW) {
         //le payement est immédiatement terminé,
         $intent->setStatus(Intent::STATUS_DONE);
         $intent->setType(Intent::TYPE_RECURING);
         $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_sepa_offline_completed'));
     }
     $response = new Response();
     $response->setStatusCode(500);
     return $response;
 }