/**
  * {@inheritdoc}
  */
 public function execute(Bank $bank, $amount, $routeName)
 {
     $token = md5(uniqid('mollie_'));
     try {
         $redirectUrl = $this->router->generate($routeName, ['token' => $token], UrlGeneratorInterface::ABSOLUTE_URL);
     } catch (\Exception $exception) {
         throw new IDealExecuteException('Router not configured or does not exist');
     }
     try {
         $payment = $this->mollie->payments->create(['amount' => $amount, 'description' => $this->description, 'redirectUrl' => $redirectUrl, 'method' => Mollie_API_Object_Method::IDEAL, 'issuer' => $bank->getId()]);
         $this->filesystem->dumpFile($this->getFilePath($token), $payment->id);
         $this->eventDispatcher->dispatch(PaymentEvents::PAYMENT_PLACED, new PaymentPlacedEvent(new \DateTime('now'), $amount, $payment->id, $payment->status));
         return new RedirectResponse($payment->getPaymentUrl());
     } catch (\Exception $exception) {
         throw new IDealExecuteException($exception->getMessage());
     }
 }
Exemple #2
0
 public function testBank()
 {
     $bank = new Bank('identifier', 'awesomebank');
     $this->assertSame('identifier', $bank->getId());
     $this->assertSame('awesomebank', $bank->getName());
 }