Page 1 of 1

Help with PHP code

Posted: Sun Aug 17, 2008 7:41 pm
by redlake2
I hired a php programmer to do a payment module for me (I am a C++ programmer) and I can't see how he can get the correct order details from when an order is place. I am not sure what happens after an order is placed. I have purchased Shop-script software and they say that they are unable to help me. As I understand it the function payment_form_html is called when the person clicks to go to the payment page. The $orderID is supposed to be passed in but I don't know where this variable is added to ensure it is correct.

The programmer wrote his own code to get the max number of the current transaction but I don't see how this can work if mulitple customers are ordering at the same time there is too much room for error.

If a page is already loading with the current details then the orderid must be in existence to be passed through correctly.

I also need to extract the billing_country which is a field in the orders table, but it too comes out blank.

function payment_form_html($orderID){

$res = '';

// billing details
$q1 = db_query("select * from ".CUSTOMER_ADDRESSES_TABLE. " where addressID='$_REQUEST[billingAddressID]'");
$r1 = db_fetch_row($q1);

// email address of customer
$qemail = db_query("select * from ".CUSTOMERS_TABLE." where customerID='".$r1['customerID']."'");
$remail = db_fetch_row($qemail);

// get order id
$q = db_query("select max(orderID) from ".ORDERS_TABLE);
$r = db_fetch_row($q);
$r[0]++;
$oid = $r[0];
$orderID = $oid ;
$order = ordGetOrder( $orderID );
$order_amount = RoundFloatValue($order['order_amount']);
$PaymentMethod = $this->_getSettingValue('CONF_EWAY_PAYMENT_METHOD');
$billingCountry = $order[billing_country];
echo "billing country : $billingCountry";

if ($PaymentMethod == EWAY_REAL_TIME || $PaymentMethod == EWAY_REAL_TIME_TESTING_MODE){

$Correct_Gateway;
if ($PaymentMethod == EWAY_REAL_TIME)
$Correct_Gate way = EWAY_PAYMENT_LIVE_REAL_TIME;
else
$Correct_Gateway = EWAY_PAYMENT_LIVE_REAL_TIME_TESTING_MODE;

$post_1=array(
'CUSTID' => $this->_getSettingValue('CONF_EWAY_CUSTID'),
'PAYMENT' => $this->_getSettingValue('CONF_EWAY_PAYMENT_METHOD'),
'GATEWAY' => $Correct_Gateway,
'AMT' => $order_amount,
'MTID' => $orderID,
'SUCCESSURL' => substr(getTransactionResultURL('success'),0,255),
'FAILURL' => substr(getTransactionResultURL('failure'),0,255),
'NAME' => substr($order['billing_firstname'].' '.$order['billing_lastname'],0,30),
'EMAIL' => substr($order['customer_email'],0,64),
'MODE' => 'SAVE',
'USE_LIVE' => $this->_getSettingValue('CONF_EWAY_LIVE_GATEWAY'),
);

code continues but I think I have given you enough to see the issue.

I thought that the $order was an array that should return the relevant fields from the orde r table specific to this order. I don't know why I am not seeing the correct values. If i get it to echo the orderid to the screen without the query to the database then the value is zero. Why?

Would appreciate anyones help on this. :-(