'eProcessingNetwork Gateway', 'api_version' => 2.0, 'class_name' => 'wpsc_merchant_epngateway', 'has_recurring_billing' => true, 'display_name' => 'eProcessing CC Payment', 'wp_admin_cannot_cancel' => false, 'requirements' => array( /// so that you can restrict merchant modules to PHP 5, if you use PHP 5 features ///'php_version' => 5.0, ), 'form' => 'form_epngateway', 'submit_function' => 'submit_epngateway', // this may be legacy, not yet decided 'internalname' => 'wpsc_merchant_epngateway', ); class wpsc_merchant_epngateway extends wpsc_merchant { // Build an array we can send to eProcessing Network function construct_value_array(){ $data = array( ); //ePN account data entered in settings in admin area $data['ePNAccount'] = get_option( 'ePNAccountNum' ); $data['RestrictKey'] = get_option( 'RestrictKey' ); //Make sure that the URL to Logo field contains an image link. //DBE will give a vague error message and not allow the processing page to load if the URL doesn't point to an image. if (preg_match('/([^\s]+(?=\.(jpg|gif|png))\.\2)/i', get_option('epn_logo'))) { $data['LogoURL'] = get_option('epn_logo'); } $data['HTML'] = "No"; // CC data $data['CardType'] = $_POST['cctype']; $data['CardNo'] = $_POST['card_number']; $data['ExpMonth'] = $_POST['expiry']['month']; $data['ExpYear'] = substr($_POST['expiry']['year'],2,2); $data['CVV2'] = $_POST['card_code']; $data['CVV2Type'] = 1; // Billing Data $data['FirstName'] = $this->cart_data['billing_address']['first_name']; $data['LastName'] = $this->cart_data['billing_address']['last_name']; $data['EMail'] = $this->cart_data['email_address']; $data['Address'] = $this->cart_data['billing_address']['address']; $data['City'] = $this->cart_data['billing_address']['city']; $data['State'] = $this->cart_data['billing_address']['state']; $data['Country'] = $this->cart_data['billing_address']['country']; $data['Zip'] = $this->cart_data['billing_address']['post_code']; //Order $data['Total'] = $this->cart_data['total_price']; $data['SessID'] = $this->cart_data['session_id']; $data['PurchID'] = $this->purchase_id; $this->collected_gateway_data = $data; } function submit() { //Set purchase state as "Processing" $this->set_purchase_processed_by_purchid(2); if (get_option('epn_debug') == "Yes") { //Debug mode $data = $this->collected_gateway_data; $data['email'] = get_option('epn_debug_email'); $data['PostURL'] = "https://www.eProcessingNetwork.com/cgi-bin/dbe/order.pl"; $this->collected_gateway_data = $data; // initiate cURL w/ protocol & URL of remote host $ch=curl_init("https://www.eprocessingnetwork.com/cgi-bin/Reflect/transact.pl "); // normal POST request curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$this->collected_gateway_data); // set response to return as variable curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); // trap response into $response var $response=curl_exec($ch); // close cURL transfer curl_close($ch); $this->set_transaction_details("Test Transaction", 1 ); echo($response); } elseif (get_option('epn_mode') == "0") { //Actions performed if DBE mode // Create Form to POST $output = "
If you are not automatically forwarded to the payment site, you can click the \"Continue\" button below.
"; echo($output); echo(""); exit(); } else { //Actions performed if TDBE mode // initiate cURL w/ protocol & URL of remote host $ch=curl_init("https://www.eProcessingNetwork.Com/cgi-bin/tdbe/transact.pl"); // normal POST request curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$this->collected_gateway_data); // set response to return as variable curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); // trap response into $response var $response=curl_exec($ch); // close cURL transfer curl_close($ch); $auth=substr($response,1,1); if ($auth=="Y") { //Set transaction detail to "accepted payment" $this->set_transaction_details(substr($response,11,6), 3 ); $this->go_to_transaction_results($this->cart_data['session_id']); }else{ //Set detail to "payment declined" and show error message $this->set_transaction_details("N/A", 6 ); $endofmessage = strpos($response,'","'); $errMess = substr($response,2,($endofmessage-2)); //$errMess = $response; $this->set_error_message($errMess); $this->return_to_checkout(); } exit(); } } } function form_epngateway() { if (get_option("epn_visa")=="1") { $epn_visaY="checked='checked'"; }elseif (get_option("enp_visa")=="0") { $epn_visaN="checked='checked'"; } if (get_option("epn_discover")=="1") { $epn_discoverY="checked='checked'"; }elseif (get_option("enp_discover")=="0") { $epn_discoverN="checked='checked'"; } if (get_option("epn_mastercard")=="1") { $epn_mastercardY="checked='checked'"; }elseif (get_option("enp_mastercard")=="0") { $epn_mastercardN="checked='checked'"; } if (get_option("epn_amex")=="1") { $epn_amexY="checked='checked'"; }elseif (get_option("enp_amex")=="0") { $epn_amexN="checked='checked'"; } if (get_option("epn_mode")=="1") { $epn_modeY="checked='checked'";//TDBE }elseif (get_option("enp_mode")=="0") { $epn_modeN="checked='checked'";//DBE } if (get_option("epn_debug")=="Yes") { $epn_debugY="checked='checked'"; } $output = "