/** * @param GatewayInterface $gateway * @param Store $session * @param Dispatcher $dispatcher * @return mixed * @throws TransactionFailedException */ public function handle(GatewayInterface $gateway, Store $session, Dispatcher $dispatcher) { $session->set('params', $this->details()); $response = $gateway->purchase($this->details())->send(); if ($response->isRedirect()) { // redirect to offsite payment gateway $dispatcher->fire(new TransactionRedirect($response->getMessage())); return $response->getRedirectUrl(); } else { $dispatcher->fire(new TransactionFailed($response->getMessage(), $response->getTransactionReference())); throw new TransactionFailedException($response->getMessage()); } }
/** * This is a proxy for gateway->completePurchase * * @param array $parameters * * @return \Omnipay\Common\Message\Response */ public function completePurchase(array $parameters = array()) { return $this->gateway->completePurchase($parameters)->send(); }
/** * Executes multiple refunds with the provided payment gateway * @param \Omnipay\Common\GatewayInterface $gateway Omnipay payment gateway * @param Model_Brand_Refund[] $refunds * @param array $params pass this to the gateway * @return \Omnipay\Common\Message\ResponseInterface $response payment gateway response */ public function execute_multiple_refunds(GatewayInterface $gateway, array $refunds, array $params = array()) { $params = Arr::merge($this->convert_multiple_refunds($refunds), $params); $response = $gateway->refund($params)->send(); $raw_response = $response->getData(); $status = $response->isSuccessful() ? Model_Brand_Refund::TRANSACTION_REFUNDED : NULL; foreach ($refunds as $refund) { $refund->raw_response = $raw_response; $refund->transaction_status = $status; } return $response; }
/** * @param GatewayInterface $gateway * @param Store $session * @param Dispatcher $dispatcher * * @return array */ public function handle(GatewayInterface $gateway, Store $session, Dispatcher $dispatcher) { $response = $gateway->completePurchase($session->get('params'))->setToken($this->token)->setPayerId($this->payerId)->send(); $dispatcher->fire(new TransactionSuccessful(array_merge($response->getData(), $session->get('params')))); return $response->getData(); }