public function let(Intent $intent)
 {
     $intent->getCreatedAt()->willReturn(new \DateTime('2014-12-22'));
     $intent->getId()->willReturn(144);
     $this->intent = $intent;
     $this->beConstructedWith(self::PREFIX);
 }
 public function it_should_not_create_pdf_document_already_created(PdfDocument $doc)
 {
     $this->intent->getPaymentMethod()->willReturn(SepaOfflinePaymentMethod::ID);
     $this->event->getDocument()->willReturn($doc);
     $this->event->setDocument(Argument::Type('ZendPdf\\PdfDocument'))->shouldNotBeCalled();
     $this->event->stopPropagation()->shouldNotBeCalled();
     $this->generate($this->event);
 }
 public function it_should_handle_pay(Intent $intent)
 {
     $intent->getStatus()->willReturn(Intent::STATUS_NEW);
     $intent->getId()->willReturn(666);
     $this->em->persist($intent)->shouldBeCalled();
     $this->em->flush()->shouldBeCalled();
     $intent->setStatus('done')->shouldBeCalled();
     $resp = $this->pay($intent)->shouldHaveType('Symfony\\Component\\HttpFoundation\\Response');
 }
Example #4
0
 /**
  * @Route("/intent/{id}/show" , name="donate_admin_reporting_intent_show", defaults={"id" = 0})
  */
 public function intentShowAction(Request $request, Intent $intent)
 {
     $customerId = $intent->getCustomer()->getId();
     $entityMgr = $this->getDoctrine()->getManager();
     $paymentsQuery = $entityMgr->getRepository('DonateCoreBundle:Payment')->getPaymentsListByIntent(['intentId' => $intent->getId()]);
     $otherIntentsQuery = $entityMgr->getRepository('DonateCoreBundle:Intent')->getIntentsListByCustomer(['customerId' => $customerId], 5, $intent->getId());
     $otherIntents = $otherIntentsQuery->getResult();
     $pagination = $this->getPagination($request, $paymentsQuery, 12);
     return $this->render('DonateAdminBundle:Reporting:intentShow.html.twig', ['intent' => $intent, 'pagination' => $pagination, 'customerOtherIntents' => $otherIntents]);
 }
Example #5
0
 /**
  * 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;
 }
Example #7
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();
 }
Example #8
0
 /**
  * En cache pour 1h
  */
 public function statsIntentsAction()
 {
     $response = new Response();
     $response->setPublic();
     $response->setSharedMaxAge(3600);
     $ir = $this->getDoctrine()->getManager()->getRepository('DonateCoreBundle:Intent');
     $stats = [];
     foreach (Intent::getPossibleStatus() as $status) {
         $stats[$status] = $ir->getCountByStatus($status);
     }
     return $this->render('DonateAdminBundle:Dashboard:statsIntents.html.twig', ['id' => 'stats-intents', 'title' => $this->get('translator')->trans('Donations distributions'), 'stats' => $stats], $response);
 }
Example #9
0
 public function intentType()
 {
     return $this->getOne(Intent::getTypes());
 }
 /**
  * @{inheritdoc}
  * Generate RUM from a KEY + a MD5sum
  */
 public function generate(Intent $intent)
 {
     //CODECLIENT-WEB-YYYY-MM-DD-ORDERID
     $rum = $this->prefix . '-WEB-' . $intent->getCreatedAt()->format('Y-m-d') . '-' . $intent->getId();
     return strtoupper(str_pad($rum, 35, ' ', STR_PAD_LEFT));
 }
Example #11
0
 /**
  * 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;
 }
Example #12
0
 public function addIntent(Intent $intent)
 {
     $this->intents[] = $intent;
     $intent->setCustomer($this);
     return $this;
 }
Example #13
0
 /**
  * {@inheritdoc}
  * @since 2.4 flip keys and values and add choices_as_values option
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $types = array_flip(Intent::getTypesLabel());
     $status = array_flip(Intent::getStatusLabel());
     $builder->add('type', 'choice', array('label' => 'Donation types', 'choices' => $types, 'required' => true, 'multiple' => true, 'expanded' => true, 'data' => array_values($types), 'translation_domain' => 'forms', 'choices_as_values' => true))->add('status', 'choice', array('label' => 'Status', 'choices' => $status, 'required' => true, 'multiple' => true, 'expanded' => true, 'data' => array_values($status), 'choices_as_values' => true))->add('email', 'text', array('label' => "Email", 'required' => false))->add('minAmount', 'text', array('label' => "Min amount", 'required' => false))->add('maxAmount', 'text', array('label' => "Max amount", 'required' => false))->add('minCreatedAt', 'date', array('label' => 'Donation submitted', 'input' => 'datetime', 'widget' => 'single_text', 'format' => "dd/MM/yyyy", 'required' => false))->add('maxCreatedAt', 'date', array('input' => 'datetime', 'widget' => 'single_text', 'format' => "dd/MM/yyyy", 'required' => false))->add('submit_filter', 'submit', array('label' => 'Filter'))->add('submit_export', 'submit', array('label' => 'Export'));
 }
 public function it_should_persist_payment_if_no_intent(Intent $intent, Payment $payment)
 {
     //on ajoute bien le payment a l'intent
     $intent->addPayment($payment)->shouldNotBeCalled();
     $payment->setIntent($intent)->shouldNotBeCalled();
     $payment->getStatus()->willReturn(Payment::STATUS_PAYED);
     //on change le status de l'intent
     $intent->setStatus(Intent::STATUS_DONE)->shouldNotBeCalled();
     $this->attachPayment(false, $payment);
     //on persist les deux entity
     $this->manager->persist($payment)->shouldHaveBeenCalled();
 }
Example #15
0
 /**
  * Génère un numéro de commande Ogone à partir de l'IntentId
  * @param  Ecedi\Donate\CoreBundle\Entity\Intent $intent
  * @return string
  */
 protected function orderId(Intent $intent)
 {
     return $this->container->getParameter('donate_ogone.prefix') . '-' . $intent->getId();
 }