Test Failed
Push — develop ( 9b582e...f48c84 )
by Reüel
14:00
created

src/Integration.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\EMS\ECommerce;
4
5
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration;
6
7
/**
8
 * Title: EMS e-Commerce integration
9
 * Description:
10
 * Copyright: 2005-2019 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author Reüel van der Steege
14
 * @version 2.0.3
15
 * @since 1.0.0
16
 */
17
class Integration extends AbstractIntegration {
18
	public function __construct() {
19
		$this->id            = 'ems-ecommerce';
20
		$this->name          = 'EMS e-Commerce';
21
		$this->product_url   = '';
22
		$this->dashboard_url = array(
23
			__( 'test', 'pronamic_ideal' ) => 'https://test.ipg-online.com/vt/login',
24
			__( 'live', 'pronamic_ideal' ) => 'https://www.ipg-online.com/vt/login',
25
		);
26
		$this->provider      = 'ems';
27
		$this->supports      = array(
28
			'webhook',
29
			'webhook_log',
30
			'webhook_no_config',
31
		);
32
33
		$this->set_manual_url( __( 'https://www.pronamic.eu/support/how-to-connect-ems-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ) );
0 ignored issues
show
The method set_manual_url() does not exist on Pronamic\WordPress\Pay\G...S\ECommerce\Integration. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
		$this->/** @scrutinizer ignore-call */ 
34
         set_manual_url( __( 'https://www.pronamic.eu/support/how-to-connect-ems-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ) );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
35
		// Actions
36
		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
37
38
		if ( ! has_action( 'wp_loaded', $function ) ) {
39
			add_action( 'wp_loaded', $function );
40
		}
41
	}
42
43
	public function get_settings_fields() {
44
		$fields = array();
45
46
		// Storename.
47
		$fields[] = array(
48
			'section'  => 'general',
49
			'filter'   => FILTER_UNSAFE_RAW,
50
			'meta_key' => '_pronamic_gateway_ems_ecommerce_storename',
51
			'title'    => _x( 'Storename', 'ems', 'pronamic_ideal' ),
52
			'type'     => 'text',
53
			'classes'  => array( 'code' ),
54
		);
55
56
		// Shared secret.
57
		$fields[] = array(
58
			'section'  => 'general',
59
			'filter'   => FILTER_UNSAFE_RAW,
60
			'meta_key' => '_pronamic_gateway_ems_ecommerce_secret',
61
			'title'    => _x( 'Shared Secret', 'ems', 'pronamic_ideal' ),
62
			'type'     => 'text',
63
			'classes'  => array( 'large-text', 'code' ),
64
		);
65
66
		// Purchase ID.
67
		$fields[] = array(
68
			'section'     => 'advanced',
69
			'filter'      => array(
70
				'filter' => FILTER_SANITIZE_STRING,
71
				'flags'  => FILTER_FLAG_NO_ENCODE_QUOTES,
72
			),
73
			'meta_key'    => '_pronamic_gateway_ems_ecommerce_order_id',
74
			'title'       => __( 'Order ID', 'pronamic_ideal' ),
75
			'type'        => 'text',
76
			'classes'     => array( 'regular-text', 'code' ),
77
			'tooltip'     => sprintf(
78
				/* translators: %s: <code>{orderId}</code> */
79
				__( 'The EMS e-Commerce %s parameter.', 'pronamic_ideal' ),
80
				sprintf( '<code>%s</code>', 'orderId' )
81
			),
82
			'description' => sprintf(
83
				'%s %s<br />%s',
84
				__( 'Available tags:', 'pronamic_ideal' ),
85
				sprintf(
86
					'<code>%s</code> <code>%s</code>',
87
					'{order_id}',
88
					'{payment_id}'
89
				),
90
				sprintf(
91
					/* translators: %s: {order_id} */
92
					__( 'Default: <code>%s</code>', 'pronamic_ideal' ),
93
					'{order_id}'
94
				)
95
			),
96
		);
97
98
		// Notification URL.
99
		$fields[] = array(
100
			'section'  => 'feedback',
101
			/* translators: Translate 'notification' the same as in the EMS e-Commerce dashboard. */
102
			'title'    => _x( 'Notification URL', 'EMS e-Commerce', 'pronamic_ideal' ),
103
			'type'     => 'text',
104
			'classes'  => array( 'large-text', 'code' ),
105
			'value'    => home_url( '/' ),
106
			'readonly' => true,
107
			/* translators: Translate 'notification' the same as in the EMS e-Commerce dashboard. */
108
			'tooltip'  => _x(
109
				'The Notification URL as sent with each transaction to receive automatic payment status updates on.',
110
				'EMS e-Commerce',
111
				'pronamic_ideal'
112
			),
113
		);
114
115
		return $fields;
116
	}
117
118
	public function get_config( $post_id ) {
119
		$config = new Config();
120
121
		$config->storename = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_storename', true );
122
		$config->secret    = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_secret', true );
123
		$config->mode      = get_post_meta( $post_id, '_pronamic_gateway_mode', true );
124
		$config->order_id  = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_order_id', true );
125
126
		return $config;
127
	}
128
129
	/**
130
	 * Get gateway.
131
	 *
132
	 * @param int $post_id Post ID.
133
	 * @return Gateway
134
	 */
135
	public function get_gateway( $post_id ) {
136
		return new Gateway( $this->get_config( $post_id ) );
137
	}
138
}
139