Laravel 5.1文件下载

Laravel 5.1文件下载,laravel,Laravel,在我的laravel 5.1应用程序中,我有以下paypal集成功能。以下函数在支付数据过帐后返回支付状态。我需要的是允许用户下载文件后付款是批准的。我该怎么做 public function getPaymentStatus() { // Get the payment ID before session clear $payment_id = Session::get('paypal_payment_id'); $package_name = Session::ge

在我的laravel 5.1应用程序中,我有以下paypal集成功能。以下函数在支付数据过帐后返回支付状态。我需要的是允许用户下载文件后付款是批准的。我该怎么做

public function getPaymentStatus()
{
    // Get the payment ID before session clear
    $payment_id = Session::get('paypal_payment_id');

    $package_name = Session::get('package_name');
    $package_id = Session::get('$package_id');

    // clear the session payment ID
    Session::forget('paypal_payment_id');

    if (empty(Input::get('PayerID')) || empty(Input::get('token'))) {
        return Redirect::route('original.route')
            ->with('error', 'Payment failed');
    }

    $payment = Payment::get($payment_id, $this->_api_context);

    // PaymentExecution object includes information necessary
    // to execute a PayPal account payment.
    // The payer_id is added to the request query parameters
    // when the user is redirected from paypal back to your site
    $execution = new PaymentExecution();
    $execution->setPayerId(Input::get('PayerID'));

    //Execute the payment
    $result = $payment->execute($execution, $this->_api_context);

    // echo '<pre>';print_r($result);echo '</pre>';exit; // DEBUG RESULT, remove it later

    if ($result->getState() == 'approved') { // payment made

        //ToDo Release Later
        return Redirect::route('original.route')
            ->with('success', 'Payment success');

        // ToDo Release Later
        // $this->allow_download($package_id, $package_name);
    }

    return Redirect::route('original.route')
        ->with('error', 'Payment failed');
}
公共函数getPaymentStatus()
{
//在清除会话之前获取付款ID
$payment\u id=Session::get('paypal\u payment\u id');
$package_name=Session::get('package_name');
$package_id=Session::get(“$package_id”);
//清除会话付款ID
会话::忘记('paypal_payment_id');
if(空(输入::get('PayerID'))| |空(输入::get('token')){
return Redirect::route('original.route')
->带有('error','Payment failed');
}
$payment=payment::get($payment\u id,$this->\u api\u上下文);
//PaymentExecution对象包含必要的信息
//执行PayPal帐户付款。
//付款人id将添加到请求查询参数中
//当用户从paypal重定向回您的站点时
$execution=新的PaymentExecution();
$execution->setPayerId(输入::get('PayerID');
//执行付款
$result=$payment->execute($execution,$this->\u api\u上下文);
//回显“”;打印($result);回显“”;退出;//调试结果,稍后将其删除
如果($result->getState()=='approved'){//已付款
//待办事项稍后发布
return Redirect::route('original.route')
->带有(‘成功’、‘付款成功’);
//待办事项稍后发布
//$this->allow_download($package_id,$package_name);
}
return Redirect::route('original.route')
->带有('error','Payment failed');
}
我想让用户得到这样的链接

if ($result->getState() == 'approved') { // payment made

        //ToDo Release Later
        Session::set('approved', true);
        return Redirect::route('original.route')
            ->with('success', 'Payment success');

        // ToDo Release Later
        // $this->allow_download($package_id, $package_name);
    }
@if(Session::get('approved'))

    < href="/packages/{{$package_id}}/{{$name}}">click here to download</a>.

@endif 
单击此处下载。
如果($result->getState()=='approved'){//已付款
//待办事项稍后发布
会话::set('approved',true);
return Redirect::route('original.route')
->带有(‘成功’、‘付款成功’);
//待办事项稍后发布
//$this->allow_download($package_id,$package_name);
}
@if(会话::get('approved'))
单击此处下载。
@恩迪夫

您有DB用于结果付款吗?没有,目前我不想要。我只想在付款批准后启动下载。这还没有完成,你不想保留日期吗?你可以这样做,但这不是一个好的选择。最好使用
Session::flash
否则用户每次访问页面时都会看到下载文件的链接,但用户每次付款:)吗?这个选项是最糟糕的,你需要把所有东西都保存在数据库中是的,我完全同意
if ($result->getState() == 'approved') { // payment made

        //ToDo Release Later
        Session::set('approved', true);
        return Redirect::route('original.route')
            ->with('success', 'Payment success');

        // ToDo Release Later
        // $this->allow_download($package_id, $package_name);
    }
@if(Session::get('approved'))

    < href="/packages/{{$package_id}}/{{$name}}">click here to download</a>.

@endif