【发布时间】:2020-05-11 21:52:02
【问题描述】:
我一直在使用 Paypal SDK,并且我有一个操作可以验证 付款顺序。
我想在交易过程中捕获并处理 Paypal 错误,以便稍后在消息中显示。
我尝试在 catch 上添加 PayPal\Exception\PayPalConnectionException,但没有任何结果。
这是它显示错误的方式:
https://i.stack.imgur.com/zlRge.png
我的代码操作:
public static function actionGetorder($orderId)
{
try
{
// 3. Call PayPal to get the transaction details
$client = PayPalClient::client();
$response = $client->execute(new OrdersGetRequest($orderId)); //The order ID isn't valid so it will give the error
var_dump ($response->result->payer->email_address);
print "Status: {$response->result->status}\n";
}
catch (PayPal\Exception\PayPalConnectionException $ex)
{
echo "lol";
}
}
这个想法是在那个代码中它应该显示 lol 消息但它没有,所以是否可以捕获并处理错误以及如何处理?
感谢阅读,问候。
【问题讨论】:
-
我猜你只是使用了错误的异常。
..ConnectionException我认为响应连接失败或错误的凭据。