我想为下面的图片添加自定义错误页面。此页面必须显示错误。我怎样才能做到这一点? 我正在使用下面给出的代码。在这段代码中,我有一个try部分和一个catch部分。此代码由2checkout提供。我试图从catch部分返回视图,但这没有用。出现同样的错误,如图所示。它可能是什么解决方案?
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\TwoCheckoutAccount;
use File;
//use App\Twocheckout\lib\Twocheckout as Twocheckout;
use Twocheckout;
use Twocheckout_Charge;
use App\Price;
use App\Payment;
class PaymentsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index($type, $id)
{
$twoCheckOut = TwoCheckoutAccount::find(1);
$price = Price::where('priceable', '=', $type)->firstOrFail();
return view('payment')->with('twoCheckOut',$twoCheckOut)->with(['type'=>$type, 'id'=>$id, 'price'=>$price->price]);
}
public function process(Request $request)
{
$twoCheckOut = TwoCheckoutAccount::find(1);
File::requireOnce(app_path() . "/Twocheckout/lib/Twocheckout.php");
Twocheckout::verifySSL(false);
Twocheckout::privateKey($twoCheckOut->private_key);
Twocheckout::sellerId($twoCheckOut->sellerid);
if ($twoCheckOut->mode == "sandbox")
Twocheckout::sandbox(true);
$payble_product_type = $request->payble_product_type;
$payble_product_id = $request->payble_product_id;
$price = Price::where('priceable', '=', $payble_product_type)->firstOrFail();
try {
$charge = Twocheckout_Charge::auth(array(
"merchantOrderId" => ucfirst($payble_product_type)."#".$payble_product_id,
"token" => $_POST['token'],
"currency" => 'USD',
"total" => $price->price,
"tangible" => "N",
"li_#_name" => $payble_product_type,
"billingAddr" => array(
"name" => $request->purchaser_name,
"addrLine1" => $request->purchaser_addr1,
"addrLine2" => $request->purchaser_addr2,
"city" => $request->purchaser_city,
"state" => $request->purchaser_state,
"zipCode" => $request->purchaser_zipcode,
"country" => $request->purchaser_country,
"email" => $request->purchaser_email,
"phoneNumber" => $request->purchaser_phone
)
));
if ($charge['response']['responseCode'] == 'APPROVED') {
$payment = new Payment;
$payment->paymentable_id = $payble_product_id;
$payment->paymentable_type = "App\\".ucfirst($payble_product_type);
$payment->transactionId_2co = $charge['response']['transactionId'];
$payment->order_num_2co = $charge['response']['orderNumber'];
$payment->responseMsg_2co = $charge['response']['responseMsg'];
$payment->responseCode_2co = $charge['response']['responseCode'];
$payment->total_2co = $charge['response']['total'];
$payment->save();
return view('payment_confirmation')->with('transId', $payment->transactionId_2co);
}
} catch (Twocheckout_Error $e) {print_r($e->getMessage());}
}
}