Passed
Push — master ( 872870...a12c54 )
by Reüel
04:08
created
src/Client.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @param string $access_token Access token.
75 75
 	 */
76
-	public function set_access_token( $access_token ) {
76
+	public function set_access_token($access_token) {
77 77
 		$this->access_token = $access_token;
78 78
 	}
79 79
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @param string $merchant_profile Merchant profile id.
91 91
 	 */
92
-	public function set_merchant_profile( $merchant_profile ) {
92
+	public function set_merchant_profile($merchant_profile) {
93 93
 		$this->merchant_profile = $merchant_profile;
94 94
 	}
95 95
 
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	public function get_issuers() {
100 100
 		return array(
101
-			'ABNANL2A' => __( 'ABN Amro', 'pronamic_ideal' ),
102
-			'RABONL2U' => __( 'Rabobank', 'pronamic_ideal' ),
103
-			'INGBNL2A' => __( 'ING Bank', 'pronamic_ideal' ),
104
-			'SNSBNL2A' => __( 'SNS Bank', 'pronamic_ideal' ),
105
-			'ASNBNL21' => __( 'ASN Bank', 'pronamic_ideal' ),
106
-			'RBRBNL21' => __( 'RegioBank', 'pronamic_ideal' ),
107
-			'TRIONL2U' => __( 'Triodos Bank', 'pronamic_ideal' ),
108
-			'FVLBNL22' => __( 'Van Lanschot', 'pronamic_ideal' ),
109
-			'KNABNL2H' => __( 'Knab', 'pronamic_ideal' ),
110
-			'BUNQNL2A' => __( 'Bunq', 'pronamic_ideal' ),
111
-			'MOYONL21' => __( 'MoneYou', 'pronamic_ideal' ),
101
+			'ABNANL2A' => __('ABN Amro', 'pronamic_ideal'),
102
+			'RABONL2U' => __('Rabobank', 'pronamic_ideal'),
103
+			'INGBNL2A' => __('ING Bank', 'pronamic_ideal'),
104
+			'SNSBNL2A' => __('SNS Bank', 'pronamic_ideal'),
105
+			'ASNBNL21' => __('ASN Bank', 'pronamic_ideal'),
106
+			'RBRBNL21' => __('RegioBank', 'pronamic_ideal'),
107
+			'TRIONL2U' => __('Triodos Bank', 'pronamic_ideal'),
108
+			'FVLBNL22' => __('Van Lanschot', 'pronamic_ideal'),
109
+			'KNABNL2H' => __('Knab', 'pronamic_ideal'),
110
+			'BUNQNL2A' => __('Bunq', 'pronamic_ideal'),
111
+			'MOYONL21' => __('MoneYou', 'pronamic_ideal'),
112 112
 		);
113 113
 	}
114 114
 
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return bool|object
124 124
 	 */
125
-	private function send_request( $end_point, $method = 'GET', array $data = array(), $expected_response_code = 200 ) {
125
+	private function send_request($end_point, $method = 'GET', array $data = array(), $expected_response_code = 200) {
126 126
 		// Request.
127 127
 		$url = self::API_URL . $end_point;
128 128
 
129
-		if ( is_array( $data ) && ! empty( $data ) ) {
130
-			$data = wp_json_encode( $data );
129
+		if (is_array($data) && ! empty($data)) {
130
+			$data = wp_json_encode($data);
131 131
 		}
132 132
 
133
-		$response = wp_remote_request( $url, array(
133
+		$response = wp_remote_request($url, array(
134 134
 			'method'  => $method,
135 135
 			'headers' => array(
136 136
 				'Accept'        => 'application/json',
@@ -138,29 +138,29 @@  discard block
 block discarded – undo
138 138
 				'Authorization' => 'Bearer ' . $this->get_access_token(),
139 139
 			),
140 140
 			'body'    => $data,
141
-		) );
141
+		));
142 142
 
143 143
 		// Response code.
144
-		$response_code = wp_remote_retrieve_response_code( $response );
144
+		$response_code = wp_remote_retrieve_response_code($response);
145 145
 
146
-		if ( $expected_response_code != $response_code ) { // WPCS: loose comparison ok.
147
-			$this->error = new WP_Error( 'nocks_error', 'Unexpected response code.' );
146
+		if ($expected_response_code != $response_code) { // WPCS: loose comparison ok.
147
+			$this->error = new WP_Error('nocks_error', 'Unexpected response code.');
148 148
 		}
149 149
 
150 150
 		// Body.
151
-		$body = wp_remote_retrieve_body( $response );
151
+		$body = wp_remote_retrieve_body($response);
152 152
 
153
-		$data = json_decode( $body );
153
+		$data = json_decode($body);
154 154
 
155
-		if ( ! is_object( $data ) ) {
156
-			$this->error = new WP_Error( 'nocks_error', 'Could not parse response.' );
155
+		if ( ! is_object($data)) {
156
+			$this->error = new WP_Error('nocks_error', 'Could not parse response.');
157 157
 
158 158
 			return false;
159 159
 		}
160 160
 
161 161
 		// Nocks error.
162
-		if ( isset( $data->error, $data->error->message ) ) {
163
-			$this->error = new WP_Error( 'nocks_error', $data->error->message, $data->error );
162
+		if (isset($data->error, $data->error->message)) {
163
+			$this->error = new WP_Error('nocks_error', $data->error->message, $data->error);
164 164
 
165 165
 			return false;
166 166
 		}
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
 	public function get_merchant_profiles() {
177 177
 		$profiles = array();
178 178
 
179
-		$merchants = $this->send_request( 'merchant', 'GET' );
179
+		$merchants = $this->send_request('merchant', 'GET');
180 180
 
181
-		if ( $merchants ) {
182
-			foreach ( $merchants->data as $merchant ) {
183
-				foreach ( $merchant->merchant_profiles->data as $profile ) {
184
-					$profiles[ $profile->uuid ] = $merchant->name . ' - ' . $profile->name;
181
+		if ($merchants) {
182
+			foreach ($merchants->data as $merchant) {
183
+				foreach ($merchant->merchant_profiles->data as $profile) {
184
+					$profiles[$profile->uuid] = $merchant->name . ' - ' . $profile->name;
185 185
 				}
186 186
 			}
187 187
 		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return array|bool|mixed|object
198 198
 	 */
199
-	public function start_transaction( Transaction $transaction ) {
199
+	public function start_transaction(Transaction $transaction) {
200 200
 		return $this->send_request(
201 201
 			'transaction',
202 202
 			'POST',
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return array|bool|mixed|object
214 214
 	 */
215
-	public function get_transaction( $transaction_uuid ) {
215
+	public function get_transaction($transaction_uuid) {
216 216
 		return $this->send_request(
217 217
 			'transaction/' . $transaction_uuid,
218 218
 			'GET'
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return array|bool|mixed|object
231 231
 	 */
232
-	public function get_transaction_quote( $source_currency, $target_currency, $amount, $payment_method ) {
232
+	public function get_transaction_quote($source_currency, $target_currency, $amount, $payment_method) {
233 233
 		$data = array(
234 234
 			'source_currency'  => $source_currency,
235 235
 			'target_currency'  => $target_currency,
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 				'amount'   => (string) $amount,
239 239
 				'currency' => $source_currency,
240 240
 			),
241
-			'payment_method'   => array( 'method' => $payment_method ),
241
+			'payment_method'   => array('method' => $payment_method),
242 242
 		);
243 243
 
244 244
 		return $this->send_request(
Please login to merge, or discard this patch.
src/Gateway.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param Config $config Config.
32 32
 	 */
33
-	public function __construct( Config $config ) {
34
-		parent::__construct( $config );
33
+	public function __construct(Config $config) {
34
+		parent::__construct($config);
35 35
 
36
-		$this->set_method( self::METHOD_HTTP_REDIRECT );
36
+		$this->set_method(self::METHOD_HTTP_REDIRECT);
37 37
 
38 38
 		// Client.
39 39
 		$this->client = new Client();
40 40
 
41
-		$this->client->set_access_token( $config->access_token );
42
-		$this->client->set_merchant_profile( $config->merchant_profile );
41
+		$this->client->set_access_token($config->access_token);
42
+		$this->client->set_merchant_profile($config->merchant_profile);
43 43
 
44 44
 		// Feature supports.
45 45
 		$this->supports = array(
@@ -65,22 +65,22 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param Payment $payment The payment.
67 67
 	 */
68
-	public function start( Payment $payment ) {
68
+	public function start(Payment $payment) {
69 69
 		$payment_method = $payment->get_method();
70 70
 		$currency       = $payment->get_total_amount()->get_currency()->get_alphabetic_code();
71 71
 		$amount         = $payment->get_total_amount()->get_value();
72 72
 
73
-		if ( empty( $payment_method ) ) {
73
+		if (empty($payment_method)) {
74 74
 			$payment_method = PaymentMethods::GULDEN;
75 75
 		}
76 76
 
77
-		if ( PaymentMethods::GULDEN === $payment_method ) {
78
-			switch ( $currency ) {
77
+		if (PaymentMethods::GULDEN === $payment_method) {
78
+			switch ($currency) {
79 79
 				case 'EUR':
80 80
 					// Convert to EUR.
81
-					$quote = $this->client->get_transaction_quote( 'EUR', 'NLG', $amount, Methods::IDEAL );
81
+					$quote = $this->client->get_transaction_quote('EUR', 'NLG', $amount, Methods::IDEAL);
82 82
 
83
-					if ( $quote ) {
83
+					if ($quote) {
84 84
 						$amount   = $quote->data->target_amount->amount;
85 85
 						$currency = 'NLG';
86 86
 					}
@@ -96,39 +96,39 @@  discard block
 block discarded – undo
96 96
 		$transaction->description      = $payment->get_description();
97 97
 		$transaction->currency         = $currency;
98 98
 		$transaction->amount           = $amount;
99
-		$transaction->payment_method   = Methods::transform( $payment->get_method() );
99
+		$transaction->payment_method   = Methods::transform($payment->get_method());
100 100
 		$transaction->redirect_url     = $payment->get_return_url();
101
-		$transaction->callback_url     = add_query_arg( 'nocks_webhook', '', home_url( '/' ) );
101
+		$transaction->callback_url     = add_query_arg('nocks_webhook', '', home_url('/'));
102 102
 		$transaction->description      = $payment->get_description();
103 103
 
104
-		if ( null !== $payment->get_customer() ) {
104
+		if (null !== $payment->get_customer()) {
105 105
 			$transaction->locale = $payment->get_customer()->get_locale();
106 106
 		}
107 107
 
108 108
 		// Issuer.
109
-		if ( Methods::IDEAL === $transaction->payment_method ) {
109
+		if (Methods::IDEAL === $transaction->payment_method) {
110 110
 			$transaction->issuer = $payment->get_issuer();
111 111
 		}
112 112
 
113 113
 		// Start transaction.
114
-		$result = $this->client->start_transaction( $transaction );
114
+		$result = $this->client->start_transaction($transaction);
115 115
 
116 116
 		// Handle errors.
117 117
 		$error = $this->client->get_error();
118 118
 
119
-		if ( is_wp_error( $error ) ) {
119
+		if (is_wp_error($error)) {
120 120
 			$this->error = $error;
121 121
 
122 122
 			return;
123 123
 		}
124 124
 
125 125
 		// Update payment.
126
-		if ( isset( $result->data->payments->data[0]->uuid ) ) {
127
-			$payment->set_transaction_id( $result->data->uuid );
126
+		if (isset($result->data->payments->data[0]->uuid)) {
127
+			$payment->set_transaction_id($result->data->uuid);
128 128
 		}
129 129
 
130
-		if ( isset( $result->data->payments->data[0]->metadata->url ) ) {
131
-			$payment->set_action_url( $result->data->payments->data[0]->metadata->url );
130
+		if (isset($result->data->payments->data[0]->metadata->url)) {
131
+			$payment->set_action_url($result->data->payments->data[0]->metadata->url);
132 132
 		}
133 133
 	}
134 134
 
@@ -137,23 +137,23 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @param Payment $payment The payment.
139 139
 	 */
140
-	public function update_status( Payment $payment ) {
140
+	public function update_status(Payment $payment) {
141 141
 		$transaction_id = $payment->get_transaction_id();
142 142
 
143
-		$nocks_payment = $this->client->get_transaction( $transaction_id );
143
+		$nocks_payment = $this->client->get_transaction($transaction_id);
144 144
 
145
-		if ( ! $nocks_payment ) {
146
-			$payment->set_status( Core_Statuses::FAILURE );
145
+		if ( ! $nocks_payment) {
146
+			$payment->set_status(Core_Statuses::FAILURE);
147 147
 
148 148
 			$this->error = $this->client->get_error();
149 149
 
150 150
 			return;
151 151
 		}
152 152
 
153
-		if ( is_object( $nocks_payment ) && isset( $nocks_payment->data->status ) ) {
154
-			$status = Statuses::transform( $nocks_payment->data->status );
153
+		if (is_object($nocks_payment) && isset($nocks_payment->data->status)) {
154
+			$status = Statuses::transform($nocks_payment->data->status);
155 155
 
156
-			$payment->set_status( $status );
156
+			$payment->set_status($status);
157 157
 		}
158 158
 	}
159 159
 }
Please login to merge, or discard this patch.