/** * Build a PaymentResult object from adapter results * * @param PaymentTransactionResponse $response processed response object * @param string $finalStatus final transaction status. * * @return PaymentResult */ public static function fromResults(PaymentTransactionResponse $response, $finalStatus) { if ($finalStatus === FinalStatus::FAILED) { return PaymentResult::newFailure($response->getErrors()); } if (!$response) { return PaymentResult::newEmpty(); } if ($response->getErrors()) { // TODO: We will probably want the ability to refresh to a new form // as well and display errors at the same time. return PaymentResult::newRefresh($response->getErrors()); } if ($response->getRedirect()) { return PaymentResult::newRedirect($response->getRedirect()); } return PaymentResult::newSuccess(); }