ストライプでは、テスト番号4000 0000 0000 0341
は、Stripe Testing pageごとに「このカードを顧客オブジェクトに接続すると成功しますが、 "私の場合は、このような状況をエラーのように扱い、エラーが発生したことを顧客に報告するのではなく、エラーハンドラに送信します。ストライプ/ PHP:顧客オブジェクトの処理に失敗しましたが、請求が失敗しました(4000000000000341)
私はPHPでこれをやっているので、APIからJSONオブジェクトを取得するのではなく、顧客のPHPオブジェクトを取得しています。私はStripe APIの新機能ですので、ここで何をすべきかわかりません。私はこの状況に関する情報を検索しようとしましたが、役に立たないものは見つかりませんでした。そして、このケースは既存のSOの質問によって処理されたようには見えません。
コードの抜粋は以下のとおりです。お客様に請求されなかった場合は$charge_failed
〜true
と設定する必要があります。
\Stripe\Stripe::setApiKey(STRIPE_SECRET_KEY);
// Create a customer.
try {
$customer = \Stripe\Customer::create(array("source" => $my_token, 'email' => $customers_email, "description" => $my_description));
$charge_failed = false; //TODO Set this boolean according to whether the charge passed or failed.
if ($charge_failed) {
//TODO Report to the user that the charge failed and they need to resubmit.
die();
}
}
catch(\Stripe\Error\Card $e) {
// Card was declined. Report the card declined to the user.
die();
}
catch (\Stripe\Error\RateLimit $e) {
// Report the error appropriately.
die();
} catch (\Stripe\Error\InvalidRequest $e) {
// Report the error appropriately.
die();
} catch (\Stripe\Error\Authentication $e) {
// Report the error appropriately.
die();
} catch (\Stripe\Error\ApiConnection $e) {
// Report the error appropriately.
die();
} catch (\Stripe\Error\Base $e) {
// Report the error appropriately.
die();
} catch (Exception $e) {
// Report the error appropriately.
die();
}