Failed Conditions
Push — feature/post-pay ( d9bc4c...326874 )
by Reüel
04:36
created
src/Gateway.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param Config $config Config.
40 40
 	 */
41
-	public function __construct( Config $config ) {
42
-		parent::__construct( $config );
41
+	public function __construct(Config $config) {
42
+		parent::__construct($config);
43 43
 
44 44
 		$this->supports = array(
45 45
 			'payment_status_request',
46 46
 		);
47 47
 
48
-		$this->set_method( self::METHOD_HTTP_REDIRECT );
48
+		$this->set_method(self::METHOD_HTTP_REDIRECT);
49 49
 
50
-		$this->client = new Client( $config->merchant_id, $config->merchant_key );
51
-		$this->client->set_test_mode( self::MODE_TEST === $config->mode );
50
+		$this->client = new Client($config->merchant_id, $config->merchant_key);
51
+		$this->client->set_test_mode(self::MODE_TEST === $config->mode);
52 52
 	}
53 53
 
54 54
 	/**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
 		$result = $this->client->get_directory();
63 63
 
64
-		if ( $result ) {
64
+		if ($result) {
65 65
 			$groups[] = array(
66 66
 				'options' => $result,
67 67
 			);
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @param Payment $payment Payment.
114 114
 	 */
115
-	public function start( Payment $payment ) {
115
+	public function start(Payment $payment) {
116 116
 		// Order and purchase ID.
117 117
 		$order_id    = $payment->get_order_id();
118
-		$purchase_id = strval( empty( $order_id ) ? $payment->get_id() : $order_id );
118
+		$purchase_id = strval(empty($order_id) ? $payment->get_id() : $order_id);
119 119
 
120 120
 		// Maximum length for purchase ID is 16 characters, otherwise an error will occur:
121 121
 		// ideal_sisow_error - purchaseid too long (16).
122
-		$purchase_id = substr( $purchase_id, 0, 16 );
122
+		$purchase_id = substr($purchase_id, 0, 16);
123 123
 
124 124
 		// New transaction request.
125 125
 		$request = new TransactionRequest(
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 
130 130
 		$request->merge_parameters(
131 131
 			array(
132
-				'payment'      => Methods::transform( $payment->get_method(), $payment->get_method() ),
133
-				'purchaseid'   => substr( $purchase_id, 0, 16 ),
132
+				'payment'      => Methods::transform($payment->get_method(), $payment->get_method()),
133
+				'purchaseid'   => substr($purchase_id, 0, 16),
134 134
 				'entrancecode' => $payment->get_entrance_code(),
135 135
 				'amount'       => $payment->get_total_amount()->get_cents(),
136
-				'description'  => substr( $payment->get_description(), 0, 32 ),
137
-				'testmode'     => ( self::MODE_TEST === $this->config->mode ) ? 'true' : 'false',
136
+				'description'  => substr($payment->get_description(), 0, 32),
137
+				'testmode'     => (self::MODE_TEST === $this->config->mode) ? 'true' : 'false',
138 138
 				'returnurl'    => $payment->get_return_url(),
139 139
 				'cancelurl'    => $payment->get_return_url(),
140 140
 				'notifyurl'    => $payment->get_return_url(),
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 		);
147 147
 
148 148
 		// Payment method.
149
-		$this->set_payment_method( null === $payment->get_method() ? PaymentMethods::IDEAL : $payment->get_method() );
149
+		$this->set_payment_method(null === $payment->get_method() ? PaymentMethods::IDEAL : $payment->get_method());
150 150
 
151 151
 		// Additional parameters for payment method.
152
-		if ( PaymentMethods::IDEALQR === $payment->get_method() ) {
153
-			$request->set_parameter( 'qrcode', 'true' );
152
+		if (PaymentMethods::IDEALQR === $payment->get_method()) {
153
+			$request->set_parameter('qrcode', 'true');
154 154
 		}
155 155
 
156 156
 		// Customer.
157
-		if ( null !== $payment->get_customer() ) {
157
+		if (null !== $payment->get_customer()) {
158 158
 			$customer = $payment->get_customer();
159 159
 
160 160
 			$request->merge_parameters(
@@ -164,25 +164,25 @@  discard block
 block discarded – undo
164 164
 				)
165 165
 			);
166 166
 
167
-			if ( null !== $customer->get_locale() ) {
167
+			if (null !== $customer->get_locale()) {
168 168
 				/*
169 169
 				 * @link https://github.com/wp-pay-gateways/sisow/tree/feature/post-pay/documentation#parameter-locale
170 170
 				 */
171
-				$sisow_locale = strtoupper( substr( $customer->get_locale(), -2 ) );
171
+				$sisow_locale = strtoupper(substr($customer->get_locale(), -2));
172 172
 
173
-				$request->set_parameter( 'locale', $sisow_locale );
173
+				$request->set_parameter('locale', $sisow_locale);
174 174
 			}
175 175
 
176
-			if ( null !== $customer->get_birth_date() ) {
177
-				$request->set_parameter( 'birth_date', $customer->get_birth_date()->format( 'dmY' ) );
176
+			if (null !== $customer->get_birth_date()) {
177
+				$request->set_parameter('birth_date', $customer->get_birth_date()->format('dmY'));
178 178
 			}
179 179
 		}
180 180
 
181 181
 		// Billing address.
182
-		if ( null !== $payment->get_billing_address() ) {
182
+		if (null !== $payment->get_billing_address()) {
183 183
 			$address = $payment->get_billing_address();
184 184
 
185
-			if ( null !== $address->get_name() ) {
185
+			if (null !== $address->get_name()) {
186 186
 				$name = $address->get_name();
187 187
 
188 188
 				$request->merge_parameters(
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 		}
211 211
 
212 212
 		// Shipping address.
213
-		if ( null !== $payment->get_shipping_address() ) {
213
+		if (null !== $payment->get_shipping_address()) {
214 214
 			$address = $payment->get_shipping_address();
215 215
 
216
-			if ( null !== $address->get_name() ) {
216
+			if (null !== $address->get_name()) {
217 217
 				$name = $address->get_name();
218 218
 
219 219
 				$request->merge_parameters(
@@ -240,22 +240,22 @@  discard block
 block discarded – undo
240 240
 		}
241 241
 
242 242
 		// Lines.
243
-		if ( null !== $payment->get_lines() ) {
243
+		if (null !== $payment->get_lines()) {
244 244
 			$lines = $payment->get_lines();
245 245
 
246 246
 			$x = 1;
247 247
 
248
-			foreach ( $lines as $line ) {
249
-				$net_price = ( null === $line->get_unit_price_excluding_tax() ) ? null : $line->get_unit_price_excluding_tax()->get_cents();
250
-				$total     = ( null === $line->get_total_amount() ) ? null : $line->get_total_amount()->get_cents();
251
-				$net_total = ( null === $line->get_total_amount_excluding_tax() ) ? null : $line->get_total_amount_excluding_tax()->get_cents();
252
-				$tax       = ( null === $line->get_tax_amount() ) ? null : $line->get_tax_amount()->get_cents();
248
+			foreach ($lines as $line) {
249
+				$net_price = (null === $line->get_unit_price_excluding_tax()) ? null : $line->get_unit_price_excluding_tax()->get_cents();
250
+				$total     = (null === $line->get_total_amount()) ? null : $line->get_total_amount()->get_cents();
251
+				$net_total = (null === $line->get_total_amount_excluding_tax()) ? null : $line->get_total_amount_excluding_tax()->get_cents();
252
+				$tax       = (null === $line->get_tax_amount()) ? null : $line->get_tax_amount()->get_cents();
253 253
 
254 254
 				$product_id = $line->get_id();
255 255
 
256
-				if ( PaymentLineType::SHIPPING === $line->get_type() ) {
256
+				if (PaymentLineType::SHIPPING === $line->get_type()) {
257 257
 					$product_id = 'shipping';
258
-				} elseif ( PaymentLineType::FEE === $line->get_type() ) {
258
+				} elseif (PaymentLineType::FEE === $line->get_type()) {
259 259
 					$product_id = 'paymentfee';
260 260
 				}
261 261
 
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
 		}
278 278
 
279 279
 		// Create transaction.
280
-		$result = $this->client->create_transaction( $request );
280
+		$result = $this->client->create_transaction($request);
281 281
 
282
-		if ( false !== $result ) {
283
-			$payment->set_transaction_id( $result->id );
284
-			$payment->set_action_url( $result->issuer_url );
282
+		if (false !== $result) {
283
+			$payment->set_transaction_id($result->id);
284
+			$payment->set_action_url($result->issuer_url);
285 285
 		} else {
286 286
 			$this->error = $this->client->get_error();
287 287
 		}
@@ -292,16 +292,16 @@  discard block
 block discarded – undo
292 292
 	 *
293 293
 	 * @param Payment $payment Payment.
294 294
 	 */
295
-	public function update_status( Payment $payment ) {
295
+	public function update_status(Payment $payment) {
296 296
 		$request = new StatusRequest(
297 297
 			$payment->get_transaction_id(),
298 298
 			$this->config->merchant_id,
299 299
 			$this->config->shop_id
300 300
 		);
301 301
 
302
-		$result = $this->client->get_status( $request );
302
+		$result = $this->client->get_status($request);
303 303
 
304
-		if ( false === $result ) {
304
+		if (false === $result) {
305 305
 			$this->error = $this->client->get_error();
306 306
 
307 307
 			return;
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
 
310 310
 		$transaction = $result;
311 311
 
312
-		$payment->set_status( $transaction->status );
313
-		$payment->set_consumer_name( $transaction->consumer_name );
314
-		$payment->set_consumer_account_number( $transaction->consumer_account );
315
-		$payment->set_consumer_city( $transaction->consumer_city );
312
+		$payment->set_status($transaction->status);
313
+		$payment->set_consumer_name($transaction->consumer_name);
314
+		$payment->set_consumer_account_number($transaction->consumer_account);
315
+		$payment->set_consumer_city($transaction->consumer_city);
316 316
 	}
317 317
 }
Please login to merge, or discard this patch.