@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * @param string $merchant_id Merchant ID. |
38 | 38 | * @param string|null $shop_id Shop ID. |
39 | 39 | */ |
40 | - public function __construct( $merchant_id, $shop_id = null ) { |
|
41 | - $this->set_parameter( 'merchantid', $merchant_id ); |
|
42 | - $this->set_parameter( 'shopid', $shop_id ); |
|
40 | + public function __construct($merchant_id, $shop_id = null) { |
|
41 | + $this->set_parameter('merchantid', $merchant_id); |
|
42 | + $this->set_parameter('shopid', $shop_id); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * @param string $parameter Parameter. |
49 | 49 | * @return string|null |
50 | 50 | */ |
51 | - public function get_parameter( $parameter ) { |
|
52 | - if ( isset( $this->parameters[ $parameter ] ) ) { |
|
53 | - return $this->parameters[ $parameter ]; |
|
51 | + public function get_parameter($parameter) { |
|
52 | + if (isset($this->parameters[$parameter])) { |
|
53 | + return $this->parameters[$parameter]; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | return null; |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @param string $parameter Parameter. |
63 | 63 | * @param string|null $value Value. |
64 | 64 | */ |
65 | - public function set_parameter( $parameter, $value ) { |
|
66 | - $this->parameters[ $parameter ] = $value; |
|
65 | + public function set_parameter($parameter, $value) { |
|
66 | + $this->parameters[$parameter] = $value; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param array $parameters Parameters. |
82 | 82 | */ |
83 | - public function merge_parameters( $parameters ) { |
|
84 | - $this->parameters = array_merge( $this->parameters, $parameters ); |
|
83 | + public function merge_parameters($parameters) { |
|
84 | + $this->parameters = array_merge($this->parameters, $parameters); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | * @param string $merchant_key Merchant key. |
100 | 100 | * @return string |
101 | 101 | */ |
102 | - public function get_signature( $merchant_key ) { |
|
102 | + public function get_signature($merchant_key) { |
|
103 | 103 | $data = $this->get_signature_data(); |
104 | 104 | |
105 | 105 | $data[] = $merchant_key; |
106 | 106 | |
107 | - $string = implode( '', $data ); |
|
107 | + $string = implode('', $data); |
|
108 | 108 | |
109 | - $signature = sha1( $string ); |
|
109 | + $signature = sha1($string); |
|
110 | 110 | |
111 | 111 | return $signature; |
112 | 112 | } |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @param string $merchant_key Merchant key. |
118 | 118 | */ |
119 | - public function sign( $merchant_key ) { |
|
120 | - $signature = $this->get_signature( $merchant_key ); |
|
119 | + public function sign($merchant_key) { |
|
120 | + $signature = $this->get_signature($merchant_key); |
|
121 | 121 | |
122 | - $this->set_parameter( 'sha1', $signature ); |
|
122 | + $this->set_parameter('sha1', $signature); |
|
123 | 123 | } |
124 | 124 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param string $merchant_id Merchant ID. |
69 | 69 | * @param string $merchant_key Merchant key. |
70 | 70 | */ |
71 | - public function __construct( $merchant_id, $merchant_key ) { |
|
71 | + public function __construct($merchant_id, $merchant_key) { |
|
72 | 72 | $this->merchant_id = $merchant_id; |
73 | 73 | $this->merchant_key = $merchant_key; |
74 | 74 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @param boolean $test_mode True if test mode, false otherwise. |
89 | 89 | */ |
90 | - public function set_test_mode( $test_mode ) { |
|
90 | + public function set_test_mode($test_mode) { |
|
91 | 91 | $this->test_mode = $test_mode; |
92 | 92 | } |
93 | 93 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * @param Request|null $request Request. |
99 | 99 | * @return false|SimpleXMLElement |
100 | 100 | */ |
101 | - private function send_request( $method, Request $request = null ) { |
|
101 | + private function send_request($method, Request $request = null) { |
|
102 | 102 | $url = self::API_URL . '/' . $method; |
103 | 103 | |
104 | - if ( null !== $request ) { |
|
105 | - $request->sign( $this->merchant_key ); |
|
104 | + if (null !== $request) { |
|
105 | + $request->sign($this->merchant_key); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | $result = Core_Util::remote_get_body( |
@@ -110,24 +110,24 @@ discard block |
||
110 | 110 | 200, |
111 | 111 | array( |
112 | 112 | 'method' => 'POST', |
113 | - 'body' => ( null === $request ) ? null : $request->get_parameters(), |
|
113 | + 'body' => (null === $request) ? null : $request->get_parameters(), |
|
114 | 114 | ) |
115 | 115 | ); |
116 | 116 | |
117 | - if ( $result instanceof WP_Error ) { |
|
117 | + if ($result instanceof WP_Error) { |
|
118 | 118 | $this->error = $result; |
119 | 119 | |
120 | 120 | return false; |
121 | 121 | } |
122 | 122 | |
123 | - if ( ! is_string( $result ) ) { |
|
123 | + if ( ! is_string($result)) { |
|
124 | 124 | return false; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // XML. |
128 | - $xml = Core_Util::simplexml_load_string( $result ); |
|
128 | + $xml = Core_Util::simplexml_load_string($result); |
|
129 | 129 | |
130 | - if ( $xml instanceof WP_Error ) { |
|
130 | + if ($xml instanceof WP_Error) { |
|
131 | 131 | $this->error = $xml; |
132 | 132 | |
133 | 133 | return false; |
@@ -142,31 +142,31 @@ discard block |
||
142 | 142 | * @param SimpleXMLElement $document Document. |
143 | 143 | * @return WP_Error|Transaction|Error |
144 | 144 | */ |
145 | - private function parse_document( SimpleXMLElement $document ) { |
|
145 | + private function parse_document(SimpleXMLElement $document) { |
|
146 | 146 | $this->error = null; |
147 | 147 | |
148 | 148 | $name = $document->getName(); |
149 | 149 | |
150 | - switch ( $name ) { |
|
150 | + switch ($name) { |
|
151 | 151 | case 'errorresponse': |
152 | - $sisow_error = ErrorParser::parse( $document->error ); |
|
152 | + $sisow_error = ErrorParser::parse($document->error); |
|
153 | 153 | |
154 | - $this->error = new WP_Error( 'ideal_sisow_error', $sisow_error->message, $sisow_error ); |
|
154 | + $this->error = new WP_Error('ideal_sisow_error', $sisow_error->message, $sisow_error); |
|
155 | 155 | |
156 | 156 | return $sisow_error; |
157 | 157 | case 'transactionrequest': |
158 | - $transaction = TransactionParser::parse( $document->transaction ); |
|
158 | + $transaction = TransactionParser::parse($document->transaction); |
|
159 | 159 | |
160 | 160 | return $transaction; |
161 | 161 | case 'statusresponse': |
162 | - $transaction = TransactionParser::parse( $document->transaction ); |
|
162 | + $transaction = TransactionParser::parse($document->transaction); |
|
163 | 163 | |
164 | 164 | return $transaction; |
165 | 165 | default: |
166 | 166 | return new WP_Error( |
167 | 167 | 'ideal_sisow_error', |
168 | 168 | /* translators: %s: XML document element name */ |
169 | - sprintf( __( 'Unknwon Sisow message (%s)', 'pronamic_ideal' ), $name ) |
|
169 | + sprintf(__('Unknwon Sisow message (%s)', 'pronamic_ideal'), $name) |
|
170 | 170 | ); |
171 | 171 | } |
172 | 172 | } |
@@ -177,27 +177,27 @@ discard block |
||
177 | 177 | * @return array|false |
178 | 178 | */ |
179 | 179 | public function get_directory() { |
180 | - if ( $this->test_mode ) { |
|
180 | + if ($this->test_mode) { |
|
181 | 181 | return array( |
182 | - '99' => __( 'Sisow Bank (test)', 'pronamic_ideal' ), |
|
182 | + '99' => __('Sisow Bank (test)', 'pronamic_ideal'), |
|
183 | 183 | ); |
184 | 184 | } |
185 | 185 | |
186 | 186 | // Request. |
187 | - $result = $this->send_request( RequestMethods::DIRECTORY_REQUEST ); |
|
187 | + $result = $this->send_request(RequestMethods::DIRECTORY_REQUEST); |
|
188 | 188 | |
189 | - if ( false === $result ) { |
|
189 | + if (false === $result) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | |
193 | 193 | // Parse. |
194 | 194 | $directory = array(); |
195 | 195 | |
196 | - foreach ( $result->directory->issuer as $issuer ) { |
|
196 | + foreach ($result->directory->issuer as $issuer) { |
|
197 | 197 | $id = (string) $issuer->issuerid; |
198 | 198 | $name = (string) $issuer->issuername; |
199 | 199 | |
200 | - $directory[ $id ] = $name; |
|
200 | + $directory[$id] = $name; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | return $directory; |
@@ -209,18 +209,18 @@ discard block |
||
209 | 209 | * @param TransactionRequest $request Transaction request. |
210 | 210 | * @return Transaction|false |
211 | 211 | */ |
212 | - public function create_transaction( TransactionRequest $request ) { |
|
212 | + public function create_transaction(TransactionRequest $request) { |
|
213 | 213 | // Request. |
214 | - $response = $this->send_request( RequestMethods::TRANSACTION_REQUEST, $request ); |
|
214 | + $response = $this->send_request(RequestMethods::TRANSACTION_REQUEST, $request); |
|
215 | 215 | |
216 | - if ( false === $response ) { |
|
216 | + if (false === $response) { |
|
217 | 217 | return false; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Parse. |
221 | - $message = $this->parse_document( $response ); |
|
221 | + $message = $this->parse_document($response); |
|
222 | 222 | |
223 | - if ( $message instanceof Transaction ) { |
|
223 | + if ($message instanceof Transaction) { |
|
224 | 224 | return $message; |
225 | 225 | } |
226 | 226 | |
@@ -233,18 +233,18 @@ discard block |
||
233 | 233 | * @param StatusRequest $request Status request object. |
234 | 234 | * @return Transaction|false |
235 | 235 | */ |
236 | - public function get_status( StatusRequest $request ) { |
|
236 | + public function get_status(StatusRequest $request) { |
|
237 | 237 | // Request. |
238 | - $response = $this->send_request( RequestMethods::STATUS_REQUEST, $request ); |
|
238 | + $response = $this->send_request(RequestMethods::STATUS_REQUEST, $request); |
|
239 | 239 | |
240 | - if ( false === $response ) { |
|
240 | + if (false === $response) { |
|
241 | 241 | return false; |
242 | 242 | } |
243 | 243 | |
244 | 244 | // Parse. |
245 | - $message = $this->parse_document( $response ); |
|
245 | + $message = $this->parse_document($response); |
|
246 | 246 | |
247 | - if ( $message instanceof Transaction ) { |
|
247 | + if ($message instanceof Transaction) { |
|
248 | 248 | return $message; |
249 | 249 | } |
250 | 250 |
@@ -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 | } |