fn_pay_confirm_is_valid

Validate Saferpay payment.

Description

(boolean) fn_pay_confirm_is_valid( $gateway, $posted ); 

Returns (boolean)

Parameters (2)

0. $gateway
The gateway.
1. $posted
The posted.

Usage

  1. if ( !function_exists( 'fn_pay_confirm_is_valid' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-payment-gateway-for-saferpay/fn-saferpay.php'; 
  3.  
  4. // The gateway. 
  5. $gateway = null; 
  6.  
  7. // The posted. 
  8. $posted = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = fn_pay_confirm_is_valid($gateway, $posted); 
  12.  

Defined (1)

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

/fn-saferpay.php  
  1. function fn_pay_confirm_is_valid($gateway, $posted) 
  2. $verfication = ""; 
  3. $status = true; 
  4.  
  5. try 
  6. // Ask Saferpay to confirm the payment 
  7. $verfication = fn_verify_saferpay_payment($gateway, $posted); 
  8. catch(Exception $e) 
  9. $msg = __('Could not connect to the payment provider', 'fnwc-woocommerce' ); 
  10.  
  11. // This is serious, we inform the administrator 
  12. $gateway->alert_admin($msg . "\r\nOrder ID: ". $order->id); 
  13. $status = false;  
  14.  
  15. // Saferpay does not confirm the payment and returns an error 
  16. if ($status && stripos($verfication, "ERROR") !== false) { 
  17.  
  18. // This is serious, we inform the administrator 
  19. $gateway->alert_admin($verfication); 
  20. return false;  
  21.  
  22. return $status;