Listener   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 14
c 1
b 0
f 0
dl 0
loc 29
ccs 0
cts 17
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A listen() 0 28 4
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\OmniKassa;
4
5
use Pronamic\WordPress\Pay\Plugin;
6
7
/**
8
 * Title: OmniKassa listener
9
 * Description:
10
 * Copyright: 2005-2020 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author  Remco Tolsma
14
 * @version 2.0.3
15
 * @since   1.0.0
16
 */
17
class Listener {
18
	public static function listen() {
19
		if ( ! filter_has_var( INPUT_POST, 'Data' ) || ! filter_has_var( INPUT_POST, 'Seal' ) ) {
20
			return;
21
		}
22
23
		$input_data = filter_input( INPUT_POST, 'Data' );
24
25
		$data = Client::parse_piped_string( $input_data );
26
27
		$transaction_reference = $data['transactionReference'];
28
29
		$payment = get_pronamic_payment_by_meta( '_pronamic_payment_omnikassa_transaction_reference', $transaction_reference );
30
31
		if ( null === $payment ) {
32
			return;
33
		}
34
35
		// Add note.
36
		$note = sprintf(
37
			/* translators: %s: payment provider name */
38
			__( 'Webhook requested by %s.', 'pronamic_ideal' ),
39
			__( 'OmniKassa', 'pronamic_ideal' )
40
		);
41
42
		$payment->add_note( $note );
43
44
		// Update payment.
45
		Plugin::update_payment( $payment );
46
	}
47
}
48