M2_AuthorizeNetCP

Builds and sends an AuthorizeNet CP Request.

Defined (1)

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

/lib/authorize.net/lib/AuthorizeNetCP.php  
  1. class M2_AuthorizeNetCP extends M2_AuthorizeNetAIM 
  2.  
  3. const LIVE_URL = 'https://cardpresent.authorize.net/gateway/transact.dll'; 
  4.  
  5. public $verify_x_fields = false;  
  6.  
  7. /** 
  8. * Holds all the x_* name/values that will be posted in the request.  
  9. * Default values are provided for best practice fields. 
  10. */ 
  11. protected $_x_post_fields = array( 
  12. "cpversion" => "1.0",  
  13. "delim_char" => ", ",  
  14. "encap_char" => "|",  
  15. "market_type" => "2",  
  16. "response_format" => "1", // 0 - XML, 1 - NVP 
  17. ); 
  18.  
  19. /** 
  20. * Device Types (x_device_type) 
  21. * 1 = Unknown 
  22. * 2 = Unattended Terminal 
  23. * 3 = Self Service Terminal 
  24. * 4 = Electronic Cash Register 
  25. * 5 = Personal Computer- Based Terminal 
  26. * 6 = AirPay 
  27. * 7 = Wireless POS 
  28. * 8 = Website 
  29. * 9 = Dial Terminal 
  30. * 10 = Virtual Terminal 
  31. */ 
  32.  
  33. /** 
  34. * Only used if merchant wants to send custom fields. 
  35. */ 
  36. private $_custom_fields = array(); 
  37.  
  38. /** 
  39. * Strip sentinels and set track1 field. 
  40. * @param string $track1data 
  41. */ 
  42. public function setTrack1Data($track1data) { 
  43. if (preg_match('/^%.*\?$/', $track1data)) { 
  44. $this->track1 = substr($track1data, 1, -1); 
  45. } else { 
  46. $this->track1 = $track1data;  
  47.  
  48. /** 
  49. * Strip sentinels and set track2 field. 
  50. * @param string $track2data 
  51. */ 
  52. public function setTrack2Data($track2data) { 
  53. if (preg_match('/^;.*\?$/', $track2data)) { 
  54. $this->track2 = substr($track2data, 1, -1); 
  55. } else { 
  56. $this->track2 = $track2data;  
  57.  
  58. /** 
  59. * @param string $response 
  60. *  
  61. * @return AuthorizeNetAIM_Response 
  62. */ 
  63. protected function _handleResponse($response) 
  64. return new M2_AuthorizeNetCP_Response($response, $this->_x_post_fields['delim_char'], $this->_x_post_fields['encap_char'], $this->_custom_fields); 
  65.