1 | <?php |
||
2 | /** |
||
3 | * Integration |
||
4 | * |
||
5 | * @author Pronamic <[email protected]> |
||
6 | * @copyright 2005-2020 Pronamic |
||
7 | * @license GPL-3.0-or-later |
||
8 | * @package Pronamic\WordPress\Pay\Payments |
||
9 | */ |
||
10 | |||
11 | namespace Pronamic\WordPress\Pay\Gateways\Sisow; |
||
12 | |||
13 | use Pronamic\WordPress\Pay\AbstractGatewayIntegration; |
||
0 ignored issues
–
show
|
|||
14 | use Pronamic\WordPress\Pay\Payments\Payment; |
||
15 | |||
16 | /** |
||
17 | * Title: Sisow integration |
||
18 | * Description: |
||
19 | * Copyright: 2005-2020 Pronamic |
||
20 | * Company: Pronamic |
||
21 | * |
||
22 | * @author Remco Tolsma |
||
23 | * @version 2.0.4 |
||
24 | * @since 1.0.0 |
||
25 | */ |
||
26 | class Integration extends AbstractGatewayIntegration { |
||
27 | /** |
||
28 | * Construct Sisow integration. |
||
29 | * |
||
30 | * @param array $args Arguments. |
||
31 | */ |
||
32 | public function __construct( $args = array() ) { |
||
33 | $args = wp_parse_args( |
||
34 | $args, |
||
35 | array( |
||
36 | 'id' => 'sisow-ideal', |
||
37 | 'name' => 'Sisow', |
||
38 | 'url' => 'https://www.sisow.nl/', |
||
39 | 'product_url' => 'https://www.sisow.nl/epay-online-betaalmogelijkheden/epay-informatie', |
||
40 | 'dashboard_url' => 'https://www.sisow.nl/Sisow/iDeal/Login.aspx', |
||
41 | 'register_url' => 'https://www.sisow.nl/Sisow/iDeal/Aanmelden.aspx?r=120872', |
||
42 | 'provider' => 'sisow', |
||
43 | 'supports' => array( |
||
44 | 'webhook', |
||
45 | 'webhook_log', |
||
46 | 'webhook_no_config', |
||
47 | ), |
||
48 | 'manual_url' => \__( 'https://www.pronamic.eu/support/how-to-connect-sisow-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ), |
||
49 | ) |
||
50 | ); |
||
51 | |||
52 | parent::__construct( $args ); |
||
53 | |||
54 | /** |
||
55 | * Filter Pronamic Pay return should redirect. |
||
56 | * |
||
57 | * @link https://github.com/wp-pay/core/blob/2.2.7/src/Plugin.php#L435-L436 |
||
58 | */ |
||
59 | \add_filter( 'pronamic_pay_return_should_redirect', array( $this, 'return_should_redirect' ), 10, 2 ); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Filter whether or not to redirect when handling return. |
||
64 | * |
||
65 | * @param bool $should_redirect Whether or not to redirect. |
||
66 | * @param Payment $payment Payment. |
||
67 | * |
||
68 | * @return bool |
||
69 | */ |
||
70 | public function return_should_redirect( $should_redirect, Payment $payment ) { |
||
71 | // Check if the request is a callback request. |
||
72 | if ( filter_has_var( \INPUT_GET, 'callback' ) && filter_input( \INPUT_GET, 'callback', \FILTER_VALIDATE_BOOLEAN ) ) { |
||
73 | $should_redirect = false; |
||
74 | } |
||
75 | |||
76 | // Check if the request is a notify request. |
||
77 | if ( filter_has_var( \INPUT_GET, 'notify' ) && filter_input( \INPUT_GET, 'notify', \FILTER_VALIDATE_BOOLEAN ) ) { |
||
78 | // Log webhook request. |
||
79 | do_action( 'pronamic_pay_webhook_log_payment', $payment ); |
||
80 | |||
81 | $should_redirect = false; |
||
82 | } |
||
83 | |||
84 | return $should_redirect; |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * Get settings fields. |
||
89 | * |
||
90 | * @return array |
||
91 | */ |
||
92 | public function get_settings_fields() { |
||
93 | $fields = array(); |
||
94 | |||
95 | // Intro. |
||
96 | $fields[] = array( |
||
97 | 'section' => 'general', |
||
98 | 'type' => 'html', |
||
99 | 'html' => sprintf( |
||
100 | /* translators: %s: Sisow */ |
||
101 | __( 'Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal' ), |
||
102 | __( 'Sisow', 'pronamic_ideal' ) |
||
103 | ), |
||
104 | ); |
||
105 | |||
106 | // Merchant ID. |
||
107 | $fields[] = array( |
||
108 | 'section' => 'general', |
||
109 | 'filter' => FILTER_SANITIZE_STRING, |
||
110 | 'methods' => array( 'sisow' ), |
||
111 | 'meta_key' => '_pronamic_gateway_sisow_merchant_id', |
||
112 | 'title' => _x( 'Merchant ID', 'sisow', 'pronamic_ideal' ), |
||
113 | 'type' => 'text', |
||
114 | 'classes' => array( 'code' ), |
||
115 | 'tooltip' => __( 'Merchant ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ), |
||
116 | ); |
||
117 | |||
118 | // Merchant Key. |
||
119 | $fields[] = array( |
||
120 | 'section' => 'general', |
||
121 | 'filter' => FILTER_SANITIZE_STRING, |
||
122 | 'methods' => array( 'sisow' ), |
||
123 | 'meta_key' => '_pronamic_gateway_sisow_merchant_key', |
||
124 | 'title' => _x( 'Merchant Key', 'sisow', 'pronamic_ideal' ), |
||
125 | 'type' => 'text', |
||
126 | 'classes' => array( 'regular-text', 'code' ), |
||
127 | 'tooltip' => __( 'Merchant Key as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ), |
||
128 | ); |
||
129 | |||
130 | // Shop ID. |
||
131 | $fields[] = array( |
||
132 | 'section' => 'general', |
||
133 | 'filter' => FILTER_SANITIZE_STRING, |
||
134 | 'methods' => array( 'sisow' ), |
||
135 | 'meta_key' => '_pronamic_gateway_sisow_shop_id', |
||
136 | 'title' => _x( 'Shop ID', 'sisow', 'pronamic_ideal' ), |
||
137 | 'type' => 'text', |
||
138 | 'classes' => array( 'regular-text', 'code' ), |
||
139 | 'tooltip' => __( 'Shop ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ), |
||
140 | /* translators: %s: 0 */ |
||
141 | 'description' => sprintf( __( 'Default: <code>%s</code>', 'pronamic_ideal' ), 0 ), |
||
142 | 'default' => 0, |
||
143 | ); |
||
144 | |||
145 | return $fields; |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * Get configuration. |
||
150 | * |
||
151 | * @param int $post_id Post ID. |
||
152 | * @return Config |
||
153 | */ |
||
154 | public function get_config( $post_id ) { |
||
155 | $config = new Config(); |
||
156 | |||
157 | $config->merchant_id = $this->get_meta( $post_id, 'sisow_merchant_id' ); |
||
158 | $config->merchant_key = $this->get_meta( $post_id, 'sisow_merchant_key' ); |
||
159 | $config->shop_id = $this->get_meta( $post_id, 'sisow_shop_id' ); |
||
160 | $config->mode = $this->get_meta( $post_id, 'mode' ); |
||
161 | |||
162 | return $config; |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * Get gateway. |
||
167 | * |
||
168 | * @param int $post_id Post ID. |
||
169 | * @return Gateway |
||
170 | */ |
||
171 | public function get_gateway( $post_id ) { |
||
172 | return new Gateway( $this->get_config( $post_id ) ); |
||
173 | } |
||
174 | } |
||
175 |
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