From: Charles Scott Date: Tue, 24 May 2016 15:44:32 +0000 (-0400) Subject: Split into two scripts one for Test and the toher for Production X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=48b4fd92ba7d5f874a7daf8fa341c9cb1bd9e220;p=prog%2FAuthorizeNetRelay.git Split into two scripts one for Test and the toher for Production --- diff --git a/glmAuthNetRelay/AuthNetRelay.php b/glmAuthNetRelay/AuthNetRelay.php deleted file mode 100644 index b0db168..0000000 --- a/glmAuthNetRelay/AuthNetRelay.php +++ /dev/null @@ -1,106 +0,0 @@ - 'https://secure.authorize.net/gateway/transact.dll', - 'Test' => 'https://test.authorize.net/gateway/transact.dll' -); - -// Post URL selection -$post_url = $PostURLs[$processingMode]; - -// Log request array -if ($debug) { - $debugFile = fopen("debug.txt", "w"); - fwrite($debugFile, "\n\n\nDate: ".date('m/d/Y h:i:s')."\n\nSubmitted Array\n".print_r($_REQUEST,1)); -} - -// Create Post string -$post_string = ''; -$sep = ''; -foreach($_REQUEST as $k=>$v) { - $post_string .= $sep.$k.'='.urlencode($v); - $sep = '&'; -} - -// log Post String -if ($debug) { - fwrite($debugFile, "\n\nPost String\n".$post_string); -} - -// Setup curl request -$curl_request = curl_init($post_url); -curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_string); -curl_setopt($curl_request, CURLOPT_HEADER, 0); -curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); -curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); -curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); - -// Check if we need to verify the peer connection to Authorize.net -if ($VERIFY_PEER) { - curl_setopt($curl_request, CURLOPT_CAINFO, $certPEM); -} else { - curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); -} - -// If this is an XML request then set curl opt header to text/xml -if (preg_match('/xml/',$post_url)) { - curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); -} - -// Send request -$response = curl_exec($curl_request); - -// Return response string directly back to calling site -echo $response; - -// Log any error and response string -if ($debug) { - - if ($curl_error = curl_error($curl_request)) { - fwrite($debugFile, "\n\nCURL ERROR\n$curl_error\n\n"); - } - - fwrite($debugFile, "\n\nResponse\n".print_r($response,1)); - fclose($debugFile); -} - - diff --git a/glmAuthNetRelay/AuthNetRelayProduction.php b/glmAuthNetRelay/AuthNetRelayProduction.php new file mode 100644 index 0000000..a6fed36 --- /dev/null +++ b/glmAuthNetRelay/AuthNetRelayProduction.php @@ -0,0 +1,117 @@ + 'https://secure.authorize.net/gateway/transact.dll', + 'Test' => 'https://test.authorize.net/gateway/transact.dll' +); + +// Post URL selection +$post_url = $PostURLs[$processingMode]; + +// Log request array +if ($debug) { + $debugFile = fopen("debug.txt", "w"); + fwrite($debugFile, "\n\n\nDate: ".date('m/d/Y h:i:s')."\n\nSubmitted Array\n".print_r($_REQUEST,1)); +} + +// Create Post string +$post_string = ''; +$sep = ''; +foreach($_REQUEST as $k=>$v) { + $post_string .= $sep.$k.'='.urlencode($v); + $sep = '&'; +} + +// log Post String +if ($debug) { + fwrite($debugFile, "\n\nPost String\n".$post_string); +} + +// Setup curl request +$curl_request = curl_init($post_url); +curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_string); +curl_setopt($curl_request, CURLOPT_HEADER, 0); +curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); +curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); +curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); + +// Check if we need to verify the peer connection to Authorize.net +if ($VERIFY_PEER) { + curl_setopt($curl_request, CURLOPT_CAINFO, $certPEM); +} else { + curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); +} + +// If this is an XML request then set curl opt header to text/xml +if (preg_match('/xml/',$post_url)) { + curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); +} + +// Send request +$response = curl_exec($curl_request); + +// Return response string directly back to calling site +echo $response; + +// Log any error and response string +if ($debug) { + + if ($curl_error = curl_error($curl_request)) { + fwrite($debugFile, "\n\nCURL ERROR\n$curl_error\n\n"); + } + + fwrite($debugFile, "\n\nResponse\n".print_r($response,1)); + fclose($debugFile); +} + + diff --git a/glmAuthNetRelay/AuthNetRelayTest.php b/glmAuthNetRelay/AuthNetRelayTest.php new file mode 100644 index 0000000..d36b413 --- /dev/null +++ b/glmAuthNetRelay/AuthNetRelayTest.php @@ -0,0 +1,117 @@ + 'https://secure.authorize.net/gateway/transact.dll', + 'Test' => 'https://test.authorize.net/gateway/transact.dll' +); + +// Post URL selection +$post_url = $PostURLs[$processingMode]; + +// Log request array +if ($debug) { + $debugFile = fopen("debug.txt", "w"); + fwrite($debugFile, "\n\n\nDate: ".date('m/d/Y h:i:s')."\n\nSubmitted Array\n".print_r($_REQUEST,1)); +} + +// Create Post string +$post_string = ''; +$sep = ''; +foreach($_REQUEST as $k=>$v) { + $post_string .= $sep.$k.'='.urlencode($v); + $sep = '&'; +} + +// log Post String +if ($debug) { + fwrite($debugFile, "\n\nPost String\n".$post_string); +} + +// Setup curl request +$curl_request = curl_init($post_url); +curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_string); +curl_setopt($curl_request, CURLOPT_HEADER, 0); +curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); +curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); +curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); + +// Check if we need to verify the peer connection to Authorize.net +if ($VERIFY_PEER) { + curl_setopt($curl_request, CURLOPT_CAINFO, $certPEM); +} else { + curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); +} + +// If this is an XML request then set curl opt header to text/xml +if (preg_match('/xml/',$post_url)) { + curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); +} + +// Send request +$response = curl_exec($curl_request); + +// Return response string directly back to calling site +echo $response; + +// Log any error and response string +if ($debug) { + + if ($curl_error = curl_error($curl_request)) { + fwrite($debugFile, "\n\nCURL ERROR\n$curl_error\n\n"); + } + + fwrite($debugFile, "\n\nResponse\n".print_r($response,1)); + fclose($debugFile); +} + + diff --git a/glmAuthNetRelay/debug.txt b/glmAuthNetRelay/debug.txt index 4d0a15f..d953352 100644 --- a/glmAuthNetRelay/debug.txt +++ b/glmAuthNetRelay/debug.txt @@ -1,7 +1,7 @@ -Date: 05/24/2016 11:19:44 +Date: 05/24/2016 11:42:49 Submitted Array Array @@ -12,8 +12,8 @@ Array [x_relay_response] => FALSE [x_encap_char] => | [x_test_request] => 1 - [x_amount] => 121 - [x_card_num] => 6011000000000013 + [x_amount] => 48 + [x_card_num] => 4007000000027 [x_card_code] => 123 [x_exp_date] => 2/2017 [x_first_name] => John @@ -35,7 +35,7 @@ Array Post String -x_version=3.1&x_delim_char=%2C&x_delim_data=TRUE&x_relay_response=FALSE&x_encap_char=%7C&x_test_request=1&x_amount=121&x_card_num=6011000000000013&x_card_code=123&x_exp_date=2%2F2017&x_first_name=John&x_last_name=Smith&x_address=120+E.+Lake+St.%2C+Apt+2&x_city=Petoskey&x_state=MI&x_zip=49770&x_country=US&x_invoice_num=13d1d7e29e8f27ab7e8f&x_description=Star+Line+Mackinaw+City+-+Event+Tickets&x_email=info%40gaslightmedia.com&x_email_customer=&x_phone=231-487-0692&x_type=AUTH_CAPTURE&x_login=44pvQ8D7d&x_tran_key=8rj6ME772K9Pe9pJ +x_version=3.1&x_delim_char=%2C&x_delim_data=TRUE&x_relay_response=FALSE&x_encap_char=%7C&x_test_request=1&x_amount=48&x_card_num=4007000000027&x_card_code=123&x_exp_date=2%2F2017&x_first_name=John&x_last_name=Smith&x_address=120+E.+Lake+St.%2C+Apt+2&x_city=Petoskey&x_state=MI&x_zip=49770&x_country=US&x_invoice_num=13d1d7e29e8f27ab7e8f&x_description=Star+Line+Mackinaw+City+-+Event+Tickets&x_email=info%40gaslightmedia.com&x_email_customer=&x_phone=231-487-0692&x_type=AUTH_CAPTURE&x_login=44pvQ8D7d&x_tran_key=8rj6ME772K9Pe9pJ Response -|3|,|1|,|6|,|(TESTMODE) The credit card number is invalid.|,|000000|,|P|,|0|,|13d1d7e29e8f27ab7e8f|,|Star Line Mackinaw City - Event Tickets|,|121.00|,|CC|,|auth_capture|,||,|John|,|Smith|,||,|120 E. Lake St., Apt 2|,|Petoskey|,|MI|,|49770|,|US|,|231-487-0692|,||,|info@gaslightmedia.com|,||,||,||,||,||,||,||,||,||,||,||,||,||,|288538B103D9FFE0FF6607363386F536|,||,||,||,||,||,||,||,||,||,||,||,||,|XXXX0013|,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,|| \ No newline at end of file +|1|,|1|,|1|,|(TESTMODE) This transaction has been approved.|,|000000|,|P|,|0|,|13d1d7e29e8f27ab7e8f|,|Star Line Mackinaw City - Event Tickets|,|48.00|,|CC|,|auth_capture|,||,|John|,|Smith|,||,|120 E. Lake St., Apt 2|,|Petoskey|,|MI|,|49770|,|US|,|231-487-0692|,||,|info@gaslightmedia.com|,||,||,||,||,||,||,||,||,||,||,||,||,||,|9EF4754875042B8F1C7304DED51DCBAC|,||,||,||,||,||,||,||,||,||,||,||,||,|XXXX0027|,|Visa|,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,|| \ No newline at end of file