src/runtime/offers-flow.js
/**
   * Starts the offers flow or alreadySubscribed flow.
   * @return {!Promise}
   */
Starts the offers flow or alreadySubscribed flow.
@return {!Promise}
Starts the offers flow or alreadySubscribed flow . @return { !Promise }
start() {
    if (this.activityIframeViewPromise_) {
      return this.activityIframeViewPromise_.then((activityIframeView) => {
        if (!activityIframeView) {
          return Promise.resolve();
        }
        this.deps_
          .callbacks()
          .triggerFlowStarted(SubscriptionFlows.SHOW_OFFERS, {
            skus: this.skus_,
            source: 'SwG',
          });
        activityIframeView.onCancel(() => {
          this.deps_
            .callbacks()
            .triggerFlowCanceled(SubscriptionFlows.SHOW_OFFERS);
        });
        activityIframeView.on(
          SkuSelectedResponse,
          this.startPayFlow_.bind(this)
        );
        activityIframeView.on(
          AlreadySubscribedResponse,
          this.handleLinkRequest_.bind(this)
        );
        activityIframeView.on(
          ViewSubscriptionsResponse,
          this.startNativeFlow_.bind(this)
        );
        this.activityIframeView_ = activityIframeView;
        return this.clientConfig_.then((clientConfig) => {
          if (!this.activityIframeView_) {
            return;
          }
          return this.dialogManager_.openView(
            this.activityIframeView_,
             false,
            this.getDialogConfig_(clientConfig)
          );
        });
      });
    }
    return Promise.resolve();
  }
start ( ) { if ( this . activityIframeViewPromise_ ) { return this . activityIframeViewPromise_ . then ( ( activityIframeView ) => { if ( ! activityIframeView ) { return Promise . resolve ( ) ; } this . deps_ . callbacks ( ) . triggerFlowStarted ( SubscriptionFlows . SHOW_OFFERS , { skus : this . skus_ , source : 'SwG' , } ) ; activityIframeView . onCancel ( ( ) => { this . deps_ . callbacks ( ) . triggerFlowCanceled ( SubscriptionFlows . SHOW_OFFERS ) ; } ) ; activityIframeView . on ( SkuSelectedResponse , this . startPayFlow_ . bind ( this ) ) ; activityIframeView . on ( AlreadySubscribedResponse , this . handleLinkRequest_ . bind ( this ) ) ; activityIframeView . on ( ViewSubscriptionsResponse , this . startNativeFlow_ . bind ( this ) ) ; this . activityIframeView_ = activityIframeView ; return this . clientConfig_ . then ( ( clientConfig ) => { if ( ! this . activityIframeView_ ) { return ; } return this . dialogManager_ . openView ( this . activityIframeView_ , false , this . getDialogConfig_ ( clientConfig ) ) ; } ) ; } ) ; } return Promise . resolve ( ) ; }
Starts the offers flow or alreadySubscribed flow.
Starts the offers flow or alreadySubscribed flow .
// So no error if skipped to payment screen. // Start/cancel events. // The second parameter is required by Propensity in AMP. /* hidden */