@@ -16,32 +16,32 @@ |
||
16 | 16 | */ |
17 | 17 | class Listener { |
18 | 18 | public static function listen() { |
19 | - if ( ! filter_has_var( INPUT_POST, 'Data' ) || ! filter_has_var( INPUT_POST, 'Seal' ) ) { |
|
19 | + if ( ! filter_has_var(INPUT_POST, 'Data') || ! filter_has_var(INPUT_POST, 'Seal')) { |
|
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | - $input_data = filter_input( INPUT_POST, 'Data' ); |
|
23 | + $input_data = filter_input(INPUT_POST, 'Data'); |
|
24 | 24 | |
25 | - $data = Client::parse_piped_string( $input_data ); |
|
25 | + $data = Client::parse_piped_string($input_data); |
|
26 | 26 | |
27 | 27 | $transaction_reference = $data['transactionReference']; |
28 | 28 | |
29 | - $payment = get_pronamic_payment_by_meta( '_pronamic_payment_omnikassa_transaction_reference', $transaction_reference ); |
|
29 | + $payment = get_pronamic_payment_by_meta('_pronamic_payment_omnikassa_transaction_reference', $transaction_reference); |
|
30 | 30 | |
31 | - if ( null === $payment ) { |
|
31 | + if (null === $payment) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Add note. |
36 | 36 | $note = sprintf( |
37 | 37 | /* translators: %s: OmniKassa */ |
38 | - __( 'Webhook requested by %s.', 'pronamic_ideal' ), |
|
39 | - __( 'OmniKassa', 'pronamic_ideal' ) |
|
38 | + __('Webhook requested by %s.', 'pronamic_ideal'), |
|
39 | + __('OmniKassa', 'pronamic_ideal') |
|
40 | 40 | ); |
41 | 41 | |
42 | - $payment->add_note( $note ); |
|
42 | + $payment->add_note($note); |
|
43 | 43 | |
44 | 44 | // Update payment. |
45 | - Plugin::update_payment( $payment ); |
|
45 | + Plugin::update_payment($payment); |
|
46 | 46 | } |
47 | 47 | } |
@@ -16,35 +16,35 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class Settings extends GatewaySettings { |
18 | 18 | public function __construct() { |
19 | - add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) ); |
|
20 | - add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) ); |
|
19 | + add_filter('pronamic_pay_gateway_sections', array($this, 'sections')); |
|
20 | + add_filter('pronamic_pay_gateway_fields', array($this, 'fields')); |
|
21 | 21 | } |
22 | 22 | |
23 | - public function sections( array $sections ) { |
|
23 | + public function sections(array $sections) { |
|
24 | 24 | // iDEAL |
25 | 25 | $sections['omnikassa'] = array( |
26 | - 'title' => __( 'OmniKassa', 'pronamic_ideal' ), |
|
27 | - 'methods' => array( 'omnikassa' ), |
|
26 | + 'title' => __('OmniKassa', 'pronamic_ideal'), |
|
27 | + 'methods' => array('omnikassa'), |
|
28 | 28 | ); |
29 | 29 | |
30 | 30 | // Advanced |
31 | 31 | $sections['omnikassa_advanced'] = array( |
32 | - 'title' => __( 'Advanced', 'pronamic_ideal' ), |
|
33 | - 'methods' => array( 'omnikassa' ), |
|
32 | + 'title' => __('Advanced', 'pronamic_ideal'), |
|
33 | + 'methods' => array('omnikassa'), |
|
34 | 34 | ); |
35 | 35 | |
36 | 36 | return $sections; |
37 | 37 | } |
38 | 38 | |
39 | - public function fields( array $fields ) { |
|
39 | + public function fields(array $fields) { |
|
40 | 40 | // Merchant ID |
41 | 41 | $fields[] = array( |
42 | 42 | 'filter' => FILTER_SANITIZE_STRING, |
43 | 43 | 'section' => 'omnikassa', |
44 | 44 | 'meta_key' => '_pronamic_gateway_omnikassa_merchant_id', |
45 | - 'title' => __( 'Merchant ID', 'pronamic_ideal' ), |
|
45 | + 'title' => __('Merchant ID', 'pronamic_ideal'), |
|
46 | 46 | 'type' => 'text', |
47 | - 'classes' => array( 'code' ), |
|
47 | + 'classes' => array('code'), |
|
48 | 48 | ); |
49 | 49 | |
50 | 50 | // Secret Key |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | 'filter' => FILTER_SANITIZE_STRING, |
53 | 53 | 'section' => 'omnikassa', |
54 | 54 | 'meta_key' => '_pronamic_gateway_omnikassa_secret_key', |
55 | - 'title' => __( 'Secret Key', 'pronamic_ideal' ), |
|
55 | + 'title' => __('Secret Key', 'pronamic_ideal'), |
|
56 | 56 | 'type' => 'text', |
57 | - 'classes' => array( 'large-text', 'code' ), |
|
57 | + 'classes' => array('large-text', 'code'), |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | // Key Version |
@@ -62,21 +62,21 @@ discard block |
||
62 | 62 | 'filter' => FILTER_SANITIZE_STRING, |
63 | 63 | 'section' => 'omnikassa', |
64 | 64 | 'meta_key' => '_pronamic_gateway_omnikassa_key_version', |
65 | - 'title' => __( 'Key Version', 'pronamic_ideal' ), |
|
65 | + 'title' => __('Key Version', 'pronamic_ideal'), |
|
66 | 66 | 'type' => 'text', |
67 | - 'classes' => array( 'code' ), |
|
67 | + 'classes' => array('code'), |
|
68 | 68 | 'size' => 5, |
69 | - 'description' => sprintf( __( 'You can find the key version in the <a href="%s" target="_blank">OmniKassa Download Dashboard</a>.', 'pronamic_ideal' ), 'https://download.omnikassa.rabobank.nl/' ), |
|
69 | + 'description' => sprintf(__('You can find the key version in the <a href="%s" target="_blank">OmniKassa Download Dashboard</a>.', 'pronamic_ideal'), 'https://download.omnikassa.rabobank.nl/'), |
|
70 | 70 | ); |
71 | 71 | |
72 | 72 | // Transaction feedback |
73 | 73 | $fields[] = array( |
74 | 74 | 'section' => 'omnikassa', |
75 | - 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
75 | + 'title' => __('Transaction feedback', 'pronamic_ideal'), |
|
76 | 76 | 'type' => 'description', |
77 | 77 | 'html' => sprintf( |
78 | 78 | '<span class="dashicons dashicons-yes"></span> %s', |
79 | - __( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' ) |
|
79 | + __('Payment status updates will be processed without any additional configuration.', 'pronamic_ideal') |
|
80 | 80 | ), |
81 | 81 | ); |
82 | 82 | |
@@ -85,23 +85,23 @@ discard block |
||
85 | 85 | 'filter' => FILTER_SANITIZE_STRING, |
86 | 86 | 'section' => 'omnikassa_advanced', |
87 | 87 | 'meta_key' => '_pronamic_gateway_omnikassa_order_id', |
88 | - 'title' => __( 'Order ID', 'pronamic_ideal' ), |
|
88 | + 'title' => __('Order ID', 'pronamic_ideal'), |
|
89 | 89 | 'type' => 'text', |
90 | - 'classes' => array( 'regular-text', 'code' ), |
|
90 | + 'classes' => array('regular-text', 'code'), |
|
91 | 91 | 'tooltip' => sprintf( |
92 | - __( 'The OmniKassa %s parameter.', 'pronamic_ideal' ), |
|
93 | - sprintf( '<code>%s</code>', 'orderId' ) |
|
92 | + __('The OmniKassa %s parameter.', 'pronamic_ideal'), |
|
93 | + sprintf('<code>%s</code>', 'orderId') |
|
94 | 94 | ), |
95 | 95 | 'description' => sprintf( |
96 | 96 | '%s %s<br />%s', |
97 | - __( 'Available tags:', 'pronamic_ideal' ), |
|
97 | + __('Available tags:', 'pronamic_ideal'), |
|
98 | 98 | sprintf( |
99 | 99 | '<code>%s</code> <code>%s</code>', |
100 | 100 | '{order_id}', |
101 | 101 | '{payment_id}' |
102 | 102 | ), |
103 | 103 | sprintf( |
104 | - __( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
|
104 | + __('Default: <code>%s</code>', 'pronamic_ideal'), |
|
105 | 105 | '{payment_id}' |
106 | 106 | ) |
107 | 107 | ), |
@@ -19,21 +19,21 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @var array |
21 | 21 | */ |
22 | - private static $characters_n = array( '0-9' ); |
|
22 | + private static $characters_n = array('0-9'); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * A - Indicates that an alphabetical value [aA-zZ] is accepted |
26 | 26 | * |
27 | 27 | * @var array |
28 | 28 | */ |
29 | - private static $characters_a = array( 'A-Z', 'a-z' ); |
|
29 | + private static $characters_a = array('A-Z', 'a-z'); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * A + N |
33 | 33 | * |
34 | 34 | * @var array |
35 | 35 | */ |
36 | - private static $characters_an = array( 'A-Z', 'a-z', '0-9' ); |
|
36 | + private static $characters_an = array('A-Z', 'a-z', '0-9'); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Filter N characters |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return string |
45 | 45 | */ |
46 | - public static function filter_n( $string, $max = null ) { |
|
47 | - return Core_DataHelper::filter( self::$characters_n, $string, $max ); |
|
46 | + public static function filter_n($string, $max = null) { |
|
47 | + return Core_DataHelper::filter(self::$characters_n, $string, $max); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - public static function filter_a( $string, $max = null ) { |
|
59 | - return Core_DataHelper::filter( self::$characters_a, $string, $max ); |
|
58 | + public static function filter_a($string, $max = null) { |
|
59 | + return Core_DataHelper::filter(self::$characters_a, $string, $max); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string |
69 | 69 | */ |
70 | - public static function filter_an( $string, $max = null ) { |
|
71 | - return Core_DataHelper::filter( self::$characters_an, $string, $max ); |
|
70 | + public static function filter_an($string, $max = null) { |
|
71 | + return Core_DataHelper::filter(self::$characters_an, $string, $max); |
|
72 | 72 | } |
73 | 73 | } |
@@ -157,8 +157,8 @@ |
||
157 | 157 | * |
158 | 158 | * @return string|null |
159 | 159 | */ |
160 | - public static function transform( $response_code ) { |
|
161 | - switch ( $response_code ) { |
|
160 | + public static function transform($response_code) { |
|
161 | + switch ($response_code) { |
|
162 | 162 | case self::TRANSACTION_SUCCES : |
163 | 163 | return Statuses::SUCCESS; |
164 | 164 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @parm array $list |
27 | 27 | */ |
28 | - public function __construct( array $list = array() ) { |
|
28 | + public function __construct(array $list = array()) { |
|
29 | 29 | $this->list = $list; |
30 | 30 | } |
31 | 31 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param string $payment_mean_brand |
36 | 36 | */ |
37 | - public function add_payment_mean_brand( $payment_mean_brand ) { |
|
37 | + public function add_payment_mean_brand($payment_mean_brand) { |
|
38 | 38 | $this->list[] = $payment_mean_brand; |
39 | 39 | } |
40 | 40 | |
@@ -44,6 +44,6 @@ discard block |
||
44 | 44 | * @return string |
45 | 45 | */ |
46 | 46 | public function __toString() { |
47 | - return implode( ', ', $this->list ); |
|
47 | + return implode(', ', $this->list); |
|
48 | 48 | } |
49 | 49 | } |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | ); |
58 | 58 | } |
59 | 59 | |
60 | - public static function is_supported_language( $language ) { |
|
60 | + public static function is_supported_language($language) { |
|
61 | 61 | $languages = self::get_supported_language_codes(); |
62 | 62 | |
63 | - return in_array( $language, $languages, true ); |
|
63 | + return in_array($language, $languages, true); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | public function __construct() { |
193 | 193 | $this->payment_mean_brand_list = array(); |
194 | 194 | |
195 | - $this->set_interface_version( self::INTERFACE_VERSION_HP_1_0 ); |
|
195 | + $this->set_interface_version(self::INTERFACE_VERSION_HP_1_0); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @param string $url an URL |
211 | 211 | */ |
212 | - public function set_action_url( $url ) { |
|
212 | + public function set_action_url($url) { |
|
213 | 213 | $this->action_url = $url; |
214 | 214 | } |
215 | 215 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @param string $interface_version |
229 | 229 | */ |
230 | - public function set_interface_version( $interface_version ) { |
|
230 | + public function set_interface_version($interface_version) { |
|
231 | 231 | $this->interface_version = $interface_version; |
232 | 232 | } |
233 | 233 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @param string $currency_numeric_code |
247 | 247 | */ |
248 | - public function set_currency_numeric_code( $currency_numeric_code ) { |
|
248 | + public function set_currency_numeric_code($currency_numeric_code) { |
|
249 | 249 | $this->currency_numeric_code = $currency_numeric_code; |
250 | 250 | } |
251 | 251 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @param string $merchant_id |
265 | 265 | */ |
266 | - public function set_merchant_id( $merchant_id ) { |
|
266 | + public function set_merchant_id($merchant_id) { |
|
267 | 267 | $this->merchant_id = $merchant_id; |
268 | 268 | } |
269 | 269 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @param string $normal_return_url |
285 | 285 | */ |
286 | - public function set_normal_return_url( $normal_return_url ) { |
|
286 | + public function set_normal_return_url($normal_return_url) { |
|
287 | 287 | $this->normal_return_url = $normal_return_url; |
288 | 288 | } |
289 | 289 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @param float $amount |
303 | 303 | */ |
304 | - public function set_amount( $amount ) { |
|
304 | + public function set_amount($amount) { |
|
305 | 305 | $this->amount = $amount; |
306 | 306 | } |
307 | 307 | |
@@ -320,8 +320,8 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @param string $transaction_reference |
322 | 322 | */ |
323 | - public function set_transaction_reference( $transaction_reference ) { |
|
324 | - $this->transaction_reference = DataHelper::filter_an( $transaction_reference, 35 ); |
|
323 | + public function set_transaction_reference($transaction_reference) { |
|
324 | + $this->transaction_reference = DataHelper::filter_an($transaction_reference, 35); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @param string $key_version |
340 | 340 | */ |
341 | - public function set_key_version( $key_version ) { |
|
341 | + public function set_key_version($key_version) { |
|
342 | 342 | $this->key_version = $key_version; |
343 | 343 | } |
344 | 344 | |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @param string $automatic_response_url |
360 | 360 | */ |
361 | - public function set_automatic_response_url( $automatic_response_url ) { |
|
361 | + public function set_automatic_response_url($automatic_response_url) { |
|
362 | 362 | $this->automatic_response_url = $automatic_response_url; |
363 | 363 | } |
364 | 364 | |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @param string $customer_language |
378 | 378 | */ |
379 | - public function set_customer_language( $customer_language ) { |
|
379 | + public function set_customer_language($customer_language) { |
|
380 | 380 | $this->customer_language = $customer_language; |
381 | 381 | } |
382 | 382 | |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @param string $payment_mean_brand |
387 | 387 | */ |
388 | - public function add_payment_mean_brand( $payment_mean_brand ) { |
|
388 | + public function add_payment_mean_brand($payment_mean_brand) { |
|
389 | 389 | $this->payment_mean_brand_list[] = $payment_mean_brand; |
390 | 390 | } |
391 | 391 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * @return string ANS128 listString comma separated list |
396 | 396 | */ |
397 | 397 | public function get_payment_mean_brand_list() { |
398 | - return apply_filters( 'pronamic_pay_omnikassa_payment_mean_brand_list', implode( ', ', $this->payment_mean_brand_list ) ); |
|
398 | + return apply_filters('pronamic_pay_omnikassa_payment_mean_brand_list', implode(', ', $this->payment_mean_brand_list)); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * |
413 | 413 | * @param string $order_id |
414 | 414 | */ |
415 | - public function set_order_id( $order_id ) { |
|
415 | + public function set_order_id($order_id) { |
|
416 | 416 | $this->order_id = $order_id; |
417 | 417 | } |
418 | 418 | |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | public function get_formatted_expiration_date() { |
434 | 434 | $result = null; |
435 | 435 | |
436 | - if ( null !== $this->expiration_date ) { |
|
437 | - $result = $this->expiration_date->format( DATE_ISO8601 ); |
|
436 | + if (null !== $this->expiration_date) { |
|
437 | + $result = $this->expiration_date->format(DATE_ISO8601); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | return $result; |
@@ -445,19 +445,19 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @param DateTime $date |
447 | 447 | */ |
448 | - public function set_expiration_date( DateTime $date = null ) { |
|
448 | + public function set_expiration_date(DateTime $date = null) { |
|
449 | 449 | $this->expiration_date = $date; |
450 | 450 | } |
451 | 451 | |
452 | 452 | public function get_data_array() { |
453 | 453 | // Payment Request - required fields |
454 | 454 | $required_fields = array( |
455 | - 'amount' => strval( $this->get_amount() ), |
|
456 | - 'currencyCode' => strval( $this->get_currency_numeric_code() ), |
|
455 | + 'amount' => strval($this->get_amount()), |
|
456 | + 'currencyCode' => strval($this->get_currency_numeric_code()), |
|
457 | 457 | 'merchantId' => $this->get_merchant_id(), |
458 | 458 | 'normalReturnUrl' => $this->get_normal_return_url(), |
459 | 459 | 'transactionReference' => $this->get_transaction_reference(), |
460 | - 'keyVersion' => strval( $this->get_key_version() ), |
|
460 | + 'keyVersion' => strval($this->get_key_version()), |
|
461 | 461 | ); |
462 | 462 | |
463 | 463 | // Payment request - optional fields |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | ); |
471 | 471 | |
472 | 472 | // @link http://briancray.com/2009/04/25/remove-null-values-php-arrays/ |
473 | - $optional_fields = array_filter( $optional_fields ); |
|
473 | + $optional_fields = array_filter($optional_fields); |
|
474 | 474 | |
475 | 475 | // Data |
476 | 476 | $data = $required_fields + $optional_fields; |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | public function get_data() { |
487 | 487 | $data = $this->get_data_array(); |
488 | 488 | |
489 | - return self::create_piped_string( $data ); |
|
489 | + return self::create_piped_string($data); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * |
504 | 504 | * @return string |
505 | 505 | */ |
506 | - public function set_secret_key( $secret_key ) { |
|
506 | + public function set_secret_key($secret_key) { |
|
507 | 507 | $this->secret_key = $secret_key; |
508 | 508 | } |
509 | 509 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | $data = $this->get_data(); |
517 | 517 | $secret_key = $this->get_secret_key(); |
518 | 518 | |
519 | - return self::compute_seal( $data, $secret_key ); |
|
519 | + return self::compute_seal($data, $secret_key); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -527,11 +527,11 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @return string seal |
529 | 529 | */ |
530 | - public static function compute_seal( $data, $secret_key ) { |
|
530 | + public static function compute_seal($data, $secret_key) { |
|
531 | 531 | $value = $data . $secret_key; |
532 | - $value = utf8_encode( $value ); |
|
532 | + $value = utf8_encode($value); |
|
533 | 533 | |
534 | - return hash( self::HASH_ALGORITHM_SHA256, $value ); |
|
534 | + return hash(self::HASH_ALGORITHM_SHA256, $value); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -555,9 +555,9 @@ discard block |
||
555 | 555 | * |
556 | 556 | * @return string |
557 | 557 | */ |
558 | - public static function create_piped_string( array $data ) { |
|
558 | + public static function create_piped_string(array $data) { |
|
559 | 559 | // @link http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/functions.php#L1385 |
560 | - return _http_build_query( $data, null, '|', '', false ); |
|
560 | + return _http_build_query($data, null, '|', '', false); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | /** |
@@ -567,14 +567,14 @@ discard block |
||
567 | 567 | * |
568 | 568 | * @return array |
569 | 569 | */ |
570 | - public static function parse_piped_string( $string ) { |
|
570 | + public static function parse_piped_string($string) { |
|
571 | 571 | $data = array(); |
572 | 572 | |
573 | - $pairs = explode( '|', $string ); |
|
574 | - foreach ( $pairs as $pair ) { |
|
575 | - list( $key, $value ) = explode( '=', $pair ); |
|
573 | + $pairs = explode('|', $string); |
|
574 | + foreach ($pairs as $pair) { |
|
575 | + list($key, $value) = explode('=', $pair); |
|
576 | 576 | |
577 | - $data[ $key ] = $value; |
|
577 | + $data[$key] = $value; |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | return $data; |
@@ -29,24 +29,24 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param Config $config Config. |
31 | 31 | */ |
32 | - public function __construct( Config $config ) { |
|
33 | - parent::__construct( $config ); |
|
32 | + public function __construct(Config $config) { |
|
33 | + parent::__construct($config); |
|
34 | 34 | |
35 | - $this->set_method( self::METHOD_HTML_FORM ); |
|
35 | + $this->set_method(self::METHOD_HTML_FORM); |
|
36 | 36 | |
37 | 37 | // Client. |
38 | 38 | $this->client = new Client(); |
39 | 39 | |
40 | 40 | $action_url = Client::ACTION_URL_PRUDCTION; |
41 | 41 | |
42 | - if ( self::MODE_TEST === $config->mode ) { |
|
42 | + if (self::MODE_TEST === $config->mode) { |
|
43 | 43 | $action_url = Client::ACTION_URL_TEST; |
44 | 44 | } |
45 | 45 | |
46 | - $this->client->set_action_url( $action_url ); |
|
47 | - $this->client->set_merchant_id( $config->merchant_id ); |
|
48 | - $this->client->set_key_version( $config->key_version ); |
|
49 | - $this->client->set_secret_key( $config->secret_key ); |
|
46 | + $this->client->set_action_url($action_url); |
|
47 | + $this->client->set_merchant_id($config->merchant_id); |
|
48 | + $this->client->set_key_version($config->key_version); |
|
49 | + $this->client->set_secret_key($config->secret_key); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -70,33 +70,33 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @param Payment $payment Payment. |
72 | 72 | */ |
73 | - public function start( Payment $payment ) { |
|
74 | - $transaction_reference = $payment->get_meta( 'omnikassa_transaction_reference' ); |
|
73 | + public function start(Payment $payment) { |
|
74 | + $transaction_reference = $payment->get_meta('omnikassa_transaction_reference'); |
|
75 | 75 | |
76 | - if ( empty( $transaction_reference ) ) { |
|
77 | - $transaction_reference = md5( uniqid( '', true ) ); |
|
76 | + if (empty($transaction_reference)) { |
|
77 | + $transaction_reference = md5(uniqid('', true)); |
|
78 | 78 | |
79 | - $payment->set_meta( 'omnikassa_transaction_reference', $transaction_reference ); |
|
79 | + $payment->set_meta('omnikassa_transaction_reference', $transaction_reference); |
|
80 | 80 | } |
81 | 81 | |
82 | - $payment->set_transaction_id( $transaction_reference ); |
|
83 | - $payment->set_action_url( $this->client->get_action_url() ); |
|
82 | + $payment->set_transaction_id($transaction_reference); |
|
83 | + $payment->set_action_url($this->client->get_action_url()); |
|
84 | 84 | |
85 | 85 | $language = null; |
86 | 86 | |
87 | - if ( null !== $payment->get_customer() ) { |
|
87 | + if (null !== $payment->get_customer()) { |
|
88 | 88 | $language = $payment->get_customer()->get_language(); |
89 | 89 | } |
90 | 90 | |
91 | - $this->client->set_customer_language( LocaleHelper::transform( $language ) ); |
|
92 | - $this->client->set_currency_numeric_code( $payment->get_total_amount()->get_currency()->get_numeric_code() ); |
|
93 | - $this->client->set_order_id( $payment->format_string( $this->config->order_id ) ); |
|
94 | - $this->client->set_normal_return_url( home_url( '/' ) ); |
|
95 | - $this->client->set_automatic_response_url( home_url( '/' ) ); |
|
96 | - $this->client->set_amount( $payment->get_total_amount()->get_cents() ); |
|
97 | - $this->client->set_transaction_reference( $transaction_reference ); |
|
91 | + $this->client->set_customer_language(LocaleHelper::transform($language)); |
|
92 | + $this->client->set_currency_numeric_code($payment->get_total_amount()->get_currency()->get_numeric_code()); |
|
93 | + $this->client->set_order_id($payment->format_string($this->config->order_id)); |
|
94 | + $this->client->set_normal_return_url(home_url('/')); |
|
95 | + $this->client->set_automatic_response_url(home_url('/')); |
|
96 | + $this->client->set_amount($payment->get_total_amount()->get_cents()); |
|
97 | + $this->client->set_transaction_reference($transaction_reference); |
|
98 | 98 | |
99 | - switch ( $payment->get_method() ) { |
|
99 | + switch ($payment->get_method()) { |
|
100 | 100 | /* |
101 | 101 | * If this field is not supplied in the payment request, then |
102 | 102 | * by default the customer will be redirected to the Rabo |
@@ -128,38 +128,38 @@ discard block |
||
128 | 128 | */ |
129 | 129 | case PaymentMethods::BANCONTACT: |
130 | 130 | case PaymentMethods::MISTER_CASH: |
131 | - $this->client->add_payment_mean_brand( Methods::BCMC ); |
|
131 | + $this->client->add_payment_mean_brand(Methods::BCMC); |
|
132 | 132 | |
133 | 133 | break; |
134 | 134 | case PaymentMethods::CREDIT_CARD: |
135 | - $this->client->add_payment_mean_brand( Methods::MAESTRO ); |
|
136 | - $this->client->add_payment_mean_brand( Methods::MASTERCARD ); |
|
137 | - $this->client->add_payment_mean_brand( Methods::VISA ); |
|
138 | - $this->client->add_payment_mean_brand( Methods::VPAY ); |
|
135 | + $this->client->add_payment_mean_brand(Methods::MAESTRO); |
|
136 | + $this->client->add_payment_mean_brand(Methods::MASTERCARD); |
|
137 | + $this->client->add_payment_mean_brand(Methods::VISA); |
|
138 | + $this->client->add_payment_mean_brand(Methods::VPAY); |
|
139 | 139 | |
140 | 140 | break; |
141 | 141 | case PaymentMethods::DIRECT_DEBIT: |
142 | - $this->client->add_payment_mean_brand( Methods::INCASSO ); |
|
142 | + $this->client->add_payment_mean_brand(Methods::INCASSO); |
|
143 | 143 | |
144 | 144 | break; |
145 | 145 | case PaymentMethods::MAESTRO: |
146 | - $this->client->add_payment_mean_brand( Methods::MAESTRO ); |
|
146 | + $this->client->add_payment_mean_brand(Methods::MAESTRO); |
|
147 | 147 | |
148 | 148 | break; |
149 | 149 | case PaymentMethods::IDEAL: |
150 | - $this->client->add_payment_mean_brand( Methods::IDEAL ); |
|
150 | + $this->client->add_payment_mean_brand(Methods::IDEAL); |
|
151 | 151 | |
152 | 152 | break; |
153 | 153 | default: |
154 | - $this->client->add_payment_mean_brand( Methods::IDEAL ); |
|
155 | - $this->client->add_payment_mean_brand( Methods::VISA ); |
|
156 | - $this->client->add_payment_mean_brand( Methods::MASTERCARD ); |
|
157 | - $this->client->add_payment_mean_brand( Methods::MAESTRO ); |
|
158 | - $this->client->add_payment_mean_brand( Methods::VPAY ); |
|
159 | - $this->client->add_payment_mean_brand( Methods::BCMC ); |
|
160 | - $this->client->add_payment_mean_brand( Methods::INCASSO ); |
|
161 | - $this->client->add_payment_mean_brand( Methods::ACCEPTGIRO ); |
|
162 | - $this->client->add_payment_mean_brand( Methods::REMBOURS ); |
|
154 | + $this->client->add_payment_mean_brand(Methods::IDEAL); |
|
155 | + $this->client->add_payment_mean_brand(Methods::VISA); |
|
156 | + $this->client->add_payment_mean_brand(Methods::MASTERCARD); |
|
157 | + $this->client->add_payment_mean_brand(Methods::MAESTRO); |
|
158 | + $this->client->add_payment_mean_brand(Methods::VPAY); |
|
159 | + $this->client->add_payment_mean_brand(Methods::BCMC); |
|
160 | + $this->client->add_payment_mean_brand(Methods::INCASSO); |
|
161 | + $this->client->add_payment_mean_brand(Methods::ACCEPTGIRO); |
|
162 | + $this->client->add_payment_mean_brand(Methods::REMBOURS); |
|
163 | 163 | |
164 | 164 | break; |
165 | 165 | } |
@@ -180,57 +180,57 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param Payment $payment Payment. |
182 | 182 | */ |
183 | - public function update_status( Payment $payment ) { |
|
184 | - $input_data = filter_input( INPUT_POST, 'Data' ); |
|
185 | - $input_seal = filter_input( INPUT_POST, 'Seal', FILTER_SANITIZE_STRING ); |
|
183 | + public function update_status(Payment $payment) { |
|
184 | + $input_data = filter_input(INPUT_POST, 'Data'); |
|
185 | + $input_seal = filter_input(INPUT_POST, 'Seal', FILTER_SANITIZE_STRING); |
|
186 | 186 | |
187 | - $data = Client::parse_piped_string( $input_data ); |
|
187 | + $data = Client::parse_piped_string($input_data); |
|
188 | 188 | |
189 | - $seal = Client::compute_seal( $input_data, $this->config->secret_key ); |
|
189 | + $seal = Client::compute_seal($input_data, $this->config->secret_key); |
|
190 | 190 | |
191 | 191 | // Check if the posted seal is equal to our seal. |
192 | - if ( 0 === strcasecmp( $input_seal, $seal ) ) { |
|
192 | + if (0 === strcasecmp($input_seal, $seal)) { |
|
193 | 193 | $response_code = $data['responseCode']; |
194 | 194 | |
195 | - $status = ResponseCodes::transform( $response_code ); |
|
195 | + $status = ResponseCodes::transform($response_code); |
|
196 | 196 | |
197 | 197 | // Set the status of the payment. |
198 | - $payment->set_status( $status ); |
|
198 | + $payment->set_status($status); |
|
199 | 199 | |
200 | 200 | $labels = array( |
201 | - 'amount' => __( 'Amount', 'pronamic_ideal' ), |
|
202 | - 'captureDay' => _x( 'Capture Day', 'creditcard', 'pronamic_ideal' ), |
|
203 | - 'captureMode' => _x( 'Capture Mode', 'creditcard', 'pronamic_ideal' ), |
|
204 | - 'currencyCode' => __( 'Currency Code', 'pronamic_ideal' ), |
|
205 | - 'merchantId' => __( 'Merchant ID', 'pronamic_ideal' ), |
|
206 | - 'orderId' => __( 'Order ID', 'pronamic_ideal' ), |
|
207 | - 'transactionDateTime' => __( 'Transaction Date Time', 'pronamic_ideal' ), |
|
208 | - 'transactionReference' => __( 'Transaction Reference', 'pronamic_ideal' ), |
|
209 | - 'keyVersion' => __( 'Key Version', 'pronamic_ideal' ), |
|
210 | - 'authorisationId' => __( 'Authorisation ID', 'pronamic_ideal' ), |
|
211 | - 'paymentMeanBrand' => __( 'Payment Mean Brand', 'pronamic_ideal' ), |
|
212 | - 'paymentMeanType' => __( 'Payment Mean Type', 'pronamic_ideal' ), |
|
213 | - 'responseCode' => __( 'Response Code', 'pronamic_ideal' ), |
|
201 | + 'amount' => __('Amount', 'pronamic_ideal'), |
|
202 | + 'captureDay' => _x('Capture Day', 'creditcard', 'pronamic_ideal'), |
|
203 | + 'captureMode' => _x('Capture Mode', 'creditcard', 'pronamic_ideal'), |
|
204 | + 'currencyCode' => __('Currency Code', 'pronamic_ideal'), |
|
205 | + 'merchantId' => __('Merchant ID', 'pronamic_ideal'), |
|
206 | + 'orderId' => __('Order ID', 'pronamic_ideal'), |
|
207 | + 'transactionDateTime' => __('Transaction Date Time', 'pronamic_ideal'), |
|
208 | + 'transactionReference' => __('Transaction Reference', 'pronamic_ideal'), |
|
209 | + 'keyVersion' => __('Key Version', 'pronamic_ideal'), |
|
210 | + 'authorisationId' => __('Authorisation ID', 'pronamic_ideal'), |
|
211 | + 'paymentMeanBrand' => __('Payment Mean Brand', 'pronamic_ideal'), |
|
212 | + 'paymentMeanType' => __('Payment Mean Type', 'pronamic_ideal'), |
|
213 | + 'responseCode' => __('Response Code', 'pronamic_ideal'), |
|
214 | 214 | ); |
215 | 215 | |
216 | 216 | $note = ''; |
217 | 217 | |
218 | 218 | $note .= '<p>'; |
219 | - $note .= __( 'OmniKassa transaction data in response message:', 'pronamic_ideal' ); |
|
219 | + $note .= __('OmniKassa transaction data in response message:', 'pronamic_ideal'); |
|
220 | 220 | $note .= '</p>'; |
221 | 221 | |
222 | 222 | $note .= '<dl>'; |
223 | 223 | |
224 | - foreach ( $labels as $key => $label ) { |
|
225 | - if ( isset( $data[ $key ] ) ) { |
|
226 | - $note .= sprintf( '<dt>%s</dt>', esc_html( $label ) ); |
|
227 | - $note .= sprintf( '<dd>%s</dd>', esc_html( $data[ $key ] ) ); |
|
224 | + foreach ($labels as $key => $label) { |
|
225 | + if (isset($data[$key])) { |
|
226 | + $note .= sprintf('<dt>%s</dt>', esc_html($label)); |
|
227 | + $note .= sprintf('<dd>%s</dd>', esc_html($data[$key])); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | 231 | $note .= '</dl>'; |
232 | 232 | |
233 | - $payment->add_note( $note ); |
|
233 | + $payment->add_note($note); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | } |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return string|null |
22 | 22 | */ |
23 | - public static function transform( $language ) { |
|
24 | - if ( ! is_string( $language ) ) { |
|
23 | + public static function transform($language) { |
|
24 | + if ( ! is_string($language)) { |
|
25 | 25 | return null; |
26 | 26 | } |
27 | 27 | |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | ); |
39 | 39 | |
40 | 40 | // Sub string. |
41 | - $locale = substr( $language, 0, 2 ); |
|
41 | + $locale = substr($language, 0, 2); |
|
42 | 42 | |
43 | 43 | // Upper case. |
44 | - $locale = strtoupper( $locale ); |
|
44 | + $locale = strtoupper($locale); |
|
45 | 45 | |
46 | 46 | // Is supported? |
47 | - if ( in_array( $locale, $supported, true ) ) { |
|
47 | + if (in_array($locale, $supported, true)) { |
|
48 | 48 | return $locale; |
49 | 49 | } |
50 | 50 |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | $this->name = 'Rabobank - OmniKassa'; |
21 | 21 | $this->product_url = 'https://www.rabobank.nl/bedrijven/betalen/geld-ontvangen/rabo-omnikassa/'; |
22 | 22 | $this->dashboard_url = array( |
23 | - __( 'admin', 'pronamic_ideal' ) => 'https://dashboard.omnikassa.rabobank.nl/', |
|
24 | - __( 'download', 'pronamic_ideal' ) => 'https://download.omnikassa.rabobank.nl/', |
|
23 | + __('admin', 'pronamic_ideal') => 'https://dashboard.omnikassa.rabobank.nl/', |
|
24 | + __('download', 'pronamic_ideal') => 'https://download.omnikassa.rabobank.nl/', |
|
25 | 25 | ); |
26 | 26 | $this->provider = 'rabobank'; |
27 | 27 | $this->deprecated = true; |
28 | 28 | |
29 | 29 | // Actions |
30 | - $function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
|
30 | + $function = array(__NAMESPACE__ . '\Listener', 'listen'); |
|
31 | 31 | |
32 | - if ( ! has_action( 'wp_loaded', $function ) ) { |
|
33 | - add_action( 'wp_loaded', $function ); |
|
32 | + if ( ! has_action('wp_loaded', $function)) { |
|
33 | + add_action('wp_loaded', $function); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | 'section' => 'general', |
48 | 48 | 'filter' => FILTER_SANITIZE_STRING, |
49 | 49 | 'meta_key' => '_pronamic_gateway_omnikassa_merchant_id', |
50 | - 'title' => __( 'Merchant ID', 'pronamic_ideal' ), |
|
50 | + 'title' => __('Merchant ID', 'pronamic_ideal'), |
|
51 | 51 | 'type' => 'text', |
52 | - 'classes' => array( 'code' ), |
|
52 | + 'classes' => array('code'), |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | // Secret Key |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | 'section' => 'general', |
58 | 58 | 'filter' => FILTER_SANITIZE_STRING, |
59 | 59 | 'meta_key' => '_pronamic_gateway_omnikassa_secret_key', |
60 | - 'title' => __( 'Secret Key', 'pronamic_ideal' ), |
|
60 | + 'title' => __('Secret Key', 'pronamic_ideal'), |
|
61 | 61 | 'type' => 'text', |
62 | - 'classes' => array( 'large-text', 'code' ), |
|
62 | + 'classes' => array('large-text', 'code'), |
|
63 | 63 | ); |
64 | 64 | |
65 | 65 | // Key Version |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | 'section' => 'general', |
68 | 68 | 'filter' => FILTER_SANITIZE_STRING, |
69 | 69 | 'meta_key' => '_pronamic_gateway_omnikassa_key_version', |
70 | - 'title' => __( 'Key Version', 'pronamic_ideal' ), |
|
70 | + 'title' => __('Key Version', 'pronamic_ideal'), |
|
71 | 71 | 'type' => 'text', |
72 | - 'classes' => array( 'code' ), |
|
72 | + 'classes' => array('code'), |
|
73 | 73 | 'size' => 5, |
74 | - 'description' => sprintf( __( 'You can find the key version in the <a href="%s" target="_blank">OmniKassa Download Dashboard</a>.', 'pronamic_ideal' ), 'https://download.omnikassa.rabobank.nl/' ), |
|
74 | + 'description' => sprintf(__('You can find the key version in the <a href="%s" target="_blank">OmniKassa Download Dashboard</a>.', 'pronamic_ideal'), 'https://download.omnikassa.rabobank.nl/'), |
|
75 | 75 | ); |
76 | 76 | |
77 | 77 | // Purchase ID |
@@ -79,23 +79,23 @@ discard block |
||
79 | 79 | 'section' => 'advanced', |
80 | 80 | 'filter' => FILTER_SANITIZE_STRING, |
81 | 81 | 'meta_key' => '_pronamic_gateway_omnikassa_order_id', |
82 | - 'title' => __( 'Order ID', 'pronamic_ideal' ), |
|
82 | + 'title' => __('Order ID', 'pronamic_ideal'), |
|
83 | 83 | 'type' => 'text', |
84 | - 'classes' => array( 'regular-text', 'code' ), |
|
84 | + 'classes' => array('regular-text', 'code'), |
|
85 | 85 | 'tooltip' => sprintf( |
86 | - __( 'The OmniKassa %s parameter.', 'pronamic_ideal' ), |
|
87 | - sprintf( '<code>%s</code>', 'orderId' ) |
|
86 | + __('The OmniKassa %s parameter.', 'pronamic_ideal'), |
|
87 | + sprintf('<code>%s</code>', 'orderId') |
|
88 | 88 | ), |
89 | 89 | 'description' => sprintf( |
90 | 90 | '%s %s<br />%s', |
91 | - __( 'Available tags:', 'pronamic_ideal' ), |
|
91 | + __('Available tags:', 'pronamic_ideal'), |
|
92 | 92 | sprintf( |
93 | 93 | '<code>%s</code> <code>%s</code>', |
94 | 94 | '{order_id}', |
95 | 95 | '{payment_id}' |
96 | 96 | ), |
97 | 97 | sprintf( |
98 | - __( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
|
98 | + __('Default: <code>%s</code>', 'pronamic_ideal'), |
|
99 | 99 | '{payment_id}' |
100 | 100 | ) |
101 | 101 | ), |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | return $fields; |
105 | 105 | } |
106 | 106 | |
107 | - public function get_config( $post_id ) { |
|
107 | + public function get_config($post_id) { |
|
108 | 108 | $config = new Config(); |
109 | 109 | |
110 | - $config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_merchant_id', true ); |
|
111 | - $config->secret_key = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_secret_key', true ); |
|
112 | - $config->key_version = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_key_version', true ); |
|
113 | - $config->order_id = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_order_id', true ); |
|
114 | - $config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
110 | + $config->merchant_id = get_post_meta($post_id, '_pronamic_gateway_omnikassa_merchant_id', true); |
|
111 | + $config->secret_key = get_post_meta($post_id, '_pronamic_gateway_omnikassa_secret_key', true); |
|
112 | + $config->key_version = get_post_meta($post_id, '_pronamic_gateway_omnikassa_key_version', true); |
|
113 | + $config->order_id = get_post_meta($post_id, '_pronamic_gateway_omnikassa_order_id', true); |
|
114 | + $config->mode = get_post_meta($post_id, '_pronamic_gateway_mode', true); |
|
115 | 115 | |
116 | 116 | return $config; |
117 | 117 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param int $post_id Post ID. |
123 | 123 | * @return Gateway |
124 | 124 | */ |
125 | - public function get_gateway( $post_id ) { |
|
126 | - return new Gateway( $this->get_config( $post_id ) ); |
|
125 | + public function get_gateway($post_id) { |
|
126 | + return new Gateway($this->get_config($post_id)); |
|
127 | 127 | } |
128 | 128 | } |