third_party/subscriptions-project/swg.js
/**
   * Actual implementation of isReadyToPay in a private method so that
   * we can add callbacks to the promise to measure latencies.
   *
   * @param {!IsReadyToPayRequest} isReadyToPayRequest
   * @return {!Promise} The promise will contain the boolean result and error
   *     message when possible.
   * @private
   */
Actual implementation of isReadyToPay in a private method so that
we can add callbacks to the promise to measure latencies.

@param {!IsReadyToPayRequest} isReadyToPayRequest
@return {!Promise} The promise will contain the boolean result and error
message when possible.
@private
Actual implementation of isReadyToPay in a private method so that we can add callbacks to the promise to measure latencies . @param { !IsReadyToPayRequest } isReadyToPayRequest @return { !Promise } The promise will contain the boolean result and error message when possible . @private
isReadyToPay_(isReadyToPayRequest) {
    if (this.upiHandler_.isUpiRequest(isReadyToPayRequest)) {
      return this.upiHandler_.isReadyToPay(isReadyToPayRequest);
    }
    if (
      chromeSupportsPaymentRequest() &&
      !isNativeDisabledInRequest(isReadyToPayRequest)
    ) {
      if (isReadyToPayRequest.apiVersion >= 2) {
        return this.isReadyToPayApiV2ForChromePaymentRequest_(
          isReadyToPayRequest
        );
      } else {
        const webPromise = this.webActivityDelegate_.isReadyToPay(
          isReadyToPayRequest
        );
        const nativePromise = this.delegate_.isReadyToPay(isReadyToPayRequest);
        if (
          doesMerchantSupportOnlyTokenizedCards(isReadyToPayRequest) &&
          !chromeSupportsPaymentHandler()
        ) {
          return nativePromise;
        }
        return nativePromise.then(() => webPromise);
      }
    }
    const webPromise = this.webActivityDelegate_.isReadyToPay(
      isReadyToPayRequest
    );
    return webPromise;
  }
isReadyToPay_ ( isReadyToPayRequest ) { if ( this . upiHandler_ . isUpiRequest ( isReadyToPayRequest ) ) { return this . upiHandler_ . isReadyToPay ( isReadyToPayRequest ) ; } if ( chromeSupportsPaymentRequest ( ) && ! isNativeDisabledInRequest ( isReadyToPayRequest ) ) { if ( isReadyToPayRequest . apiVersion >= 2 ) { return this . isReadyToPayApiV2ForChromePaymentRequest_ ( isReadyToPayRequest ) ; } else { const webPromise = this . webActivityDelegate_ . isReadyToPay ( isReadyToPayRequest ) ; const nativePromise = this . delegate_ . isReadyToPay ( isReadyToPayRequest ) ; if ( doesMerchantSupportOnlyTokenizedCards ( isReadyToPayRequest ) && ! chromeSupportsPaymentHandler ( ) ) { return nativePromise ; } return nativePromise . then ( ( ) => webPromise ) ; } } const webPromise = this . webActivityDelegate_ . isReadyToPay ( isReadyToPayRequest ) ; return webPromise ; }
Actual implementation of isReadyToPay in a private method so that
 we can add callbacks to the promise to measure latencies.
Actual implementation of isReadyToPay in a private method so that we can add callbacks to the promise to measure latencies .
// This is the apiVersion 1 branch. // If the merchant supports only Tokenized cards then just rely on // delegate to give us the result. // This will need to change once b/78519188 is fixed. // Return webIsReadyToPay only if delegateIsReadyToPay has been // executed.