@@ -38,17 +38,17 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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_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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * $ Dollar |
62 | 62 | */ |
63 | 63 | public static function get_pattern() { |
64 | - if ( null === self::$pattern ) { |
|
64 | + if (null === self::$pattern) { |
|
65 | 65 | $characters = array( |
66 | 66 | 'A-Z', |
67 | 67 | 'a-z', |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * We use a # as a regex delimiter instead of a / so we don't have to escape the slash. |
91 | 91 | * @link http://stackoverflow.com/q/12239424 |
92 | 92 | */ |
93 | - self::$pattern = '#[^' . implode( $characters ) . ']#'; |
|
93 | + self::$pattern = '#[^' . implode($characters) . ']#'; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | return self::$pattern; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param string $string String to filter. |
103 | 103 | * @return mixed |
104 | 104 | */ |
105 | - public static function filter( $string ) { |
|
106 | - return preg_replace( self::get_pattern(), '', $string ); |
|
105 | + public static function filter($string) { |
|
106 | + return preg_replace(self::get_pattern(), '', $string); |
|
107 | 107 | } |
108 | 108 | } |
@@ -33,57 +33,57 @@ |
||
33 | 33 | * @param SimpleXMLElement $xml XML element to parse. |
34 | 34 | * @return Transaction |
35 | 35 | */ |
36 | - public static function parse( SimpleXMLElement $xml ) { |
|
36 | + public static function parse(SimpleXMLElement $xml) { |
|
37 | 37 | $transaction = new Transaction(); |
38 | 38 | |
39 | 39 | // Transaction request. |
40 | - if ( isset( $xml->trxid ) ) { |
|
41 | - $transaction->id = Security::filter( $xml->trxid ); |
|
40 | + if (isset($xml->trxid)) { |
|
41 | + $transaction->id = Security::filter($xml->trxid); |
|
42 | 42 | } |
43 | 43 | |
44 | - if ( isset( $xml->issuerurl ) ) { |
|
45 | - $transaction->issuer_url = urldecode( Security::filter( $xml->issuerurl ) ); |
|
44 | + if (isset($xml->issuerurl)) { |
|
45 | + $transaction->issuer_url = urldecode(Security::filter($xml->issuerurl)); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // Status response. |
49 | - if ( isset( $xml->status ) ) { |
|
50 | - $transaction->status = Security::filter( $xml->status ); |
|
49 | + if (isset($xml->status)) { |
|
50 | + $transaction->status = Security::filter($xml->status); |
|
51 | 51 | } |
52 | 52 | |
53 | - if ( isset( $xml->amount ) ) { |
|
54 | - $transaction->amount = Util::cents_to_amount( Security::filter( $xml->amount ) ); |
|
53 | + if (isset($xml->amount)) { |
|
54 | + $transaction->amount = Util::cents_to_amount(Security::filter($xml->amount)); |
|
55 | 55 | } |
56 | 56 | |
57 | - if ( isset( $xml->purchaseid ) ) { |
|
58 | - $transaction->purchase_id = Security::filter( $xml->purchaseid ); |
|
57 | + if (isset($xml->purchaseid)) { |
|
58 | + $transaction->purchase_id = Security::filter($xml->purchaseid); |
|
59 | 59 | } |
60 | 60 | |
61 | - if ( isset( $xml->description ) ) { |
|
62 | - $transaction->description = Security::filter( $xml->description ); |
|
61 | + if (isset($xml->description)) { |
|
62 | + $transaction->description = Security::filter($xml->description); |
|
63 | 63 | } |
64 | 64 | |
65 | - if ( isset( $xml->entrancecode ) ) { |
|
66 | - $transaction->entrance_code = Security::filter( $xml->entrancecode ); |
|
65 | + if (isset($xml->entrancecode)) { |
|
66 | + $transaction->entrance_code = Security::filter($xml->entrancecode); |
|
67 | 67 | } |
68 | 68 | |
69 | - if ( isset( $xml->issuerid ) ) { |
|
70 | - $transaction->issuer_id = Security::filter( $xml->issuerid ); |
|
69 | + if (isset($xml->issuerid)) { |
|
70 | + $transaction->issuer_id = Security::filter($xml->issuerid); |
|
71 | 71 | } |
72 | 72 | |
73 | - if ( isset( $xml->timestamp ) ) { |
|
74 | - $transaction->timestamp = new DateTime( Security::filter( $xml->timestamp ) ); |
|
73 | + if (isset($xml->timestamp)) { |
|
74 | + $transaction->timestamp = new DateTime(Security::filter($xml->timestamp)); |
|
75 | 75 | } |
76 | 76 | |
77 | - if ( isset( $xml->consumername ) ) { |
|
78 | - $transaction->consumer_name = Security::filter( $xml->consumername ); |
|
77 | + if (isset($xml->consumername)) { |
|
78 | + $transaction->consumer_name = Security::filter($xml->consumername); |
|
79 | 79 | } |
80 | 80 | |
81 | - if ( isset( $xml->consumeraccount ) ) { |
|
82 | - $transaction->consumer_account = Security::filter( $xml->consumeraccount ); |
|
81 | + if (isset($xml->consumeraccount)) { |
|
82 | + $transaction->consumer_account = Security::filter($xml->consumeraccount); |
|
83 | 83 | } |
84 | 84 | |
85 | - if ( isset( $xml->consumercity ) ) { |
|
86 | - $transaction->consumer_city = Security::filter( $xml->consumercity ); |
|
85 | + if (isset($xml->consumercity)) { |
|
86 | + $transaction->consumer_city = Security::filter($xml->consumercity); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return $transaction; |