/**
  * @expectedException \Usoft\IDealBundle\Exceptions\IDealExecuteException
  *
  * @throws \Usoft\IDealBundle\Exceptions\IDealExecuteException
  */
 public function testExecuteException()
 {
     $this->router->expects($this->once())->method('generate')->with('confirm_route')->willReturn('http://www.awesome-app.com/foo/bar?token=foobar');
     $this->mollieAPIClient->payments = $this->payments;
     $this->bank->expects($this->once())->method('getId')->willReturn(666);
     $this->payments->expects($this->once())->method('create')->with(["amount" => 12.43, "description" => 'awesome test', "redirectUrl" => 'http://www.awesome-app.com/foo/bar?token=foobar', "method" => Mollie_API_Object_Method::IDEAL, "issuer" => 666])->willThrowException(new \Exception());
     $this->eventDispatcher->expects($this->never())->method('dispatch');
     $this->mollieDriver->execute($this->bank, 12.43, 'confirm_route');
 }
 /**
  * {@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 #3
0
 public function testBank()
 {
     $bank = new Bank('identifier', 'awesomebank');
     $this->assertSame('identifier', $bank->getId());
     $this->assertSame('awesomebank', $bank->getName());
 }