/**
  * @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());
     }
 }
Пример #2
0
 /**
  * Executes the purchase with the provided payment gateway
  * @param	\Omnipay\Common\GatewayInterface			$gateway Omnipay payment gateway
  * @param	array										$params pass this to the gateway
  * @return	\Omnipay\Common\Message\ResponseInterface	$response payment gateway response
  */
 public function execute_purchase(GatewayInterface $gateway, array $params = array())
 {
     $include_card = isset($params['card']) && isset($params['card']['number']);
     $params = Arr::merge($params, $this->convert_purchase($include_card));
     $response = $gateway->purchase($params)->send();
     $this->payment_id = $response->getTransactionReference();
     $this->raw_response = $response->getData();
     if ($response->isSuccessful()) {
         $this->status = Model_Payment::PAID;
     } else {
         if ($response->isRedirect()) {
             $this->status = Model_Payment::PENDING;
         }
     }
     return $response;
 }
 /**
  * This is a proxy for gateway->purchase
  *
  * @param array $parameters
  *
  * @return \Omnipay\Common\Message\Response
  */
 public function purchase(array $parameters = array())
 {
     return $this->gateway->purchase($parameters)->send();
 }