<commit_before>var paymayaSdk = require("./../../lib/paymaya/PaymayaSDK");
var Checkout = require("./../../lib/paymaya/api/Checkout");
var Item = require("./../../lib/paymaya/model/checkout/Item");
var ItemAmount = require("./../../lib/paymaya/model/checkout/ItemAmount");
var ItemAmountDetails = require("./../../lib/paymaya/model/checkout/ItemAmountDetails");
var User = require("./User");

(function() {
	
	// Initialize Paymaya SDK with Checkout API key, secret key and environment(SANDBOX or PRODUCTION)
	paymayaSdk.initCheckout("<KEY>", "<KEY>", paymayaSdk.ENVIRONMENT.SANDBOX);

	// Contruct item amount details
	var itemAmountDetails = _getItemAmountDetails();

	// Construct item amount
	var itemAmount = _getItemAmount(itemAmountDetails);

	// Contruct item
	var item = _getItem(itemAmount, itemAmount);

	// Construct buyer object
	var user = new User();
	var buyer = user.getBuyer();

	// Contruct item list
	var items = [];
	items.push(item);

	// Initialize Checkout
	var checkout = new Checkout();
	_executeInitiateCheckout(checkout, buyer, items, itemAmount);

})();

function _getItemAmountDetails() {
	var itemAmountDetailsOptions = {
		shippingFee: "14.00",
		tax: "5.00",
		subTotal: "50.00" 
	}
	return new ItemAmountDetails(itemAmountDetailsOptions);
}

function _getItemAmount(itemAmountDetails) {
	var itemAmountOptions = {
		currency: "PHP",
		value: "69.00",
		details: itemAmountDetails
	}
	return new ItemAmount(itemAmountOptions);
}

function _getItem(amount, totalAmount) {
	var itemOptions = {
		name: "<NAME>",
		code: "pm_belt",
		description: "Medium-sv",
		amount: amount,
		totalAmount: totalAmount
	}
	return new Item(itemOptions);
}

function _executeInitiateCheckout(checkout, buyer, items, itemAmount) {
	checkout.buyer = buyer;
	checkout.items = items;
	checkout.totalAmount = itemAmount;
	checkout.requestReferenceNumber = "123456789";
	var onInitiateCheckout = function(err, response) {
		if(err) {
			console.log("Error: " + err);
			return;
		}
		if(response) {
			console.log(JSON.stringify(response));
		}

		_executeGetCheckout(checkout, response.checkoutId);
	}
	console.log("\nInitiating Checkout Api");
	checkout.execute(onInitiateCheckout);
}

function _executeGetCheckout(checkout, checkoutId) {
	checkout.checkoutId = checkoutId;
	var onRetrieveCheckout = function(err, response) {
		if(err) {
			console.log("Error: " + err);
			//return;
		}
		if(response) {
			console.log(JSON.stringify(response));
		}
	}
	console.log("\nRetrieving Checkout Api");
	checkout.get(onRetrieveCheckout);
}<commit_msg>Add return statement on retrieve checkout<commit_after>var paymayaSdk = require("./../../lib/paymaya/PaymayaSDK");
var Checkout = require("./../../lib/paymaya/api/Checkout");
var Item = require("./../../lib/paymaya/model/checkout/Item");
var ItemAmount = require("./../../lib/paymaya/model/checkout/ItemAmount");
var ItemAmountDetails = require("./../../lib/paymaya/model/checkout/ItemAmountDetails");
var User = require("./User");

(function() {
	
	// Initialize Paymaya SDK with Checkout API key, secret key and environment(SANDBOX or PRODUCTION)
	paymayaSdk.initCheckout("pk-iaioBC2pbY6d3BVRSebsJxghSHeJDW4n6navI7tYdrN", "<KEY>", paymayaSdk.ENVIRONMENT.SANDBOX);

	// Contruct item amount details
	var itemAmountDetails = _getItemAmountDetails();

	// Construct item amount
	var itemAmount = _getItemAmount(itemAmountDetails);

	// Contruct item
	var item = _getItem(itemAmount, itemAmount);

	// Construct buyer object
	var user = new User();
	var buyer = user.getBuyer();

	// Contruct item list
	var items = [];
	items.push(item);

	// Initialize Checkout
	var checkout = new Checkout();
	_executeInitiateCheckout(checkout, buyer, items, itemAmount);

})();

function _getItemAmountDetails() {
	var itemAmountDetailsOptions = {
		shippingFee: "14.00",
		tax: "5.00",
		subTotal: "50.00" 
	}
	return new ItemAmountDetails(itemAmountDetailsOptions);
}

function _getItemAmount(itemAmountDetails) {
	var itemAmountOptions = {
		currency: "PHP",
		value: "69.00",
		details: itemAmountDetails
	}
	return new ItemAmount(itemAmountOptions);
}

function _getItem(amount, totalAmount) {
	var itemOptions = {
		name: "<NAME>",
		code: "pm_belt",
		description: "Medium-sv",
		amount: amount,
		totalAmount: totalAmount
	}
	return new Item(itemOptions);
}

function _executeInitiateCheckout(checkout, buyer, items, itemAmount) {
	checkout.buyer = buyer;
	checkout.items = items;
	checkout.totalAmount = itemAmount;
	checkout.requestReferenceNumber = "123456789";
	var onInitiateCheckout = function(err, response) {
		if(err) {
			console.log("Error: " + err);
			return;
		}
		if(response) {
			console.log(JSON.stringify(response));
		}

		_executeGetCheckout(checkout, response.checkoutId);
	}
	console.log("\nInitiating Checkout Api");
	checkout.execute(onInitiateCheckout);
}

function _executeGetCheckout(checkout, checkoutId) {
	checkout.checkoutId = checkoutId;
	var onRetrieveCheckout = function(err, response) {
		if(err) {
			console.log("Error: " + err);
			return;
		}
		if(response) {
			console.log(JSON.stringify(response));
		}
	}
	console.log("\nRetrieving Checkout Api");
	checkout.get(onRetrieveCheckout);
}
{'fraction_non_alphanumeric': 0.14274676453544524, 'fraction_numerical': 0.010430751400424957, 'mean_word_length': 4.683863885839736, 'pattern_counts': {'":': 0, '<': 8, '<?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': '7636356', 'n_tokens_mistral': 1855, 'n_tokens_neox': 1718, 'n_words': 349}