<commit_before>class PaymentMaker

	PAYMENT_TYPES = [:donation, :registration]
	
	## If successful payment, return receipt
	## else, return errors

	def initialize(host_model, payment_type, full_params, admin=nil)
		@host_model = host_model
		@payment_type = payment_type
		@full_params = full_params
		@amount = correct_amount #@payment_type == :registration ? RideYear.current_fee : @host_model.amount
		@by_check = admin && ( @full_params[:receipt][:by_check] == "1" )
		@admin = admin
	end

	def correct_amount
		if @payment_type == :registration 
			if @host_model.ride_option == 'Custom'
				@host_model.custom_ride_option.registration_fee
			else
				RideYear.current_fee 
			end
		else
			@host_model.amount
		end
	end

	def process_payment
		unless inputs_are_valid
			return prep_errors_hash
		end
		if @by_check
			prep_and_return_receipt
		else
			call_paypal
		end
	end

	def inputs_are_valid
		if @payment_type == :donation
			@host_model.valid? && validate_payment_info && define_billing_adddress && prep_transaction_details<commit_msg>ammend payment maker "correct_amount" method to find reg fee by ride year<commit_after>class PaymentMaker

	PAYMENT_TYPES = [:donation, :registration]
	
	## If successful payment, return receipt
	## else, return errors

	def initialize(host_model, payment_type, full_params, admin=nil)
		@host_model = host_model
		@payment_type = payment_type
		@full_params = full_params
		@amount = correct_amount #@payment_type == :registration ? RideYear.current_fee : @host_model.amount
		@by_check = admin && ( @full_params[:receipt][:by_check] == "1" )
		@admin = admin
	end

	def correct_amount
		if @payment_type == :registration 
			if !RideYear::OPTIONS.include?( @host_model.ride_option )
				CustomRideOption.find_by( display_name: ryr.ride_option ).registration_fee
			else
				RideYear.current_fee 
			end
		else
			@host_model.amount
		end
	end

	def process_payment
		unless inputs_are_valid
			return prep_errors_hash
		end
		if @by_check
			prep_and_return_receipt
		else
			call_paypal
		end
	end

	def inputs_are_valid
		if @payment_type == :donation
			@host_model.valid? && validate_payment_info && define_billing_adddress && prep_transaction_details
{'fraction_non_alphanumeric': 0.08333333333333333, 'fraction_numerical': 0.0009057971014492754, 'mean_word_length': 4.67866323907455, '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': '6314864', 'n_tokens_mistral': 841, 'n_tokens_neox': 735, 'n_words': 165}