third_party/gpay/src/upi_handler.js
/**
   * Checks whether can make a payment with Tez on this device.
   *
   * @private
   * @param {!PaymentRequest} request The payment request object.
   * @return {!Promise<boolean>} a promise containing the result of whether can
   *     make payment.
   */
Checks whether can make a payment with Tez on this device.
@private
@param {!PaymentRequest} request The payment request object.
@return {!Promise} a promise containing the result of whether can
make payment.
Checks whether can make a payment with Tez on this device . @private @param { !PaymentRequest } request The payment request object . @return { !Promise } a promise containing the result of whether can make payment .
checkCanMakePayment_(request) {
    const cacheResult =
        window.sessionStorage.getItem(Constants.UPI_CAN_MAKE_PAYMENT_CACHE_KEY);
    if (cacheResult) {
      return Promise.resolve(cacheResult === 'true');
    }
    if (!request.canMakePayment) {
      return Promise.resolve(true);
    }
    let canMakePaymentPromise = request.canMakePayment();
    return canMakePaymentPromise.then(result => {
      if (result) {
        window.sessionStorage.setItem(
            Constants.UPI_CAN_MAKE_PAYMENT_CACHE_KEY, result.toString());
      }
      return result;
    });
  }
checkCanMakePayment_ ( request ) { const cacheResult = window . sessionStorage . getItem ( Constants . UPI_CAN_MAKE_PAYMENT_CACHE_KEY ) ; if ( cacheResult ) { return Promise . resolve ( cacheResult === 'true' ) ; } if ( ! request . canMakePayment ) { return Promise . resolve ( true ) ; } let canMakePaymentPromise = request . canMakePayment ( ) ; return canMakePaymentPromise . then ( result => { if ( result ) { window . sessionStorage . setItem ( Constants . UPI_CAN_MAKE_PAYMENT_CACHE_KEY , result . toString ( ) ) ; } return result ; } ) ; }
Checks whether can make a payment with Tez on this device.
Checks whether can make a payment with Tez on this device .
// Checks canMakePayment cache, and use the cache result if it exists. // Feature detect canMakePayment(). // Store the result in cache if the result is true to avoid quota error // caused by querying multiple times with different data. // Doesn't store false because if we do so, user will be redirected to // Google Play again after installing Google Pay if Chrome is not closed.