<?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");


// Pull in the NuSOAP code
require_once($master_config_root_path . "shared/nusoap-0.9.5/lib/nusoap.php"); 



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


logger3("_REQUEST['cc']",$_REQUEST['cc']);
$cc = $_REQUEST['cc'];
logger3("cc",$cc);

// Create the client instance
logger3("master_config_GSP_gateway",$master_config_GSP_gateway);
$client = new nusoap_client($master_config_GSP_gateway, true);
logger3("client",$client);
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
	logger3("Constructor error",$err);
// At this point, you know the call that follows will fail
}

# $merchant_id = YOUR MERCHANT ID;
# $merchant_token = 'YOUR MERCHANT TOKEN';
# $traceID = '123445';
# $hash = md5 ($merchant_id.$merchant_token.$traceID); $amount = '100.50';
# $currency = 'USD';
# $customer_firstname = 'James Richard'; 
# $customer_lastname = 'Scott Jones';
# $customer_email = 'james@gmail.com'; 
# $customer_phone = '50688888888';
# $customer_ip = $_SERVER['REMOTE_ADDR']; 
# $billing_street = 'Street 1 first avenue'; 
# $billing_postalcode = '90210';
# $billing_city = 'Miami';
# $billing_state = 'FL';
# $billing_country = 'US';
# $cc_number ='400000000000';
# $cc_type='visa';
# $cc_cardholder = 'James Scott';
# $cc_ex_month = '10';
# $cc_ex_year = '2012';
# $cc_ccv = '657';


### 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);


// Call the SOAP method
$tmp_result = $client->call('newTransaction', array('data' => array('merchant_id' => $merchant_id,'merchant_token' => $merchant_token,'hashkey' => $hash,'traceid' => $traceID, 'amount'=>$amount,'currency'=>$currency,'customer_firstname' => $customer_firstname,'customer_lastname' => $customer_lastname,'customer_email' => $customer_email, 'customer_phone' => $customer_phone, 'customer_ip' => $customer_ip,'billing_street' => $billing_street,'billing_postalcode' => $billing_postalcode,'billing_city' => $billing_city, 'billing_state' => $billing_state, 'billing_country' => $billing_country, 'cc_number' => $cc_number, 'cc_type' => $cc_type, 'cc_cardholder' => $cc_cardholder, 'cc_ex_month' => $cc_ex_month, 'cc_ex_year' => $cc_ex_year, 'cc_ccv' => $cc_ccv)));

// Get the Response
logger3("**** Response ****",$x);
logger3("TransactionID = " , $tmp_result['transaction_id']);
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['result_code']); 
logger3("Transaction Result Text = " , $tmp_result['result_text']);
?>