PaymentRequest: abort() メソッド

安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。

PaymentRequest.abort()PaymentRequest インターフェイスのメソッドで、ユーザーエージェントに決済リクエストを終了させ、ユーザーインターフェイスが表示された場合は消去します。

構文

abort()

引数

なし。

返値

なし (undefined)。

次の例では、放棄または放置された可能性のある決済リクエストをクリアするためのタイムアウトを設定しています。

const request = new PaymentRequest(supportedInstruments, details, options);

const paymentTimeout = setTimeout(() => {
  clearTimeout(paymentTimeout);
  request
    .abort()
    .then(() => {
      print("Payment timed out after 20 minutes.");
    })
    .catch(() => {
      print(
        "Unable to abort, because the user is currently in the process " +
          "of paying."
      );
    });
}, 20 * 60 * 1000); /* 20 minutes */

仕様書

Specification
Payment Request API 1.1
# dom-paymentrequest-abort

ブラウザーの互換性

BCD tables only load in the browser

関連情報