@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @param string $email_address E-mailadress of the consumer. |
| 60 | 60 | */ |
| 61 | - public function set_email_address( $email_address ) { |
|
| 61 | + public function set_email_address($email_address) { |
|
| 62 | 62 | $this->email_address = $email_address; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @param string $date_of_birth Date of birth. |
| 69 | 69 | */ |
| 70 | - public function set_date_of_birth( $date_of_birth ) { |
|
| 70 | + public function set_date_of_birth($date_of_birth) { |
|
| 71 | 71 | $this->date_of_birth = $date_of_birth; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @param string $gender Gender. |
| 78 | 78 | */ |
| 79 | - public function set_gender( $gender ) { |
|
| 79 | + public function set_gender($gender) { |
|
| 80 | 80 | $this->gender = $gender; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param string $initials Initials. |
| 87 | 87 | */ |
| 88 | - public function set_initials( $initials ) { |
|
| 88 | + public function set_initials($initials) { |
|
| 89 | 89 | $this->initials = $initials; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @param string $telephone_number Telephone number. |
| 96 | 96 | */ |
| 97 | - public function set_telephone_number( $telephone_number ) { |
|
| 97 | + public function set_telephone_number($telephone_number) { |
|
| 98 | 98 | $this->telephone_number = $telephone_number; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | 'telephoneNumber' => $this->telephone_number, |
| 113 | 113 | ); |
| 114 | 114 | |
| 115 | - $data = array_filter( $data ); |
|
| 115 | + $data = array_filter($data); |
|
| 116 | 116 | |
| 117 | - if ( empty( $data ) ) { |
|
| 117 | + if (empty($data)) { |
|
| 118 | 118 | return null; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param array $fields Fields. |
| 128 | 128 | * @return array |
| 129 | 129 | */ |
| 130 | - public function get_signature_fields( $fields = array() ) { |
|
| 130 | + public function get_signature_fields($fields = array()) { |
|
| 131 | 131 | $fields[] = $this->email_address; |
| 132 | 132 | $fields[] = $this->date_of_birth; |
| 133 | 133 | $fields[] = $this->gender; |
@@ -35,23 +35,23 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param Config $config Config. |
| 37 | 37 | */ |
| 38 | - public function __construct( Config $config ) { |
|
| 39 | - parent::__construct( $config ); |
|
| 38 | + public function __construct(Config $config) { |
|
| 39 | + parent::__construct($config); |
|
| 40 | 40 | |
| 41 | - $this->set_method( self::METHOD_HTTP_REDIRECT ); |
|
| 41 | + $this->set_method(self::METHOD_HTTP_REDIRECT); |
|
| 42 | 42 | |
| 43 | 43 | // Client. |
| 44 | 44 | $this->client = new Client(); |
| 45 | 45 | |
| 46 | 46 | $url = Client::URL_PRODUCTION; |
| 47 | 47 | |
| 48 | - if ( self::MODE_TEST === $config->mode ) { |
|
| 48 | + if (self::MODE_TEST === $config->mode) { |
|
| 49 | 49 | $url = Client::URL_SANDBOX; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - $this->client->set_url( $url ); |
|
| 53 | - $this->client->set_refresh_token( $config->refresh_token ); |
|
| 54 | - $this->client->set_signing_key( $config->signing_key ); |
|
| 52 | + $this->client->set_url($url); |
|
| 53 | + $this->client->set_refresh_token($config->refresh_token); |
|
| 54 | + $this->client->set_signing_key($config->signing_key); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -78,88 +78,88 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @param Payment $payment Payment. |
| 80 | 80 | */ |
| 81 | - public function start( Payment $payment ) { |
|
| 81 | + public function start(Payment $payment) { |
|
| 82 | 82 | // Merchant order ID. |
| 83 | - $merchant_order_id = $payment->format_string( $this->config->order_id ); |
|
| 83 | + $merchant_order_id = $payment->format_string($this->config->order_id); |
|
| 84 | 84 | |
| 85 | - $payment->set_meta( 'omnikassa_2_merchant_order_id', $merchant_order_id ); |
|
| 85 | + $payment->set_meta('omnikassa_2_merchant_order_id', $merchant_order_id); |
|
| 86 | 86 | |
| 87 | 87 | // New order. |
| 88 | 88 | $order = new Order( |
| 89 | 89 | $merchant_order_id, |
| 90 | - MoneyTransformer::transform( $payment->get_amount() ), |
|
| 90 | + MoneyTransformer::transform($payment->get_amount()), |
|
| 91 | 91 | $payment->get_return_url() |
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | 94 | // Shipping address. |
| 95 | - $order->set_shipping_detail( AddressTransformer::transform( $payment->get_shipping_address() ) ); |
|
| 95 | + $order->set_shipping_detail(AddressTransformer::transform($payment->get_shipping_address())); |
|
| 96 | 96 | |
| 97 | 97 | // Billing address. |
| 98 | - $order->set_billing_detail( AddressTransformer::transform( $payment->get_billing_address() ) ); |
|
| 98 | + $order->set_billing_detail(AddressTransformer::transform($payment->get_billing_address())); |
|
| 99 | 99 | |
| 100 | 100 | // Customer information. |
| 101 | 101 | $customer = $payment->get_customer(); |
| 102 | 102 | |
| 103 | - if ( null !== $customer ) { |
|
| 104 | - $order->set_language( $customer->get_language() ); |
|
| 103 | + if (null !== $customer) { |
|
| 104 | + $order->set_language($customer->get_language()); |
|
| 105 | 105 | |
| 106 | 106 | $customer_information = new CustomerInformation(); |
| 107 | 107 | |
| 108 | - $customer_information->set_email_address( $customer->get_email() ); |
|
| 109 | - $customer_information->set_telephone_number( $customer->get_phone() ); |
|
| 108 | + $customer_information->set_email_address($customer->get_email()); |
|
| 109 | + $customer_information->set_telephone_number($customer->get_phone()); |
|
| 110 | 110 | |
| 111 | - $order->set_customer_information( $customer_information ); |
|
| 111 | + $order->set_customer_information($customer_information); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | // Payment brand. |
| 115 | - $payment_brand = PaymentBrands::transform( $payment->get_method() ); |
|
| 115 | + $payment_brand = PaymentBrands::transform($payment->get_method()); |
|
| 116 | 116 | |
| 117 | - $order->set_payment_brand( $payment_brand ); |
|
| 117 | + $order->set_payment_brand($payment_brand); |
|
| 118 | 118 | |
| 119 | - if ( null !== $payment_brand ) { |
|
| 119 | + if (null !== $payment_brand) { |
|
| 120 | 120 | // Payment brand force should only be set if payment brand is not empty. |
| 121 | - $order->set_payment_brand_force( PaymentBrandForce::FORCE_ONCE ); |
|
| 121 | + $order->set_payment_brand_force(PaymentBrandForce::FORCE_ONCE); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | // Description. |
| 125 | - $order->set_description( $payment->get_description() ); |
|
| 125 | + $order->set_description($payment->get_description()); |
|
| 126 | 126 | |
| 127 | 127 | // Lines. |
| 128 | - if ( null !== $payment->get_lines() ) { |
|
| 128 | + if (null !== $payment->get_lines()) { |
|
| 129 | 129 | $order_items = new OrderItems(); |
| 130 | 130 | |
| 131 | - foreach ( $payment->get_lines() as $line ) { |
|
| 131 | + foreach ($payment->get_lines() as $line) { |
|
| 132 | 132 | $item = new OrderItem( |
| 133 | 133 | $line->get_name(), |
| 134 | 134 | $line->get_quantity(), |
| 135 | - MoneyTransformer::transform( $line->get_total_amount() ), |
|
| 136 | - Category::transform( $line->get_type() ) |
|
| 135 | + MoneyTransformer::transform($line->get_total_amount()), |
|
| 136 | + Category::transform($line->get_type()) |
|
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | - $order_items->add_item( $item ); |
|
| 139 | + $order_items->add_item($item); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $order->set_order_items( $order_items ); |
|
| 142 | + $order->set_order_items($order_items); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // Maybe update access token. |
| 146 | 146 | $this->maybe_update_access_token(); |
| 147 | 147 | |
| 148 | 148 | // Handle errors. |
| 149 | - if ( $this->get_client_error() ) { |
|
| 149 | + if ($this->get_client_error()) { |
|
| 150 | 150 | return; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Announce order. |
| 154 | - $result = $this->client->order_announce( $this->config, $order ); |
|
| 154 | + $result = $this->client->order_announce($this->config, $order); |
|
| 155 | 155 | |
| 156 | 156 | // Handle errors. |
| 157 | - if ( $this->get_client_error() ) { |
|
| 157 | + if ($this->get_client_error()) { |
|
| 158 | 158 | return; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if ( $result ) { |
|
| 162 | - $payment->set_action_url( $result->redirectUrl ); |
|
| 161 | + if ($result) { |
|
| 162 | + $payment->set_action_url($result->redirectUrl); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
@@ -168,45 +168,45 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @param Payment $payment Payment. |
| 170 | 170 | */ |
| 171 | - public function update_status( Payment $payment ) { |
|
| 172 | - if ( ! ReturnParameters::contains( $_GET ) ) { // WPCS: CSRF ok. |
|
| 171 | + public function update_status(Payment $payment) { |
|
| 172 | + if ( ! ReturnParameters::contains($_GET)) { // WPCS: CSRF ok. |
|
| 173 | 173 | return; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $parameters = ReturnParameters::from_array( $_GET ); // WPCS: CSRF ok. |
|
| 176 | + $parameters = ReturnParameters::from_array($_GET); // WPCS: CSRF ok. |
|
| 177 | 177 | |
| 178 | 178 | // Note. |
| 179 | 179 | $note_values = array( |
| 180 | 180 | 'order_id' => $parameters->get_order_id(), |
| 181 | 181 | 'status' => $parameters->get_status(), |
| 182 | 182 | 'signature' => $parameters->get_signature(), |
| 183 | - 'valid' => $parameters->is_valid( $this->config->signing_key ) ? 'true' : 'false', |
|
| 183 | + 'valid' => $parameters->is_valid($this->config->signing_key) ? 'true' : 'false', |
|
| 184 | 184 | ); |
| 185 | 185 | |
| 186 | 186 | $note = ''; |
| 187 | 187 | |
| 188 | 188 | $note .= '<p>'; |
| 189 | - $note .= __( 'OmniKassa 2.0 return URL requested:', 'pronamic_ideal' ); |
|
| 189 | + $note .= __('OmniKassa 2.0 return URL requested:', 'pronamic_ideal'); |
|
| 190 | 190 | $note .= '</p>'; |
| 191 | 191 | |
| 192 | 192 | $note .= '<dl>'; |
| 193 | 193 | |
| 194 | - foreach ( $note_values as $key => $value ) { |
|
| 195 | - $note .= sprintf( '<dt>%s</dt>', esc_html( $key ) ); |
|
| 196 | - $note .= sprintf( '<dd>%s</dd>', esc_html( $value ) ); |
|
| 194 | + foreach ($note_values as $key => $value) { |
|
| 195 | + $note .= sprintf('<dt>%s</dt>', esc_html($key)); |
|
| 196 | + $note .= sprintf('<dd>%s</dd>', esc_html($value)); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | $note .= '</dl>'; |
| 200 | 200 | |
| 201 | - $payment->add_note( $note ); |
|
| 201 | + $payment->add_note($note); |
|
| 202 | 202 | |
| 203 | 203 | // Validate. |
| 204 | - if ( ! $parameters->is_valid( $this->config->signing_key ) ) { |
|
| 204 | + if ( ! $parameters->is_valid($this->config->signing_key)) { |
|
| 205 | 205 | return; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Status. |
| 209 | - $payment->set_status( Statuses::transform( $parameters->get_status() ) ); |
|
| 209 | + $payment->set_status(Statuses::transform($parameters->get_status())); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -216,14 +216,14 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @return void |
| 218 | 218 | */ |
| 219 | - public function handle_notification( Notification $notification ) { |
|
| 220 | - if ( ! $notification->is_valid( $this->config->signing_key ) ) { |
|
| 219 | + public function handle_notification(Notification $notification) { |
|
| 220 | + if ( ! $notification->is_valid($this->config->signing_key)) { |
|
| 221 | 221 | return; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - switch ( $notification->get_event_name() ) { |
|
| 224 | + switch ($notification->get_event_name()) { |
|
| 225 | 225 | case 'merchant.order.status.changed': |
| 226 | - $this->handle_merchant_order_status_changed( $notification ); |
|
| 226 | + $this->handle_merchant_order_status_changed($notification); |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
@@ -234,39 +234,39 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @return void |
| 236 | 236 | */ |
| 237 | - private function handle_merchant_order_status_changed( Notification $notification ) { |
|
| 237 | + private function handle_merchant_order_status_changed(Notification $notification) { |
|
| 238 | 238 | do { |
| 239 | - $order_results = $this->client->get_order_results( $notification->get_authentication() ); |
|
| 239 | + $order_results = $this->client->get_order_results($notification->get_authentication()); |
|
| 240 | 240 | |
| 241 | - if ( ! $order_results || $order_results->is_valid( $this->config->signing_key ) ) { |
|
| 241 | + if ( ! $order_results || $order_results->is_valid($this->config->signing_key)) { |
|
| 242 | 242 | return; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - foreach ( $order_results as $order_result ) { |
|
| 246 | - $payment = get_pronamic_payment_by_meta( '_pronamic_payment_omnikassa_2_merchant_order_id', $order_result->get_merchant_order_id() ); |
|
| 245 | + foreach ($order_results as $order_result) { |
|
| 246 | + $payment = get_pronamic_payment_by_meta('_pronamic_payment_omnikassa_2_merchant_order_id', $order_result->get_merchant_order_id()); |
|
| 247 | 247 | |
| 248 | - if ( empty( $payment ) ) { |
|
| 248 | + if (empty($payment)) { |
|
| 249 | 249 | continue; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - $payment->set_transaction_id( $order_result->get_omnikassa_order_id() ); |
|
| 253 | - $payment->set_status( Statuses::transform( $order_result->get_order_status() ) ); |
|
| 252 | + $payment->set_transaction_id($order_result->get_omnikassa_order_id()); |
|
| 253 | + $payment->set_status(Statuses::transform($order_result->get_order_status())); |
|
| 254 | 254 | |
| 255 | 255 | // Note. |
| 256 | 256 | $note = ''; |
| 257 | 257 | |
| 258 | 258 | $note .= '<p>'; |
| 259 | - $note .= __( 'OmniKassa 2.0 webhook URL requested:', 'pronamic_ideal' ); |
|
| 259 | + $note .= __('OmniKassa 2.0 webhook URL requested:', 'pronamic_ideal'); |
|
| 260 | 260 | $note .= '</p>'; |
| 261 | 261 | $note .= '<pre>'; |
| 262 | - $note .= wp_json_encode( $order_result->get_json(), JSON_PRETTY_PRINT ); |
|
| 262 | + $note .= wp_json_encode($order_result->get_json(), JSON_PRETTY_PRINT); |
|
| 263 | 263 | $note .= '</pre>'; |
| 264 | 264 | |
| 265 | - $payment->add_note( $note ); |
|
| 265 | + $payment->add_note($note); |
|
| 266 | 266 | |
| 267 | 267 | $payment->save(); |
| 268 | 268 | } |
| 269 | - } while ( $order_results->more_available() ); |
|
| 269 | + } while ($order_results->more_available()); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -275,20 +275,20 @@ discard block |
||
| 275 | 275 | * @return void |
| 276 | 276 | */ |
| 277 | 277 | private function maybe_update_access_token() { |
| 278 | - if ( $this->config->is_access_token_valid() ) { |
|
| 278 | + if ($this->config->is_access_token_valid()) { |
|
| 279 | 279 | return; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | $data = $this->client->get_access_token_data(); |
| 283 | 283 | |
| 284 | - if ( ! is_object( $data ) ) { |
|
| 284 | + if ( ! is_object($data)) { |
|
| 285 | 285 | return; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $this->config->access_token = $data->token; |
| 289 | 289 | $this->config->access_token_valid_until = $data->validUntil; |
| 290 | 290 | |
| 291 | - update_post_meta( $this->config->post_id, '_pronamic_gateway_omnikassa_2_access_token', $data->token ); |
|
| 291 | + update_post_meta($this->config->post_id, '_pronamic_gateway_omnikassa_2_access_token', $data->token); |
|
| 292 | 292 | update_post_meta( |
| 293 | 293 | $this->config->post_id, |
| 294 | 294 | '_pronamic_gateway_omnikassa_2_access_token_valid_until', |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | private function get_client_error() { |
| 305 | 305 | $error = $this->client->get_error(); |
| 306 | 306 | |
| 307 | - if ( is_wp_error( $error ) ) { |
|
| 307 | + if (is_wp_error($error)) { |
|
| 308 | 308 | $this->error = $error; |
| 309 | 309 | |
| 310 | 310 | return $error; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @param string $city City. |
| 100 | 100 | * @param string $country_code Country code. |
| 101 | 101 | */ |
| 102 | - public function __construct( $last_name, $street, $postal_code, $city, $country_code ) { |
|
| 102 | + public function __construct($last_name, $street, $postal_code, $city, $country_code) { |
|
| 103 | 103 | $this->last_name = $last_name; |
| 104 | 104 | $this->street = $street; |
| 105 | 105 | $this->postal_code = $postal_code; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @param string $first_name First name. |
| 123 | 123 | */ |
| 124 | - public function set_first_name( $first_name ) { |
|
| 124 | + public function set_first_name($first_name) { |
|
| 125 | 125 | $this->first_name = $first_name; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @param string $middle_name Middle name. |
| 141 | 141 | */ |
| 142 | - public function set_middle_name( $middle_name ) { |
|
| 142 | + public function set_middle_name($middle_name) { |
|
| 143 | 143 | $this->middle_name = $middle_name; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @param string $last_name Last name. |
| 159 | 159 | */ |
| 160 | - public function set_last_name( $last_name ) { |
|
| 160 | + public function set_last_name($last_name) { |
|
| 161 | 161 | $this->last_name = $last_name; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @param string $street Street. |
| 177 | 177 | */ |
| 178 | - public function set_street( $street ) { |
|
| 178 | + public function set_street($street) { |
|
| 179 | 179 | $this->street = $street; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @param string $house_number House number. |
| 195 | 195 | */ |
| 196 | - public function set_house_number( $house_number ) { |
|
| 196 | + public function set_house_number($house_number) { |
|
| 197 | 197 | $this->house_number = $house_number; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @param string $house_number_addition House number addition. |
| 213 | 213 | */ |
| 214 | - public function set_house_number_addition( $house_number_addition ) { |
|
| 214 | + public function set_house_number_addition($house_number_addition) { |
|
| 215 | 215 | $this->house_number_addition = $house_number_addition; |
| 216 | 216 | } |
| 217 | 217 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @param string $postal_code Postal code. |
| 231 | 231 | */ |
| 232 | - public function set_postal_code( $postal_code ) { |
|
| 232 | + public function set_postal_code($postal_code) { |
|
| 233 | 233 | $this->postal_code = $postal_code; |
| 234 | 234 | } |
| 235 | 235 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @param string $city City. |
| 249 | 249 | */ |
| 250 | - public function set_city( $city ) { |
|
| 250 | + public function set_city($city) { |
|
| 251 | 251 | $this->city = $city; |
| 252 | 252 | } |
| 253 | 253 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @param string $country_code Country code. |
| 267 | 267 | */ |
| 268 | - public function set_country_code( $country_code ) { |
|
| 268 | + public function set_country_code($country_code) { |
|
| 269 | 269 | $this->country_code = $country_code; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -282,11 +282,11 @@ discard block |
||
| 282 | 282 | $object->lastName = $this->last_name; |
| 283 | 283 | $object->street = $this->street; |
| 284 | 284 | |
| 285 | - if ( null !== $this->house_number ) { |
|
| 285 | + if (null !== $this->house_number) { |
|
| 286 | 286 | $object->houseNumber = $this->house_number; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if ( null !== $this->house_number_addition ) { |
|
| 289 | + if (null !== $this->house_number_addition) { |
|
| 290 | 290 | $object->houseNumberAddition = $this->house_number_addition; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -303,17 +303,17 @@ discard block |
||
| 303 | 303 | * @param array $fields Fields. |
| 304 | 304 | * @return array |
| 305 | 305 | */ |
| 306 | - public function get_signature_fields( $fields = array() ) { |
|
| 306 | + public function get_signature_fields($fields = array()) { |
|
| 307 | 307 | $fields[] = $this->first_name; |
| 308 | 308 | $fields[] = $this->middle_name; |
| 309 | 309 | $fields[] = $this->last_name; |
| 310 | 310 | $fields[] = $this->street; |
| 311 | 311 | |
| 312 | - if ( null !== $this->house_number ) { |
|
| 312 | + if (null !== $this->house_number) { |
|
| 313 | 313 | $fields[] = $this->house_number; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if ( null !== $this->house_number_addition ) { |
|
| 316 | + if (null !== $this->house_number_addition) { |
|
| 317 | 317 | $fields[] = $this->house_number_addition; |
| 318 | 318 | } |
| 319 | 319 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param Money $amount Amount. |
| 83 | 83 | * @param string $category Category. |
| 84 | 84 | */ |
| 85 | - public function __construct( $name, $quantity, Money $amount, $category ) { |
|
| 85 | + public function __construct($name, $quantity, Money $amount, $category) { |
|
| 86 | 86 | $this->name = $name; |
| 87 | 87 | $this->quantity = $quantity; |
| 88 | 88 | $this->amount = $amount; |
@@ -169,26 +169,26 @@ discard block |
||
| 169 | 169 | public function get_json() { |
| 170 | 170 | $object = (object) array(); |
| 171 | 171 | |
| 172 | - if ( null !== $this->id ) { |
|
| 172 | + if (null !== $this->id) { |
|
| 173 | 173 | $object->id = $this->id; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $object->name = $this->name; |
| 177 | 177 | |
| 178 | - if ( null !== $this->description ) { |
|
| 178 | + if (null !== $this->description) { |
|
| 179 | 179 | $object->description = $this->description; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $object->quantity = $this->quantity; |
| 183 | 183 | $object->amount = $this->amount->get_json(); |
| 184 | 184 | |
| 185 | - if ( null !== $this->tax ) { |
|
| 185 | + if (null !== $this->tax) { |
|
| 186 | 186 | $object->tax = $this->tax->get_json(); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $object->category = $this->category; |
| 190 | 190 | |
| 191 | - if ( null !== $this->vat_category ) { |
|
| 191 | + if (null !== $this->vat_category) { |
|
| 192 | 192 | $object->vatCategory = $this->vat_category; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | * @param array $data Data. |
| 202 | 202 | * @return array |
| 203 | 203 | */ |
| 204 | - public function get_signature_fields( $data = array() ) { |
|
| 205 | - if ( null !== $this->id ) { |
|
| 204 | + public function get_signature_fields($data = array()) { |
|
| 205 | + if (null !== $this->id) { |
|
| 206 | 206 | $data[] = $this->id; |
| 207 | 207 | } |
| 208 | 208 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $data[] = $this->amount->get_currency(); |
| 213 | 213 | $data[] = $this->amount->get_amount(); |
| 214 | 214 | |
| 215 | - if ( null === $this->tax ) { |
|
| 215 | + if (null === $this->tax) { |
|
| 216 | 216 | $data[] = null; |
| 217 | 217 | } else { |
| 218 | 218 | $data[] = $this->tax->get_currency(); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | $data[] = $this->category; |
| 223 | 223 | |
| 224 | - if ( null !== $this->vatCategory ) { |
|
| 224 | + if (null !== $this->vatCategory) { |
|
| 225 | 225 | $data[] = $this->vatCategory; |
| 226 | 226 | } |
| 227 | 227 | |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | * @param array $order_results Order results. |
| 48 | 48 | * @param string $signature Signature. |
| 49 | 49 | */ |
| 50 | - public function __construct( $more_available, array $order_results, $signature ) { |
|
| 51 | - parent::__construct( $signature ); |
|
| 50 | + public function __construct($more_available, array $order_results, $signature) { |
|
| 51 | + parent::__construct($signature); |
|
| 52 | 52 | |
| 53 | 53 | $this->more_available = $more_available; |
| 54 | 54 | $this->order_results = $order_results; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | $fields[] = $this->more_available() ? 'true' : 'false'; |
| 75 | 75 | |
| 76 | - foreach ( $this->order_results as $order_result ) { |
|
| 76 | + foreach ($this->order_results as $order_result) { |
|
| 77 | 77 | $fields[] = $order_result->get_merchant_order_id(); |
| 78 | 78 | $fields[] = $order_result->get_omnikassa_order_id(); |
| 79 | 79 | $fields[] = $order_result->get_poi_id(); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @return ArrayIterator |
| 96 | 96 | */ |
| 97 | 97 | public function getIterator() { |
| 98 | - return new ArrayIterator( $this->order_results ); |
|
| 98 | + return new ArrayIterator($this->order_results); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -105,27 +105,27 @@ discard block |
||
| 105 | 105 | * @return OrderResults |
| 106 | 106 | * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties. |
| 107 | 107 | */ |
| 108 | - public static function from_object( stdClass $object ) { |
|
| 109 | - if ( ! isset( $object->signature ) ) { |
|
| 110 | - throw new InvalidArgumentException( 'Object must contain `signature` property.' ); |
|
| 108 | + public static function from_object(stdClass $object) { |
|
| 109 | + if ( ! isset($object->signature)) { |
|
| 110 | + throw new InvalidArgumentException('Object must contain `signature` property.'); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if ( ! isset( $object->moreOrderResultsAvailable ) ) { |
|
| 114 | - throw new InvalidArgumentException( 'Object must contain `moreOrderResultsAvailable` property.' ); |
|
| 113 | + if ( ! isset($object->moreOrderResultsAvailable)) { |
|
| 114 | + throw new InvalidArgumentException('Object must contain `moreOrderResultsAvailable` property.'); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( ! isset( $object->orderResults ) ) { |
|
| 118 | - throw new InvalidArgumentException( 'Object must contain `orderResults` property.' ); |
|
| 117 | + if ( ! isset($object->orderResults)) { |
|
| 118 | + throw new InvalidArgumentException('Object must contain `orderResults` property.'); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if ( ! is_array( $object->orderResults ) ) { |
|
| 122 | - throw new InvalidArgumentException( 'The `orderResults` property must be an array.' ); |
|
| 121 | + if ( ! is_array($object->orderResults)) { |
|
| 122 | + throw new InvalidArgumentException('The `orderResults` property must be an array.'); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $order_results = array(); |
| 126 | 126 | |
| 127 | - foreach ( $object->orderResults as $o ) { |
|
| 128 | - $order_results[] = OrderResult::from_object( $o ); |
|
| 127 | + foreach ($object->orderResults as $o) { |
|
| 128 | + $order_results[] = OrderResult::from_object($o); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | return new self( |
@@ -142,19 +142,19 @@ discard block |
||
| 142 | 142 | * @return OrderResults |
| 143 | 143 | * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. |
| 144 | 144 | */ |
| 145 | - public static function from_json( $json ) { |
|
| 146 | - $data = json_decode( $json ); |
|
| 145 | + public static function from_json($json) { |
|
| 146 | + $data = json_decode($json); |
|
| 147 | 147 | |
| 148 | 148 | $validator = new Validator(); |
| 149 | 149 | |
| 150 | 150 | $validator->validate( |
| 151 | 151 | $data, |
| 152 | 152 | (object) array( |
| 153 | - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/order-results.json' ), |
|
| 153 | + '$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/order-results.json'), |
|
| 154 | 154 | ), |
| 155 | 155 | Constraint::CHECK_MODE_EXCEPTIONS |
| 156 | 156 | ); |
| 157 | 157 | |
| 158 | - return self::from_object( $data ); |
|
| 158 | + return self::from_object($data); |
|
| 159 | 159 | } |
| 160 | 160 | } |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | * @param PronamicAddress|null $pronamic_address Pronamic address to convert. |
| 27 | 27 | * @return Address |
| 28 | 28 | */ |
| 29 | - public static function transform( PronamicAddress $pronamic_address = null ) { |
|
| 30 | - if ( null === $pronamic_address ) { |
|
| 29 | + public static function transform(PronamicAddress $pronamic_address = null) { |
|
| 30 | + if (null === $pronamic_address) { |
|
| 31 | 31 | return null; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -39,19 +39,19 @@ discard block |
||
| 39 | 39 | $city = $pronamic_address->get_city(); |
| 40 | 40 | $country_code = $pronamic_address->get_country_code(); |
| 41 | 41 | |
| 42 | - if ( ! isset( $last_name, $street, $postal_code, $city, $country_code ) ) { |
|
| 42 | + if ( ! isset($last_name, $street, $postal_code, $city, $country_code)) { |
|
| 43 | 43 | return null; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - $address = new Address( $last_name, $street, $postal_code, $city, $country_code ); |
|
| 46 | + $address = new Address($last_name, $street, $postal_code, $city, $country_code); |
|
| 47 | 47 | |
| 48 | - if ( null !== $name ) { |
|
| 49 | - $address->set_first_name( $name->get_first_name() ); |
|
| 50 | - $address->set_middle_name( $name->get_middle_name() ); |
|
| 48 | + if (null !== $name) { |
|
| 49 | + $address->set_first_name($name->get_first_name()); |
|
| 50 | + $address->set_middle_name($name->get_middle_name()); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $address->set_house_number( $pronamic_address->get_house_number() ); |
|
| 54 | - $address->set_house_number_addition( $pronamic_address->get_house_number_addition() ); |
|
| 53 | + $address->set_house_number($pronamic_address->get_house_number()); |
|
| 54 | + $address->set_house_number_addition($pronamic_address->get_house_number_addition()); |
|
| 55 | 55 | |
| 56 | 56 | return $address; |
| 57 | 57 | } |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | * @param array $fields Fields. |
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | - public static function get_signature_fields_combined( $fields ) { |
|
| 28 | - return implode( ',', $fields ); |
|
| 27 | + public static function get_signature_fields_combined($fields) { |
|
| 28 | + return implode(',', $fields); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -35,24 +35,24 @@ discard block |
||
| 35 | 35 | * @param string $signing_key Signing Key. |
| 36 | 36 | * @return string|null |
| 37 | 37 | */ |
| 38 | - public static function get_signature( Signable $signable, $signing_key ) { |
|
| 38 | + public static function get_signature(Signable $signable, $signing_key) { |
|
| 39 | 39 | $fields = $signable->get_signature_fields(); |
| 40 | 40 | |
| 41 | - if ( empty( $fields ) ) { |
|
| 41 | + if (empty($fields)) { |
|
| 42 | 42 | return null; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if ( empty( $signing_key ) ) { |
|
| 45 | + if (empty($signing_key)) { |
|
| 46 | 46 | return null; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $decoded_signing_key = base64_decode( $signing_key ); |
|
| 49 | + $decoded_signing_key = base64_decode($signing_key); |
|
| 50 | 50 | |
| 51 | - if ( false === $decoded_signing_key ) { |
|
| 51 | + if (false === $decoded_signing_key) { |
|
| 52 | 52 | return null; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $combined = self::get_signature_fields_combined( $fields ); |
|
| 55 | + $combined = self::get_signature_fields_combined($fields); |
|
| 56 | 56 | |
| 57 | 57 | $signature = hash_hmac( |
| 58 | 58 | 'sha512', |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | * @param string $signature_b Signature B. |
| 71 | 71 | * @return bool True if valid, false otherwise. |
| 72 | 72 | */ |
| 73 | - public static function validate_signature( $signature_a, $signature_b ) { |
|
| 74 | - if ( empty( $signature_a ) || empty( $signature_b ) ) { |
|
| 73 | + public static function validate_signature($signature_a, $signature_b) { |
|
| 74 | + if (empty($signature_a) || empty($signature_b)) { |
|
| 75 | 75 | // Empty signature string or null from calculation. |
| 76 | 76 | return false; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - return ( 0 === strcasecmp( $signature_a, $signature_b ) ); |
|
| 79 | + return (0 === strcasecmp($signature_a, $signature_b)); |
|
| 80 | 80 | } |
| 81 | 81 | } |
@@ -40,8 +40,8 @@ |
||
| 40 | 40 | * @param string $type Pronamic payment line type. |
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | - public static function transform( $type ) { |
|
| 44 | - switch ( $type ) { |
|
| 43 | + public static function transform($type) { |
|
| 44 | + switch ($type) { |
|
| 45 | 45 | case PaymentLineType::DIGITAL: |
| 46 | 46 | return self::DIGITAL; |
| 47 | 47 | case PaymentLineType::DISCOUNT: |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @param array $items Order items. |
| 32 | 32 | */ |
| 33 | - public function __construct( $items = null ) { |
|
| 34 | - if ( is_array( $items ) ) { |
|
| 35 | - foreach ( $items as $item ) { |
|
| 36 | - $this->add_item( $item ); |
|
| 33 | + public function __construct($items = null) { |
|
| 34 | + if (is_array($items)) { |
|
| 35 | + foreach ($items as $item) { |
|
| 36 | + $this->add_item($item); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return OrderItem |
| 45 | 45 | */ |
| 46 | - public function new_item( $name, $quantity, Money $amount, $category ) { |
|
| 47 | - $item = new OrderItem( $name, $quantity, $amount, $category ); |
|
| 46 | + public function new_item($name, $quantity, Money $amount, $category) { |
|
| 47 | + $item = new OrderItem($name, $quantity, $amount, $category); |
|
| 48 | 48 | |
| 49 | - $this->add_item( $item ): |
|
| 49 | + $this->add_item($item): |
|
| 50 | 50 | |
| 51 | 51 | return $item; |
| 52 | 52 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @param OrderItem $item Order item. |
| 58 | 58 | */ |
| 59 | - public function add_item( OrderItem $item ) { |
|
| 59 | + public function add_item(OrderItem $item) { |
|
| 60 | 60 | $this->order_items[] = $item; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function get_json() { |
| 78 | 78 | $data = array_map( |
| 79 | - function( $item ) { |
|
| 79 | + function($item) { |
|
| 80 | 80 | return $item->get_json(); |
| 81 | 81 | }, |
| 82 | 82 | $this->get_order_items() |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | * @param array $fields Fields. |
| 92 | 92 | * @return array |
| 93 | 93 | */ |
| 94 | - public function get_signature_fields( $fields = array() ) { |
|
| 95 | - foreach ( $this->get_order_items() as $item ) { |
|
| 96 | - $fields = $item->get_signature_fields( $fields ); |
|
| 94 | + public function get_signature_fields($fields = array()) { |
|
| 95 | + foreach ($this->get_order_items() as $item) { |
|
| 96 | + $fields = $item->get_signature_fields($fields); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | return $fields; |