Split into two scripts one for Test and the toher for Production
authorCharles Scott <cscott@ws6.gaslightmedia.com>
Tue, 24 May 2016 15:44:32 +0000 (11:44 -0400)
committerCharles Scott <cscott@ws6.gaslightmedia.com>
Tue, 24 May 2016 15:44:32 +0000 (11:44 -0400)
glmAuthNetRelay/AuthNetRelay.php [deleted file]
glmAuthNetRelay/AuthNetRelayProduction.php [new file with mode: 0644]
glmAuthNetRelay/AuthNetRelayTest.php [new file with mode: 0644]
glmAuthNetRelay/debug.txt

diff --git a/glmAuthNetRelay/AuthNetRelay.php b/glmAuthNetRelay/AuthNetRelay.php
deleted file mode 100644 (file)
index b0db168..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-/*
- * Authorize.net Relay Script
- *
- * This is used to relay transaction requests to Authorize.net for sites on
- * old servers that don't support new SSL requirements.
- *
- * Call this script using HTTP rather than HTTPS
- *
- * If $debug is on this code with store information on the last request in
- * debug.txt in this directory. Only the last request will be in that file.
- *
- * If you get a "certificate verify failed" or similar error, check the 
- * $certPEM file path and perhaps update that file from the following URL.
- *
- * https://curl.haxx.se/ca/cacert.pem
- *
- * Authorize.Net Test Account Information
- *   Admin Interface:  https://test.authorize.net/
- *             login:                  GLM4AuthNet
- *             PW:                 GLm7AuTHnet
- *   API Access
- *             API Login ID:           44pvQ8D7d
- *             Transaction Key:        8rj6ME772K9Pe9pJ
- *             Secret Question:        Simon
- *
- *   Authorize.net test card numbers
- *             American Express        370000000000002
- *             Discover                        6011000000000012
- *             Visa                            4007000000027
- *                                                     4012888818888
- *             JCB                                     3088000000000017
- *             Diners Club                     38000000000006
- *             Carte Blanche           38000000000006
- *
- */
-
-$processingMode = 'Test';       // 'Test' or 'Production'
-$debug = true;
-$VERIFY_PEER = true;
-$certPEM = '/var/www/server/ws6.gaslightmedia.com/AuthorizeNetRelay/ssl/cacert.pem';
-$PostURLs = array(
-    'Production' => '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 (file)
index 0000000..a6fed36
--- /dev/null
@@ -0,0 +1,117 @@
+<?php
+/*
+ * Authorize.net Relay Script - Test Mode
+ *
+ * This is used to relay transaction requests to Authorize.net for sites on
+ * old servers that don't support new SSL requirements.
+ *
+ * Call this script using HTTP rather than HTTPS
+ *
+ * There are two scripts in this directory. The only difference is that one
+ * is for Test mode and the other for Production mode, as noted in the file
+ * name. Use these URLs to call these scripts for these modes...
+ *
+ * Test Mode:
+ *      http://ws6.gaslightmedia.com/AuthorizeNetRelay/glmAuthNetRelay/AuthNetRelayTest.php
+ * Production Mode:
+ *      http://ws6.gaslightmedia.com/AuthorizeNetRelay/glmAuthNetRelay/AuthNetRelayProduction.php
+ *
+ * If $debug is on this code with store information on the last request in
+ * debug.txt in this directory. Only the last request will be in that file.
+ *
+ * If you get a "certificate verify failed" or similar error, check the
+ * $certPEM file path and perhaps update that file from the following URL.
+ *
+ * https://curl.haxx.se/ca/cacert.pem
+ *
+ * Authorize.Net Test Account Information
+ *   Admin Interface:   https://test.authorize.net/
+ *              login:                  GLM4AuthNet
+ *              PW:                     GLm7AuTHnet
+ *   API Access
+ *              API Login ID:           44pvQ8D7d
+ *              Transaction Key:        8rj6ME772K9Pe9pJ
+ *              Secret Question:        Simon
+ *
+ *   Authorize.net test card numbers
+ *              American Express        370000000000002
+ *              Discover                6011000000000012
+ *              Visa                    4007000000027
+ *                                      4012888818888
+ *              JCB                     3088000000000017
+ *              Diners Club             38000000000006
+ *              Carte Blanche           38000000000006
+ *
+ */
+
+// This is the Production Script
+$processingMode = 'Production';       // 'Test' or 'Production'
+
+$debug = true;
+$VERIFY_PEER = true;
+$certPEM = '/var/www/server/ws6.gaslightmedia.com/AuthorizeNetRelay/ssl/cacert.pem';
+$PostURLs = array(
+    'Production' => '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 (file)
index 0000000..d36b413
--- /dev/null
@@ -0,0 +1,117 @@
+<?php
+/*
+ * Authorize.net Relay Script - Test Mode
+ *
+ * This is used to relay transaction requests to Authorize.net for sites on
+ * old servers that don't support new SSL requirements.
+ *
+ * Call this script using HTTP rather than HTTPS
+ *
+ * There are two scripts in this directory. The only difference is that one
+ * is for Test mode and the other for Production mode, as noted in the file
+ * name. Use these URLs to call these scripts for these modes...
+ *
+ * Test Mode:
+ *      http://ws6.gaslightmedia.com/AuthorizeNetRelay/glmAuthNetRelay/AuthNetRelayTest.php
+ * Production Mode:
+ *      http://ws6.gaslightmedia.com/AuthorizeNetRelay/glmAuthNetRelay/AuthNetRelayProduction.php
+ *
+ * If $debug is on this code with store information on the last request in
+ * debug.txt in this directory. Only the last request will be in that file.
+ *
+ * If you get a "certificate verify failed" or similar error, check the
+ * $certPEM file path and perhaps update that file from the following URL.
+ *
+ * https://curl.haxx.se/ca/cacert.pem
+ *
+ * Authorize.Net Test Account Information
+ *   Admin Interface:   https://test.authorize.net/
+ *              login:                  GLM4AuthNet
+ *              PW:                     GLm7AuTHnet
+ *   API Access
+ *              API Login ID:           44pvQ8D7d
+ *              Transaction Key:        8rj6ME772K9Pe9pJ
+ *              Secret Question:        Simon
+ *
+ *   Authorize.net test card numbers
+ *              American Express        370000000000002
+ *              Discover                6011000000000012
+ *              Visa                    4007000000027
+ *                                      4012888818888
+ *              JCB                     3088000000000017
+ *              Diners Club             38000000000006
+ *              Carte Blanche           38000000000006
+ *
+ */
+
+// This is the Test Script
+$processingMode = 'Test';       // 'Test' or 'Production'
+
+$debug = true;
+$VERIFY_PEER = true;
+$certPEM = '/var/www/server/ws6.gaslightmedia.com/AuthorizeNetRelay/ssl/cacert.pem';
+$PostURLs = array(
+    'Production' => '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);
+}
+
+
index 4d0a15f..d953352 100644 (file)
@@ -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