Hyzepher Posted October 12, 2003 Share Posted October 12, 2003 Hi I am setting up a site in Ireland using a credit card facility called Realex. They have given me some sample php code to generate a request & response for cc validation etc. Could anyone have a look and maybe point me in the right direction to integrating this with osC? Request php // -------------------------------------------------------------// Replace these with the values you receive from realex $merchantid = "yourMerchantId"; $secret = "yourSecret"; $timestamp = strftime("%Y%m%d%H%M%S"); mt_srand((double)microtime()*1000000); // --------------------------------------------- // Replace these with the values you want to use $orderid = $timestamp."-".mt_rand(1, 999); $curr = "EUR"; $amount = "3000"; // --------------------------------------------- $tmp = "$timestamp.$merchantid.$orderid.$amount.$curr"; $md5hash = md5($tmp); $tmp = "$md5hash.$secret"; $md5hash = md5($tmp); ?> </head> <body bgcolor="#FFFFFF"> <form action=https://epage.payandshop.com/epage.cgi method=post> <input type=hidden name="MERCHANT_ID" value="<?=$merchantid?>"> <input type=hidden name="ORDER_ID" value="<?=$orderid?>"> <input type=hidden name="CURRENCY" value="<?=$curr?>"> <input type=hidden name="AMOUNT" value="<?=$amount?>"> <input type=hidden name="TIMESTAMP" value="<?=$timestamp?>"> <input type=hidden name="MD5HASH" value="<?=$md5hash?>"> <input type=hidden name="AUTO_SETTLE_FLAG" value="1"> <input type=submit value="Proceed to secure server"> </form> <font face=verdana> <font size=3><b>php Sample - Realex Payments realAuth redirect</b></font> <p> <font size=2>Select View/Source to see the output <ul> <li>In the example I use the date/time and a random number as the order id - you may have your own scheme. <li>You should replace <code>merchantid</code> and <code>secret</code> with the values provided by payandshop.com </ul> </font> </body> </html> Response PHP $timestamp = $TIMESTAMP;$result = $RESULT; $orderid = $ORDER_ID; $message = $MESSAGE; $authcode = $AUTHCODE; $pasref = $PASREF; // ------------------------------------------------------------- // Replace these with the values you receive from realexpayments $merchantid = "yourMerchantId"; $secret = "yourSecret"; // --------------------------------------------- $tmp = "$timestamp.$merchantid.$orderid.$result.$message.$pasref.$authcode"; $md5hash = md5($tmp); $tmp = "$md5hash.$secret"; $md5hash = md5($tmp); if ($md5hash != $MD5HASH) { echo "hashes don't match - response not authenticated!"; } // --------------------------- // send yourself an email or send the customer an email // or update a database or whatever you want to do here. ?> <body bgcolor="#FFFFFF"> <font face=verdana,helvetica,arial size=2> <? if ($result == "00") { ?> Thank you <br/><br/> To continue browsing please <a href="http://yourdomain.com"><b><u>click here</u></b></a> <br/><br/> <? } else { ?> <br/><br/> There was an error processing your subscription. Please contact our customer care department at <a href="mailto:[email protected]"><b><u>[email protected]</u></b></a> or if you would prefer to subscribe by phone, call on 01 2839428349 <? } ?> </font> </body> </html> Thanks Chris Hinctyncpaype 1 Quote Link to comment Share on other sites More sharing options...
Hyzepher Posted October 13, 2003 Author Share Posted October 13, 2003 I have made some headway into this but I have a problem. What do I pass for the 'order amount' - what is the osCommerce variable etc that will give the correct order total. i.e. <input type=hidden name="AMOUNT" value="<?=$amount?>"> Chris 87jukettocl 1 Quote Link to comment Share on other sites More sharing options...
blazesoftware Posted February 10, 2005 Share Posted February 10, 2005 Hi Chris, Did you ever get this to work ? Thanks I have made some headway into this but I have a problem. What do I pass for the 'order amount' - what is the osCommerce variable etc that will give the correct order total. i.e. <input type=hidden name="AMOUNT" value="<?=$amount?>"> Chris <{POST_SNAPBACK}> Quote Link to comment Share on other sites More sharing options...
quomo Posted November 2, 2005 Share Posted November 2, 2005 (edited) Hi Any chance to get that code if you resolved it? I installed a payment module (basically modifying an old one) and all is working fine BUT the MD5HASH thingy. Have a look at this: the following code creates the hidden fields in the form. I manage to make all work, but the MD5HASH is not being calculated, as I just havent got a clue and add the code as is given by REALEX. function process_button() { global $HTTP_SERVER_VARS, $order, $customer_id; $sequence = rand(1, 1000); $process_button_string = tep_draw_hidden_field('customers_id', $customer_id) . tep_draw_hidden_field('customers_name', $order->customer['firstname'] . ' ' . $order->customer['lastname']) . tep_draw_hidden_field('customers_company', $order->customer['company']) . tep_draw_hidden_field('customers_street_address', $order->customer['street_address']) . tep_draw_hidden_field('customers_suburb', $order->customer['suburb']) . tep_draw_hidden_field('customers_city', $order->customer['city']) . tep_draw_hidden_field('customers_postcode', $order->customer['postcode']) . tep_draw_hidden_field('customers_state', $order->customer['state']) . tep_draw_hidden_field('customers_country', $order->customer['country']['title']) . tep_draw_hidden_field('customers_telephone', $order->customer['telephone']) . tep_draw_hidden_field('customers_email_address', $order->customer['email_address']) . tep_draw_hidden_field('customers_address_format_id', $order->customer['format_id']) . tep_draw_hidden_field('delivery_name', $order->delivery['firstname'] . ' ' . $order->delivery['lastname']) . tep_draw_hidden_field('delivery_company', $order->delivery['company']) . tep_draw_hidden_field('delivery_street_address', $order->delivery['street_address']) . tep_draw_hidden_field('delivery_suburb', $order->delivery['suburb']) . tep_draw_hidden_field('delivery_city', $order->delivery['city']) . tep_draw_hidden_field('delivery_postcode', $order->delivery['postcode']) . tep_draw_hidden_field('delivery_state', $order->delivery['state']) . tep_draw_hidden_field('delivery_country', $order->delivery['country']['title']) . tep_draw_hidden_field('delivery_address_format_id', $order->delivery['format_id']) . tep_draw_hidden_field('billing_name', $order->billing['firstname'] . ' ' . $order->billing['lastname']) . tep_draw_hidden_field('billing_company', $order->billing['company']) . tep_draw_hidden_field('billing_street_address', $order->billing['street_address']) . tep_draw_hidden_field('billing_suburb', $order->billing['suburb']) . tep_draw_hidden_field('billing_city', $order->billing['city']) . tep_draw_hidden_field('billing_postcode', $order->billing['postcode']) . tep_draw_hidden_field('billing_state', $order->billing['state']) . tep_draw_hidden_field('billing_country', $order->billing['country']['title']) . tep_draw_hidden_field('billing_address_format_id', $order->billing['format_id']) . tep_draw_hidden_field('payment_method', $order->info['payment_method']) . tep_draw_hidden_field('cc_type', $order->info['cc_type']) . tep_draw_hidden_field('cc_owner', $order->info['cc_owner']) . tep_draw_hidden_field('realex_cc_owner', $HTTP_POST_VARS['realex_cc_owner']) . tep_draw_hidden_field('realex_cc_number', $HTTP_POST_VARS['realex_cc_number']) . tep_draw_hidden_field('realex_cc_expires_month', $HTTP_POST_VARS['realex_cc_expires_month']) . tep_draw_hidden_field('realex_cc_expires_year', $HTTP_POST_VARS['realex_cc_expires_year']) . tep_draw_hidden_field('cc_number', $this->cc_card_number) . tep_draw_hidden_field('cc_expires', $this->cc_expiry_month . substr($this->cc_expiry_year, -2)) . tep_draw_hidden_field('orders_status', $order->info['order_status']) . tep_draw_hidden_field('CURRENCY', $order->info['currency']) . tep_draw_hidden_field('currency_value', $order->info['currency_value']) . tep_draw_hidden_field('ORDER_ID', $timestamp = strftime("%Y%m%d%H%M%S") . mt_srand((double)microtime()*1000000)."-".mt_rand(1, 999)) . tep_draw_hidden_field('orders_status_id', $order->info['order_status']) . tep_draw_hidden_field('MERCHANT_ID', MODULE_PAYMENT_REALEX_MERCHANT_ID) . tep_draw_hidden_field('card_number', $this->cc_card_number) . tep_draw_hidden_field('card_exp_date', $this->cc_expiry_month . substr($this->cc_expiry_year, -2)) . tep_draw_hidden_field('description', MODULE_PAYMENT_REALEX_TEXT_DESCRIPTION_SHOP) . tep_draw_hidden_field('cart_id', $this->cartID) . tep_draw_hidden_field('AMOUNT', number_format($order->info['total'], 2)) . tep_draw_hidden_field('comments', $order->info['comments']) . tep_draw_hidden_field('TIMESTAMP', $timestamp = strftime("%Y%m%d%H%M%S") . mt_srand((double)microtime()*1000000)) . tep_draw_hidden_field('MD5HASH', $md5hash =( $tmp = "$timestamp.$merchantid.$orderid.$amount.$currency". $md5hash = md5($tmp). $tmp = "$md5hash.$secret". $md5hash = md5($tmp)) ) . tep_draw_hidden_field('AUTO_SETTLE_FLAG', '0') . tep_draw_hidden_field('x_email_merchant', ((MODULE_PAYMENT_REALEX_EMAIL_MERCHANT == 'True') ? 'TRUE' : 'FALSE')); Does the code you have help me?? Once this is resolved, it will be turn into a contribution. Edited November 2, 2005 by quomo Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.