public function testFetchTransaction()
 {
     $request = $this->gateway->fetchTransaction(array('apiKey' => 'key', 'transactionReference' => 'tr_Qzin4iTWrU'));
     $this->assertInstanceOf('Omnipay\\Mollie\\Message\\FetchTransactionRequest', $request);
     $data = $request->getData();
     $this->assertSame('tr_Qzin4iTWrU', $data['id']);
 }
 /**
  * @param FinancialTransactionInterface $transaction
  * @return CommunicationException|IdealIssuerTemporarilyUnavailableException|MollieTemporarilyUnavailableException
  */
 public function createMollieRedirectActionException(FinancialTransactionInterface $transaction)
 {
     $parameters = $this->getPurchaseParameters($transaction);
     $response = $this->gateway->purchase($parameters)->send();
     if ($this->logger) {
         $this->logger->info(json_encode($response->getRequest()->getData()));
         $this->logger->info(json_encode($response->getData()));
     }
     if ($response->isRedirect()) {
         $transaction->setTrackingId($response->getTransactionReference());
         $actionRequest = new ActionRequiredException('Redirect the user to Molie.');
         $actionRequest->setFinancialTransaction($transaction);
         $actionRequest->setAction(new VisitUrl($response->getRedirectUrl()));
         if ($this->logger) {
             $this->logger->info(sprintf('Create a new redirect exception for transaction "%s".', $response->getTransactionReference()));
         }
         return $actionRequest;
     }
     if (!$response->isSuccessful()) {
         $data = $response->getData();
         if (isset($data['error']) && isset($data['error']['type']) && $data['error']['type'] == 'system') {
             if (isset($data['error']['field']) && $data['error']['field'] == 'issuer') {
                 return new IdealIssuerTemporarilyUnavailableException("Can't start payment because of an issue with the issuer. Other issuers may work.");
             }
             return new MollieTemporarilyUnavailableException($response->getMessage());
         }
     }
     return new CommunicationException("Can't create Mollie payment");
 }
 /**
  * Warms up the cache.
  *
  * @param string $cacheDir The cache directory
  */
 public function warmUp($cacheDir)
 {
     try {
         if (!in_array($this->environment, ['dev', 'test'])) {
             $issuers = $this->gateway->fetchIssuers()->send()->getIssuers();
         } else {
             $issuers = array(new Issuer('ideal_TESTNL99', 'TBM Bank', 'ideal'));
         }
         $cacheFile = "<?php return array(" . PHP_EOL;
         foreach ($issuers as $issuer) {
             $cacheFile .= sprintf('new \\Omnipay\\Common\\Issuer(%s, %s, %s),' . PHP_EOL, var_export($issuer->getId(), true), var_export($issuer->getName(), true), var_export($issuer->getPaymentMethod(), true));
         }
         $cacheFile .= ");";
         $this->writeCacheFile($cacheDir . '/ruudk_payment_mollie_issuers.php', $cacheFile);
     } catch (\Exception $exception) {
         throw new \RuntimeException($exception->getMessage());
     }
 }
Exemple #4
0
 public function testFetchCustomer()
 {
     $request = $this->gateway->fetchCustomer(array('apiKey' => 'key', 'customerReference' => 'cst_bSNBBJBzdG'));
     $this->assertInstanceOf('Omnipay\\Mollie\\Message\\FetchCustomerRequest', $request);
 }
 public function testRefund()
 {
     $request = $this->gateway->refund(array('amount' => '10.00'));
 }