@@ -80,8 +80,8 @@ |
||
| 80 | 80 | * |
| 81 | 81 | * @return string |
| 82 | 82 | */ |
| 83 | - public static function transform( $payment_method ) { |
|
| 84 | - switch ( $payment_method ) { |
|
| 83 | + public static function transform($payment_method) { |
|
| 84 | + switch ($payment_method) { |
|
| 85 | 85 | case Core_PaymentMethods::BANCONTACT: |
| 86 | 86 | return self::BANCONTACT; |
| 87 | 87 | |
@@ -16,37 +16,37 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class Settings extends GatewaySettings { |
| 18 | 18 | public function __construct() { |
| 19 | - add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) ); |
|
| 20 | - add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) ); |
|
| 19 | + add_filter('pronamic_pay_gateway_sections', array($this, 'sections')); |
|
| 20 | + add_filter('pronamic_pay_gateway_fields', array($this, 'fields')); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function sections( array $sections ) { |
|
| 23 | + public function sections(array $sections) { |
|
| 24 | 24 | // iDEAL |
| 25 | 25 | $sections['ems_ecommerce'] = array( |
| 26 | - 'title' => __( 'EMS e-Commerce', 'pronamic_ideal' ), |
|
| 27 | - 'methods' => array( 'ems_ecommerce' ), |
|
| 28 | - 'description' => __( 'Account details are provided by the payment provider after registration. These settings need to match with the payment provider dashboard.', 'pronamic_ideal' ), |
|
| 26 | + 'title' => __('EMS e-Commerce', 'pronamic_ideal'), |
|
| 27 | + 'methods' => array('ems_ecommerce'), |
|
| 28 | + 'description' => __('Account details are provided by the payment provider after registration. These settings need to match with the payment provider dashboard.', 'pronamic_ideal'), |
|
| 29 | 29 | ); |
| 30 | 30 | |
| 31 | 31 | // Advanced |
| 32 | 32 | $sections['ems_ecommerce_advanced'] = array( |
| 33 | - 'title' => __( 'Advanced', 'pronamic_ideal' ), |
|
| 34 | - 'methods' => array( 'ems_ecommerce' ), |
|
| 35 | - 'description' => __( 'Optional settings for advanced usage only.', 'pronamic_ideal' ), |
|
| 33 | + 'title' => __('Advanced', 'pronamic_ideal'), |
|
| 34 | + 'methods' => array('ems_ecommerce'), |
|
| 35 | + 'description' => __('Optional settings for advanced usage only.', 'pronamic_ideal'), |
|
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | 38 | return $sections; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function fields( array $fields ) { |
|
| 41 | + public function fields(array $fields) { |
|
| 42 | 42 | // Storename |
| 43 | 43 | $fields[] = array( |
| 44 | 44 | 'filter' => FILTER_UNSAFE_RAW, |
| 45 | 45 | 'section' => 'ems_ecommerce', |
| 46 | 46 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_storename', |
| 47 | - 'title' => _x( 'Storename', 'ems', 'pronamic_ideal' ), |
|
| 47 | + 'title' => _x('Storename', 'ems', 'pronamic_ideal'), |
|
| 48 | 48 | 'type' => 'text', |
| 49 | - 'classes' => array( 'code' ), |
|
| 49 | + 'classes' => array('code'), |
|
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | 52 | // Shared secret |
@@ -54,19 +54,19 @@ discard block |
||
| 54 | 54 | 'filter' => FILTER_UNSAFE_RAW, |
| 55 | 55 | 'section' => 'ems_ecommerce', |
| 56 | 56 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_secret', |
| 57 | - 'title' => _x( 'Shared Secret', 'ems', 'pronamic_ideal' ), |
|
| 57 | + 'title' => _x('Shared Secret', 'ems', 'pronamic_ideal'), |
|
| 58 | 58 | 'type' => 'text', |
| 59 | - 'classes' => array( 'large-text', 'code' ), |
|
| 59 | + 'classes' => array('large-text', 'code'), |
|
| 60 | 60 | ); |
| 61 | 61 | |
| 62 | 62 | // Transaction feedback |
| 63 | 63 | $fields[] = array( |
| 64 | 64 | 'section' => 'ems_ecommerce', |
| 65 | - 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
| 65 | + 'title' => __('Transaction feedback', 'pronamic_ideal'), |
|
| 66 | 66 | 'type' => 'description', |
| 67 | 67 | 'html' => sprintf( |
| 68 | 68 | '<span class="dashicons dashicons-yes"></span> %s', |
| 69 | - __( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' ) |
|
| 69 | + __('Payment status updates will be processed without any additional configuration.', 'pronamic_ideal') |
|
| 70 | 70 | ), |
| 71 | 71 | ); |
| 72 | 72 | |
@@ -78,23 +78,23 @@ discard block |
||
| 78 | 78 | ), |
| 79 | 79 | 'section' => 'ems_ecommerce_advanced', |
| 80 | 80 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_order_id', |
| 81 | - 'title' => __( 'Order ID', 'pronamic_ideal' ), |
|
| 81 | + 'title' => __('Order ID', 'pronamic_ideal'), |
|
| 82 | 82 | 'type' => 'text', |
| 83 | - 'classes' => array( 'regular-text', 'code' ), |
|
| 83 | + 'classes' => array('regular-text', 'code'), |
|
| 84 | 84 | 'tooltip' => sprintf( |
| 85 | - __( 'The EMS e-Commerce %s parameter.', 'pronamic_ideal' ), |
|
| 86 | - sprintf( '<code>%s</code>', 'orderId' ) |
|
| 85 | + __('The EMS e-Commerce %s parameter.', 'pronamic_ideal'), |
|
| 86 | + sprintf('<code>%s</code>', 'orderId') |
|
| 87 | 87 | ), |
| 88 | 88 | 'description' => sprintf( |
| 89 | 89 | '%s %s<br />%s', |
| 90 | - __( 'Available tags:', 'pronamic_ideal' ), |
|
| 90 | + __('Available tags:', 'pronamic_ideal'), |
|
| 91 | 91 | sprintf( |
| 92 | 92 | '<code>%s</code> <code>%s</code>', |
| 93 | 93 | '{order_id}', |
| 94 | 94 | '{payment_id}' |
| 95 | 95 | ), |
| 96 | 96 | sprintf( |
| 97 | - __( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
|
| 97 | + __('Default: <code>%s</code>', 'pronamic_ideal'), |
|
| 98 | 98 | '{order_id}' |
| 99 | 99 | ) |
| 100 | 100 | ), |
@@ -29,8 +29,8 @@ |
||
| 29 | 29 | * |
| 30 | 30 | * @return null|string |
| 31 | 31 | */ |
| 32 | - public static function transform( $status ) { |
|
| 33 | - switch ( $status ) { |
|
| 32 | + public static function transform($status) { |
|
| 33 | + switch ($status) { |
|
| 34 | 34 | case self::OPEN : |
| 35 | 35 | return Core_Statuses::OPEN; |
| 36 | 36 | |
@@ -20,16 +20,16 @@ |
||
| 20 | 20 | $this->name = 'EMS e-Commerce'; |
| 21 | 21 | $this->product_url = ''; |
| 22 | 22 | $this->dashboard_url = array( |
| 23 | - __( 'test', 'pronamic_ideal' ) => 'https://test.ipg-online.com/vt/login', |
|
| 24 | - __( 'live', 'pronamic_ideal' ) => 'https://www.ipg-online.com/vt/login', |
|
| 23 | + __('test', 'pronamic_ideal') => 'https://test.ipg-online.com/vt/login', |
|
| 24 | + __('live', 'pronamic_ideal') => 'https://www.ipg-online.com/vt/login', |
|
| 25 | 25 | ); |
| 26 | - $this->provider = 'ems'; |
|
| 26 | + $this->provider = 'ems'; |
|
| 27 | 27 | |
| 28 | 28 | // Actions |
| 29 | - $function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
|
| 29 | + $function = array(__NAMESPACE__ . '\Listener', 'listen'); |
|
| 30 | 30 | |
| 31 | - if ( ! has_action( 'wp_loaded', $function ) ) { |
|
| 32 | - add_action( 'wp_loaded', $function ); |
|
| 31 | + if ( ! has_action('wp_loaded', $function)) { |
|
| 32 | + add_action('wp_loaded', $function); |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
@@ -16,24 +16,24 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Listener { |
| 18 | 18 | public static function listen() { |
| 19 | - if ( ! filter_has_var( INPUT_POST, 'ems_notify_payment_id' ) ) { |
|
| 19 | + if ( ! filter_has_var(INPUT_POST, 'ems_notify_payment_id')) { |
|
| 20 | 20 | return; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - $payment_id = filter_input( INPUT_POST, 'ems_notify_payment_id' ); |
|
| 23 | + $payment_id = filter_input(INPUT_POST, 'ems_notify_payment_id'); |
|
| 24 | 24 | |
| 25 | - $payment = get_pronamic_payment( $payment_id ); |
|
| 25 | + $payment = get_pronamic_payment($payment_id); |
|
| 26 | 26 | |
| 27 | 27 | // Add note. |
| 28 | 28 | $note = sprintf( |
| 29 | 29 | /* translators: %s: EMS */ |
| 30 | - __( 'Webhook requested by %s.', 'pronamic_ideal' ), |
|
| 31 | - __( 'EMS', 'pronamic_ideal' ) |
|
| 30 | + __('Webhook requested by %s.', 'pronamic_ideal'), |
|
| 31 | + __('EMS', 'pronamic_ideal') |
|
| 32 | 32 | ); |
| 33 | 33 | |
| 34 | - $payment->add_note( $note ); |
|
| 34 | + $payment->add_note($note); |
|
| 35 | 35 | |
| 36 | 36 | // Update payment. |
| 37 | - Plugin::update_payment( $payment ); |
|
| 37 | + Plugin::update_payment($payment); |
|
| 38 | 38 | } |
| 39 | 39 | } |
@@ -15,13 +15,13 @@ |
||
| 15 | 15 | * @since 1.0.0 |
| 16 | 16 | */ |
| 17 | 17 | class ConfigFactory extends GatewayConfigFactory { |
| 18 | - public function get_config( $post_id ) { |
|
| 18 | + public function get_config($post_id) { |
|
| 19 | 19 | $config = new Config(); |
| 20 | 20 | |
| 21 | - $config->storename = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_storename', true ); |
|
| 22 | - $config->secret = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_secret', true ); |
|
| 23 | - $config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
| 24 | - $config->order_id = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_order_id', true ); |
|
| 21 | + $config->storename = get_post_meta($post_id, '_pronamic_gateway_ems_ecommerce_storename', true); |
|
| 22 | + $config->secret = get_post_meta($post_id, '_pronamic_gateway_ems_ecommerce_secret', true); |
|
| 23 | + $config->mode = get_post_meta($post_id, '_pronamic_gateway_mode', true); |
|
| 24 | + $config->order_id = get_post_meta($post_id, '_pronamic_gateway_ems_ecommerce_order_id', true); |
|
| 25 | 25 | |
| 26 | 26 | return $config; |
| 27 | 27 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * |
| 157 | 157 | * @param string $url Action URL. |
| 158 | 158 | */ |
| 159 | - public function set_action_url( $url ) { |
|
| 159 | + public function set_action_url($url) { |
|
| 160 | 160 | $this->action_url = $url; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @param string $code Currency numeric code. |
| 176 | 176 | */ |
| 177 | - public function set_currency_numeric_code( $code ) { |
|
| 177 | + public function set_currency_numeric_code($code) { |
|
| 178 | 178 | $this->currency_numeric_code = $code; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * |
| 193 | 193 | * @param string $storename Storename. |
| 194 | 194 | */ |
| 195 | - public function set_storename( $storename ) { |
|
| 195 | + public function set_storename($storename) { |
|
| 196 | 196 | $this->storename = $storename; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @param string $return_url Return URL. |
| 214 | 214 | */ |
| 215 | - public function set_return_url( $return_url ) { |
|
| 215 | + public function set_return_url($return_url) { |
|
| 216 | 216 | $this->return_url = $return_url; |
| 217 | 217 | } |
| 218 | 218 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * |
| 231 | 231 | * @param float $amount Amount. |
| 232 | 232 | */ |
| 233 | - public function set_amount( $amount ) { |
|
| 233 | + public function set_amount($amount) { |
|
| 234 | 234 | $this->amount = $amount; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * |
| 249 | 249 | * @param string $notification_url Notification URL. |
| 250 | 250 | */ |
| 251 | - public function set_notification_url( $notification_url ) { |
|
| 251 | + public function set_notification_url($notification_url) { |
|
| 252 | 252 | $this->notification_url = $notification_url; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * |
| 267 | 267 | * @param string $language Language. |
| 268 | 268 | */ |
| 269 | - public function set_language( $language ) { |
|
| 269 | + public function set_language($language) { |
|
| 270 | 270 | $this->language = $language; |
| 271 | 271 | } |
| 272 | 272 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @param string $payment_method Payment method. |
| 277 | 277 | */ |
| 278 | - public function set_payment_method( $payment_method ) { |
|
| 278 | + public function set_payment_method($payment_method) { |
|
| 279 | 279 | $this->payment_method = $payment_method; |
| 280 | 280 | } |
| 281 | 281 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @param string $order_id Order ID. |
| 304 | 304 | */ |
| 305 | - public function set_order_id( $order_id ) { |
|
| 305 | + public function set_order_id($order_id) { |
|
| 306 | 306 | $this->order_id = $order_id; |
| 307 | 307 | } |
| 308 | 308 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | * |
| 321 | 321 | * @param int $payment_id Payment ID. |
| 322 | 322 | */ |
| 323 | - public function set_payment_id( $payment_id ) { |
|
| 323 | + public function set_payment_id($payment_id) { |
|
| 324 | 324 | $this->payment_id = $payment_id; |
| 325 | 325 | } |
| 326 | 326 | |
@@ -331,9 +331,9 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @return DateTime |
| 333 | 333 | */ |
| 334 | - public function get_transaction_datetime( $create_new = false ) { |
|
| 335 | - if ( null === $this->transaction_datetime || $create_new ) { |
|
| 336 | - $this->transaction_datetime = new DateTime( null, new DateTimeZone( 'UTC' ) ); |
|
| 334 | + public function get_transaction_datetime($create_new = false) { |
|
| 335 | + if (null === $this->transaction_datetime || $create_new) { |
|
| 336 | + $this->transaction_datetime = new DateTime(null, new DateTimeZone('UTC')); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | return $this->transaction_datetime; |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * |
| 345 | 345 | * @param DateTime $datetime Transaction date time. |
| 346 | 346 | */ |
| 347 | - public function set_transaction_datetime( DateTime $datetime ) { |
|
| 347 | + public function set_transaction_datetime(DateTime $datetime) { |
|
| 348 | 348 | $this->transaction_datetime = $datetime; |
| 349 | 349 | } |
| 350 | 350 | |
@@ -360,11 +360,11 @@ discard block |
||
| 360 | 360 | // According the EMS documentation the timezone should be in `Area/Location` notation, but it seems like `UTC` is also working. |
| 361 | 361 | 'timezone' => 'UTC', |
| 362 | 362 | // In WordPress, PHP's `time()` will always return `UTC` and is the same as calling `current_time( 'timestamp', true )`. |
| 363 | - 'txndatetime' => $this->get_transaction_datetime()->format( 'Y:m:d-H:i:s' ), |
|
| 363 | + 'txndatetime' => $this->get_transaction_datetime()->format('Y:m:d-H:i:s'), |
|
| 364 | 364 | 'hash_algorithm' => 'SHA256', |
| 365 | 365 | 'storename' => $this->get_storename(), |
| 366 | 366 | 'mode' => 'payonly', |
| 367 | - 'chargetotal' => number_format( ( $this->get_amount() / 100 ), 2, '.', '' ), |
|
| 367 | + 'chargetotal' => number_format(($this->get_amount() / 100), 2, '.', ''), |
|
| 368 | 368 | 'currency' => $this->get_currency_numeric_code(), |
| 369 | 369 | ); |
| 370 | 370 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | ); |
| 382 | 382 | |
| 383 | 383 | // @link http://briancray.com/2009/04/25/remove-null-values-php-arrays/ |
| 384 | - $optional_fields = array_filter( $optional_fields ); |
|
| 384 | + $optional_fields = array_filter($optional_fields); |
|
| 385 | 385 | |
| 386 | 386 | // Data. |
| 387 | 387 | $data = $required_fields + $optional_fields; |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | * |
| 406 | 406 | * @return void |
| 407 | 407 | */ |
| 408 | - public function set_secret( $secret ) { |
|
| 408 | + public function set_secret($secret) { |
|
| 409 | 409 | $this->secret = $secret; |
| 410 | 410 | } |
| 411 | 411 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | $secret, |
| 427 | 427 | ); |
| 428 | 428 | |
| 429 | - return self::compute_hash( $values ); |
|
| 429 | + return self::compute_hash($values); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -436,11 +436,11 @@ discard block |
||
| 436 | 436 | * |
| 437 | 437 | * @return string |
| 438 | 438 | */ |
| 439 | - public static function compute_hash( $values ) { |
|
| 440 | - $value = implode( '', $values ); |
|
| 441 | - $value = bin2hex( $value ); |
|
| 439 | + public static function compute_hash($values) { |
|
| 440 | + $value = implode('', $values); |
|
| 441 | + $value = bin2hex($value); |
|
| 442 | 442 | |
| 443 | - return hash( self::HASH_ALGORITHM_SHA256, $value ); |
|
| 443 | + return hash(self::HASH_ALGORITHM_SHA256, $value); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | /** |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | * |
| 463 | 463 | * @param string $issuer_id Issuer ID. |
| 464 | 464 | */ |
| 465 | - public function set_issuer_id( $issuer_id ) { |
|
| 465 | + public function set_issuer_id($issuer_id) { |
|
| 466 | 466 | $this->issuer_id = $issuer_id; |
| 467 | 467 | } |
| 468 | 468 | |
@@ -30,23 +30,23 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @param Config $config Config. |
| 32 | 32 | */ |
| 33 | - public function __construct( Config $config ) { |
|
| 34 | - parent::__construct( $config ); |
|
| 33 | + public function __construct(Config $config) { |
|
| 34 | + parent::__construct($config); |
|
| 35 | 35 | |
| 36 | - $this->set_method( self::METHOD_HTML_FORM ); |
|
| 36 | + $this->set_method(self::METHOD_HTML_FORM); |
|
| 37 | 37 | |
| 38 | 38 | // Client. |
| 39 | 39 | $this->client = new Client(); |
| 40 | 40 | |
| 41 | 41 | $action_url = Client::ACTION_URL_PRODUCTION; |
| 42 | 42 | |
| 43 | - if ( self::MODE_TEST === $config->mode ) { |
|
| 43 | + if (self::MODE_TEST === $config->mode) { |
|
| 44 | 44 | $action_url = Client::ACTION_URL_TEST; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $this->client->set_action_url( $action_url ); |
|
| 48 | - $this->client->set_storename( $config->storename ); |
|
| 49 | - $this->client->set_secret( $config->secret ); |
|
| 47 | + $this->client->set_action_url($action_url); |
|
| 48 | + $this->client->set_storename($config->storename); |
|
| 49 | + $this->client->set_secret($config->secret); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -70,31 +70,31 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @param Payment $payment Payment. |
| 72 | 72 | */ |
| 73 | - public function start( Payment $payment ) { |
|
| 74 | - $payment->set_action_url( $this->client->get_action_url() ); |
|
| 73 | + public function start(Payment $payment) { |
|
| 74 | + $payment->set_action_url($this->client->get_action_url()); |
|
| 75 | 75 | |
| 76 | - $this->client->set_payment_id( $payment->get_id() ); |
|
| 77 | - $this->client->set_currency_numeric_code( $payment->get_total_amount()->get_currency()->get_numeric_code() ); |
|
| 78 | - $this->client->set_order_id( $payment->format_string( $this->config->order_id ) ); |
|
| 79 | - $this->client->set_return_url( home_url( '/' ) ); |
|
| 80 | - $this->client->set_notification_url( home_url( '/' ) ); |
|
| 81 | - $this->client->set_amount( $payment->get_total_amount()->get_cents() ); |
|
| 82 | - $this->client->set_issuer_id( $payment->get_issuer() ); |
|
| 76 | + $this->client->set_payment_id($payment->get_id()); |
|
| 77 | + $this->client->set_currency_numeric_code($payment->get_total_amount()->get_currency()->get_numeric_code()); |
|
| 78 | + $this->client->set_order_id($payment->format_string($this->config->order_id)); |
|
| 79 | + $this->client->set_return_url(home_url('/')); |
|
| 80 | + $this->client->set_notification_url(home_url('/')); |
|
| 81 | + $this->client->set_amount($payment->get_total_amount()->get_cents()); |
|
| 82 | + $this->client->set_issuer_id($payment->get_issuer()); |
|
| 83 | 83 | |
| 84 | 84 | // Language. |
| 85 | - if ( null !== $payment->get_customer() ) { |
|
| 86 | - $this->client->set_language( $payment->get_customer()->get_locale() ); |
|
| 85 | + if (null !== $payment->get_customer()) { |
|
| 86 | + $this->client->set_language($payment->get_customer()->get_locale()); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Payment method. |
| 90 | - $payment_method = PaymentMethods::transform( $payment->get_method() ); |
|
| 90 | + $payment_method = PaymentMethods::transform($payment->get_method()); |
|
| 91 | 91 | |
| 92 | - if ( null === $payment_method && '' !== $payment->get_method() ) { |
|
| 92 | + if (null === $payment_method && '' !== $payment->get_method()) { |
|
| 93 | 93 | // Leap of faith if the WordPress payment method could not transform to a EMS method? |
| 94 | 94 | $payment_method = $payment->get_method(); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $this->client->set_payment_method( $payment_method ); |
|
| 97 | + $this->client->set_payment_method($payment_method); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -112,40 +112,40 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @param Payment $payment Payment. |
| 114 | 114 | */ |
| 115 | - public function update_status( Payment $payment ) { |
|
| 116 | - $approval_code = filter_input( INPUT_POST, 'approval_code', FILTER_SANITIZE_STRING ); |
|
| 115 | + public function update_status(Payment $payment) { |
|
| 116 | + $approval_code = filter_input(INPUT_POST, 'approval_code', FILTER_SANITIZE_STRING); |
|
| 117 | 117 | |
| 118 | - $input_hash = filter_input( INPUT_POST, 'response_hash' ); |
|
| 118 | + $input_hash = filter_input(INPUT_POST, 'response_hash'); |
|
| 119 | 119 | |
| 120 | 120 | $hash_values = array( |
| 121 | 121 | $this->client->get_secret(), |
| 122 | 122 | $approval_code, |
| 123 | - filter_input( INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING ), |
|
| 124 | - filter_input( INPUT_POST, 'currency', FILTER_SANITIZE_STRING ), |
|
| 125 | - filter_input( INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING ), |
|
| 123 | + filter_input(INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING), |
|
| 124 | + filter_input(INPUT_POST, 'currency', FILTER_SANITIZE_STRING), |
|
| 125 | + filter_input(INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING), |
|
| 126 | 126 | $this->client->get_storename(), |
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | - if ( filter_has_var( INPUT_POST, 'notification_hash' ) ) { |
|
| 130 | - $input_hash = filter_input( INPUT_POST, 'notification_hash' ); |
|
| 129 | + if (filter_has_var(INPUT_POST, 'notification_hash')) { |
|
| 130 | + $input_hash = filter_input(INPUT_POST, 'notification_hash'); |
|
| 131 | 131 | |
| 132 | 132 | $hash_values = array( |
| 133 | - filter_input( INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING ), |
|
| 133 | + filter_input(INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING), |
|
| 134 | 134 | $this->client->get_secret(), |
| 135 | - filter_input( INPUT_POST, 'currency', FILTER_SANITIZE_STRING ), |
|
| 136 | - filter_input( INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING ), |
|
| 135 | + filter_input(INPUT_POST, 'currency', FILTER_SANITIZE_STRING), |
|
| 136 | + filter_input(INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING), |
|
| 137 | 137 | $this->client->get_storename(), |
| 138 | 138 | $approval_code, |
| 139 | 139 | ); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $hash = Client::compute_hash( $hash_values ); |
|
| 142 | + $hash = Client::compute_hash($hash_values); |
|
| 143 | 143 | |
| 144 | 144 | // Check if the posted hash is equal to the calculated response or notification hash. |
| 145 | - if ( 0 === strcasecmp( $input_hash, $hash ) ) { |
|
| 146 | - $response_code = substr( $approval_code, 0, 1 ); |
|
| 145 | + if (0 === strcasecmp($input_hash, $hash)) { |
|
| 146 | + $response_code = substr($approval_code, 0, 1); |
|
| 147 | 147 | |
| 148 | - switch ( $response_code ) { |
|
| 148 | + switch ($response_code) { |
|
| 149 | 149 | case 'Y': |
| 150 | 150 | $status = Statuses::SUCCESS; |
| 151 | 151 | |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | case 'N': |
| 154 | 154 | $status = Statuses::FAILURE; |
| 155 | 155 | |
| 156 | - $fail_code = filter_input( INPUT_POST, 'fail_rc', FILTER_SANITIZE_NUMBER_INT ); |
|
| 156 | + $fail_code = filter_input(INPUT_POST, 'fail_rc', FILTER_SANITIZE_NUMBER_INT); |
|
| 157 | 157 | |
| 158 | - if ( '5993' === $fail_code ) { |
|
| 158 | + if ('5993' === $fail_code) { |
|
| 159 | 159 | $status = Statuses::CANCELLED; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -168,43 +168,43 @@ discard block |
||
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // Set the status of the payment. |
| 171 | - $payment->set_status( $status ); |
|
| 171 | + $payment->set_status($status); |
|
| 172 | 172 | |
| 173 | 173 | $labels = array( |
| 174 | - 'approval_code' => __( 'Approval code', 'pronamic_ideal' ), |
|
| 175 | - 'oid' => __( 'Order ID', 'pronamic_ideal' ), |
|
| 176 | - 'refnumber' => _x( 'Reference number', 'creditcard', 'pronamic_ideal' ), |
|
| 177 | - 'status' => __( 'Status', 'pronamic_ideal' ), |
|
| 178 | - 'txndate_processed' => __( 'Time of transaction processing', 'pronamic_ideal' ), |
|
| 179 | - 'tdate' => __( 'Identification for transaction', 'pronamic_ideal' ), |
|
| 180 | - 'fail_reason' => __( 'Fail reason', 'pronamic_ideal' ), |
|
| 181 | - 'response_hash' => __( 'Response hash', 'pronamic_ideal' ), |
|
| 182 | - 'processor_response_code' => __( 'Processor response code', 'pronamic_ideal' ), |
|
| 183 | - 'fail_rc' => __( 'Fail code', 'pronamic_ideal' ), |
|
| 184 | - 'terminal_id' => __( 'Terminal ID', 'pronamic_ideal' ), |
|
| 185 | - 'ccbin' => __( 'Creditcard issuing bank', 'pronamic_ideal' ), |
|
| 186 | - 'cccountry' => __( 'Creditcard country', 'pronamic_ideal' ), |
|
| 187 | - 'ccbrand' => __( 'Creditcard brand', 'pronamic_ideal' ), |
|
| 174 | + 'approval_code' => __('Approval code', 'pronamic_ideal'), |
|
| 175 | + 'oid' => __('Order ID', 'pronamic_ideal'), |
|
| 176 | + 'refnumber' => _x('Reference number', 'creditcard', 'pronamic_ideal'), |
|
| 177 | + 'status' => __('Status', 'pronamic_ideal'), |
|
| 178 | + 'txndate_processed' => __('Time of transaction processing', 'pronamic_ideal'), |
|
| 179 | + 'tdate' => __('Identification for transaction', 'pronamic_ideal'), |
|
| 180 | + 'fail_reason' => __('Fail reason', 'pronamic_ideal'), |
|
| 181 | + 'response_hash' => __('Response hash', 'pronamic_ideal'), |
|
| 182 | + 'processor_response_code' => __('Processor response code', 'pronamic_ideal'), |
|
| 183 | + 'fail_rc' => __('Fail code', 'pronamic_ideal'), |
|
| 184 | + 'terminal_id' => __('Terminal ID', 'pronamic_ideal'), |
|
| 185 | + 'ccbin' => __('Creditcard issuing bank', 'pronamic_ideal'), |
|
| 186 | + 'cccountry' => __('Creditcard country', 'pronamic_ideal'), |
|
| 187 | + 'ccbrand' => __('Creditcard brand', 'pronamic_ideal'), |
|
| 188 | 188 | ); |
| 189 | 189 | |
| 190 | 190 | $note = ''; |
| 191 | 191 | |
| 192 | 192 | $note .= '<p>'; |
| 193 | - $note .= __( 'EMS e-Commerce transaction data in response message:', 'pronamic_ideal' ); |
|
| 193 | + $note .= __('EMS e-Commerce transaction data in response message:', 'pronamic_ideal'); |
|
| 194 | 194 | $note .= '</p>'; |
| 195 | 195 | |
| 196 | 196 | $note .= '<dl>'; |
| 197 | 197 | |
| 198 | - foreach ( $labels as $key => $label ) { |
|
| 199 | - if ( filter_has_var( INPUT_POST, $key ) ) { |
|
| 200 | - $note .= sprintf( '<dt>%s</dt>', esc_html( $label ) ); |
|
| 201 | - $note .= sprintf( '<dd>%s</dd>', esc_html( filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING ) ) ); |
|
| 198 | + foreach ($labels as $key => $label) { |
|
| 199 | + if (filter_has_var(INPUT_POST, $key)) { |
|
| 200 | + $note .= sprintf('<dt>%s</dt>', esc_html($label)); |
|
| 201 | + $note .= sprintf('<dd>%s</dd>', esc_html(filter_input(INPUT_POST, $key, FILTER_SANITIZE_STRING))); |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | $note .= '</dl>'; |
| 206 | 206 | |
| 207 | - $payment->add_note( $note ); |
|
| 207 | + $payment->add_note($note); |
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | } |