<commit_before>import { Meteor } from 'meteor/meteor';
import { Email } from 'meteor/email';
import StripeConstructor from 'stripe';
import { check, Match } from 'meteor/check';
import Settings from '/logic/core/settings';

let stripe;

/**
 * @summary Configure Stripe options
 */
Meteor.startup(() => {
  const settings = Settings.get('stripe') || {};
  const { secretKey } = settings;
  stripe = StripeConstructor(secretKey);<commit_msg>Create WCASA Donation product in Stripe if it does not yet exist.<commit_after>import { Meteor } from 'meteor/meteor';
import { Email } from 'meteor/email';
import StripeConstructor from 'stripe';
import { check, Match } from 'meteor/check';
import Settings from '/logic/core/settings';

let stripe;
let product;

/**
 * @summary Configure Stripe options
 */
Meteor.startup(() => {
  const settings = Settings.get('stripe') || {};
  const { secretKey } = settings;
  stripe = StripeConstructor(secretKey);

  // Check to see if there is an existing WCASA Donation product for
  // recurring donations.  If not, create one.
  stripe.products.list({ type: 'service' }, (error, products) => {
    if (error) throw new Meteor.Error(error);

    products.data.forEach((prod) => {
      if (prod.name === 'WCASA Donation') product = prod;
    });

    // If no product was found, create one
    if (!product) {
      stripe.products.create({
        name: 'WCASA Donation',
        type: 'service',
      }, (err, prod) => {
        if (err) throw new Meteor.Error(err);
        product = prod;
      });
    }
  });
{'fraction_non_alphanumeric': 0.14387096774193547, 'fraction_numerical': 0.0, 'mean_word_length': 3.456896551724138, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '6856777', 'n_tokens_mistral': 501, 'n_tokens_neox': 470, 'n_words': 143}