<commit_before>require 'klarna/checkout'

Spree::CheckoutController.class_eval do

  def push
    # get the id
    checkout_id = params[:klarna_order]

    # call klarna API
    client = get_client

    @remote_order = client.read_order(checkout_id)

    if @remote_order.status == "checkout_complete"      
      @remote_order.status = "created";
      @remote_order.merchant_reference = { 'order_id' => @order.number }
      # update order (remote)
      client.create_order(@remote_order)
    end    

  end

  def confirmation
    # get the id
    checkout_id = params[:klarna_order]

    # call klarna API
    client = get_client

    @remote_order = client.read_order(checkout_id)
<commit_msg>Bypass authenticy token validation (Klarna callback)<commit_after>require 'klarna/checkout'

Spree::CheckoutController.class_eval do

  skip_before_filter :verify_authenticity_token

  def push
    # get the id
    checkout_id = params[:klarna_order]

    # call klarna API
    client = get_client

    @remote_order = client.read_order(checkout_id)

    if @remote_order.status == "checkout_complete"      
      @remote_order.status = "created";
      @remote_order.merchant_reference = { 'order_id' => @order.number }
      # update order (remote)
      client.create_order(@remote_order)
    end    

  end

  def confirmation
    # get the id
    checkout_id = params[:klarna_order]

    # call klarna API
    client = get_client

    @remote_order = client.read_order(checkout_id)

{'fraction_non_alphanumeric': 0.08681022880215343, 'fraction_numerical': 0.0, 'mean_word_length': 3.2607449856733526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5896349', 'n_tokens_mistral': 490, 'n_tokens_neox': 470, 'n_words': 99}