container->get('net15.payment.mode.manager')->getAll(); // View the list of payment buttons return $this->render('@Payment/Default/home.html.twig',['paymentModeList'=>$paymentModeList]); } /** * @param string $publicKey * @return RedirectResponse */ public function redirectAction(string $publicKey){ $paymentMode = $this->container->get('net15.payment.mode.manager')->getByPublicKey($publicKey); return $this->redirectToRoute($paymentMode->getPaymentType().'_default', ['publicKey'=>$publicKey]); } /** * @param Request $request * @return Response * @throws Exception */ public function testPaymentModeAction(Request $request){ if ($this->getUser()){ $user = $this->getUser(); if (!$user instanceof UserBasketInterface) return null; }else{ $birth_day = new \DateTime('1980-01-20T15:03:01.012345Z'); $user = new User(); $user->setUsername(uniqid('test')); $user->setLastName('berra'); $user->setFirstName('hohahi'); $user->setAddress('26 PLACE DU 8 MAI'); $user->setEmail($this->generate_email(5)); $user->setCity('Aurillac'); $user->setCountry('France'); $user->setCellPhone('06 52 14 45 23'); $user->setPassword('489AZE15$'); $user->setBirthdate($birth_day); $user->setGender(0); $user->setPhone('05 23 65 98 74'); $user->setZipCode('15000'); $user->setCountryCode(250); $manager = $this->getDoctrine()->getManager(); $manager->persist($user); $manager->flush(); } $transaction = $this->container->get('net15.transaction.manager')->create($user); if (!$transaction instanceof Transaction) return null; $product = new TransactionProduct(); $product->setLabel('ProductX'); $product->setPrice(400); $basketLine = new BasketLine(); $basketLine->setDefault($product); $basketLine->setQuantity(1); $transaction = $this->container->get('net15.transaction.manager')->addBasketLine($transaction, $basketLine); // Stored the transaction in session $request->getSession()->set('transactionPK', $transaction->getPublicKey()); $paymentModeList = $this->container->get('net15.payment.mode.manager')->getAll(); // View the list of payment buttons return $this->render('@Payment/Default/home.html.twig',['paymentModeList'=>$paymentModeList]); } public function generate_email($lenght){ $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $str = ''; $max = mb_strlen($characters, '8bit')-1; for ($i = 0; $i < $lenght; ++$i){ $str .= $characters[random_int(0, $max)]; } return $str . '@gmail.com'; } }