<commit_before>module Shoppe
  module Paytrail
    module OrderExtensions
      def redirect_to_paytrail(success_url, failure_url, notification_url)
        response = PaytrailClient::Payment.create(order_number: number,
                                                  currency: 'EUR',
                                                  locale: 'en_US',
                                                  url_set: {
                                                    success: success_url,
                                                    failure: failure_url,
                                                    notification: notification_url
                                                  },
                                                  price: format('%.2f', total))

        response['url']
      rescue
        raise Shoppe::Errors::PaymentDeclined
      end

      def handle_paytrail_payment(params, confirmed = false)
        PaytrailClient::Payment.verify_payment!(params['ORDER_NUMBER'],
                                                params['TIMESTAMP'],
                                                params['PAID'],
                                                params['METHOD'],
                                                params['RETURN_AUTHCODE'])

        payment = payments.find_by(reference: params['ORDER_NUMBER'])

        if payment.nil?
          payment = payments.create(amount:     total,
                          reference:  params['ORDER_NUMBER'],
                          method:     'Paytrail',
                          refundable: false,
                          confirmed:  confirmed)
        end
        
        paytment.update_attribute(confirmed: confirmed)

        save!<commit_msg>Moving so fast that the chars have a hard time catching up<commit_after>module Shoppe
  module Paytrail
    module OrderExtensions
      def redirect_to_paytrail(success_url, failure_url, notification_url)
        response = PaytrailClient::Payment.create(order_number: number,
                                                  currency: 'EUR',
                                                  locale: 'en_US',
                                                  url_set: {
                                                    success: success_url,
                                                    failure: failure_url,
                                                    notification: notification_url
                                                  },
                                                  price: format('%.2f', total))

        response['url']
      rescue
        raise Shoppe::Errors::PaymentDeclined
      end

      def handle_paytrail_payment(params, confirmed = false)
        PaytrailClient::Payment.verify_payment!(params['ORDER_NUMBER'],
                                                params['TIMESTAMP'],
                                                params['PAID'],
                                                params['METHOD'],
                                                params['RETURN_AUTHCODE'])
        binding.pry
        payment = payments.find_by(reference: params['ORDER_NUMBER'])

        if payment.nil?
          payment = payments.create(amount:     total,
                          reference:  params['ORDER_NUMBER'],
                          method:     'Paytrail',
                          refundable: false,
                          confirmed:  confirmed)
        end

        payment.update_attribute(confirmed: confirmed)

        save!
{'fraction_non_alphanumeric': 0.06640293868324386, 'fraction_numerical': 0.0005651313930488839, 'mean_word_length': 0.9291553133514986, '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': 48, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2751412', 'n_tokens_mistral': 634, 'n_tokens_neox': 623, 'n_words': 133}