Test Failed
Push — develop ( 53e90d...a934e6 )
by Remco
05:09
created

src/Integration.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Icepay;
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: ICEPAY integration
9
 * Description:
10
 * Copyright: 2005-2020 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author Reüel van der Steege
14
 * @version 2.0.6
15
 * @since 1.0.0
16
 */
17
class Integration extends AbstractGatewayIntegration {
18 3
	/**
19 3
	 * Construct ICEPAY integration.
20 3
	 *
21
	 * @param array $args Arguments.
22 3
	 */
23 3
	public function __construct( $args = array() ) {
24 3
		$args = wp_parse_args(
25 3
			$args,
26 3
			array(
27 3
				'id'            => 'icepay-ideal',
28 3
				'name'          => 'ICEPAY',
29
				'url'           => 'https://icepay.com/',
30
				'product_url'   => \__( 'https://icepay.com/nl/en/pricing-and-accounts/', 'pronamic_ideal' ),
31
				'manual_url'    => \__( 'https://www.pronamic.eu/support/how-to-connect-icepay-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ),
32 3
				'dashboard_url' => 'https://portal.icepay.com/',
33
				'provider'      => 'icepay',
34 3
				'supports'      => array(
35 3
					'webhook',
36 3
					'webhook_log',
37 3
				),
38 3
			)
39 3
		);
40 3
41
		parent::__construct( $args );
42
43
		// Actions
44
		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
45 3
46
		if ( ! has_action( 'wp_loaded', $function ) ) {
47
			add_action( 'wp_loaded', $function );
48 3
		}
49
	}
50 3
51 1
	public function get_settings_fields() {
52
		$fields = array();
53 3
54
		// Merchant ID
55 1
		$fields[] = array(
56 1
			'section'  => 'general',
57
			'filter'   => FILTER_SANITIZE_STRING,
58
			'meta_key' => '_pronamic_gateway_icepay_merchant_id',
59 1
			'title'    => _x( 'Merchant ID', 'icepay', 'pronamic_ideal' ),
60 1
			'type'     => 'text',
61 1
			'tooltip'  => __( 'Merchant ID as mentioned in the ICEPAY dashboard at the "My websites" page.', 'pronamic_ideal' ),
62 1
		);
63 1
64 1
		// Secret Code
65 1
		$fields[] = array(
66
			'section'  => 'general',
67
			'filter'   => FILTER_SANITIZE_STRING,
68
			'meta_key' => '_pronamic_gateway_icepay_secret_code',
69 1
			'title'    => _x( 'Secret Code', 'icepay', 'pronamic_ideal' ),
70 1
			'type'     => 'text',
71 1
			'classes'  => array( 'regular-text', 'code' ),
72 1
			'tooltip'  => __( 'Secret Code as mentioned in the ICEPAY dashboard at the "My websites" page.', 'pronamic_ideal' ),
73 1
		);
74 1
75
		// Purchase ID
76 1
		$fields[] = array(
77
			'section'     => 'advanced',
78
			'filter'      => array(
79
				'filter' => FILTER_SANITIZE_STRING,
80 1
				'flags'  => FILTER_FLAG_NO_ENCODE_QUOTES,
81 1
			),
82
			'meta_key'    => '_pronamic_gateway_icepay_order_id',
83 1
			'title'       => __( 'Order ID', 'pronamic_ideal' ),
84 1
			'type'        => 'text',
85
			'classes'     => array( 'regular-text', 'code' ),
86 1
			'tooltip'     => sprintf(
87 1
				/* translators: %s: <code>OrderID</code> */
88 1
				__( 'The Icepay %s parameter.', 'pronamic_ideal' ),
89
				sprintf( '<code>%s</code>', 'OrderID' )
90 1
			),
91
			'description' => sprintf(
92 1
				'%s %s<br />%s',
93 1
				__( 'Available tags:', 'pronamic_ideal' ),
94
				sprintf(
95 1
					'<code>%s</code> <code>%s</code>',
96 1
					'{order_id}',
97 1
					'{payment_id}'
98 1
				),
99 1
				sprintf(
100 1
					/* translators: %s: <code>{payment_id}</code> */
101 1
					__( 'Default: <code>%s</code>', 'pronamic_ideal' ),
102
					'{payment_id}'
103 1
				)
104
			),
105 1
		);
106 1
107
		// Thank you page URL
108
		$fields[] = array(
109
			'section'  => 'feedback',
110
			'title'    => __( 'Thank you page URL', 'pronamic_ideal' ),
111
			'type'     => 'text',
112 1
			'classes'  => array( 'regular-text', 'code' ),
113 1
			'value'    => home_url( '/' ),
114 1
			'readonly' => true,
115 1
		);
116
117 1
		// Error page URL
118
		$fields[] = array(
119
			'section'  => 'feedback',
120
			'title'    => __( 'Error page URL', 'pronamic_ideal' ),
121
			'type'     => 'text',
122 1
			'classes'  => array( 'regular-text', 'code' ),
123 1
			'value'    => home_url( '/' ),
124 1
			'readonly' => true,
125 1
		);
126
127 1
		// Postback URL
128
		$fields[] = array(
129
			'section'  => 'feedback',
130
			'title'    => __( 'Postback URL', 'pronamic_ideal' ),
131
			'type'     => 'text',
132 1
			'classes'  => array( 'regular-text', 'code' ),
133 1
			'value'    => home_url( '/' ),
134 1
			'readonly' => true,
135 1
		);
136
137 1
		return $fields;
138
	}
139
140
	public function get_config( $post_id ) {
141 1
		$config = new Config();
142
143
		$config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_icepay_merchant_id', true );
144 2
		$config->secret_code = get_post_meta( $post_id, '_pronamic_gateway_icepay_secret_code', true );
145 2
		$config->order_id    = get_post_meta( $post_id, '_pronamic_gateway_icepay_order_id', true );
146
147 2
		return $config;
148 2
	}
149 2
150
	/**
151 2
	 * Get gateway.
152
	 *
153
	 * @param int $post_id Post ID.
154
	 * @return Gateway
155
	 */
156
	public function get_gateway( $post_id ) {
157
		return new Gateway( $this->get_config( $post_id ) );
158
	}
159
}
160