gpt4 book ai didi

php - Stripe 如何处理 InvalidRequest 错误

转载 作者:可可西里 更新时间:2023-11-01 00:31:16 24 4
gpt4 key购买 nike

我想处理这个错误,但是我无法让它在我的 catch 中工作。我试过使用多个错误短语,例如 Stripe\Error\InvalidRequestinvalid_request_error,但它们都不起作用。

注意:我只包含了必要的代码,我的支付系统工作正常。

这是我的代码:

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.";
}

最佳答案

来自 Stripe API 文档关于错误的部分:

catch (\Stripe\Error\InvalidRequest $e) {
// Invalid parameters were supplied to Stripe's API
} catch (\Stripe\Error\Authentication $e) {
// Authentication with Stripe's API failed
// (maybe you changed API keys recently)
} catch (\Stripe\Error\ApiConnection $e) {
// Network communication with Stripe failed
} catch (\Stripe\Error\Base $e) {
// Display a very generic error to the user, and maybe send
// yourself an email
} catch (Exception $e) {
// Something else happened, completely unrelated to Stripe
}

关于php - Stripe 如何处理 InvalidRequest 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29823254/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com