<commit_before>/**
 * # transaction
 * Copyright (c)2011, by <NAME> <<EMAIL>>
 *
 * @author <NAME> <<EMAIL>>
 * @license MIT (see LICENSE)
 */

var config = require('./config');
var DaimyoError = require('./error');
var xmlutils = require('./xmlutils');
var settings = config.settings;
var debug = config.debug;
var transaction = exports;

var VALID_TRANSACTIONS = ['purchase', 'authorize', 'capture', 'void', 'credit'];

/**
 * ## MAPPINGS
 * *Mappings between Daimyo fields and Samurai node names*
 */
transaction.MAPPINGS = {
  currency: 'currency_code'
};
 * ## getTransactionPath(type, [transactionId])<commit_msg>Added XML parsing recipes for transactions.<commit_after>/**
 * # transaction
 * Copyright (c)2011, by <NAME> <<EMAIL>>
 *
 * @author <NAME> <<EMAIL>>
 * @license MIT (see LICENSE)
 */

var config = require('./config');
var DaimyoError = require('./error');
var xmlutils = require('./xmlutils');
var authpost = require('./authpost');
var messages = require('./messages');
var daimyoRecipes = require('./daimyo').recipes;
var settings = config.settings;
var debug = config.debug;
var transaction = exports;

var VALID_TRANSACTIONS = ['purchase', 'authorize', 'capture', 'void', 'credit'];

/**
 * ## MAPPINGS
 * *Mappings between Daimyo fields and Samurai node names*
 */
transaction.MAPPINGS = {
  currency: 'currency_code'
};

/**
 * ## transaction.recipes
 * *Recipes for parsing XML data*
 *
 * Recipes are used to parse XML data returned by the Samurai gateway. For more
 * infomration on parsing recipes, see `xmlutils` documentation.
 *
 * The key name of each recipe corresponds to the XML node name.
 *
 * @private
 */
transaction.recipes = {
  transaction: {
    reference_id: xmlutils.toString,
    transaction_token: xmlutils.toString,
    created_at: xmlutils.toDate,
    descriptor: xmlutils.toString,
    custom: xmlutils.toString,
    transaction_type: xmlutils.toString,
    amount: xmlutils.toFloat,
    currency_code: xmlutils.toString,
    success: xmlutils.toBool
  },
  paymentMethod: daimyoRecipes.paymentMethod
};

/**
 * ## getTransactionPath(type, [transactionId])
{'fraction_non_alphanumeric': 0.14800759013282733, 'fraction_numerical': 0.003795066413662239, 'mean_word_length': 4.463730569948186, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, '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': '721982', 'n_tokens_mistral': 649, 'n_tokens_neox': 630, 'n_words': 181}