@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param int|string $poi_id POI ID. |
62 | 62 | * @param string $signature Signature. |
63 | 63 | */ |
64 | - public function __construct( $authentication, $expiry, $event_name, $poi_id, $signature ) { |
|
65 | - parent::__construct( $signature ); |
|
64 | + public function __construct($authentication, $expiry, $event_name, $poi_id, $signature) { |
|
65 | + parent::__construct($signature); |
|
66 | 66 | |
67 | 67 | $this->authentication = $authentication; |
68 | 68 | $this->expiry = $expiry; |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @return bool True if notice authentication token is epxired, false otherwise. |
95 | 95 | */ |
96 | 96 | public function is_expired() { |
97 | - $timestamp = strtotime( $this->get_expiry() ); |
|
97 | + $timestamp = strtotime($this->get_expiry()); |
|
98 | 98 | |
99 | - if ( false === $timestamp ) { |
|
99 | + if (false === $timestamp) { |
|
100 | 100 | return true; |
101 | 101 | } |
102 | 102 | |
@@ -142,25 +142,25 @@ discard block |
||
142 | 142 | * @return Notification |
143 | 143 | * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties. |
144 | 144 | */ |
145 | - public static function from_object( stdClass $object ) { |
|
146 | - if ( ! isset( $object->signature ) ) { |
|
147 | - throw new InvalidArgumentException( 'Object must contain `signature` property.' ); |
|
145 | + public static function from_object(stdClass $object) { |
|
146 | + if ( ! isset($object->signature)) { |
|
147 | + throw new InvalidArgumentException('Object must contain `signature` property.'); |
|
148 | 148 | } |
149 | 149 | |
150 | - if ( ! isset( $object->authentication ) ) { |
|
151 | - throw new InvalidArgumentException( 'Object must contain `authentication` property.' ); |
|
150 | + if ( ! isset($object->authentication)) { |
|
151 | + throw new InvalidArgumentException('Object must contain `authentication` property.'); |
|
152 | 152 | } |
153 | 153 | |
154 | - if ( ! isset( $object->expiry ) ) { |
|
155 | - throw new InvalidArgumentException( 'Object must contain `expiry` property.' ); |
|
154 | + if ( ! isset($object->expiry)) { |
|
155 | + throw new InvalidArgumentException('Object must contain `expiry` property.'); |
|
156 | 156 | } |
157 | 157 | |
158 | - if ( ! isset( $object->eventName ) ) { |
|
159 | - throw new InvalidArgumentException( 'Object must contain `eventName` property.' ); |
|
158 | + if ( ! isset($object->eventName)) { |
|
159 | + throw new InvalidArgumentException('Object must contain `eventName` property.'); |
|
160 | 160 | } |
161 | 161 | |
162 | - if ( ! isset( $object->poiId ) ) { |
|
163 | - throw new InvalidArgumentException( 'Object must contain `poiId` property.' ); |
|
162 | + if ( ! isset($object->poiId)) { |
|
163 | + throw new InvalidArgumentException('Object must contain `poiId` property.'); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | return new self( |
@@ -179,19 +179,19 @@ discard block |
||
179 | 179 | * @return Notification |
180 | 180 | * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. |
181 | 181 | */ |
182 | - public static function from_json( $json ) { |
|
183 | - $data = json_decode( $json ); |
|
182 | + public static function from_json($json) { |
|
183 | + $data = json_decode($json); |
|
184 | 184 | |
185 | 185 | $validator = new Validator(); |
186 | 186 | |
187 | 187 | $validator->validate( |
188 | 188 | $data, |
189 | 189 | (object) array( |
190 | - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/notification.json' ), |
|
190 | + '$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/notification.json'), |
|
191 | 191 | ), |
192 | 192 | Constraint::CHECK_MODE_EXCEPTIONS |
193 | 193 | ); |
194 | 194 | |
195 | - return self::from_object( $data ); |
|
195 | + return self::from_object($data); |
|
196 | 196 | } |
197 | 197 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string $code Code. |
46 | 46 | * @param string $message Message. |
47 | 47 | */ |
48 | - public function __construct( $code, $message ) { |
|
48 | + public function __construct($code, $message) { |
|
49 | 49 | $this->code = $code; |
50 | 50 | $this->message = $message; |
51 | 51 | } |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | * @return Error |
76 | 76 | * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties. |
77 | 77 | */ |
78 | - public static function from_object( stdClass $object ) { |
|
79 | - if ( ! isset( $object->errorCode ) ) { |
|
80 | - throw new InvalidArgumentException( 'Object must contain `errorCode` property.' ); |
|
78 | + public static function from_object(stdClass $object) { |
|
79 | + if ( ! isset($object->errorCode)) { |
|
80 | + throw new InvalidArgumentException('Object must contain `errorCode` property.'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $message = null; |
84 | 84 | |
85 | - if ( isset( $object->errorMessage ) ) { |
|
85 | + if (isset($object->errorMessage)) { |
|
86 | 86 | $message = $object->errorMessage; |
87 | 87 | } |
88 | 88 | |
89 | - if ( isset( $object->consumerMessage ) ) { |
|
89 | + if (isset($object->consumerMessage)) { |
|
90 | 90 | $message = $object->consumerMessage; |
91 | 91 | } |
92 | 92 | |
@@ -103,19 +103,19 @@ discard block |
||
103 | 103 | * @return Error |
104 | 104 | * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. |
105 | 105 | */ |
106 | - public static function from_json( $json ) { |
|
107 | - $data = json_decode( $json ); |
|
106 | + public static function from_json($json) { |
|
107 | + $data = json_decode($json); |
|
108 | 108 | |
109 | 109 | $validator = new Validator(); |
110 | 110 | |
111 | 111 | $validator->validate( |
112 | 112 | $data, |
113 | 113 | (object) array( |
114 | - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/json-schema-error.json' ), |
|
114 | + '$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/json-schema-error.json'), |
|
115 | 115 | ), |
116 | 116 | Constraint::CHECK_MODE_EXCEPTIONS |
117 | 117 | ); |
118 | 118 | |
119 | - return self::from_object( $data ); |
|
119 | + return self::from_object($data); |
|
120 | 120 | } |
121 | 121 | } |
@@ -26,16 +26,16 @@ |
||
26 | 26 | * @param string $post_id Post ID. |
27 | 27 | * @return Config |
28 | 28 | */ |
29 | - public function get_config( $post_id ) { |
|
29 | + public function get_config($post_id) { |
|
30 | 30 | $config = new Config(); |
31 | 31 | |
32 | - $config->post_id = intval( $post_id ); |
|
33 | - $config->mode = $this->get_meta( $post_id, 'mode' ); |
|
34 | - $config->refresh_token = $this->get_meta( $post_id, 'omnikassa_2_refresh_token' ); |
|
35 | - $config->signing_key = $this->get_meta( $post_id, 'omnikassa_2_signing_key' ); |
|
36 | - $config->access_token = $this->get_meta( $post_id, 'omnikassa_2_access_token' ); |
|
37 | - $config->access_token_valid_until = $this->get_meta( $post_id, 'omnikassa_2_access_token_valid_until' ); |
|
38 | - $config->order_id = $this->get_meta( $post_id, 'omnikassa_2_order_id' ); |
|
32 | + $config->post_id = intval($post_id); |
|
33 | + $config->mode = $this->get_meta($post_id, 'mode'); |
|
34 | + $config->refresh_token = $this->get_meta($post_id, 'omnikassa_2_refresh_token'); |
|
35 | + $config->signing_key = $this->get_meta($post_id, 'omnikassa_2_signing_key'); |
|
36 | + $config->access_token = $this->get_meta($post_id, 'omnikassa_2_access_token'); |
|
37 | + $config->access_token_valid_until = $this->get_meta($post_id, 'omnikassa_2_access_token_valid_until'); |
|
38 | + $config->order_id = $this->get_meta($post_id, 'omnikassa_2_order_id'); |
|
39 | 39 | |
40 | 40 | return $config; |
41 | 41 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param string $currency Authentication. |
45 | 45 | * @param int $amount Amount in cents. |
46 | 46 | */ |
47 | - public function __construct( $currency, $amount ) { |
|
47 | + public function __construct($currency, $amount) { |
|
48 | 48 | $this->currency = $currency; |
49 | 49 | $this->amount = $amount; |
50 | 50 | } |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | * @return Money |
87 | 87 | * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties. |
88 | 88 | */ |
89 | - public static function from_object( stdClass $object ) { |
|
90 | - if ( ! isset( $object->currency ) ) { |
|
91 | - throw new InvalidArgumentException( 'Object must contain `currency` property.' ); |
|
89 | + public static function from_object(stdClass $object) { |
|
90 | + if ( ! isset($object->currency)) { |
|
91 | + throw new InvalidArgumentException('Object must contain `currency` property.'); |
|
92 | 92 | } |
93 | 93 | |
94 | - if ( ! isset( $object->amount ) ) { |
|
95 | - throw new InvalidArgumentException( 'Object must contain `amount` property.' ); |
|
94 | + if ( ! isset($object->amount)) { |
|
95 | + throw new InvalidArgumentException('Object must contain `amount` property.'); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return new self( |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | * @return Money |
109 | 109 | * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid. |
110 | 110 | */ |
111 | - public static function from_json( $json ) { |
|
112 | - $data = json_decode( $json ); |
|
111 | + public static function from_json($json) { |
|
112 | + $data = json_decode($json); |
|
113 | 113 | |
114 | 114 | $validator = new Validator(); |
115 | 115 | |
116 | 116 | $validator->validate( |
117 | 117 | $data, |
118 | 118 | (object) array( |
119 | - '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/json-schema-money.json' ), |
|
119 | + '$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/json-schema-money.json'), |
|
120 | 120 | ), |
121 | 121 | Constraint::CHECK_MODE_EXCEPTIONS |
122 | 122 | ); |
123 | 123 | |
124 | - return self::from_object( $data ); |
|
124 | + return self::from_object($data); |
|
125 | 125 | } |
126 | 126 | } |
@@ -113,13 +113,13 @@ |
||
113 | 113 | * |
114 | 114 | * @return string|null |
115 | 115 | */ |
116 | - public static function transform( $payment_method, $default = null ) { |
|
117 | - if ( ! is_scalar( $payment_method ) ) { |
|
116 | + public static function transform($payment_method, $default = null) { |
|
117 | + if ( ! is_scalar($payment_method)) { |
|
118 | 118 | return null; |
119 | 119 | } |
120 | 120 | |
121 | - if ( isset( self::$map[ $payment_method ] ) ) { |
|
122 | - return self::$map[ $payment_method ]; |
|
121 | + if (isset(self::$map[$payment_method])) { |
|
122 | + return self::$map[$payment_method]; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return $default; |
@@ -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 |
@@ -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 | } |