1 | <?php |
||
2 | |||
3 | namespace Pronamic\WordPress\Pay\Gateways\EMS\ECommerce; |
||
4 | |||
5 | use Pronamic\WordPress\Pay\AbstractGatewayIntegration; |
||
0 ignored issues
–
show
|
|||
6 | |||
7 | /** |
||
8 | * Title: EMS e-Commerce integration |
||
9 | * Description: |
||
10 | * Copyright: 2005-2020 Pronamic |
||
11 | * Company: Pronamic |
||
12 | * |
||
13 | * @author Reüel van der Steege |
||
14 | * @version 2.0.4 |
||
15 | * @since 1.0.0 |
||
16 | */ |
||
17 | class Integration extends AbstractGatewayIntegration { |
||
18 | /** |
||
19 | * Construct EMS e-Commerce integration. |
||
20 | * |
||
21 | * @param array $args Arguments. |
||
22 | */ |
||
23 | public function __construct( $args = array() ) { |
||
24 | $args = wp_parse_args( |
||
25 | $args, |
||
26 | array( |
||
27 | 'id' => 'ems-ecommerce', |
||
28 | 'name' => 'EMS e-Commerce', |
||
29 | 'provider' => 'ems', |
||
30 | 'product_url' => null, |
||
31 | 'dashboard_url' => array( |
||
32 | \__( 'test', 'pronamic_ideal' ) => 'https://test.ipg-online.com/vt/login', |
||
33 | \__( 'live', 'pronamic_ideal' ) => 'https://www.ipg-online.com/vt/login', |
||
34 | ), |
||
35 | 'supports' => array( |
||
36 | 'webhook', |
||
37 | 'webhook_log', |
||
38 | 'webhook_no_config', |
||
39 | ), |
||
40 | 'manual_url' => \__( 'https://www.pronamic.eu/support/how-to-connect-ems-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ), |
||
41 | ) |
||
42 | ); |
||
43 | |||
44 | parent::__construct( $args ); |
||
45 | |||
46 | // Actions |
||
47 | $function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
||
48 | |||
49 | if ( ! has_action( 'wp_loaded', $function ) ) { |
||
50 | add_action( 'wp_loaded', $function ); |
||
51 | } |
||
52 | } |
||
53 | |||
54 | public function get_settings_fields() { |
||
55 | $fields = array(); |
||
56 | |||
57 | // Storename. |
||
58 | $fields[] = array( |
||
59 | 'section' => 'general', |
||
60 | 'filter' => FILTER_UNSAFE_RAW, |
||
61 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_storename', |
||
62 | 'title' => _x( 'Storename', 'ems', 'pronamic_ideal' ), |
||
63 | 'type' => 'text', |
||
64 | 'classes' => array( 'code' ), |
||
65 | ); |
||
66 | |||
67 | // Shared secret. |
||
68 | $fields[] = array( |
||
69 | 'section' => 'general', |
||
70 | 'filter' => FILTER_UNSAFE_RAW, |
||
71 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_secret', |
||
72 | 'title' => _x( 'Shared Secret', 'ems', 'pronamic_ideal' ), |
||
73 | 'type' => 'text', |
||
74 | 'classes' => array( 'large-text', 'code' ), |
||
75 | ); |
||
76 | |||
77 | // Purchase ID. |
||
78 | $fields[] = array( |
||
79 | 'section' => 'advanced', |
||
80 | 'filter' => array( |
||
81 | 'filter' => FILTER_SANITIZE_STRING, |
||
82 | 'flags' => FILTER_FLAG_NO_ENCODE_QUOTES, |
||
83 | ), |
||
84 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_order_id', |
||
85 | 'title' => __( 'Order ID', 'pronamic_ideal' ), |
||
86 | 'type' => 'text', |
||
87 | 'classes' => array( 'regular-text', 'code' ), |
||
88 | 'tooltip' => sprintf( |
||
89 | /* translators: %s: <code>{orderId}</code> */ |
||
90 | __( 'The EMS e-Commerce %s parameter.', 'pronamic_ideal' ), |
||
91 | sprintf( '<code>%s</code>', 'orderId' ) |
||
92 | ), |
||
93 | 'description' => sprintf( |
||
94 | '%s %s<br />%s', |
||
95 | __( 'Available tags:', 'pronamic_ideal' ), |
||
96 | sprintf( |
||
97 | '<code>%s</code> <code>%s</code>', |
||
98 | '{order_id}', |
||
99 | '{payment_id}' |
||
100 | ), |
||
101 | sprintf( |
||
102 | /* translators: %s: {order_id} */ |
||
103 | __( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
||
104 | '{order_id}' |
||
105 | ) |
||
106 | ), |
||
107 | ); |
||
108 | |||
109 | // Notification URL. |
||
110 | $fields[] = array( |
||
111 | 'section' => 'feedback', |
||
112 | /* translators: Translate 'notification' the same as in the EMS e-Commerce dashboard. */ |
||
113 | 'title' => _x( 'Notification URL', 'EMS e-Commerce', 'pronamic_ideal' ), |
||
114 | 'type' => 'text', |
||
115 | 'classes' => array( 'large-text', 'code' ), |
||
116 | 'value' => home_url( '/' ), |
||
117 | 'readonly' => true, |
||
118 | /* translators: Translate 'notification' the same as in the EMS e-Commerce dashboard. */ |
||
119 | 'tooltip' => _x( |
||
120 | 'The Notification URL as sent with each transaction to receive automatic payment status updates on.', |
||
121 | 'EMS e-Commerce', |
||
122 | 'pronamic_ideal' |
||
123 | ), |
||
124 | ); |
||
125 | |||
126 | return $fields; |
||
127 | } |
||
128 | |||
129 | public function get_config( $post_id ) { |
||
130 | $config = new Config(); |
||
131 | |||
132 | $config->storename = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_storename', true ); |
||
133 | $config->secret = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_secret', true ); |
||
134 | $config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
||
0 ignored issues
–
show
It seems like
get_post_meta($post_id, ...ic_gateway_mode', true) can also be of type false . However, the property $mode is declared as type string . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||
135 | $config->order_id = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_order_id', true ); |
||
136 | |||
137 | return $config; |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * Get gateway. |
||
142 | * |
||
143 | * @param int $post_id Post ID. |
||
144 | * @return Gateway |
||
145 | */ |
||
146 | public function get_gateway( $post_id ) { |
||
147 | return new Gateway( $this->get_config( $post_id ) ); |
||
148 | } |
||
149 | } |
||
150 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths