tribulant

First Data form CONNECT 2.0

Sep 7th, 2011
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.55 KB | None | 0 0
  1. <?php
  2.  
  3. //the posting URL
  4. $fdurl = ($this -> get_option('fd_test') == "Y") ?
  5. //'https://www.staging.linkpointcentral.com/lpc/servlet/lppay' :
  6. //'https://www.linkpointcentral.com/lpc/servlet/lppay';
  7. "https://connect.merchanttest.firstdataglobalgateway.com/IPGConnect/gateway/processing" :
  8. "https://connect.firstdataglobalgateway.com/IPGConnect/gateway/processing";
  9.  
  10. $chargetotal = number_format($Order -> total($order -> id, $shipping = true, $applydiscount = true, $styles = true, $fields = true), 2, '.', '');
  11. $storename = $this -> get_option('fd_store');
  12. $secret = $this -> get_option('fd_secret');
  13. $oid = $order -> id;
  14.  
  15. //billing details
  16. $bname = $user -> bill_fname . " " . $user -> bill_lname;
  17. $baddr1 = $user -> bill_address;
  18. $bcity = $user -> bill_city;
  19.  
  20. if ($user -> bill_country == "227") {
  21.     global $us_states;
  22.     require_once $this -> plugin_base() . DS . 'includes' . DS . 'variables.php';
  23.  
  24.     foreach ($us_states as $us_state_code => $us_state_value) {    
  25.         if ($user -> bill_state == $us_state_value) {
  26.             $bstate = $us_state_code;  
  27.             break 1;
  28.         }
  29.     }
  30. } else {
  31.     $bstate = $user -> bill_state;
  32. }
  33.  
  34. $bzip = $user -> bill_zipcode;
  35.  
  36. //shipping details
  37. $sname = $user -> ship_fname . " " . $user -> ship_lname;
  38. $saddr1 = $user -> ship_address;
  39. $scity = $user -> ship_city;
  40. $sstate = $user -> ship_state;
  41. $szip = $user -> ship_zipcode;
  42.  
  43. $email = $user -> user_email;
  44. $txnorg = 'eci';
  45. $txntype = 'sale';
  46. $timezonestring = $this -> get_option('fd_timezone');
  47. date_default_timezone_set($timezonestring);
  48. $txntimezone = $timezonestring;
  49. $txndatetime = date("Y:m:d-H:i:s", time());
  50. $subchargetotal = number_format($Order -> total($order -> id, $shipping = false, $applydiscount = true, $styles = true, $fields = true), 2, '.', '');
  51. $shipping = number_format($Order -> shipping_total($subchargetotal, $order -> id), 2, '.', '');
  52. $userid = $user -> ID;
  53. $responseSuccessURL = $wpcoHtml -> retainquery('type=fd', $wpcoHtml -> return_url());
  54. $responseFailURL = $wpcoHtml -> fail_url();
  55. $responseURL = $wpcoHtml -> retainquery('type=fd', $wpcoHtml -> return_url());;
  56. $paymentMethod = 'credit card';
  57. $mode = 'Fullpay';
  58.  
  59. $str = $storename . $txndatetime . $chargetotal . $secret;
  60.  
  61. for ($i = 0; $i < strlen($str); $i++){
  62.     $hex_str .= dechex(ord($str[$i]));
  63. }
  64.  
  65. $hash = hash('sha256', $hex_str);
  66.  
  67. ?>
  68.  
  69. <p><img src="<?php echo $this -> url(); ?>/images/gateways/first-data.jpg" alt="first-data" /></p>
  70.  
  71. <form action="<?php echo $fdurl; ?>" method="post" id="fd-form">
  72.     <input type="hidden" name="subtotal" value="<?php echo $chargetotal; ?>" />
  73.     <input type="hidden" name="chargetotal" value="<?php echo $chargetotal; ?>" />
  74.     <input type="hidden" name="storename" value="<?php echo $storename; ?>" />
  75.     <input type="hidden" name="oid" value="<?php echo $oid; ?>" />
  76.     <input type="hidden" name="baddr1" value="<?php echo esc_attr($baddr1); ?>" />
  77.     <input type="hidden" name="bcity" value="<?php echo esc_attr($bcity); ?>" />
  78.     <input type="hidden" name="bstate" value="<?php echo esc_attr($bstate); ?>" />
  79.     <input type="hidden" name="bzip" value="<?php echo $bzip; ?>" />
  80.     <input type="hidden" name="email" value="<?php echo $email; ?>" />
  81.     <input type="hidden" name="txntype" value="<?php echo $txntype; ?>" />
  82.     <input type="hidden" name="txntimezone" value="<?php echo $txntimezone; ?>" />
  83.     <input type="hidden" name="txndatetime" value="<?php echo $txndatetime; ?>" />
  84.     <input type="hidden" name="hash" value="<?php echo $hash; ?>" />
  85.     <input type="hidden" name="bname" value="<?php echo esc_attr($bname); ?>" />
  86.     <input type="hidden" name="userid" value="<?php echo $userid; ?>" />
  87.     <input type="hidden" name="responseSuccessURL" value="<?php echo $responseSuccessURL; ?>" />
  88.     <input type="hidden" name="responseFailURL" value="<?php echo $responseFailURL; ?>" />
  89.     <input type="hidden" name="responseURL" value="<?php echo $responseURL; ?>" />
  90.     <input type="hidden" name="trxOrigin" value="<?php echo $txnorg; ?>" />
  91.    
  92.     <p class="submit">
  93.         <?php /*<a href="<?php echo $wpcoHtml -> bill_url(); ?>" class="button"><?php _e('&laquo; Back', $this -> plugin_name); ?></a>*/ ?>
  94.         <input class="<?php echo $this -> pre; ?>button" type="button" name="back" value="<?php _e('&laquo; Back', $this -> plugin_name); ?>" onclick="history.go(-1);" />
  95.         <input class="<?php echo $this -> pre; ?>button" type="submit" name="continue" value="<?php _e('Continue &raquo;', $this -> plugin_name); ?>" />
  96.     </p>
  97. </form>
  98.  
  99. <script type="text/javascript">
  100. jQuery(document).ready(function() {
  101.     var form = document.getElementById('fd-form');
  102.     form.submit();
  103. });
  104. </script>
Advertisement
Add Comment
Please, Sign In to add comment