text: (function (root, factory) {
      if (typeof define === 'function' && define.amd) {
          define([], factory);
      } else if (typeof exports === 'object') {
          module.exports = factory();
      } else {
          factory()();
      }
  }(this, function () {
      return function () {
          $(document).on('initAffirm', function () {
              var $this = $(this);
              var $promo = $this.find('.js-affirm-promo');
              var $text = $promo.find('.js-affirm-text');
              if ($promo.length) {
                  affirm.ui.ready(function () {
                      affirm.ui.payments.get_estimate({
                          months: parseInt($promo.data('affirm-month'), 10),
                          apr: $promo.data('affirm-apr'),
                          amount: parseInt($promo.data('affirm-amount'), 10)
                      }, function (estimates) {
                          var text = $promo.data('affirm-text');
                          var dollars = 0|(estimates.payment/100);
                          var cents = (estimates.payment%100);
                          cents = cents < 10 ? '0'+cents : cents+'';                   
                          $text.text(text.replace('{dollars}', dollars).replace('{cents}', cents));
                      });
                  });
              }    
          }).trigger('initAffirm');
          $(document).ajaxComplete(function (event, request, settings) {
              if (settings.url.indexOf('Product-Variation') !== -1) {
                  $(document).trigger('initAffirm');
              }
          });
          $(document).on('click', '.js-affirm-text', function (event) {
              event.preventDefault();
              new affirm.widgets.learn_more();
          });
      };
  }));