protected function execute(InputInterface $input, OutputInterface $output) { $this->getContainer()->get("sinenco_allopass_api.init"); //$allopass = AllopassApiConf::getInstance(); $em = $this->getContainer()->get('doctrine')->getManager(); $pricepoints = $em->getRepository('SinencoAllopassPaymentBundle:PricePoint')->findAll(); foreach ($pricepoints as $pricepoint) { $em->remove($pricepoint); } $em->flush(); $api = new AllopassAPI(); $response = $api->getOnetimePricing(array('site_id' => $this->getContainer()->getParameter("allopass_payment.site_id"))); $i = 1; foreach ($response->getMarkets() as $market) { foreach ($market->getPricepoints() as $AllopassPricePoint) { $PricePoint = new PricePoint(); $PricePoint->setId($i++); $PricePoint->setPriceId($AllopassPricePoint->getId()); $PricePoint->setType($AllopassPricePoint->getType()); $PricePoint->setCategory($AllopassPricePoint->getCategory()); $PricePoint->setCountry($AllopassPricePoint->getCountryCode()); $PricePoint->setPriceAmount($AllopassPricePoint->getPrice()->getAmount()); $PricePoint->setPriceCurrency($AllopassPricePoint->getPrice()->getCurrency()); $PricePoint->setPayoutAmount($AllopassPricePoint->getPayout()->getAmount()); $PricePoint->setPayoutCurrency($AllopassPricePoint->getPayout()->getCurrency()); $em->persist($PricePoint); } } $em->flush(); $output->writeln("PricePoint Updated"); }
public function callbackAction() { $transaction_id = $_GET['transaction_id']; $this->get("sinenco_allopass_api.init"); $api = new AllopassAPI(); $response = $api->getTransaction($transaction_id); $AllopassTransaction = $response; if ($AllopassTransaction->getStatusDescription() == "success") { $em = $this->getDoctrine()->getManager(); $repository = $em->getRepository("SinencoAllopassPaymentBundle:Transaction"); $transaction = $repository->findOneBy(array("transaction_id" => $transaction_id)); if ($transaction == NULL) { $transaction = new Transaction(); $transaction->setTransactionId($AllopassTransaction->getTransactionId()); $transaction->setPriceAmount($AllopassTransaction->getPrice()->getAmount()); $transaction->setPriceCurrency($AllopassTransaction->getPrice()->getCurrency()); $datetime = new \DateTime(); $datetime->setTimestamp($AllopassTransaction->getCreationDate()->getTimestamp()); $transaction->setCreationDate($datetime); $transaction->setPayoutAmount($_GET["payout_amount"]); $transaction->setPayoutCurrency($_GET["payout_currency"]); $transaction->setData($_GET['data']); $em->persist($transaction); $em->flush(); $first_time = true; } else { $first_time = false; } $event = new AllopassPaymentCallbackEvent($transaction, $first_time); $this->container->get('event_dispatcher')->dispatch(AllopassPaymentCoreEvents::onAllopassPaymentCallback, $event); } return new Response(); }