<commit_before>// This component handles a transaction response and that's it. It should never appear except as a response.
var payment = {
  vm: {
    handleQueryParameters: function() {

      // Interpret query parameters.
      var paymentID = m.route.param("paymentId");
      var token = m.route.param("token");
      var payerID = m.route.param("PayerID");

      // If query parameters aren't provided, route to home.
      if (paymentID == null || paymentID == "" ||
          payerID == null || payerID == "") {
        if (token != null && token != "") {
          m.route("/");
          openModal(null, genericMessageModal,
            {
              messageTitle:"Payment cancelled!",
              message:"Returning to the Adventure Guild website.",
            }
          );
        }
        else {
          m.route("/");
          openModal(null, genericMessageModal,
            {
              messageTitle:"Payment error!",
              message:"No payment data to process.",
            }
          );
        }
      }
      else {
        // Make the payment and wait for a response.
      }
    }
  },
  view: function() {
    return [
      m.component(nav, {page: "payment"}),
      m.component(waitingForPayment),
      m.component(footer)
    ];
  }
}

// Component that displays while waiting for a response from the ajax call.
var waitingForPayment = {
  view: function() {
    return m("section", {
      class: "hero position-under-nav",
      config: function(el, isInit) {if(!isInit){payment.vm.handleQueryParameters();}}
    }, [
      m(".vertical-center-always payment-processing", m("div", [
        m("h1", "Processing Payment..."),
        m("div", m("img", {src:"imgs/icons/ajax-loader.gif", alt:"AJAX"}))
      ]))<commit_msg>Payment page now shoots valid request to PayPal to execute payment, and responds with proper modal and message<commit_after>// This component handles a transaction response and that's it. It should never appear except as a response.
var payment = {
  vm: {
    handleQueryParameters: function() {

      // Interpret query parameters.
      var paymentID = m.route.param("paymentId");
      var token = m.route.param("token");
      var payerID = m.route.param("PayerID");

      // If query parameters aren't provided, route to home.
      if (paymentID == null || paymentID == "" ||
          payerID == null || payerID == "") {
        if (token != null && token != "") {
          m.route("/");
          openModal(null, genericMessageModal,
            {
              messageTitle:"Payment cancelled!",
              message:"Returning to the Adventure Guild website.",
            }
          );
        }
        else {
          m.route("/");
          openModal(null, genericMessageModal,
            {
              messageTitle:"Payment error!",
              message:"No payment data to process.",
            }
          );
        }
      }
      else {
        // Make the payment and wait for a response.
        storeExecuteOrder(paymentID, payerID, function(response) {
            m.route("/");
            openModal(null, genericMessageModal,
                {
                    messageTitle: "Thank You!",
                    message: "Your purchase has been completed!\n\nYou can now use the Guildium you purchased inside our in-game store. Happy Adventuring!"
                }
            );
        });
      }
    }
  },
  view: function() {
    return [
      m.component(nav, {page: "payment"}),
      m.component(waitingForPayment),
      m.component(footer)
    ];
  }
}

// Component that displays while waiting for a response from the ajax call.
var waitingForPayment = {
  view: function() {
    return m("section", {
      class: "hero position-under-nav",
      config: function(el, isInit) {if(!isInit){payment.vm.handleQueryParameters();}}
    }, [
      m(".vertical-center-always payment-processing", [
        m("h1", "Processing Payment..."),
        m("img", {src:"imgs/icons/ajax-loader.gif", alt:"AJAX"})
        ])
{'fraction_non_alphanumeric': 0.13330029732408324, 'fraction_numerical': 0.0004955401387512388, 'mean_word_length': 1.9705665930831493, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '7452919', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1063, 'n_words': 299}