<commit_before>// Sandbox Credentials below
var apikey = '<KEY>';
var apisecret = 'f09b001b16eab639ae52e3d543181d20640aca5b74a1c29b2f481e578519448a';
var merchant_token = '<KEY>';

var payeezy = require('payeezy')(apikey, apisecret, merchant_token);
payeezy.version = "v1";


// Sandbox Environment - Replace this value for Live Environment "api.payeezy.com"
payeezy.host = "api-cert.payeezy.com";


// This will first execute an Auth followed by a Capture transaction .. followed by
// Auth followed by Void .. followed by
// Purchase followed by a Refund transaction
//runExamples();


// Below are the helper methods that will perform Authorize, Purchase, Capture, Void & Refund.

function runExamples() {
    performAuthorizeTransaction('capture');
}

exports.performAuthorizeTransaction = function(secondaryTransactionType) {
    console.log('*******************************************\nPerforming Authorize Transaction\n************************************')
    payeezy.transaction.authorize({
            method: 'credit_card',
            amount: '1299',
            currency_code: 'USD',
            credit_card: {
                card_number: '4788250000028291',
                cvv: '123',
                type: 'visa',
                exp_date: '1230',
                cardholder_name: '<NAME>'
            },
            billing_address: {
                street: '225 Liberty Street',
                city: 'NYC',
                state_province: 'NY',
                zip_postal_code: '10281',
                country: 'US'
            }
        },
        function(error, response) {
            if (error) {
                //console.log('Authorize Transaction Failed\n' + JSON.stringify(error));
				return JSON.stringify(error);
            }
            if (response) {
                //console.log('Authorize Successful.\nTransaction Tag: ' + response.transaction_tag);
                performSecondaryTransaction(secondaryTransactionType, response.transaction_id, response.transaction_tag, response.amount);
            }
        });

}



exports.performPurchaseTransaction = function(req, res) {
    //console.log('*******************************************\nPerforming Purchase Transaction\n************************************')
    payeezy.transaction.purchase(
		{
     "transactionId": "o30446-pg30417-1458555741310",
     "currencyCode": "USD",
     "paymentId": "pg30417",
     "locale": "en",
     "gatewaySettings": {
          "paymentMethodTypes": "card",
          "filteredFields": ["paymentMethodTypes"]
     },
     "cardDetails": {
          "expirationMonth": "02",
          "expirationYear": "2018",
          "cvv": "234",
          "number": "4111111111111111",
          "type": "visa",
          "holderName": "<NAME>"
     },
     "amount": "000000122526",
     "transactionType": "0100",
     "transactionTimestamp": "2016-03-21T10:22:21+0000",
     "billingAddress": {
          "lastName": "Shopper",
          "postalCode": "01242",
          "phoneNumber": "617-555-1977",
          "email": "<EMAIL>",
          "state": "MA",
          "address1": "1 Main Street",
          "address2": "",
          "firstName": "Test",
          "city": "Cambridge",
          "country": "US"
     },
     "channel": "storefront",
     "shippingAddress": {
          "lastName": "Shopper",
          "postalCode": "01242",
          "phoneNumber": "617-555-1977",
          "email": "<EMAIL>",
          "state": "MA",
          "address1": "1 Main Street",
          "address2": "",
          "firstName": "Test",
          "city": "Cambridge",
          "country": "US"
     },
     "orderId": "o30446",
     "paymentMethod": "card",
     "gatewayId": "gatewayDemo",
     "profile": {
          "id": "110454",
          "phoneNumber": "617-555-1977",
          "email": "<EMAIL>"
     }
},
        function(error, response) {
            if (error) {
                console.log('Purchase Transaction Failed\n' + error);
				res.send(error);
            }
            if (response) {
                console.log('Purchase Successful.\nTransaction Tag: ' + response.transaction_tag);
				res.send(response);
                //performSecondaryTransaction(secondaryTransactionType, response.transaction_id, response.transaction_tag, response.amount);
            }
        });
}

