@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @param Config $config Config. |
| 36 | 36 | */ |
| 37 | - public function __construct( Config $config ) { |
|
| 38 | - parent::__construct( $config ); |
|
| 37 | + public function __construct(Config $config) { |
|
| 38 | + parent::__construct($config); |
|
| 39 | 39 | |
| 40 | 40 | // Default properties for this gateway. |
| 41 | - $this->set_method( self::METHOD_HTTP_REDIRECT ); |
|
| 42 | - $this->set_slug( 'icepay' ); |
|
| 41 | + $this->set_method(self::METHOD_HTTP_REDIRECT); |
|
| 42 | + $this->set_slug('icepay'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @return bool |
| 51 | 51 | */ |
| 52 | - private function filter_ideal( $method ) { |
|
| 53 | - return is_array( $method ) && isset( $method['PaymentMethodCode'] ) && 'IDEAL' === $method['PaymentMethodCode']; |
|
| 52 | + private function filter_ideal($method) { |
|
| 53 | + return is_array($method) && isset($method['PaymentMethodCode']) && 'IDEAL' === $method['PaymentMethodCode']; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -65,28 +65,28 @@ discard block |
||
| 65 | 65 | try { |
| 66 | 66 | $methods = Icepay_Api_Webservice::getInstance() |
| 67 | 67 | ->paymentmethodService() |
| 68 | - ->setMerchantID( $this->config->merchant_id ) |
|
| 69 | - ->setSecretCode( $this->config->secret_code ) |
|
| 68 | + ->setMerchantID($this->config->merchant_id) |
|
| 69 | + ->setSecretCode($this->config->secret_code) |
|
| 70 | 70 | ->retrieveAllPaymentmethods() |
| 71 | 71 | ->asArray(); |
| 72 | - } catch ( Exception $e ) { |
|
| 72 | + } catch (Exception $e) { |
|
| 73 | 73 | return $groups; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $ideal_methods = array_filter( $methods, array( $this, 'filter_ideal' ) ); |
|
| 76 | + $ideal_methods = array_filter($methods, array($this, 'filter_ideal')); |
|
| 77 | 77 | |
| 78 | - if ( ! empty( $ideal_methods ) ) { |
|
| 78 | + if ( ! empty($ideal_methods)) { |
|
| 79 | 79 | $issuers = Icepay_Api_Webservice::getInstance()->singleMethod() |
| 80 | - ->loadFromArray( $methods ) |
|
| 81 | - ->selectPaymentMethodByCode( 'IDEAL' ) |
|
| 80 | + ->loadFromArray($methods) |
|
| 81 | + ->selectPaymentMethodByCode('IDEAL') |
|
| 82 | 82 | ->getIssuers(); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if ( $issuers ) { |
|
| 85 | + if ($issuers) { |
|
| 86 | 86 | $options = array(); |
| 87 | 87 | |
| 88 | - foreach ( $issuers as $issuer ) { |
|
| 89 | - $options[ $issuer['IssuerKeyword'] ] = $issuer['Description']; |
|
| 88 | + foreach ($issuers as $issuer) { |
|
| 89 | + $options[$issuer['IssuerKeyword']] = $issuer['Description']; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $groups[] = array( |
@@ -108,25 +108,25 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $method = new Icepay_Paymentmethod_Creditcard(); |
| 110 | 110 | |
| 111 | - if ( isset( $method->_issuer ) ) { |
|
| 111 | + if (isset($method->_issuer)) { |
|
| 112 | 112 | $issuers = $method->_issuer; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ( $issuers ) { |
|
| 115 | + if ($issuers) { |
|
| 116 | 116 | $options = array(); |
| 117 | 117 | |
| 118 | - foreach ( $issuers as $issuer ) { |
|
| 119 | - switch ( $issuer ) { |
|
| 118 | + foreach ($issuers as $issuer) { |
|
| 119 | + switch ($issuer) { |
|
| 120 | 120 | case 'AMEX': |
| 121 | - $name = _x( 'AMEX', 'Payment method name', 'pronamic_ideal' ); |
|
| 121 | + $name = _x('AMEX', 'Payment method name', 'pronamic_ideal'); |
|
| 122 | 122 | |
| 123 | 123 | break; |
| 124 | 124 | case 'MASTER': |
| 125 | - $name = _x( 'MASTER', 'Payment method name', 'pronamic_ideal' ); |
|
| 125 | + $name = _x('MASTER', 'Payment method name', 'pronamic_ideal'); |
|
| 126 | 126 | |
| 127 | 127 | break; |
| 128 | 128 | case 'VISA': |
| 129 | - $name = _x( 'VISA', 'Payment method name', 'pronamic_ideal' ); |
|
| 129 | + $name = _x('VISA', 'Payment method name', 'pronamic_ideal'); |
|
| 130 | 130 | |
| 131 | 131 | break; |
| 132 | 132 | default: |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | break; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - $options[ $issuer ] = $name; |
|
| 138 | + $options[$issuer] = $name; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $groups[] = array( |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @param Payment $payment Payment. |
| 169 | 169 | */ |
| 170 | - public function start( Payment $payment ) { |
|
| 170 | + public function start(Payment $payment) { |
|
| 171 | 171 | try { |
| 172 | 172 | /* |
| 173 | 173 | * Order ID |
@@ -182,25 +182,25 @@ discard block |
||
| 182 | 182 | // Payment object. |
| 183 | 183 | $payment_object = new Icepay_PaymentObject(); |
| 184 | 184 | $payment_object |
| 185 | - ->setAmount( $payment->get_total_amount()->get_cents() ) |
|
| 186 | - ->setReference( $payment->get_order_id() ) |
|
| 187 | - ->setDescription( $payment->get_description() ) |
|
| 188 | - ->setCurrency( $payment->get_total_amount()->get_currency()->get_alphabetic_code() ) |
|
| 189 | - ->setIssuer( $payment->get_issuer() ) |
|
| 190 | - ->setOrderID( $payment->format_string( $this->config->order_id ) ); |
|
| 191 | - |
|
| 192 | - if ( null !== $payment->get_customer() ) { |
|
| 185 | + ->setAmount($payment->get_total_amount()->get_cents()) |
|
| 186 | + ->setReference($payment->get_order_id()) |
|
| 187 | + ->setDescription($payment->get_description()) |
|
| 188 | + ->setCurrency($payment->get_total_amount()->get_currency()->get_alphabetic_code()) |
|
| 189 | + ->setIssuer($payment->get_issuer()) |
|
| 190 | + ->setOrderID($payment->format_string($this->config->order_id)); |
|
| 191 | + |
|
| 192 | + if (null !== $payment->get_customer()) { |
|
| 193 | 193 | // Language. |
| 194 | - $language = strtoupper( $payment->get_customer()->get_language() ); |
|
| 194 | + $language = strtoupper($payment->get_customer()->get_language()); |
|
| 195 | 195 | |
| 196 | - $payment_object->setLanguage( $language ); |
|
| 196 | + $payment_object->setLanguage($language); |
|
| 197 | 197 | |
| 198 | 198 | // Country. |
| 199 | 199 | $locale = $payment->get_customer()->get_locale(); |
| 200 | 200 | |
| 201 | - $country = strtoupper( substr( $locale, 3, 2 ) ); |
|
| 201 | + $country = strtoupper(substr($locale, 3, 2)); |
|
| 202 | 202 | |
| 203 | - $payment_object->setCountry( $country ); |
|
| 203 | + $payment_object->setCountry($country); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /* |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | $icepay_method = null; |
| 211 | 211 | |
| 212 | - switch ( $payment->get_method() ) { |
|
| 212 | + switch ($payment->get_method()) { |
|
| 213 | 213 | case PaymentMethods::CREDIT_CARD: |
| 214 | 214 | // @link https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/creditcard.php |
| 215 | 215 | $icepay_method = new Icepay_Paymentmethod_Creditcard(); |
@@ -233,9 +233,9 @@ discard block |
||
| 233 | 233 | break; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if ( isset( $icepay_method ) ) { |
|
| 236 | + if (isset($icepay_method)) { |
|
| 237 | 237 | // @link https://github.com/icepay/icepay/blob/2.4.0/api/icepay_api_base.php#L342-L353 |
| 238 | - $payment_object->setPaymentMethod( $icepay_method->getCode() ); |
|
| 238 | + $payment_object->setPaymentMethod($icepay_method->getCode()); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | // Protocol. |
@@ -244,17 +244,17 @@ discard block |
||
| 244 | 244 | // Basic mode. |
| 245 | 245 | $basicmode = Icepay_Basicmode::getInstance(); |
| 246 | 246 | $basicmode |
| 247 | - ->setMerchantID( $this->config->merchant_id ) |
|
| 248 | - ->setSecretCode( $this->config->secret_code ) |
|
| 249 | - ->setProtocol( $protocol ) |
|
| 250 | - ->setSuccessURL( $payment->get_return_url() ) |
|
| 251 | - ->setErrorURL( $payment->get_return_url() ) |
|
| 252 | - ->validatePayment( $payment_object ); |
|
| 247 | + ->setMerchantID($this->config->merchant_id) |
|
| 248 | + ->setSecretCode($this->config->secret_code) |
|
| 249 | + ->setProtocol($protocol) |
|
| 250 | + ->setSuccessURL($payment->get_return_url()) |
|
| 251 | + ->setErrorURL($payment->get_return_url()) |
|
| 252 | + ->validatePayment($payment_object); |
|
| 253 | 253 | |
| 254 | 254 | // Action URL. |
| 255 | - $payment->set_action_url( $basicmode->getURL() ); |
|
| 256 | - } catch ( Exception $exception ) { |
|
| 257 | - $this->error = new WP_Error( 'icepay_error', $exception->getMessage(), $exception ); |
|
| 255 | + $payment->set_action_url($basicmode->getURL()); |
|
| 256 | + } catch (Exception $exception) { |
|
| 257 | + $this->error = new WP_Error('icepay_error', $exception->getMessage(), $exception); |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
@@ -265,34 +265,34 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @throws Exception |
| 267 | 267 | */ |
| 268 | - public function update_status( Payment $payment ) { |
|
| 268 | + public function update_status(Payment $payment) { |
|
| 269 | 269 | // Get the Icepay Result and set the required fields. |
| 270 | 270 | $result = new Icepay_Result(); |
| 271 | 271 | $result |
| 272 | - ->setMerchantID( $this->config->merchant_id ) |
|
| 273 | - ->setSecretCode( $this->config->secret_code ); |
|
| 272 | + ->setMerchantID($this->config->merchant_id) |
|
| 273 | + ->setSecretCode($this->config->secret_code); |
|
| 274 | 274 | |
| 275 | 275 | try { |
| 276 | 276 | // Determine if the result can be validated. |
| 277 | - if ( $result->validate() ) { |
|
| 277 | + if ($result->validate()) { |
|
| 278 | 278 | // What was the status response. |
| 279 | - switch ( $result->getStatus() ) { |
|
| 279 | + switch ($result->getStatus()) { |
|
| 280 | 280 | case Icepay_StatusCode::SUCCESS: |
| 281 | - $payment->set_status( Statuses::SUCCESS ); |
|
| 281 | + $payment->set_status(Statuses::SUCCESS); |
|
| 282 | 282 | |
| 283 | 283 | break; |
| 284 | 284 | case Icepay_StatusCode::OPEN: |
| 285 | - $payment->set_status( Statuses::OPEN ); |
|
| 285 | + $payment->set_status(Statuses::OPEN); |
|
| 286 | 286 | |
| 287 | 287 | break; |
| 288 | 288 | case Icepay_StatusCode::ERROR: |
| 289 | - $payment->set_status( Statuses::FAILURE ); |
|
| 289 | + $payment->set_status(Statuses::FAILURE); |
|
| 290 | 290 | |
| 291 | 291 | break; |
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | - } catch ( Exception $exception ) { |
|
| 295 | - $this->error = new WP_Error( 'icepay_error', $exception->getMessage(), $exception ); |
|
| 294 | + } catch (Exception $exception) { |
|
| 295 | + $this->error = new WP_Error('icepay_error', $exception->getMessage(), $exception); |
|
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | } |
@@ -30,24 +30,24 @@ |
||
| 30 | 30 | 'Checksum', |
| 31 | 31 | ); |
| 32 | 32 | |
| 33 | - if ( ! Util::input_has_vars( INPUT_GET, $variable_names ) ) { |
|
| 33 | + if ( ! Util::input_has_vars(INPUT_GET, $variable_names)) { |
|
| 34 | 34 | return; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $reference = filter_input( INPUT_GET, 'OrderID', FILTER_SANITIZE_STRING ); |
|
| 37 | + $reference = filter_input(INPUT_GET, 'OrderID', FILTER_SANITIZE_STRING); |
|
| 38 | 38 | |
| 39 | - $payment = get_pronamic_payment( $reference ); |
|
| 39 | + $payment = get_pronamic_payment($reference); |
|
| 40 | 40 | |
| 41 | 41 | // Add note. |
| 42 | 42 | $note = sprintf( |
| 43 | 43 | /* translators: %s: ICEPAY */ |
| 44 | - __( 'Webhook requested by %s.', 'pronamic_ideal' ), |
|
| 45 | - __( 'ICEPAY', 'pronamic_ideal' ) |
|
| 44 | + __('Webhook requested by %s.', 'pronamic_ideal'), |
|
| 45 | + __('ICEPAY', 'pronamic_ideal') |
|
| 46 | 46 | ); |
| 47 | 47 | |
| 48 | - $payment->add_note( $note ); |
|
| 48 | + $payment->add_note($note); |
|
| 49 | 49 | |
| 50 | 50 | // Update payment. |
| 51 | - Plugin::update_payment( $payment ); |
|
| 51 | + Plugin::update_payment($payment); |
|
| 52 | 52 | } |
| 53 | 53 | } |