php - Get order transaction ID from authorize.net Authorize AIM -


i'm making custom woocommerce reports plugin display information , spit out .csv. have return stuff name, company name, product, , amount. following way.

/**  * check if need customer phone.  */ case 'wc_settings_tab_customer_phone':     array_push( $csv_values, self::customer_meta( get_the_id(), '_billing_phone' ) ); break; 

now i'm using authorize.net aim payment gateway woocommerce plugin transaction id generated.

i want include in .csv export. how go doing this? tried looking in plugin files , noticed transaction id $response_array[6] can't figure out how return it. if show me how tap authorize.net api , transaction id awesome! in advanced!

edit: here i've got far. added php code connect can't seem pull order transaction id. way, "x_login" , "x_tran_key" have been taken out , replaced "test123".

    case 'wc_settings_tab_authorize_id':     $post_url = "https://secure.authorize.net/gateway/transact.dll";      $post_values = array(          // api login id , transaction key must replaced valid values         "x_login"           => "test123",         "x_tran_key"        => "test123",          "x_version"         => "3.1",         "x_delim_data"      => "true",         "x_delim_char"      => "|",         "x_relay_response"  => "false",         // additional fields can added here outlined in aim integration         // guide at: http://developer.authorize.net     );       // sample code uses curl library php establish connection,     // submit post, , record response.     // if receive error, may want ensure have curl     // library enabled in php configuration     $request = curl_init($post_url); // initiate curl object         curl_setopt($request, curlopt_header, 0); // set 0 eliminate header info response         curl_setopt($request, curlopt_returntransfer, 1); // returns response data instead of true(1)         curl_setopt($request, curlopt_postfields, $post_string); // use http post send form data         curl_setopt($request, curlopt_ssl_verifypeer, false); // uncomment line if no gateway response.         $post_response = curl_exec($request); // execute curl post , store results in $post_response         // additional options may required depending upon server configuration         // can find documentation on curl options @ http://www.php.net/curl_setopt     curl_close ($request); // close curl object      // line takes response , breaks array using specified delimiting character     $response_array = explode($post_values["x_delim_char"],$post_response);      array_push( $csv_values, transactionid() ); break; 

edit 2: implementing john's code

                    case 'wc_settings_tab_authorize_id':                     $post_url = "https://secure.authorize.net/gateway/transact.dll";                      $post_values = array(                          // api login id , transaction key must replaced valid values                         "x_login"           => "test123",                         "x_tran_key"        => "test123",                          "x_version"         => "3.1",                         "x_delim_data"      => "true",                         "x_delim_char"      => "|",                         "x_relay_response"  => "false",                         // additional fields can added here outlined in aim integration                         // guide at: http://developer.authorize.net                     );                      // sample code uses curl library php establish connection,                     // submit post, , record response.                     // if receive error, may want ensure have curl                     // library enabled in php configuration                     $request = curl_init($post_url); // initiate curl object                         curl_setopt($request, curlopt_header, 0); // set 0 eliminate header info response                         curl_setopt($request, curlopt_returntransfer, 1); // returns response data instead of true(1)                         curl_setopt($request, curlopt_postfields, $post_string); // use http post send form data                         curl_setopt($request, curlopt_ssl_verifypeer, false); // uncomment line if no gateway response.                         $post_response = curl_exec($request); // execute curl post , store results in $post_response                         // additional options may required depending upon server configuration                         // can find documentation on curl options @ http://www.php.net/curl_setopt                     curl_close ($request); // close curl object                      $post_response = '1|1|1|this transaction has been approved.|4dhvnh|y|2230582188|none|test transaction validatecustomerpaymentprofile.|0.00|cc|auth_only|none|john|doe||123 main st.|bellevue|wa|98004|usa|800-555-1234|800-555-1234|email@example.com|||||||||0.00|0.00|0.00|false|none|e440d094322a0d406e01edf9ce871a4f||2|||||||||||xxxx1111|visa||||||||||||||||';                     $response_array = explode('|',$post_response);                         $transaction_id = $response_array[6];                      array_push( $csv_values, $transaction_id );                 break; 

edit 3: okay, have (excluding api , transaction key).

    /**     * check authorize.net transaction id.     */     case 'wc_settings_tab_authorize_id':         $post_url = "https://secure.authorize.net/gateway/transact.dll";          $post_values = array(          // api login id , transaction key must replaced valid values         "x_login"           => "test",         "x_tran_key"        => "test",          "x_version"         => "3.1",         "x_delim_data"      => "true",         "x_delim_char"      => "|",         "x_relay_response"  => "false",          // additional fields can added here outlined in aim integration         // guide at: http://developer.authorize.net         );          // sample code uses curl library php establish connection,         // submit post, , record response.         // if receive error, may want ensure have curl         // library enabled in php configuration         $request = curl_init($post_url); // initiate curl object         curl_setopt($request, curlopt_header, 0); // set 0 eliminate header info response         curl_setopt($request, curlopt_returntransfer, 1); // returns response data instead of true(1)         curl_setopt($request, curlopt_postfields, http_build_query($post_values)); // use http post send form data         curl_setopt($request, curlopt_ssl_verifypeer, false); // uncomment line if no gateway response.         $post_response = curl_exec($request); // execute curl post , store results in $post_response          // additional options may required depending upon server configuration         // can find documentation on curl options @ http://www.php.net/curl_setopt         curl_close ($request); // close curl object          // line takes response , breaks array using specified delimiting character         $response_array = explode($post_values["x_delim_char"],$post_response);         $transaction_id = $response_array[6];          array_push( $csv_values, $transaction_id );     break; 

still can't figure out why won't work. when try , return $transaction_id value 0. when try $post_response see returns this:

3|2|33|credit card number required.||p|0|||0.00|cc|auth_capture||||||||||||||||||||||||||thisisanalphanumericnumber|||||||||||||||||||||||||||||| 

before there alphanumberic string replaced security purposes. think may happening because i'm not setting cc number or billing address it?

the response string returned authorize.net going this:

1|1|1|this transaction has been approved.|4dhvnh|y|2230582188|none|test transaction validatecustomerpaymentprofile.|0.00|cc|auth_only|none|john|doe||123 main st.|bellevue|wa|98004|usa|800-555-1234|800-555-1234|email@example.com|||||||||0.00|0.00|0.00|false|none|e440d094322a0d406e01edf9ce871a4f||2|||||||||||xxxx1111|visa|||||||||||||||| 

this results separated | delimiting character set here:

"x_delim_char"      => "|", 

you correctly break apart string using explode():

$response_array = explode($post_values["x_delim_char"],$post_response);     

which gives data in array called $response_array.

in authorize.net's response, transaction id 2230582188. in our array seventh element can using:

$transaction_id = $response_array[6]; 

here demo showing works.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -