pmpro_twocheckoutValidate

Validate the $_POST with TwoCheckout.

Description

pmpro_twocheckoutValidate(); 

Usage

  1. if ( !function_exists( 'pmpro_twocheckoutValidate' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/services/twocheckout-ins.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = pmpro_twocheckoutValidate(); 
  7.  

Defined (1)

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

/services/twocheckout-ins.php  
  1. function pmpro_twocheckoutValidate() { 
  2. $params = array(); 
  3. foreach ( $_REQUEST as $k => $v ) 
  4. $params[$k] = $v; 
  5.  
  6. //2Checkout uses anordernumber of 1 in the hash for demo orders for some reason 
  7. if(!empty($params['demo']) && $params['demo'] == 'Y') 
  8. $params['order_number'] = 1; 
  9.  
  10. //is this a return call or notification 
  11. if(empty($params['message_type'])) 
  12. $check = Twocheckout_Return::check( $params, pmpro_getOption( 'twocheckout_secretword' ), 'array' ); 
  13. else 
  14. $check = Twocheckout_Notification::check( $params, pmpro_getOption( 'twocheckout_secretword' ), 'array' ); 
  15.  
  16. if( empty ( $check ) ) 
  17. $r = false; //HTTP failure 
  18. else if( empty ( $check['response_code'] ) ) 
  19. $r = false; //Invalid response 
  20. else 
  21. $r = $check['response_code']; 
  22.  
  23. /** 
  24. * Filter if antwocheckoutrequest is valid or not. 
  25. * @since 1.8.6.3 
  26. * @param bool $r true or false if the request is valid 
  27. * @param mixed $check remote post object from request to Twocheckout 
  28. */ 
  29. $r = apply_filters('pmpro_twocheckout_validate', $r, $check); 
  30.  
  31. return $check['response_code'] === 'Success';