function performSecondaryTransaction(secondaryTransactionType, id, tag, amount) {

    if (secondaryTransactionType == 'capture') {
        console.log('*******************************************\nPerforming Capture Transaction\n************************************')

        payeezy.transaction.capture(id, {
                method: 'credit_card',
                amount: amount,
                currency_code: 'USD',
                transaction_tag: tag,
            },

            function(error, response) {
                if (error) {
                    console.log('Capture Transaction Failed\n' + error);
					return JSON.stringify(error);
                }<commit_msg>twelve commit<commit_after>// Sandbox Credentials below
var apikey = '<KEY>';
var apisecret = 'f09b001b16eab639ae52e3d543181d20640aca5b74a1c29b2f481e578519448a';
var merchant_token = '<PASSWORD>23ddc38e9f8cdd3da8fe0';

var payeezy = require('payeezy')(apikey, apisecret, merchant_token);
payeezy.version = "v1";


// Sandbox Environment - Replace this value for Live Environment "api.payeezy.com"
payeezy.host = "api-cert.payeezy.com";


// This will first execute an Auth followed by a Capture transaction .. followed by
// Auth followed by Void .. followed by
// Purchase followed by a Refund transaction
//runExamples();


// Below are the helper methods that will perform Authorize, Purchase, Capture, Void & Refund.

function runExamples() {
    performAuthorizeTransaction('capture');
}

exports.performAuthorizeTransaction = function(secondaryTransactionType) {
    console.log('*******************************************\nPerforming Authorize Transaction\n************************************')
    payeezy.transaction.authorize({
            method: 'credit_card',
            amount: '1299',
            currency_code: 'USD',
            credit_card: {
                card_number: '4788250000028291',
                cvv: '123',
                type: 'visa',
                exp_date: '1230',
                cardholder_name: '<NAME>'
            },
            billing_address: {
                street: '225 Liberty Street',
                city: 'NYC',
                state_province: 'NY',
                zip_postal_code: '10281',
                country: 'US'
            }
        },
        function(error, response) {
            if (error) {
                //console.log('Authorize Transaction Failed\n' + JSON.stringify(error));
				return JSON.stringify(error);
            }
            if (response) {
                //console.log('Authorize Successful.\nTransaction Tag: ' + response.transaction_tag);
                performSecondaryTransaction(secondaryTransactionType, response.transaction_id, response.transaction_tag, response.amount);
            }
        });

}



exports.performPurchaseTransaction = function(req, res) {
    //console.log('*******************************************\nPerforming Purchase Transaction\n************************************')
    payeezy.transaction.purchase(
		req.body,
        function(error, response) {
            if (error) {
                console.log('Purchase Transaction Failed\n' + error);
				res.send(error);
            }
            if (response) {
                console.log('Purchase Successful.\nTransaction Tag: ' + response.transaction_tag);
				res.send(response);
                //performSecondaryTransaction(secondaryTransactionType, response.transaction_id, response.transaction_tag, response.amount);
            }
        });
}

function performSecondaryTransaction(secondaryTransactionType, id, tag, amount) {

    if (secondaryTransactionType == 'capture') {
        console.log('*******************************************\nPerforming Capture Transaction\n************************************')

        payeezy.transaction.capture(id, {
                method: 'credit_card',
                amount: amount,
                currency_code: 'USD',
                transaction_tag: tag,
            },

            function(error, response) {
                if (error) {
                    console.log('Capture Transaction Failed\n' + error);
					return JSON.stringify(error);
                }
{'fraction_non_alphanumeric': 0.17264494884158532, 'fraction_numerical': 0.036575326355403975, 'mean_word_length': 2.3322884012539187, 'pattern_counts': {'":': 47, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '1317006', 'n_tokens_mistral': 2546, 'n_tokens_neox': 2213, 'n_words': 465}