<commit_before>require 'stripe'
require 'stripe_helper'

module Locomotive
  module Ecommerce
    class StripeConfigurationHelper
      include EcommerceHelper
    end

    ::StripeHelper.configure do |config|
      helper = StripeConfigurationHelper.new

      amt_proc = lambda do |controller, token|
        purchase = Purchase.where(_id: token).first
        return nil if !purchase
        (purchase.total.round(2)*100).to_i
      end

      failure_proc = lambda do |controller, token, msg|
        purchase = Purchase.where(_id: token).first
        controller.flash[:error] = msg
        helper.checkout_path
      end

      success_proc = lambda do |controller, token, stripe|
        purchase = Purchase.where(_id: token).first
        PurchaseController.complete(token,
                                    helper.current_user(controller),
                                    helper.current_user_cart(controller),
                                    stripe)
        controller.flash[:notice] = "Thank you for your purchase."
        helper.post_checkout_path
      end

      config.charge_amount  = amt_proc
      config.charge_failure = failure_proc
      config.charge_success = success_proc
    end
  end
end
<commit_msg>pass session to Order on complete<commit_after>require 'stripe'
require 'stripe_helper'

module Locomotive
  module Ecommerce
    class StripeConfigurationHelper
      include EcommerceHelper
    end

    ::StripeHelper.configure do |config|
      helper = StripeConfigurationHelper.new

      amt_proc = lambda do |controller, token|
        purchase = Purchase.where(_id: token).first
        return nil if !purchase
        (purchase.total.round(2)*100).to_i
      end

      failure_proc = lambda do |controller, token, msg|
        purchase = Purchase.where(_id: token).first
        controller.flash[:error] = msg
        helper.checkout_path
      end

      success_proc = lambda do |controller, token, stripe|
        purchase = Purchase.where(_id: token).first
        Purchase.complete(token,
          helper.current_user(controller),
          helper.current_user_cart(controller),
          stripe,
          controller.session)
        controller.flash[:notice] = "Thank you for your purchase."
        helper.post_checkout_path
      end

      config.charge_amount  = amt_proc
      config.charge_failure = failure_proc
      config.charge_success = success_proc
    end
  end
end

{'fraction_non_alphanumeric': 0.07313064913722268, 'fraction_numerical': 0.003286770747740345, 'mean_word_length': 2.3819444444444446, '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': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5267971', 'n_tokens_mistral': 669, 'n_tokens_neox': 645, 'n_words': 156}