<commit_before>var httpRequest = require('request');
var stripe = require('./stripe');
var paypal = require('./paypal');
var amountModifier = require('./amount-modifier');

var routes = {
  'signup': function(request, reply) {
    var url = process.env.SIGNUP;
    var transaction = request.payload || {};
    if(transaction.locale !== 'en-US') {
      url = url + '-' + transaction.locale;
    }
    httpRequest({
      url: url,
      method: 'POST',
      form: {
        'opt_in': '1',
        email: transaction.email
      }
    }, function(err) {
      if (err) {
        reply({
          error: err
        });
        console.error('signup failed:', err);
      } else {
        reply({
          success: true
        });
      }
    });
  },
  'stripe': function(request, reply) {
    var transaction = request.payload || {};
    var currency = transaction.currency;
    var amount = amountModifier.stripe(transaction.amount, currency);
    if (transaction.frequency !== 'monthly') {
      stripe.single({
        amount: amount,
        currency: currency,
        stripeToken: transaction.stripeToken
      }, function(err, charge) {
        if (err) {
          reply({
            error: err
          });
          console.log('Stripe charge failed:', err);
        } else {
          reply({
            success: charge
          });
          console.log('Stripe charge sent to Stripe!');
        }
      });
    } else {
      stripe.recurring({
        // Stripe has plans with set amounts, not custom amounts.
        // So to get a custom amount we have a plan set to 1 cent, and we supply the quantity.
        // https://support.stripe.com/questions/how-can-i-create-plans-that-dont-have-a-fixed-price
        quantity: amount,
        stripeToken: transaction.stripeToken,
        email: transaction.email,
        currency: currency,
        metadata: {
          firstname: transaction.first,
          lastname: transaction.last,
          country: transaction.country,
          address: transaction.address,
          city: transaction.city,
          zip: transaction.code,
          state: transaction.province,
          locale: transaction.locale
        }
      }, function(err, subscription) {
        if (err) {
          reply({
            error: err
          });
          console.log('Stripe subscription failed:', err);
        } else {
          reply({
            success: subscription<commit_msg>ensure we only send stripe error properties we need to the client<commit_after>var httpRequest = require('request');
var stripe = require('./stripe');
var paypal = require('./paypal');
var amountModifier = require('./amount-modifier');

var routes = {
  'signup': function(request, reply) {
    var url = process.env.SIGNUP;
    var transaction = request.payload || {};
    if(transaction.locale !== 'en-US') {
      url = url + '-' + transaction.locale;
    }
    httpRequest({
      url: url,
      method: 'POST',
      form: {
        'opt_in': '1',
        email: transaction.email
      }
    }, function(err) {
      if (err) {
        reply({
          error: err
        });
        console.error('signup failed:', err);
      } else {
        reply({
          success: true
        });
      }
    });
  },
  'stripe': function(request, reply) {
    var transaction = request.payload || {};
    var currency = transaction.currency;
    var amount = amountModifier.stripe(transaction.amount, currency);
    if (transaction.frequency !== 'monthly') {
      stripe.single({
        amount: amount,
        currency: currency,
        stripeToken: transaction.stripeToken
      }, function(err, charge) {
        if (err) {
          reply({
            error: {
              code: err.code,
              rawType: err.rawType
            }
          });
          console.log('Stripe charge failed:', err);
        } else {
          reply({
            success: charge
          });
          console.log('Stripe charge sent to Stripe!');
        }
      });
    } else {
      stripe.recurring({
        // Stripe has plans with set amounts, not custom amounts.
        // So to get a custom amount we have a plan set to 1 cent, and we supply the quantity.
        // https://support.stripe.com/questions/how-can-i-create-plans-that-dont-have-a-fixed-price
        quantity: amount,
        stripeToken: transaction.stripeToken,
        email: transaction.email,
        currency: currency,
        metadata: {
          firstname: transaction.first,
          lastname: transaction.last,
          country: transaction.country,
          address: transaction.address,
          city: transaction.city,
          zip: transaction.code,
          state: transaction.province,
          locale: transaction.locale
        }
      }, function(err, subscription) {
        if (err) {
          reply({
            error: {
              code: err.code,
              rawType: err.rawType
            }
          });
          console.log('Stripe subscription failed:', err);
        } else {
          reply({
            success: subscription
{'fraction_non_alphanumeric': 0.12367491166077739, 'fraction_numerical': 0.0007852375343541421, 'mean_word_length': 1.796377607025247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4690485', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1369, 'n_words': 346}