/** * @param $transactionId * @param Request $request * @throws CheckoutException */ public function index($transactionId, Request $request) { $transaction = TransactionData::get($transactionId); if (empty($transaction->transaction)) { throw new CheckoutException('No transaction found!'); } $gatewayClass = '\\Kiberzauras\\Checkout\\Gateway\\' . Provider::getGatewayName($transaction->provider) . "Gateway"; (new $gatewayClass($transaction))->processRequest($request); }
/** * @param null $callback_url * @param null $accept_url * @param null $cancel_url * @throws CheckoutException */ public function pay($callback_url = null, $accept_url = null, $cancel_url = null) { $this->callback_url = $callback_url; $this->accept_url = $accept_url; $this->cancel_url = $cancel_url; if (!$this->accept_url) { $this->accept_url = url('/'); } if (!$this->cancel_url) { $this->cancel_url = url('/'); } if (count($this->product_list) && $this->amount > 0) { throw new CheckoutException('Can\'t use setAmount() together with addProduct(), please choose only one.'); } if (!$this->currency) { throw new CheckoutException('Currency code required'); } $expose = []; if (count($this->product_list)) { $expose = $this->handleProducts(); } if ($this->amount <= 0) { throw new CheckoutException('Amount (price) must be greater than zero'); } if (count($this->recurring_setup)) { if (!in_array($this->provider, array(Provider::PAYPAL, Provider::BRAINTREE, Provider::GOOGLEWALLET))) { throw new CheckoutException('Your selected provider cant serve subscriptions'); } } $this->request = get_object_vars($this); $this->request['product_list'] = $expose; unset($this->request['request']); $this->request = TransactionData::generate($this->request); $gatewayClass = '\\Kiberzauras\\Checkout\\Gateway\\' . Provider::getGatewayName($this->provider) . "Gateway"; (new $gatewayClass($this->request))->startPayment(); }