wp-pay-gateways    /
                    ogone
                
                            | 1 | <?php  | 
            ||||
| 2 | |||||
| 3 | namespace Pronamic\WordPress\Pay\Gateways\Ingenico\XML;  | 
            ||||
| 4 | |||||
| 5 | use Pronamic\WordPress\Pay\Core\XML\Security;  | 
            ||||
| 6 | use Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink\OrderResponse;  | 
            ||||
| 7 | use Pronamic\WordPress\Pay\Gateways\Ingenico\Parameters;  | 
            ||||
| 8 | use SimpleXMLElement;  | 
            ||||
| 9 | |||||
| 10 | /**  | 
            ||||
| 11 | * Title: Ingenico DirectLink order response XML parser  | 
            ||||
| 12 | * Description:  | 
            ||||
| 13 | * Copyright: 2005-2021 Pronamic  | 
            ||||
| 14 | * Company: Pronamic  | 
            ||||
| 15 | *  | 
            ||||
| 16 | * @author Remco Tolsma  | 
            ||||
| 17 | * @version 2.0.0  | 
            ||||
| 18 | */  | 
            ||||
| 19 | class OrderResponseParser { | 
            ||||
| 20 | /**  | 
            ||||
| 21 | * Parse the specified XML element into an iDEAL transaction object  | 
            ||||
| 22 | *  | 
            ||||
| 23 | * @param SimpleXMLElement $xml  | 
            ||||
| 24 | * @param OrderResponse $order_response  | 
            ||||
| 25 | *  | 
            ||||
| 26 | * @return null|OrderResponse  | 
            ||||
| 27 | */  | 
            ||||
| 28 | 3 | 	public static function parse( SimpleXMLElement $xml, $order_response = null ) { | 
            |||
| 29 | 3 | 		if ( ! $order_response instanceof OrderResponse ) { | 
            |||
| 30 | 3 | $order_response = new OrderResponse();  | 
            |||
| 31 | }  | 
            ||||
| 32 | |||||
| 33 | 3 | $order_response->order_id = Security::filter( $xml['orderID'] );  | 
            |||
| 34 | 3 | $order_response->pay_id = Security::filter( $xml['PAYID'] );  | 
            |||
| 35 | 3 | $order_response->nc_status = Security::filter( $xml[ Parameters::NC_STATUS ] );  | 
            |||
| 36 | 3 | $order_response->nc_error = Security::filter( $xml[ Parameters::NC_ERROR ] );  | 
            |||
| 37 | 3 | $order_response->nc_error_plus = Security::filter( $xml[ Parameters::NC_ERROR_PLUS ] );  | 
            |||
| 38 | 3 | $order_response->acceptance = Security::filter( $xml['ACCEPTANCE'] );  | 
            |||
| 39 | 3 | $order_response->status = Security::filter( $xml[ Parameters::STATUS ] );  | 
            |||
| 40 | 3 | $order_response->eci = Security::filter( $xml['ECI'] );  | 
            |||
| 41 | 3 | $order_response->amount = Security::filter( $xml[ Parameters::AMOUNT ] );  | 
            |||
| 42 | 3 | $order_response->currency = Security::filter( $xml[ Parameters::CURRENCY ] );  | 
            |||
| 43 | 3 | $order_response->pm = Security::filter( $xml['PM'] );  | 
            |||
| 44 | 3 | $order_response->brand = Security::filter( $xml['BRAND'] );  | 
            |||
| 45 | |||||
| 46 | 3 | 		if ( $xml->HTML_ANSWER ) { | 
            |||
| 47 | // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode  | 
            ||||
| 48 | 1 | $order_response->html_answer = base64_decode( Security::filter( $xml->HTML_ANSWER ) );  | 
            |||
| 
                                                                                                                                                        
                         0 ignored issues 
                            –
                            show
                                    Bug
    
    
    
        introduced 
                            by  
        
   Loading history...
                It seems like  
                    
                                                    Pronamic\WordPress\Pay\C...lter($xml->HTML_ANSWER) can also be of type null; however, parameter $string of base64_decode() does only seem to accept string, maybe add an additional type check?
                                                                                                                                                                                           (
                                     Ignorable by Annotation
                                )
                                 If this is a false-positive, you can also ignore this issue in your code via the  
   Loading history...
                 | 
                |||||
| 49 | }  | 
            ||||
| 50 | |||||
| 51 | 3 | return $order_response;  | 
            |||
| 52 | }  | 
            ||||
| 53 | }  | 
            ||||
| 54 |