|
1
|
|
|
<?php |
|
2
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink; |
|
3
|
|
|
|
|
4
|
|
|
use Pronamic\WordPress\Pay\Core\Gateway; |
|
|
|
|
|
|
5
|
|
|
use Pronamic\WordPress\Pay\Core\GatewayConfigFactory; |
|
6
|
|
|
use Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Title: Ingenico DirectLink config factory |
|
10
|
|
|
* Description: |
|
11
|
|
|
* Copyright: 2005-2019 Pronamic |
|
12
|
|
|
* Company: Pronamic |
|
13
|
|
|
* |
|
14
|
|
|
* @author Remco Tolsma |
|
15
|
|
|
* @version 2.0.0 |
|
16
|
|
|
*/ |
|
17
|
|
|
class ConfigFactory extends GatewayConfigFactory { |
|
18
|
|
|
public function get_config( $post_id ) { |
|
19
|
|
|
$config = new Config(); |
|
20
|
|
|
|
|
21
|
|
|
$config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
|
|
|
|
|
22
|
|
|
$config->psp_id = get_post_meta( $post_id, '_pronamic_gateway_ogone_psp_id', true ); |
|
|
|
|
|
|
23
|
|
|
$config->hash_algorithm = get_post_meta( $post_id, '_pronamic_gateway_ogone_hash_algorithm', true ); |
|
|
|
|
|
|
24
|
|
|
$config->sha_out_pass_phrase = get_post_meta( $post_id, '_pronamic_gateway_ogone_sha_out_pass_phrase', true ); |
|
|
|
|
|
|
25
|
|
|
$config->user_id = get_post_meta( $post_id, '_pronamic_gateway_ogone_user_id', true ); |
|
26
|
|
|
$config->password = get_post_meta( $post_id, '_pronamic_gateway_ogone_password', true ); |
|
27
|
|
|
$config->sha_in_pass_phrase = get_post_meta( $post_id, '_pronamic_gateway_ogone_directlink_sha_in_pass_phrase', true ); |
|
28
|
|
|
$config->enabled_3d_secure = get_post_meta( $post_id, '_pronamic_gateway_ogone_3d_secure_enabled', true ); |
|
|
|
|
|
|
29
|
|
|
$config->order_id = get_post_meta( $post_id, '_pronamic_gateway_ogone_order_id', true ); |
|
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
// API URL |
|
32
|
|
|
$is_utf8 = strcasecmp( get_bloginfo( 'charset' ), 'UTF-8' ) === 0; |
|
33
|
|
|
|
|
34
|
|
|
switch ( $config->mode ) { |
|
35
|
|
|
case Gateway::MODE_TEST: |
|
36
|
|
|
if ( $is_utf8 ) { |
|
37
|
|
|
$config->api_url = DirectLink::API_TEST_UTF8_URL; |
|
38
|
|
|
} else { |
|
39
|
|
|
$config->api_url = DirectLink::API_TEST_URL; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
break; |
|
43
|
|
|
default: |
|
44
|
|
|
if ( $is_utf8 ) { |
|
45
|
|
|
$config->api_url = DirectLink::API_PRODUCTION_UTF8_URL; |
|
46
|
|
|
} else { |
|
47
|
|
|
$config->api_url = DirectLink::API_PRODUCTION_URL; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
return $config; |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: