Failed Conditions
Push — develop ( 4a81b8...8a29a4 )
by Remco
05:16
created

src/Integration.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\OmniKassa;
4
5
use Pronamic\WordPress\Pay\AbstractGatewayIntegration;
0 ignored issues
show
The type Pronamic\WordPress\Pay\AbstractGatewayIntegration 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...
6
7
/**
8
 * Title: OmniKassa integration
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 Integration extends AbstractGatewayIntegration {
18
	/**
19
	 * Construct OmniKassa 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'            => 'rabobank-omnikassa',
28
				'name'          => 'Rabobank - OmniKassa',
29
				'product_url'   => 'https://www.rabobank.nl/bedrijven/betalen/geld-ontvangen/rabo-omnikassa/',
30
				'dashboard_url' => array(
31
					\__( 'admin', 'pronamic_ideal' )    => 'https://dashboard.omnikassa.rabobank.nl/',
32
					\__( 'download', 'pronamic_ideal' ) => 'https://download.omnikassa.rabobank.nl/',
33
				),
34
				'provider'      => 'rabobank',
35
				'deprecated'    => true,
36
			)
37
		);
38
39
		parent::__construct( $args );
40
41
		// Actions
42
		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
43
44
		if ( ! has_action( 'wp_loaded', $function ) ) {
45
			add_action( 'wp_loaded', $function );
46
		}
47
	}
48
49
	/**
50
	 * Get settings fields.
51
	 *
52
	 * @return array
53
	 */
54
	public function get_settings_fields() {
55
		$fields = array();
56
57
		// Merchant ID
58
		$fields[] = array(
59
			'section'  => 'general',
60
			'filter'   => FILTER_SANITIZE_STRING,
61
			'meta_key' => '_pronamic_gateway_omnikassa_merchant_id',
62
			'title'    => __( 'Merchant ID', 'pronamic_ideal' ),
63
			'type'     => 'text',
64
			'classes'  => array( 'code' ),
65
		);
66
67
		// Secret Key
68
		$fields[] = array(
69
			'section'  => 'general',
70
			'filter'   => FILTER_SANITIZE_STRING,
71
			'meta_key' => '_pronamic_gateway_omnikassa_secret_key',
72
			'title'    => __( 'Secret Key', 'pronamic_ideal' ),
73
			'type'     => 'text',
74
			'classes'  => array( 'large-text', 'code' ),
75
		);
76
77
		// Key Version
78
		$fields[] = array(
79
			'section'  => 'general',
80
			'filter'      => FILTER_SANITIZE_STRING,
81
			'meta_key'    => '_pronamic_gateway_omnikassa_key_version',
82
			'title'       => __( 'Key Version', 'pronamic_ideal' ),
83
			'type'        => 'text',
84
			'classes'     => array( 'code' ),
85
			'size'        => 5,
86
			'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/' ),
87
		);
88
89
		// Purchase ID
90
		$fields[] = array(
91
			'section'     => 'advanced',
92
			'filter'      => FILTER_SANITIZE_STRING,
93
			'meta_key'    => '_pronamic_gateway_omnikassa_order_id',
94
			'title'       => __( 'Order ID', 'pronamic_ideal' ),
95
			'type'        => 'text',
96
			'classes'     => array( 'regular-text', 'code' ),
97
			'tooltip'     => sprintf(
98
				__( 'The OmniKassa %s parameter.', 'pronamic_ideal' ),
99
				sprintf( '<code>%s</code>', 'orderId' )
100
			),
101
			'description' => sprintf(
102
				'%s %s<br />%s',
103
				__( 'Available tags:', 'pronamic_ideal' ),
104
				sprintf(
105
					'<code>%s</code> <code>%s</code>',
106
					'{order_id}',
107
					'{payment_id}'
108
				),
109
				sprintf(
110
					__( 'Default: <code>%s</code>', 'pronamic_ideal' ),
111
					'{payment_id}'
112
				)
113
			),
114
		);
115
116
		return $fields;
117
	}
118
119
	public function get_config( $post_id ) {
120
		$config = new Config();
121
122
		$config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_merchant_id', true );
123
		$config->secret_key  = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_secret_key', true );
124
		$config->key_version = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_key_version', true );
125
		$config->order_id    = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_order_id', true );
126
		$config->mode        = get_post_meta( $post_id, '_pronamic_gateway_mode', true );
127
128
		return $config;
129
	}
130
131
	/**
132
	 * Get gateway.
133
	 *
134
	 * @param int $post_id Post ID.
135
	 * @return Gateway
136
	 */
137
	public function get_gateway( $post_id ) {
138
		return new Gateway( $this->get_config( $post_id ) );
139
	}
140
}
141