我想處理這個錯誤,但是我無法讓它在我的catch
中工作。我試過使用多個錯誤短語,例如Stripe\Error\InvalidRequest
和invalid_request_error
,但它們都不起作用。條紋如何處理InvalidRequest錯誤
注:我只包括必要的代碼,我的支付系統工作正常。
這裏是我的代碼:
try {
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => $amount,
'currency' => strtolower($active_user->currency->currency_id)
));
}
catch (Stripe\Error\InvalidRequest $e) {
$msg = "Sorry, you cannot make the same payment twice.";
}
試試這個http://stackoverflow.com/a/8439615/2156785 – ANjaNA