Passed
Push — master ( 592c15...84fb32 )
by Reüel
04:16
created
src/Connect/XML/RedirectTransactionRequestMessage.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * Constructs and initialize an directory response message
27 27
 	 */
28
-	public function __construct( $merchant, $customer, $transaction ) {
29
-		parent::__construct( self::NAME );
28
+	public function __construct($merchant, $customer, $transaction) {
29
+		parent::__construct(self::NAME);
30 30
 
31 31
 		$this->merchant    = $merchant;
32 32
 		$this->customer    = $customer;
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 		$document = parent::get_document();
43 43
 
44 44
 		// Merchant
45
-		$merchant = XML_Util::add_element( $document, $document->documentElement, 'merchant' );
45
+		$merchant = XML_Util::add_element($document, $document->documentElement, 'merchant');
46 46
 
47
-		XML_Util::add_elements( $document, $merchant, array(
47
+		XML_Util::add_elements($document, $merchant, array(
48 48
 			'account'          => $this->merchant->account,
49 49
 			'site_id'          => $this->merchant->site_id,
50 50
 			'site_secure_code' => $this->merchant->site_secure_code,
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 			'redirect_url'     => $this->merchant->redirect_url,
53 53
 			'cancel_url'       => $this->merchant->cancel_url,
54 54
 			'close_window'     => $this->merchant->close_window,
55
-		) );
55
+		));
56 56
 
57 57
 		// Customer
58
-		$customer = XML_Util::add_element( $document, $document->documentElement, 'customer' );
58
+		$customer = XML_Util::add_element($document, $document->documentElement, 'customer');
59 59
 
60
-		XML_Util::add_elements( $document, $customer, array(
60
+		XML_Util::add_elements($document, $customer, array(
61 61
 			'locale'      => $this->customer->locale,
62 62
 			'ipaddress'   => $this->customer->ip_address,
63 63
 			'forwardedip' => $this->customer->forwarded_ip,
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 			'country'     => $this->customer->country,
72 72
 			'phone'       => $this->customer->phone,
73 73
 			'email'       => $this->customer->email,
74
-		) );
74
+		));
75 75
 
76 76
 		// Transaction
77
-		$transaction = XML_Util::add_element( $document, $document->documentElement, 'transaction' );
77
+		$transaction = XML_Util::add_element($document, $document->documentElement, 'transaction');
78 78
 
79
-		XML_Util::add_elements( $document, $transaction, array(
79
+		XML_Util::add_elements($document, $transaction, array(
80 80
 			'id'          => $this->transaction->id,
81 81
 			'currency'    => $this->transaction->currency,
82 82
 			'amount'      => $this->transaction->amount,
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 			'manual'      => $this->transaction->manual,
89 89
 			'gateway'     => $this->transaction->gateway,
90 90
 			'daysactive'  => $this->transaction->days_active,
91
-		) );
91
+		));
92 92
 
93 93
 		// Signature
94
-		XML_Util::add_element( $document, $document->documentElement, 'signature', $this->signature );
94
+		XML_Util::add_element($document, $document->documentElement, 'signature', $this->signature);
95 95
 
96 96
 		return $document;
97 97
 	}
Please login to merge, or discard this patch.
src/Connect/XML/DirectTransactionRequestMessage.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	 * @param Transaction $transaction
42 42
 	 * @param GatewayInfo $gateway_info
43 43
 	 */
44
-	public function __construct( Merchant $merchant, Customer $customer, Transaction $transaction, GatewayInfo $gateway_info = null ) {
45
-		parent::__construct( self::NAME );
44
+	public function __construct(Merchant $merchant, Customer $customer, Transaction $transaction, GatewayInfo $gateway_info = null) {
45
+		parent::__construct(self::NAME);
46 46
 
47 47
 		$this->merchant     = $merchant;
48 48
 		$this->customer     = $customer;
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 		$document = parent::get_document();
60 60
 
61 61
 		// Merchant
62
-		$merchant = XML_Util::add_element( $document, $document->documentElement, 'merchant' );
62
+		$merchant = XML_Util::add_element($document, $document->documentElement, 'merchant');
63 63
 
64
-		XML_Util::add_elements( $document, $merchant, array(
64
+		XML_Util::add_elements($document, $merchant, array(
65 65
 			'account'          => $this->merchant->account,
66 66
 			'site_id'          => $this->merchant->site_id,
67 67
 			'site_secure_code' => $this->merchant->site_secure_code,
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 			'redirect_url'     => $this->merchant->redirect_url,
70 70
 			'cancel_url'       => $this->merchant->cancel_url,
71 71
 			'close_window'     => $this->merchant->close_window,
72
-		) );
72
+		));
73 73
 
74 74
 		// Customer
75
-		$customer = XML_Util::add_element( $document, $document->documentElement, 'customer' );
75
+		$customer = XML_Util::add_element($document, $document->documentElement, 'customer');
76 76
 
77
-		XML_Util::add_elements( $document, $customer, array(
77
+		XML_Util::add_elements($document, $customer, array(
78 78
 			'locale'      => $this->customer->locale,
79 79
 			'ipaddress'   => $this->customer->ip_address,
80 80
 			'forwardedip' => $this->customer->forwarded_ip,
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 			'country'     => $this->customer->country,
89 89
 			'phone'       => $this->customer->phone,
90 90
 			'email'       => $this->customer->email,
91
-		) );
91
+		));
92 92
 
93 93
 		// Transaction
94
-		$transaction = XML_Util::add_element( $document, $document->documentElement, 'transaction' );
94
+		$transaction = XML_Util::add_element($document, $document->documentElement, 'transaction');
95 95
 
96
-		XML_Util::add_elements( $document, $transaction, array(
96
+		XML_Util::add_elements($document, $transaction, array(
97 97
 			'id'          => $this->transaction->id,
98 98
 			'currency'    => $this->transaction->currency,
99 99
 			'amount'      => $this->transaction->amount,
@@ -105,19 +105,19 @@  discard block
 block discarded – undo
105 105
 			'manual'      => $this->transaction->manual,
106 106
 			'gateway'     => $this->transaction->gateway,
107 107
 			'daysactive'  => $this->transaction->days_active,
108
-		) );
108
+		));
109 109
 
110 110
 		// Gateway info
111
-		if ( $this->gateway_info ) {
112
-			$gateway_info = XML_Util::add_element( $document, $document->documentElement, 'gatewayinfo' );
111
+		if ($this->gateway_info) {
112
+			$gateway_info = XML_Util::add_element($document, $document->documentElement, 'gatewayinfo');
113 113
 
114
-			XML_Util::add_elements( $document, $gateway_info, array(
114
+			XML_Util::add_elements($document, $gateway_info, array(
115 115
 				'issuerid' => $this->gateway_info->issuer_id,
116
-			) );
116
+			));
117 117
 		}
118 118
 
119 119
 		// Signature
120
-		XML_Util::add_element( $document, $document->documentElement, 'signature', $this->signature );
120
+		XML_Util::add_element($document, $document->documentElement, 'signature', $this->signature);
121 121
 
122 122
 		return $document;
123 123
 	}
Please login to merge, or discard this patch.
src/Connect/Gateway.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @param Config $config Config.
49 49
 	 */
50
-	public function __construct( Config $config ) {
51
-		parent::__construct( $config );
50
+	public function __construct(Config $config) {
51
+		parent::__construct($config);
52 52
 
53 53
 		$this->supports = array(
54 54
 			'payment_status_request',
55 55
 		);
56 56
 
57
-		$this->set_method( self::METHOD_HTTP_REDIRECT );
58
-		$this->set_slug( self::SLUG );
57
+		$this->set_method(self::METHOD_HTTP_REDIRECT);
58
+		$this->set_slug(self::SLUG);
59 59
 
60 60
 		$this->client = new Client();
61 61
 
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 		$merchant->site_id          = $this->config->site_id;
78 78
 		$merchant->site_secure_code = $this->config->site_code;
79 79
 
80
-		$result = $this->client->get_ideal_issuers( $merchant );
80
+		$result = $this->client->get_ideal_issuers($merchant);
81 81
 
82
-		if ( $result ) {
82
+		if ($result) {
83 83
 			$groups[] = array(
84 84
 				'options' => $result,
85 85
 			);
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	public function get_credit_card_issuers() {
97 97
 		$groups[] = array(
98 98
 			'options' => array(
99
-				Methods::AMEX       => _x( 'AMEX', 'Payment method name', 'pronamic_ideal' ),
100
-				Methods::MAESTRO    => _x( 'Maestro', 'Payment method name', 'pronamic_ideal' ),
101
-				Methods::MASTERCARD => _x( 'MASTER', 'Payment method name', 'pronamic_ideal' ),
102
-				Methods::VISA       => _x( 'VISA', 'Payment method name', 'pronamic_ideal' ),
99
+				Methods::AMEX       => _x('AMEX', 'Payment method name', 'pronamic_ideal'),
100
+				Methods::MAESTRO    => _x('Maestro', 'Payment method name', 'pronamic_ideal'),
101
+				Methods::MASTERCARD => _x('MASTER', 'Payment method name', 'pronamic_ideal'),
102
+				Methods::VISA       => _x('VISA', 'Payment method name', 'pronamic_ideal'),
103 103
 			),
104 104
 		);
105 105
 
@@ -124,18 +124,18 @@  discard block
 block discarded – undo
124 124
 		$customer = new Customer();
125 125
 
126 126
 		// Get gateways.
127
-		$result = $this->client->get_gateways( $merchant, $customer );
127
+		$result = $this->client->get_gateways($merchant, $customer);
128 128
 
129
-		if ( ! $result ) {
129
+		if ( ! $result) {
130 130
 			$this->error = $this->client->get_error();
131 131
 
132 132
 			return $payment_methods;
133 133
 		}
134 134
 
135
-		foreach ( $result as $method => $title ) {
136
-			$payment_method = Methods::transform_gateway_method( $method );
135
+		foreach ($result as $method => $title) {
136
+			$payment_method = Methods::transform_gateway_method($method);
137 137
 
138
-			if ( $payment_method ) {
138
+			if ($payment_method) {
139 139
 				$payment_methods[] = $payment_method;
140 140
 			}
141 141
 		}
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @param Payment $payment Payment object.
172 172
 	 */
173
-	public function start( Payment $payment ) {
173
+	public function start(Payment $payment) {
174 174
 		$payment_method = $payment->get_method();
175 175
 
176 176
 		$transaction_description = $payment->get_description();
177 177
 
178
-		if ( empty( $transaction_description ) ) {
178
+		if (empty($transaction_description)) {
179 179
 			$transaction_description = $payment->get_id();
180 180
 		}
181 181
 
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
 
192 192
 		// Customer.
193 193
 		$customer               = new Customer();
194
-		$customer->ip_address   = Server::get( 'REMOTE_ADDR', FILTER_VALIDATE_IP );
195
-		$customer->forwarded_ip = Server::get( 'HTTP_X_FORWARDED_FOR', FILTER_VALIDATE_IP );
194
+		$customer->ip_address   = Server::get('REMOTE_ADDR', FILTER_VALIDATE_IP);
195
+		$customer->forwarded_ip = Server::get('HTTP_X_FORWARDED_FOR', FILTER_VALIDATE_IP);
196 196
 
197
-		if ( null !== $payment->get_customer() ) {
197
+		if (null !== $payment->get_customer()) {
198 198
 			$name = $payment->get_customer()->get_name();
199 199
 
200
-			if ( null !== $name ) {
200
+			if (null !== $name) {
201 201
 				$customer->first_name = $name->get_first_name();
202 202
 				$customer->last_name  = $name->get_last_name();
203 203
 			}
@@ -213,71 +213,71 @@  discard block
 block discarded – undo
213 213
 		$transaction->amount      = $payment->get_total_amount()->get_cents();
214 214
 		$transaction->description = $transaction_description;
215 215
 
216
-		switch ( $payment_method ) {
216
+		switch ($payment_method) {
217 217
 			case PaymentMethods::IDEAL:
218 218
 				$transaction->gateway = Methods::IDEAL;
219 219
 
220 220
 				$issuer = $payment->get_issuer();
221 221
 
222
-				if ( empty( $issuer ) ) {
223
-					$message = new RedirectTransactionRequestMessage( $merchant, $customer, $transaction );
222
+				if (empty($issuer)) {
223
+					$message = new RedirectTransactionRequestMessage($merchant, $customer, $transaction);
224 224
 				} else {
225 225
 					$gateway_info = new GatewayInfo();
226 226
 
227 227
 					$gateway_info->issuer_id = $issuer;
228 228
 
229
-					$message = new DirectTransactionRequestMessage( $merchant, $customer, $transaction, $gateway_info );
229
+					$message = new DirectTransactionRequestMessage($merchant, $customer, $transaction, $gateway_info);
230 230
 				}
231 231
 
232 232
 				break;
233 233
 			case PaymentMethods::CREDIT_CARD:
234
-				$gateway = Methods::transform( $payment_method );
234
+				$gateway = Methods::transform($payment_method);
235 235
 
236 236
 				$issuer = $payment->get_issuer();
237 237
 
238
-				if ( empty( $issuer ) ) {
239
-					if ( $gateway ) {
238
+				if (empty($issuer)) {
239
+					if ($gateway) {
240 240
 						$transaction->gateway = $gateway;
241 241
 					}
242 242
 				} else {
243 243
 					$transaction->gateway = $issuer;
244 244
 				}
245 245
 
246
-				$message = new RedirectTransactionRequestMessage( $merchant, $customer, $transaction );
246
+				$message = new RedirectTransactionRequestMessage($merchant, $customer, $transaction);
247 247
 
248 248
 				break;
249 249
 			default:
250
-				$gateway = Methods::transform( $payment_method );
250
+				$gateway = Methods::transform($payment_method);
251 251
 
252
-				if ( $gateway ) {
252
+				if ($gateway) {
253 253
 					$transaction->gateway = $gateway;
254 254
 				}
255 255
 
256
-				if ( ! isset( $transaction->gateway ) && ! empty( $payment_method ) ) {
256
+				if ( ! isset($transaction->gateway) && ! empty($payment_method)) {
257 257
 					// Leap of faith if the WordPress payment method could not transform to a Mollie method?
258 258
 					$transaction->gateway = $payment_method;
259 259
 				}
260 260
 
261
-				$message = new RedirectTransactionRequestMessage( $merchant, $customer, $transaction );
261
+				$message = new RedirectTransactionRequestMessage($merchant, $customer, $transaction);
262 262
 		}
263 263
 
264
-		$signature = Signature::generate( $transaction->amount, $transaction->currency, $merchant->account, $merchant->site_id, $transaction->id );
264
+		$signature = Signature::generate($transaction->amount, $transaction->currency, $merchant->account, $merchant->site_id, $transaction->id);
265 265
 
266 266
 		$message->signature = $signature;
267 267
 
268
-		$response = $this->client->start_transaction( $message );
268
+		$response = $this->client->start_transaction($message);
269 269
 
270
-		if ( $response ) {
270
+		if ($response) {
271 271
 			$transaction = $response->transaction;
272 272
 
273
-			$payment->set_transaction_id( $transaction->id );
273
+			$payment->set_transaction_id($transaction->id);
274 274
 
275
-			if ( isset( $transaction->payment_url ) ) {
276
-				$payment->set_action_url( $transaction->payment_url );
275
+			if (isset($transaction->payment_url)) {
276
+				$payment->set_action_url($transaction->payment_url);
277 277
 			}
278 278
 
279
-			if ( isset( $response->gateway_info->redirect_url ) ) {
280
-				$payment->set_action_url( $response->gateway_info->redirect_url );
279
+			if (isset($response->gateway_info->redirect_url)) {
280
+				$payment->set_action_url($response->gateway_info->redirect_url);
281 281
 			}
282 282
 		} else {
283 283
 			$this->error = $this->client->get_error();
@@ -289,25 +289,25 @@  discard block
 block discarded – undo
289 289
 	 *
290 290
 	 * @param Payment $payment Payment.
291 291
 	 */
292
-	public function update_status( Payment $payment ) {
292
+	public function update_status(Payment $payment) {
293 293
 		$merchant = new Merchant();
294 294
 
295 295
 		$merchant->account          = $this->config->account_id;
296 296
 		$merchant->site_id          = $this->config->site_id;
297 297
 		$merchant->site_secure_code = $this->config->site_code;
298 298
 
299
-		$message = new StatusRequestMessage( $merchant, $payment->get_transaction_id() );
299
+		$message = new StatusRequestMessage($merchant, $payment->get_transaction_id());
300 300
 
301
-		$result = $this->client->get_status( $message );
301
+		$result = $this->client->get_status($message);
302 302
 
303
-		if ( $result ) {
304
-			$status = Statuses::transform( $result->ewallet->status );
303
+		if ($result) {
304
+			$status = Statuses::transform($result->ewallet->status);
305 305
 
306
-			$payment->set_status( $status );
307
-			$payment->set_consumer_name( $result->payment_details->account_holder_name );
308
-			$payment->set_consumer_iban( $result->payment_details->account_iban );
309
-			$payment->set_consumer_bic( $result->payment_details->account_bic );
310
-			$payment->set_consumer_account_number( $result->payment_details->account_id );
306
+			$payment->set_status($status);
307
+			$payment->set_consumer_name($result->payment_details->account_holder_name);
308
+			$payment->set_consumer_iban($result->payment_details->account_iban);
309
+			$payment->set_consumer_bic($result->payment_details->account_bic);
310
+			$payment->set_consumer_account_number($result->payment_details->account_id);
311 311
 		} else {
312 312
 			$this->error = $this->client->get_error();
313 313
 		}
Please login to merge, or discard this patch.
src/Connect/Signature.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return string
42 42
 	 */
43
-	public static function generate( $amount, $currency, $account, $site_id, $transaction_id ) {
43
+	public static function generate($amount, $currency, $account, $site_id, $transaction_id) {
44 44
 		$values = array(
45 45
 			$amount,
46 46
 			$currency,
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 			$transaction_id,
50 50
 		);
51 51
 
52
-		$string = implode( '', $values );
52
+		$string = implode('', $values);
53 53
 
54
-		$signature = md5( $string );
54
+		$signature = md5($string);
55 55
 
56 56
 		return $signature;
57 57
 	}
Please login to merge, or discard this patch.