Laravel 5.1文件下载

时间:2017-08-01 06:47:35

标签: 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::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');
}

我希望用户获得这样的链接

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

1 个答案:

答案 0 :(得分:1)

<input name="subAdmin[]" type="text">