<commit_before>const keystone		= require( 'keystone' ),
	  moment		= require( 'moment' ),
	  fs			= require( 'fs' ),
	  handlebars	= require( 'handlebars' ),	
	  helpers       = require( '../../templates/views/helpers/index' )(),
	  stripe		= require( 'stripe' )( process.env.STRIPE_SECRET_API_KEY_TEST );
	  
// define the various donation plan types ( stripe plans are used for recurring donations )
const plan_types = {

	onetime: {
		id: 'onetime',
		interval: 'none',
		interval_count: 0
	},
	
	monthly: {
		id: 'monthly',
		interval: 'month',
		interval_count: 1
	},

	annual: {
		id: 'annual',
		interval: 'month',
		interval_count: 12
	},

	biannual: {
		id: 'biannual',
		interval: 'month',
		interval_count: 6
	}
};

// define the various response message types
const message_types = {

	ERROR: 'error',
	SUCCESS: 'success',
};

// process a one-time donation via the Stripe Charge API
function oneTimeDonation( donationData ) {

	return new Promise( ( resolve, reject ) => {

		stripe.charges.create({
			amount: 	donationData.amountPennies,
			currency: 	'usd',
			source: 	donationData.token
		}, function( error, charge ) {

			if ( error ) {

				reject( error );
			} else {

				resolve( charge );
			}
		});
	});
}

// process a recurring donation using the Stripe Customer, Plan, and Subscription APIs
function recurringDonation( donationData ) {

	return new Promise( ( resolve, reject ) => {

		// create a new stripe customer using the donator's email
		createCustomer( donationData )
			.then( customer => createPlan( customer, donationData ) )
			.then( plan => createSubscription( plan ) )<commit_msg>#25 | adds description to one-time donation receipts<commit_after>const keystone		= require( 'keystone' ),
	  moment		= require( 'moment' ),
	  fs			= require( 'fs' ),
	  handlebars	= require( 'handlebars' ),	
	  helpers       = require( '../../templates/views/helpers/index' )(),
	  stripe		= require( 'stripe' )( process.env.STRIPE_SECRET_API_KEY_TEST );
	  
// define the various donation plan types ( stripe plans are used for recurring donations )
const plan_types = {

	onetime: {
		id: 'onetime',
		interval: 'none',
		interval_count: 0
	},
	
	monthly: {
		id: 'monthly',
		interval: 'month',
		interval_count: 1
	},

	annual: {
		id: 'annual',
		interval: 'month',
		interval_count: 12
	},

	biannual: {
		id: 'biannual',
		interval: 'month',
		interval_count: 6
	}
};

// define the various response message types
const message_types = {

	ERROR: 'error',
	SUCCESS: 'success',
};

// process a one-time donation via the Stripe Charge API
function oneTimeDonation( donationData ) {

	return new Promise( ( resolve, reject ) => {

		stripe.charges.create({
			amount: 		donationData.amountPennies,
			currency: 		'usd',
			description:	`$${ new Intl.NumberFormat( 'en-US' ).format( donationData.amountDollars ) } One-Time Donation`,
			source: 		donationData.token
		}, function( error, charge ) {

			if ( error ) {

				reject( error );
			} else {

				resolve( charge );
			}
		});
	});
}

// process a recurring donation using the Stripe Customer, Plan, and Subscription APIs
function recurringDonation( donationData ) {

	return new Promise( ( resolve, reject ) => {

		// create a new stripe customer using the donator's email
		createCustomer( donationData )
			.then( customer => createPlan( customer, donationData ) )
			.then( plan => createSubscription( plan ) )
{'fraction_non_alphanumeric': 0.13090695626651014, 'fraction_numerical': 0.0035221602582917524, 'mean_word_length': 3.3974193548387097, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '655797', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1092, 'n_words': 312}