wp-pay-gateways /
ogone
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink; |
||||
| 4 | |||||
| 5 | use Pronamic\WordPress\Pay\Core\Util; |
||||
| 6 | use Pronamic\WordPress\Pay\Core\XML\Security; |
||||
| 7 | use Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink; |
||||
| 8 | use Pronamic\WordPress\Pay\Gateways\Ingenico\Error; |
||||
| 9 | use Pronamic\WordPress\Pay\Gateways\Ingenico\XML\OrderResponseParser; |
||||
| 10 | |||||
| 11 | /** |
||||
| 12 | * Title: Ingenico DirectLink client |
||||
| 13 | * Description: |
||||
| 14 | * Copyright: 2005-2019 Pronamic |
||||
| 15 | * Company: Pronamic |
||||
| 16 | * |
||||
| 17 | * @author Remco Tolsma |
||||
| 18 | * @version 2.0.4 |
||||
| 19 | * @since 1.0.0 |
||||
| 20 | */ |
||||
| 21 | class Client { |
||||
| 22 | /** |
||||
| 23 | * API URL. |
||||
| 24 | * |
||||
| 25 | * @var string |
||||
| 26 | */ |
||||
| 27 | public $api_url; |
||||
| 28 | |||||
| 29 | /** |
||||
| 30 | * PSP ID. |
||||
| 31 | * |
||||
| 32 | * @var string |
||||
| 33 | */ |
||||
| 34 | public $psp_id; |
||||
| 35 | |||||
| 36 | /** |
||||
| 37 | * SHA IN. |
||||
| 38 | * |
||||
| 39 | * @var string |
||||
| 40 | */ |
||||
| 41 | public $sha_in; |
||||
| 42 | |||||
| 43 | /** |
||||
| 44 | * User ID. |
||||
| 45 | * |
||||
| 46 | * @var string |
||||
| 47 | */ |
||||
| 48 | public $user_id; |
||||
| 49 | |||||
| 50 | /** |
||||
| 51 | * Password. |
||||
| 52 | * |
||||
| 53 | * @var string |
||||
| 54 | */ |
||||
| 55 | public $password; |
||||
| 56 | |||||
| 57 | /** |
||||
| 58 | * Constructs and initializes an Ogone DirectLink client |
||||
| 59 | */ |
||||
| 60 | public function __construct() { |
||||
| 61 | $this->api_url = DirectLink::API_PRODUCTION_URL; |
||||
| 62 | } |
||||
| 63 | |||||
| 64 | /** |
||||
| 65 | * Order direct |
||||
| 66 | * |
||||
| 67 | * @param array $data Data. |
||||
| 68 | * |
||||
| 69 | * @return bool|OrderResponse |
||||
| 70 | */ |
||||
| 71 | public function order_direct( array $data = array() ) { |
||||
| 72 | $order_response = false; |
||||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||||
| 73 | |||||
| 74 | $result = Util::remote_get_body( |
||||
| 75 | $this->api_url, |
||||
| 76 | 200, |
||||
| 77 | array( |
||||
| 78 | 'method' => 'POST', |
||||
| 79 | 'sslverify' => false, |
||||
| 80 | 'body' => $data, |
||||
| 81 | ) |
||||
| 82 | ); |
||||
| 83 | |||||
| 84 | $xml = Util::simplexml_load_string( $result ); |
||||
|
0 ignored issues
–
show
It seems like
$result can also be of type WP_Error; however, parameter $string of Pronamic\WordPress\Pay\C...simplexml_load_string() 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...
|
|||||
| 85 | |||||
| 86 | $order_response = OrderResponseParser::parse( $xml ); |
||||
| 87 | |||||
| 88 | if ( ! empty( $order_response->nc_error ) ) { |
||||
| 89 | $ogone_error = new Error( |
||||
| 90 | Security::filter( $order_response->nc_error ), |
||||
| 91 | Security::filter( $order_response->nc_error_plus ) |
||||
| 92 | ); |
||||
| 93 | |||||
| 94 | throw new \Exception( (string) $ogone_error ); |
||||
| 95 | } |
||||
| 96 | |||||
| 97 | return $order_response; |
||||
| 98 | } |
||||
| 99 | } |
||||
| 100 |