【发布时间】:2017-03-26 16:59:25
【问题描述】:
我正在做一个简单的测试,使用 Stripes 默认卡对 Stripe 客户 ID 进行收费以触发卡片拒绝,但我一直认为它不会捕获错误:
try {
\Stripe\Charge::create(array(
"amount" => 1000, // Amount in cents
"currency" => "usd",
"customer" => $customer->id)
);
echo "Charge customer card entered";
} catch(\Stripe\Error\Card $e) {
echo "customer card declined exists";
} catch(Stripe_CardError $e) {
$error1 = $e->getMessage();
} catch (Stripe_InvalidRequestError $e) {
// Invalid parameters were supplied to Stripe's API
$error2 = $e->getMessage();
} catch (Stripe_AuthenticationError $e) {
// Authentication with Stripe's API failed
$error3 = $e->getMessage();
} catch (Stripe_ApiConnectionError $e) {
// Network communication with Stripe failed
$error4 = $e->getMessage();
} catch (Stripe_Error $e) {
// Display a very generic error to the user, and maybe send
// yourself an email
$error5 = $e->getMessage();
} catch (Exception $e) {
// Something else happened, completely unrelated to Stripe
$error6 = $e->getMessage();
}
我不断收到未捕获的异常
【问题讨论】:
标签: php stripe-payments