third_party/subscriptions-project/swg.js
/**
   * Check whether the user can make payments using the Payment API.
   *
   * @param {!IsReadyToPayRequest} isReadyToPayRequest
   * @return {!Promise} The promise will contain the boolean result and error
   *     message when possible.
   */
Check whether the user can make payments using the Payment API.
@param {!IsReadyToPayRequest} isReadyToPayRequest
@return {!Promise} The promise will contain the boolean result and error
message when possible.
Check whether the user can make payments using the Payment API . @param { !IsReadyToPayRequest } isReadyToPayRequest @return { !Promise } The promise will contain the boolean result and error message when possible .
isReadyToPay(isReadyToPayRequest) {
    if (isReadyToPayRequest) {
      isReadyToPayRequest = Object.assign(
        {},
        this.paymentOptions_,
        isReadyToPayRequest
      );
    }
    const startTimeMs = Date.now();
    const errorMessage =
      validateSecureContext() ||
      validateIsReadyToPayRequest(isReadyToPayRequest);
    if (errorMessage) {
      return new Promise((resolve, reject) => {
        PaymentsAsyncClient.logDevErrorToConsole_('isReadyToPay', errorMessage);
        PayFrameHelper.postMessage({
          'eventType': PostMessageEventType.LOG_IS_READY_TO_PAY_API,
          'error': PublicErrorCode.DEVELOPER_ERROR,
        });
        reject({
          'statusCode': Constants.ResponseStatus.DEVELOPER_ERROR,
          'statusMessage': errorMessage,
        });
      });
    }
    const isReadyToPayPromise = this.isReadyToPay_(isReadyToPayRequest);
    isReadyToPayPromise.then((response) => {
      PayFrameHelper.postMessage({
        'eventType': PostMessageEventType.LOG_IS_READY_TO_PAY_API,
        'clientLatencyStartMs': startTimeMs,
        'isReadyToPayApiResponse': response,
      });
      return response;
    });
    return isReadyToPayPromise;
  }
isReadyToPay ( isReadyToPayRequest ) { if ( isReadyToPayRequest ) { isReadyToPayRequest = Object . assign ( { } , this . paymentOptions_ , isReadyToPayRequest ) ; } const startTimeMs = Date . now ( ) ; const errorMessage = validateSecureContext ( ) || validateIsReadyToPayRequest ( isReadyToPayRequest ) ; if ( errorMessage ) { return new Promise ( ( resolve , reject ) => { PaymentsAsyncClient . logDevErrorToConsole_ ( 'isReadyToPay' , errorMessage ) ; PayFrameHelper . postMessage ( { 'eventType' : PostMessageEventType . LOG_IS_READY_TO_PAY_API , 'error' : PublicErrorCode . DEVELOPER_ERROR , } ) ; reject ( { 'statusCode' : Constants . ResponseStatus . DEVELOPER_ERROR , 'statusMessage' : errorMessage , } ) ; } ) ; } const isReadyToPayPromise = this . isReadyToPay_ ( isReadyToPayRequest ) ; isReadyToPayPromise . then ( ( response ) => { PayFrameHelper . postMessage ( { 'eventType' : PostMessageEventType . LOG_IS_READY_TO_PAY_API , 'clientLatencyStartMs' : startTimeMs , 'isReadyToPayApiResponse' : response , } ) ; return response ; } ) ; return isReadyToPayPromise ; }
Check whether the user can make payments using the Payment API.
Check whether the user can make payments using the Payment API .
// Merge with paymentOptions, preferring values from isReadyToPayRequest /** @type {?string} */