third_party/subscriptions-project/swg.js
/**
   * Request PaymentData, which contains necessary infomartion to complete a
   * payment.
   *
   * @param {!PaymentDataRequest} paymentDataRequest Provides necessary
   *     information to support a payment.
   */
Request PaymentData, which contains necessary infomartion to complete a
payment.

@param {!PaymentDataRequest} paymentDataRequest Provides necessary
information to support a payment.
Request PaymentData which contains necessary infomartion to complete a payment . @param { !PaymentDataRequest } paymentDataRequest Provides necessary information to support a payment .
loadPaymentData(paymentDataRequest) {
    PayFrameHelper.postMessage({
      'eventType': PostMessageEventType.LOG_BUTTON_CLICK,
    });
    const errorMessage =
      validateSecureContext() || validatePaymentDataRequest(paymentDataRequest);
    this.buyFlowMode_ =
      paymentDataRequest && paymentDataRequest.swg
        ? BuyFlowMode.SUBSCRIBE_WITH_GOOGLE
        : BuyFlowMode.PAY_WITH_GOOGLE;
    if (errorMessage) {
      this.onPaymentResponse_(
        new Promise((resolve, reject) => {
          PayFrameHelper.postMessage({
            'eventType': PostMessageEventType.LOG_LOAD_PAYMENT_DATA_API,
            'error': PublicErrorCode.DEVELOPER_ERROR,
            'buyFlowMode': this.buyFlowMode_,
          });
          PaymentsAsyncClient.logDevErrorToConsole_(
            'loadPaymentData',
            errorMessage
          );
          reject({
            'statusCode': Constants.ResponseStatus.DEVELOPER_ERROR,
            'statusMessage': errorMessage,
          });
        })
      );
      return;
    }
    const upiPaymentMethod = getUpiPaymentMethod(paymentDataRequest);
    if (upiPaymentMethod) {
      this.upiHandler_.loadPaymentData(
        paymentDataRequest,
        upiPaymentMethod,
        this.onResult_.bind(this)
      );
      return;
    }
    this.loadPaymentDataApiStartTimeMs_ = Date.now();
    this.assignInternalParams_(paymentDataRequest);
    if (
      chromeSupportsPaymentHandler() ||
      isNativeDisabledInRequest(paymentDataRequest)
    ) {
      this.webActivityDelegate_.loadPaymentData(paymentDataRequest);
    } else {
      this.delegate_.loadPaymentData(paymentDataRequest);
    }
  }
loadPaymentData ( paymentDataRequest ) { PayFrameHelper . postMessage ( { 'eventType' : PostMessageEventType . LOG_BUTTON_CLICK , } ) ; const errorMessage = validateSecureContext ( ) || validatePaymentDataRequest ( paymentDataRequest ) ; this . buyFlowMode_ = paymentDataRequest && paymentDataRequest . swg ? BuyFlowMode . SUBSCRIBE_WITH_GOOGLE : BuyFlowMode . PAY_WITH_GOOGLE ; if ( errorMessage ) { this . onPaymentResponse_ ( new Promise ( ( resolve , reject ) => { PayFrameHelper . postMessage ( { 'eventType' : PostMessageEventType . LOG_LOAD_PAYMENT_DATA_API , 'error' : PublicErrorCode . DEVELOPER_ERROR , 'buyFlowMode' : this . buyFlowMode_ , } ) ; PaymentsAsyncClient . logDevErrorToConsole_ ( 'loadPaymentData' , errorMessage ) ; reject ( { 'statusCode' : Constants . ResponseStatus . DEVELOPER_ERROR , 'statusMessage' : errorMessage , } ) ; } ) ) ; return ; } const upiPaymentMethod = getUpiPaymentMethod ( paymentDataRequest ) ; if ( upiPaymentMethod ) { this . upiHandler_ . loadPaymentData ( paymentDataRequest , upiPaymentMethod , this . onResult_ . bind ( this ) ) ; return ; } this . loadPaymentDataApiStartTimeMs_ = Date . now ( ) ; this . assignInternalParams_ ( paymentDataRequest ) ; if ( chromeSupportsPaymentHandler ( ) || isNativeDisabledInRequest ( paymentDataRequest ) ) { this . webActivityDelegate_ . loadPaymentData ( paymentDataRequest ) ; } else { this . delegate_ . loadPaymentData ( paymentDataRequest ) ; } }
Request PaymentData, which contains necessary infomartion to complete a
 payment.
Request PaymentData which contains necessary infomartion to complete a payment .
// Handler for UPI PaymentMethod // Currently we don't support UPI along with other payment methods, if // UPI is in payment methods then we assume it is UPI only. // We want to fall back to the web delegate if payment handler is supported // and isReadyToPay bit is not explicitly set to true (fallback to web if // isReadyToPay wasn't called for PH)