下のclient-idに、間違ったID値を入れた状態で、HTMLを読み込むと、PayPalの決済ボタンが現れません。
<script src="https://www.paypal.com/sdk/js?client-id=$P_credential¤cy=USD"></script>
コンソールを見ると、下のようなエラーが出ています。
ERR_ABORTED 400
SDK検証エラーになっているにもかかわらず、画面は、決済ボタンが表示されないだけで、一見、何事もなかったように正常に見えます。
このエラー状態が認識できるように、JavaScriptでアラートを表示させたいのですが、どのようにすればいいのでしょうか。
どなたかご教示いただけると幸いです。
よろしくお願いいたします。
<!DOCTYPE html> <html lang="en"> <head> <!-- Add meta tags for mobile and IE --> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title> PayPal Checkout Integration </title> </head> <body> <!-- Set up a container element for the button --> <div id="paypal-button-container"></div> <!-- Include the PayPal JavaScript SDK --> <script> <!-- Include the PayPal JavaScript SDK --> <script src="https://www.paypal.com/sdk/js?client-id=$P_credential¤cy=USD"></script> <script> // Render the PayPal button into #paypal-button-container paypal.Buttons({ // Set up the transaction createOrder: function(data, actions) { return actions.order.create({ purchase_units: [{ amount: { value: '150.00' } }] }); }, style: { layout: 'horizontal' } }).render('#paypal-button-container'); </script> </body> </html>