<?php

### DO THIS FIRST:
require_once("/BANGK!/master_config.php");
require_once($master_config_root_path . "shared/functions.shared");
require_once($master_config_root_path . "shared/session.shared");
 
//PMD core class
include($master_config_root_path . "shared/process_PMD_classes.shared");

//logger3("process_PMD_creditcards.shared | merchant_id",$merchant_id);
//logger3("process_PMD_creditcards.shared | merchant_token",$merchant_token);
logger3("process_PMD_creditcards.shared | hashkey",$hash);
logger3("process_PMD_creditcards.shared | traceid",$traceID);
logger3("process_PMD_creditcards.shared | amount",$amount);
logger3("process_PMD_creditcards.shared | customer_firstname",$customer_firstname);
logger3("process_PMD_creditcards.shared | customer_lastname",$customer_lastname);
logger3("process_PMD_creditcards.shared | customer_email",$customer_email);
logger3("process_PMD_creditcards.shared | customer_phone",$customer_phone);
logger3("process_PMD_creditcards.shared | customer_ip",$customer_ip);
logger3("process_PMD_creditcards.shared | billing_street",$billing_street);
logger3("process_PMD_creditcards.shared | billing_postalcode",$billing_postalcode);
logger3("process_PMD_creditcards.shared | billing_city",$billing_city);
logger3("process_PMD_creditcards.shared | billing_state",$billing_state);
logger3("process_PMD_creditcards.shared | billing_country",$billing_country);
logger3("process_PMD_creditcards.shared | cc_number",$cc_number);
logger3("process_PMD_creditcards.shared | cc_type",$cc_type);
logger3("process_PMD_creditcards.shared | cc_cardholder",$cc_cardholder);
logger3("process_PMD_creditcards.shared | cc_ex_month",$cc_ex_month);
logger3("process_PMD_creditcards.shared | cc_ex_year",$cc_ex_year);
logger3("process_PMD_creditcards.shared | cc_ccv",$cc_ccv);
logger3("process_PMD_creditcards.shared | ",$x);
logger3("process_PMD_creditcards.shared | ",$x);
logger3("process_PMD_creditcards.shared | ",$x);
logger3("process_PMD_creditcards.shared | ",$x);



if(strlen($billing_country) == 3) {
	$billing_country = geo_data($billing_country,"iso3","iso2");
} else if(strlen($billing_country) > 3) {
	$billing_country = geo_data(strtoupper($billing_country),"name","iso2");
}

if($customer_email == "sheasie@gmail.com") $customer_email = "shea.writer@nsdb.com";
if($customer_email == "shea.writer@gmail.com") $customer_email = "shea.writer@nsdb.com";
if($_SESSION['session']['geo']['iso2'] == "TH") $customer_ip = $master_config_vpn_ip;


### VAR CLEANUP / converts int's stuff to ascii
$customer_firstname = iconv("CP850","UTF-8",$customer_firstname);
$customer_lastname = iconv("CP850","UTF-8",$customer_lastname);
$billing_street = iconv("CP850","UTF-8",$billing_street);
$billing_city = iconv("CP850","UTF-8",$billing_city);
$billing_state = iconv("CP850","UTF-8",$billing_state);
$cc_cardholder = iconv("CP850","UTF-8",$cc_cardholder);

$tmp_result = PMD_sale($hash, $amount, $cc_number, $cc_ex_month, $cc_ex_year, $cc_ccv);

// Get the Response
logger3("**** Response ****",$x);
logger3("TransactionID = " , $tmp_result['TransactionID']);
//logger3("Traceid = " , $tmp_result['trace_id']);
//logger3("Transaction amount = " , $tmp_result['transaction_amount']); 
//logger3("Transaction currency = " , $tmp_result['transaction_currency']);
//logger3("Transaction Result = " , $tmp_result['result']);
logger3("Transaction Result Code = " , $tmp_result['ResponseCode']); 
logger3("Transaction Result Text = " , $tmp_result['message']);
?>