Failed Conditions
Push — develop ( 850abc...ab26db )
by Reüel
06:03
created

src/Listener.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Nocks;
4
5
use Pronamic\WordPress\Pay\Plugin;
6
use Pronamic\WordPress\Pay\WebhookManager;
0 ignored issues
show
The type Pronamic\WordPress\Pay\WebhookManager was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
/**
9
 * Title: Nocks listener
10
 * Description:
11
 * Copyright: 2005-2019 Pronamic
12
 * Company: Pronamic
13
 *
14
 * @author  Reüel van der Steege
15
 * @version 2.0.0
16
 * @since   1.0.0
17
 */
18
class Listener {
19
	public static function listen() {
20
		if ( ! filter_has_var( INPUT_GET, 'nocks_webhook' ) ) {
21
			return;
22
		}
23
24
		$transaction_id = file_get_contents( 'php://input' );
25
26
		$payment = get_pronamic_payment_by_transaction_id( $transaction_id );
27
28
		if ( null === $payment ) {
29
			return;
30
		}
31
32
		// Add note.
33
		$note = sprintf(
34
			/* translators: %s: Nocks */
35
			__( 'Webhook requested by %s.', 'pronamic_ideal' ),
36
			__( 'Nocks', 'pronamic_ideal' )
37
		);
38
39
		$payment->add_note( $note );
40
41
		// Log webhook request.
42
		WebhookManager::log_payment( $payment );
43
44
		// Update payment.
45
		Plugin::update_payment( $payment, false );
46
	}
47
}
48