getTransactionStatus

The Woocommerce Payment Gateway by Novalnet getTransactionStatus function.

Description

getTransactionStatus( $id ); 

Parameters (1)

0. $id
The id.

Usage

  1. if ( !function_exists( 'getTransactionStatus' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-payment-gateway-by-novalnet/callback_novalnet2woocommerce.php'; 
  3.  
  4. // The id. 
  5. $id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = getTransactionStatus($id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/callback_novalnet2woocommerce.php  
  1. function getTransactionStatus($id) { 
  2. global $lineBreak, $request, $org_tid; 
  3. $nn_status_code = 0; 
  4. $ssl_status = is_ssl() ? 'https://' : 'http://'; 
  5. $url = $ssl_status.'payport.novalnet.de/nn_infoport.xml'; 
  6. $config_data = get_post_meta($id, '_nn_config_values', true); 
  7.  
  8. if(!empty($config_data)) { 
  9. $urlparam = '<?xml version="1.0" encoding="UTF-8"?><nnxml><info_request><vendor_id>' . $config_data['vendor']. '</vendor_id>'; 
  10. $urlparam .= '<vendor_authcode>' . $config_data['auth_code'] . '</vendor_authcode>'; 
  11. $urlparam .= '<request_type>TRANSACTION_STATUS</request_type>'; 
  12. $urlparam .= '<product_id>' . $config_data['product'] . '</product_id>'; 
  13. $urlparam .= '<tid>' . $org_tid . '</tid>'; 
  14. $urlparam .='</info_request></nnxml>'; 
  15.  
  16. $ch = curl_init($url); 
  17. curl_setopt($ch, CURLOPT_POST, 1); 
  18. curl_setopt($ch, CURLOPT_POSTFIELDS, $urlparam); // add POST fields 
  19. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 
  20. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
  21. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
  22. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
  23. $data = curl_exec($ch); 
  24. curl_close($ch); 
  25.  
  26. if (strstr($data, '<status>')) { 
  27. preg_match('/status>?([^<]+)/i', $data, $matches); 
  28. $nn_status_code = $matches[1]; 
  29. return $nn_status_code;