/** * @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"); }
public function testPurchase() { $request = $this->gateway->purchase(array('amount' => '10.00')); $this->assertInstanceOf('Omnipay\\Mollie\\Message\\PurchaseRequest', $request); $this->assertSame('10.00', $request->getAmount()); }