@@ -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,68 +78,68 @@ 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 | // Shipping address. |
| 88 | 88 | $shipping_address = $payment->get_shipping_address(); |
| 89 | 89 | |
| 90 | - if ( null !== $shipping_address ) { |
|
| 90 | + if (null !== $shipping_address) { |
|
| 91 | 91 | $shipping_detail = new Address(); |
| 92 | 92 | |
| 93 | 93 | $name = $shipping_address->get_name(); |
| 94 | 94 | |
| 95 | - if ( null !== $name ) { |
|
| 96 | - $shipping_detail->set_first_name( $name->get_first_name() ); |
|
| 97 | - $shipping_detail->set_middle_name( $name->get_middle_name() ); |
|
| 98 | - $shipping_detail->set_last_name( $name->get_last_name() ); |
|
| 95 | + if (null !== $name) { |
|
| 96 | + $shipping_detail->set_first_name($name->get_first_name()); |
|
| 97 | + $shipping_detail->set_middle_name($name->get_middle_name()); |
|
| 98 | + $shipping_detail->set_last_name($name->get_last_name()); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $shipping_detail->set_street( $shipping_address->get_street_name() ); |
|
| 102 | - $shipping_detail->set_house_number( $shipping_address->get_house_number() ); |
|
| 103 | - $shipping_detail->set_house_number_addition( $shipping_address->get_house_number_addition() ); |
|
| 104 | - $shipping_detail->set_postal_code( $shipping_address->get_postal_code() ); |
|
| 105 | - $shipping_detail->set_city( $shipping_address->get_city() ); |
|
| 106 | - $shipping_detail->set_country_code( $shipping_address->get_country_code() ); |
|
| 101 | + $shipping_detail->set_street($shipping_address->get_street_name()); |
|
| 102 | + $shipping_detail->set_house_number($shipping_address->get_house_number()); |
|
| 103 | + $shipping_detail->set_house_number_addition($shipping_address->get_house_number_addition()); |
|
| 104 | + $shipping_detail->set_postal_code($shipping_address->get_postal_code()); |
|
| 105 | + $shipping_detail->set_city($shipping_address->get_city()); |
|
| 106 | + $shipping_detail->set_country_code($shipping_address->get_country_code()); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // Billing address. |
| 110 | 110 | $billing_address = $payment->get_billing_address(); |
| 111 | 111 | |
| 112 | - if ( null !== $billing_address ) { |
|
| 112 | + if (null !== $billing_address) { |
|
| 113 | 113 | $billing_detail = new Address(); |
| 114 | 114 | |
| 115 | 115 | $name = $billing_address->get_name(); |
| 116 | 116 | |
| 117 | - if ( null !== $name ) { |
|
| 118 | - $billing_detail->set_first_name( $name->get_first_name() ); |
|
| 119 | - $billing_detail->set_middle_name( $name->get_middle_name() ); |
|
| 120 | - $billing_detail->set_last_name( $name->get_last_name() ); |
|
| 117 | + if (null !== $name) { |
|
| 118 | + $billing_detail->set_first_name($name->get_first_name()); |
|
| 119 | + $billing_detail->set_middle_name($name->get_middle_name()); |
|
| 120 | + $billing_detail->set_last_name($name->get_last_name()); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - $billing_detail->set_street( $billing_address->get_street_name() ); |
|
| 124 | - $billing_detail->set_house_number( $billing_address->get_house_number() ); |
|
| 125 | - $billing_detail->set_house_number_addition( $billing_address->get_house_number_addition() ); |
|
| 126 | - $billing_detail->set_postal_code( $billing_address->get_postal_code() ); |
|
| 127 | - $billing_detail->set_city( $billing_address->get_city() ); |
|
| 128 | - $billing_detail->set_country_code( $billing_address->get_country_code() ); |
|
| 123 | + $billing_detail->set_street($billing_address->get_street_name()); |
|
| 124 | + $billing_detail->set_house_number($billing_address->get_house_number()); |
|
| 125 | + $billing_detail->set_house_number_addition($billing_address->get_house_number_addition()); |
|
| 126 | + $billing_detail->set_postal_code($billing_address->get_postal_code()); |
|
| 127 | + $billing_detail->set_city($billing_address->get_city()); |
|
| 128 | + $billing_detail->set_country_code($billing_address->get_country_code()); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Customer information. |
| 132 | 132 | $customer = $payment->get_customer(); |
| 133 | 133 | |
| 134 | - if ( null !== $customer ) { |
|
| 134 | + if (null !== $customer) { |
|
| 135 | 135 | $customer_information = new CustomerInformation(); |
| 136 | 136 | |
| 137 | - $customer_information->set_email_address( $customer->get_email() ); |
|
| 138 | - $customer_information->set_telephone_number( $customer->get_phone() ); |
|
| 137 | + $customer_information->set_email_address($customer->get_email()); |
|
| 138 | + $customer_information->set_telephone_number($customer->get_phone()); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // Payment brand. |
| 142 | - $payment_brand = PaymentBrands::transform( $payment->get_method() ); |
|
| 142 | + $payment_brand = PaymentBrands::transform($payment->get_method()); |
|
| 143 | 143 | |
| 144 | 144 | // New order. |
| 145 | 145 | $order = new Order( |
@@ -151,47 +151,47 @@ discard block |
||
| 151 | 151 | $payment->get_return_url() |
| 152 | 152 | ); |
| 153 | 153 | |
| 154 | - $order->set_description( $payment->get_description() ); |
|
| 155 | - $order->set_language( $payment->get_customer()->get_language() ); |
|
| 156 | - $order->set_order_items( $payment->get_lines() ); |
|
| 154 | + $order->set_description($payment->get_description()); |
|
| 155 | + $order->set_language($payment->get_customer()->get_language()); |
|
| 156 | + $order->set_order_items($payment->get_lines()); |
|
| 157 | 157 | |
| 158 | - if ( isset( $shipping_detail ) ) { |
|
| 159 | - $order->set_shipping_detail( $shipping_detail ); |
|
| 158 | + if (isset($shipping_detail)) { |
|
| 159 | + $order->set_shipping_detail($shipping_detail); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( isset( $billing_detail ) ) { |
|
| 163 | - $order->set_billing_detail( $billing_detail ); |
|
| 162 | + if (isset($billing_detail)) { |
|
| 163 | + $order->set_billing_detail($billing_detail); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if ( isset( $customer_information ) ) { |
|
| 167 | - $order->set_customer_information( $customer_information ); |
|
| 166 | + if (isset($customer_information)) { |
|
| 167 | + $order->set_customer_information($customer_information); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - $order->set_payment_brand( $payment_brand ); |
|
| 170 | + $order->set_payment_brand($payment_brand); |
|
| 171 | 171 | |
| 172 | - if ( null !== $payment_brand ) { |
|
| 172 | + if (null !== $payment_brand) { |
|
| 173 | 173 | // Payment brand force should only be set if payment brand is not empty. |
| 174 | - $order->set_payment_brand_force( PaymentBrandForce::FORCE_ONCE ); |
|
| 174 | + $order->set_payment_brand_force(PaymentBrandForce::FORCE_ONCE); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // Maybe update access token. |
| 178 | 178 | $this->maybe_update_access_token(); |
| 179 | 179 | |
| 180 | 180 | // Handle errors. |
| 181 | - if ( $this->get_client_error() ) { |
|
| 181 | + if ($this->get_client_error()) { |
|
| 182 | 182 | return; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // Announce order. |
| 186 | - $result = $this->client->order_announce( $this->config, $order ); |
|
| 186 | + $result = $this->client->order_announce($this->config, $order); |
|
| 187 | 187 | |
| 188 | 188 | // Handle errors. |
| 189 | - if ( $this->get_client_error() ) { |
|
| 189 | + if ($this->get_client_error()) { |
|
| 190 | 190 | return; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if ( $result ) { |
|
| 194 | - $payment->set_action_url( $result->redirectUrl ); |
|
| 193 | + if ($result) { |
|
| 194 | + $payment->set_action_url($result->redirectUrl); |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
@@ -200,45 +200,45 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @param Payment $payment Payment. |
| 202 | 202 | */ |
| 203 | - public function update_status( Payment $payment ) { |
|
| 204 | - if ( ! ReturnParameters::contains( $_GET ) ) { // WPCS: CSRF ok. |
|
| 203 | + public function update_status(Payment $payment) { |
|
| 204 | + if ( ! ReturnParameters::contains($_GET)) { // WPCS: CSRF ok. |
|
| 205 | 205 | return; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - $parameters = ReturnParameters::from_array( $_GET ); // WPCS: CSRF ok. |
|
| 208 | + $parameters = ReturnParameters::from_array($_GET); // WPCS: CSRF ok. |
|
| 209 | 209 | |
| 210 | 210 | // Note. |
| 211 | 211 | $note_values = array( |
| 212 | 212 | 'order_id' => $parameters->get_order_id(), |
| 213 | 213 | 'status' => $parameters->get_status(), |
| 214 | 214 | 'signature' => $parameters->get_signature(), |
| 215 | - 'valid' => $parameters->is_valid( $this->config->signing_key ) ? 'true' : 'false', |
|
| 215 | + 'valid' => $parameters->is_valid($this->config->signing_key) ? 'true' : 'false', |
|
| 216 | 216 | ); |
| 217 | 217 | |
| 218 | 218 | $note = ''; |
| 219 | 219 | |
| 220 | 220 | $note .= '<p>'; |
| 221 | - $note .= __( 'OmniKassa 2.0 return URL requested:', 'pronamic_ideal' ); |
|
| 221 | + $note .= __('OmniKassa 2.0 return URL requested:', 'pronamic_ideal'); |
|
| 222 | 222 | $note .= '</p>'; |
| 223 | 223 | |
| 224 | 224 | $note .= '<dl>'; |
| 225 | 225 | |
| 226 | - foreach ( $note_values as $key => $value ) { |
|
| 227 | - $note .= sprintf( '<dt>%s</dt>', esc_html( $key ) ); |
|
| 228 | - $note .= sprintf( '<dd>%s</dd>', esc_html( $value ) ); |
|
| 226 | + foreach ($note_values as $key => $value) { |
|
| 227 | + $note .= sprintf('<dt>%s</dt>', esc_html($key)); |
|
| 228 | + $note .= sprintf('<dd>%s</dd>', esc_html($value)); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | $note .= '</dl>'; |
| 232 | 232 | |
| 233 | - $payment->add_note( $note ); |
|
| 233 | + $payment->add_note($note); |
|
| 234 | 234 | |
| 235 | 235 | // Validate. |
| 236 | - if ( ! $parameters->is_valid( $this->config->signing_key ) ) { |
|
| 236 | + if ( ! $parameters->is_valid($this->config->signing_key)) { |
|
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // Status. |
| 241 | - $payment->set_status( Statuses::transform( $parameters->get_status() ) ); |
|
| 241 | + $payment->set_status(Statuses::transform($parameters->get_status())); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -248,14 +248,14 @@ discard block |
||
| 248 | 248 | * |
| 249 | 249 | * @return void |
| 250 | 250 | */ |
| 251 | - public function handle_notification( Notification $notification ) { |
|
| 252 | - if ( ! $notification->is_valid( $this->config->signing_key ) ) { |
|
| 251 | + public function handle_notification(Notification $notification) { |
|
| 252 | + if ( ! $notification->is_valid($this->config->signing_key)) { |
|
| 253 | 253 | return; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - switch ( $notification->get_event_name() ) { |
|
| 256 | + switch ($notification->get_event_name()) { |
|
| 257 | 257 | case 'merchant.order.status.changed': |
| 258 | - $this->handle_merchant_order_status_changed( $notification ); |
|
| 258 | + $this->handle_merchant_order_status_changed($notification); |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | |
@@ -266,39 +266,39 @@ discard block |
||
| 266 | 266 | * |
| 267 | 267 | * @return void |
| 268 | 268 | */ |
| 269 | - private function handle_merchant_order_status_changed( Notification $notification ) { |
|
| 269 | + private function handle_merchant_order_status_changed(Notification $notification) { |
|
| 270 | 270 | do { |
| 271 | - $order_results = $this->client->get_order_results( $notification->get_authentication() ); |
|
| 271 | + $order_results = $this->client->get_order_results($notification->get_authentication()); |
|
| 272 | 272 | |
| 273 | - if ( ! $order_results || $order_results->is_valid( $this->config->signing_key ) ) { |
|
| 273 | + if ( ! $order_results || $order_results->is_valid($this->config->signing_key)) { |
|
| 274 | 274 | return; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - foreach ( $order_results as $order_result ) { |
|
| 278 | - $payment = get_pronamic_payment_by_meta( '_pronamic_payment_omnikassa_2_merchant_order_id', $order_result->get_merchant_order_id() ); |
|
| 277 | + foreach ($order_results as $order_result) { |
|
| 278 | + $payment = get_pronamic_payment_by_meta('_pronamic_payment_omnikassa_2_merchant_order_id', $order_result->get_merchant_order_id()); |
|
| 279 | 279 | |
| 280 | - if ( empty( $payment ) ) { |
|
| 280 | + if (empty($payment)) { |
|
| 281 | 281 | continue; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - $payment->set_transaction_id( $order_result->get_omnikassa_order_id() ); |
|
| 285 | - $payment->set_status( Statuses::transform( $order_result->get_order_status() ) ); |
|
| 284 | + $payment->set_transaction_id($order_result->get_omnikassa_order_id()); |
|
| 285 | + $payment->set_status(Statuses::transform($order_result->get_order_status())); |
|
| 286 | 286 | |
| 287 | 287 | // Note. |
| 288 | 288 | $note = ''; |
| 289 | 289 | |
| 290 | 290 | $note .= '<p>'; |
| 291 | - $note .= __( 'OmniKassa 2.0 webhook URL requested:', 'pronamic_ideal' ); |
|
| 291 | + $note .= __('OmniKassa 2.0 webhook URL requested:', 'pronamic_ideal'); |
|
| 292 | 292 | $note .= '</p>'; |
| 293 | 293 | $note .= '<pre>'; |
| 294 | - $note .= wp_json_encode( $order_result->get_json(), JSON_PRETTY_PRINT ); |
|
| 294 | + $note .= wp_json_encode($order_result->get_json(), JSON_PRETTY_PRINT); |
|
| 295 | 295 | $note .= '</pre>'; |
| 296 | 296 | |
| 297 | - $payment->add_note( $note ); |
|
| 297 | + $payment->add_note($note); |
|
| 298 | 298 | |
| 299 | 299 | $payment->save(); |
| 300 | 300 | } |
| 301 | - } while ( $order_results->more_available() ); |
|
| 301 | + } while ($order_results->more_available()); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -307,20 +307,20 @@ discard block |
||
| 307 | 307 | * @return void |
| 308 | 308 | */ |
| 309 | 309 | private function maybe_update_access_token() { |
| 310 | - if ( $this->config->is_access_token_valid() ) { |
|
| 310 | + if ($this->config->is_access_token_valid()) { |
|
| 311 | 311 | return; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | $data = $this->client->get_access_token_data(); |
| 315 | 315 | |
| 316 | - if ( ! is_object( $data ) ) { |
|
| 316 | + if ( ! is_object($data)) { |
|
| 317 | 317 | return; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | $this->config->access_token = $data->token; |
| 321 | 321 | $this->config->access_token_valid_until = $data->validUntil; |
| 322 | 322 | |
| 323 | - update_post_meta( $this->config->post_id, '_pronamic_gateway_omnikassa_2_access_token', $data->token ); |
|
| 323 | + update_post_meta($this->config->post_id, '_pronamic_gateway_omnikassa_2_access_token', $data->token); |
|
| 324 | 324 | update_post_meta( |
| 325 | 325 | $this->config->post_id, |
| 326 | 326 | '_pronamic_gateway_omnikassa_2_access_token_valid_until', |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | private function get_client_error() { |
| 337 | 337 | $error = $this->client->get_error(); |
| 338 | 338 | |
| 339 | - if ( is_wp_error( $error ) ) { |
|
| 339 | + if (is_wp_error($error)) { |
|
| 340 | 340 | $this->error = $error; |
| 341 | 341 | |
| 342 | 342 | return $error; |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | * @param Money $amount Amount. |
| 154 | 154 | * @param string $merchant_return_url Merchant return URL. |
| 155 | 155 | */ |
| 156 | - public function __construct( $merchant_order_id, $amount, $merchant_return_url ) { |
|
| 157 | - $this->timestamp = date( DATE_ATOM ); |
|
| 156 | + public function __construct($merchant_order_id, $amount, $merchant_return_url) { |
|
| 157 | + $this->timestamp = date(DATE_ATOM); |
|
| 158 | 158 | $this->merchant_order_id = $merchant_order_id; |
| 159 | 159 | $this->amount = $amount; |
| 160 | 160 | $this->merchant_return_url = $merchant_return_url; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @param string $description Description. |
| 167 | 167 | */ |
| 168 | - public function set_description( $description ) { |
|
| 168 | + public function set_description($description) { |
|
| 169 | 169 | $this->description = $description; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @param string $language Language. |
| 176 | 176 | */ |
| 177 | - public function set_language( $language ) { |
|
| 177 | + public function set_language($language) { |
|
| 178 | 178 | $this->language = $language; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @param string|null $payment_brand Payment brand. |
| 185 | 185 | */ |
| 186 | - public function set_payment_brand( $payment_brand ) { |
|
| 186 | + public function set_payment_brand($payment_brand) { |
|
| 187 | 187 | $this->payment_brand = $payment_brand; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * |
| 193 | 193 | * @param string $payment_brand_force Payment brand force. |
| 194 | 194 | */ |
| 195 | - public function set_payment_brand_force( $payment_brand_force ) { |
|
| 195 | + public function set_payment_brand_force($payment_brand_force) { |
|
| 196 | 196 | $this->payment_brand_force = $payment_brand_force; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @return void |
| 205 | 205 | */ |
| 206 | - public function set_order_items( PaymentLines $payment_lines ) { |
|
| 206 | + public function set_order_items(PaymentLines $payment_lines) { |
|
| 207 | 207 | $order_items = new OrderItems(); |
| 208 | 208 | |
| 209 | - foreach ( $payment_lines as $line ) { |
|
| 209 | + foreach ($payment_lines as $line) { |
|
| 210 | 210 | // New order item. |
| 211 | 211 | $order_item = new OrderItem( |
| 212 | 212 | array( |
@@ -215,14 +215,14 @@ discard block |
||
| 215 | 215 | 'quantity' => $line->get_quantity(), |
| 216 | 216 | 'amount' => new Money( |
| 217 | 217 | $line->get_total_amount()->get_currency()->get_alphabetic_code(), |
| 218 | - intval( $line->get_total_amount()->get_cents() ) |
|
| 218 | + intval($line->get_total_amount()->get_cents()) |
|
| 219 | 219 | ), |
| 220 | 220 | 'category' => $line->get_type(), |
| 221 | 221 | ) |
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | 224 | // Add order item. |
| 225 | - $order_items->add_item( $order_item ); |
|
| 225 | + $order_items->add_item($order_item); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | $this->order_items = $order_items; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @param Address $shipping_detail Shipping address details. |
| 235 | 235 | */ |
| 236 | - public function set_shipping_detail( Address $shipping_detail ) { |
|
| 236 | + public function set_shipping_detail(Address $shipping_detail) { |
|
| 237 | 237 | $this->shipping_detail = $shipping_detail; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @param Address $billing_detail Billing address details. |
| 244 | 244 | */ |
| 245 | - public function set_billing_detail( Address $billing_detail ) { |
|
| 245 | + public function set_billing_detail(Address $billing_detail) { |
|
| 246 | 246 | $this->billing_detail = $billing_detail; |
| 247 | 247 | } |
| 248 | 248 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @param CustomerInformation $customer_information Customer information. |
| 253 | 253 | */ |
| 254 | - public function set_customer_information( CustomerInformation $customer_information ) { |
|
| 254 | + public function set_customer_information(CustomerInformation $customer_information) { |
|
| 255 | 255 | $this->customer_information = $customer_information; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -267,21 +267,21 @@ discard block |
||
| 267 | 267 | 'description' => $this->description, |
| 268 | 268 | ); |
| 269 | 269 | |
| 270 | - if ( null !== $this->order_items ) { |
|
| 270 | + if (null !== $this->order_items) { |
|
| 271 | 271 | $data['orderItems'] = $this->order_items->get_json(); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | $data['amount'] = $this->amount->get_json(); |
| 275 | 275 | |
| 276 | - if ( null !== $this->shipping_detail ) { |
|
| 276 | + if (null !== $this->shipping_detail) { |
|
| 277 | 277 | $data['shippingDetail'] = $this->shipping_detail->get_json(); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if ( null !== $this->billing_detail ) { |
|
| 280 | + if (null !== $this->billing_detail) { |
|
| 281 | 281 | $data['billingDetail'] = $this->billing_detail->get_json(); |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if ( null !== $this->customer_information ) { |
|
| 284 | + if (null !== $this->customer_information) { |
|
| 285 | 285 | $data['customerInformation'] = $this->customer_information->get_json(); |
| 286 | 286 | } |
| 287 | 287 | |
@@ -313,28 +313,28 @@ discard block |
||
| 313 | 313 | // Optional fields. |
| 314 | 314 | $optional = array(); |
| 315 | 315 | |
| 316 | - if ( null !== $this->order_items ) { |
|
| 316 | + if (null !== $this->order_items) { |
|
| 317 | 317 | $optional['order_items'] = $this->order_items->get_signature_data(); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ( null !== $this->shipping_detail ) { |
|
| 320 | + if (null !== $this->shipping_detail) { |
|
| 321 | 321 | $optional['shipping_detail'] = $this->shipping_detail->get_signature_data(); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | $optional['payment_brand'] = $this->payment_brand; |
| 325 | 325 | $optional['payment_brand_force'] = $this->payment_brand_force; |
| 326 | 326 | |
| 327 | - if ( null !== $this->customer_information ) { |
|
| 327 | + if (null !== $this->customer_information) { |
|
| 328 | 328 | $optional['customer_information'] = $this->customer_information->get_signature_data(); |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - if ( null !== $this->billing_detail ) { |
|
| 331 | + if (null !== $this->billing_detail) { |
|
| 332 | 332 | $optional['billing_detail'] = $this->billing_detail->get_signature_data(); |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | // Remove empty optional fields. |
| 336 | - $optional = array_filter( $optional ); |
|
| 336 | + $optional = array_filter($optional); |
|
| 337 | 337 | |
| 338 | - return array_merge( $fields, $optional ); |
|
| 338 | + return array_merge($fields, $optional); |
|
| 339 | 339 | } |
| 340 | 340 | } |