* @param {!PaymentDataRequest} paymentRequest * @param {!PayOptionsDef=} options
(paymentRequest, options = {})
| 18025 | * @param {!PayOptionsDef=} options |
| 18026 | */ |
| 18027 | start(paymentRequest, options = {}) { |
| 18028 | this.request_ = paymentRequest; |
| 18029 | |
| 18030 | if (!this.client_) { |
| 18031 | this.preconnect(this.preconnect_); |
| 18032 | this.initializePaymentsClient_(); |
| 18033 | } |
| 18034 | if (options.forceRedirect) { |
| 18035 | paymentRequest = Object.assign(paymentRequest, { |
| 18036 | 'forceRedirect': options.forceRedirect || false, |
| 18037 | }); |
| 18038 | } |
| 18039 | setInternalParam( |
| 18040 | paymentRequest, |
| 18041 | 'disableNative', |
| 18042 | // The page cannot be iframed at this time. May be relaxed later |
| 18043 | // for AMP and similar contexts. |
| 18044 | options.forceDisableNative || this.win_ != this.top_() |
| 18045 | ); |
| 18046 | let resolver = null; |
| 18047 | const promise = new Promise((resolve) => (resolver = resolve)); |
| 18048 | // Notice that the callback for verifier may execute asynchronously. |
| 18049 | this.redirectVerifierHelper_.useVerifier((verifier) => { |
| 18050 | if (verifier) { |
| 18051 | setInternalParam(paymentRequest, 'redirectVerifier', verifier); |
| 18052 | } |
| 18053 | if (options.forceRedirect) { |
| 18054 | const client = this.client_; |
| 18055 | this.eventManager_.getReadyPromise().then(() => { |
| 18056 | this.analytics_.getLoggingPromise().then(() => { |
| 18057 | client.loadPaymentData(paymentRequest); |
| 18058 | resolver(true); |
| 18059 | }); |
| 18060 | }); |
| 18061 | } else { |
| 18062 | this.client_.loadPaymentData(paymentRequest); |
| 18063 | resolver(true); |
| 18064 | } |
| 18065 | }); |
| 18066 | return promise; |
| 18067 | } |
| 18068 | |
| 18069 | /** |
| 18070 | * @param {function(!Promise<!PaymentData>)} callback |
no test coverage detected