       script.async = true
       script.src = "https://static.xsolla.com/embed/paystation/1.0.7/widget.min.js"
       script.addEventListener 'load', ->
-        console.debug('script loaded')
         # TODO: remove after testing
         Timeout.set 5000, ->
           resolve()

    .catch (error) ->
      console.error error

    click = DeferrablePromise()

    $(button).on 'click', ->
      button.classList.add('store-payment-button--waiting')
      click.resolve()

    $(button).on 'click', ->
      Promise.all([init, click]).then (values) ->
        console.log(values)
        XPayStationWidget.open()

  @loadXsollaScript: ->

    return unless document.querySelector('#js-xsolla-pay')
    button = document.querySelector('#js-xsolla-pay')

    trap = DeferrablePromise()
    $(button).on 'click.trap', ->
      $(button).off 'click.trap'
      button.classList.add('store-payment-button--waiting')
      trap.resolve()

    # load scripts
    init = Promise.all([@loadXsollaToken(), @loadXsollaScript()])
    .then (values) =>
      token = values[0]
      options = @optionsWithToken(token)
      XPayStationWidget.init(options)
