App\Http\Controllers\OnlinePaymentController::offsitePayment PHP Method

offsitePayment() public method

public offsitePayment ( boolean $invitationKey = false, mixed $gatewayTypeAlias = false ) : Illuminate\Http\RedirectResponse
$invitationKey boolean
$gatewayTypeAlias mixed
return Illuminate\Http\RedirectResponse
    public function offsitePayment($invitationKey = false, $gatewayTypeAlias = false)
    {
        $invitationKey = $invitationKey ?: Session::get('invitation_key');
        $invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
        if (!$gatewayTypeAlias) {
            $gatewayTypeId = Session::get($invitation->id . 'gateway_type');
        } elseif ($gatewayTypeAlias != GATEWAY_TYPE_TOKEN) {
            $gatewayTypeId = GatewayType::getIdFromAlias($gatewayTypeAlias);
        } else {
            $gatewayTypeId = $gatewayTypeAlias;
        }
        $paymentDriver = $invitation->account->paymentDriver($invitation, $gatewayTypeId);
        if ($error = Input::get('error_description') ?: Input::get('error')) {
            return $this->error($paymentDriver, $error);
        }
        try {
            if ($paymentDriver->completeOffsitePurchase(Input::all())) {
                Session::flash('message', trans('texts.applied_payment'));
            }
            return redirect()->to($invitation->getLink());
        } catch (Exception $exception) {
            return $this->error($paymentDriver, $exception);
        }
    }