<commit_before># Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
# See the LICENCE file in the repository root for full licence text.

import { route } from 'laroute'
import core from 'osu-core-singleton'
import { showLoadingOverlay } from 'utils/loading-overlay'

export class StoreXsolla
  @promiseInit: (orderNumber) ->
    Promise.all([
      StoreXsolla.fetchToken(orderNumber), StoreXsolla.fetchScript()
    ]).then (values) ->
      StoreXsolla.onXsollaReady(orderNumber)
      XPayStationWidget.init(values[0])


  @fetchScript: ->
    core.turbolinksReload.load('https://static.xsolla.com/embed/paystation/1.0.7/widget.min.js') ? Promise.resolve()


  @fetchToken: (orderNumber) ->
    new Promise (resolve, reject) ->
      $.post route('payments.xsolla.token'), { orderNumber }
      .done (data) ->
        # Make sure laroute hasn't trolled us.
        return reject(message: 'wrong token length') unless data.access_token?.length == 32
        resolve(data)
      .fail (xhr) ->
        reject(xhr: xhr)


  @onXsollaReady: (orderNumber) ->
    done = false

    XPayStationWidget.on XPayStationWidget.eventTypes.STATUS_DONE, ->
      done = true

    XPayStationWidget.on XPayStationWidget.eventTypes.CLOSE, ->
      if done
        showLoadingOverlay()
        showLoadingOverlay.flush()
        window.location = route('payments.xsolla.completed', 'foreignInvoice': orderNumber)<commit_msg>skip xsolla token length check<commit_after># Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
# See the LICENCE file in the repository root for full licence text.

import { route } from 'laroute'
import core from 'osu-core-singleton'
import { showLoadingOverlay } from 'utils/loading-overlay'

export class StoreXsolla
  @promiseInit: (orderNumber) ->
    Promise.all([
      StoreXsolla.fetchToken(orderNumber), StoreXsolla.fetchScript()
    ]).then (values) ->
      StoreXsolla.onXsollaReady(orderNumber)
      XPayStationWidget.init(values[0])


  @fetchScript: ->
    core.turbolinksReload.load('https://static.xsolla.com/embed/paystation/1.0.7/widget.min.js') ? Promise.resolve()


  @fetchToken: (orderNumber) ->
    new Promise (resolve, reject) ->
      $.post route('payments.xsolla.token'), { orderNumber }
      .done (data) ->
        resolve(data)
      .fail (xhr) ->
        reject(xhr: xhr)


  @onXsollaReady: (orderNumber) ->
    done = false

    XPayStationWidget.on XPayStationWidget.eventTypes.STATUS_DONE, ->
      done = true

    XPayStationWidget.on XPayStationWidget.eventTypes.CLOSE, ->
      if done
        showLoadingOverlay()
        showLoadingOverlay.flush()
        window.location = route('payments.xsolla.completed', 'foreignInvoice': orderNumber)
{'fraction_non_alphanumeric': 0.12015781922525108, 'fraction_numerical': 0.005021520803443328, 'mean_word_length': 3.3990536277602525, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5203969', 'n_tokens_mistral': 906, 'n_tokens_neox': 861, 'n_words': 195}