@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | - public static function get_order_id( $order_id, Payment $payment ) { |
|
| 26 | + public static function get_order_id($order_id, Payment $payment) { |
|
| 27 | 27 | // Replacements definition |
| 28 | 28 | $replacements = array( |
| 29 | 29 | '{order_id}' => $payment->get_order_id(), |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | // Find and replace |
| 34 | 34 | $order_id = str_replace( |
| 35 | - array_keys( $replacements ), |
|
| 36 | - array_values( $replacements ), |
|
| 35 | + array_keys($replacements), |
|
| 36 | + array_values($replacements), |
|
| 37 | 37 | $order_id, |
| 38 | 38 | $count |
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | 41 | // Make sure there is an dynamic part in the order ID |
| 42 | - if ( 0 === $count ) { |
|
| 42 | + if (0 === $count) { |
|
| 43 | 43 | $order_id .= $payment->get_order_id(); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -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 | ), |
@@ -15,12 +15,12 @@ |
||
| 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 ); |
|
| 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 | 24 | |
| 25 | 25 | return $config; |
| 26 | 26 | } |
@@ -23,25 +23,25 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @param Config $config |
| 25 | 25 | */ |
| 26 | - public function __construct( Config $config ) { |
|
| 27 | - parent::__construct( $config ); |
|
| 26 | + public function __construct(Config $config) { |
|
| 27 | + parent::__construct($config); |
|
| 28 | 28 | |
| 29 | - $this->set_method( Gateway::METHOD_HTML_FORM ); |
|
| 30 | - $this->set_has_feedback( true ); |
|
| 31 | - $this->set_amount_minimum( 0.01 ); |
|
| 29 | + $this->set_method(Gateway::METHOD_HTML_FORM); |
|
| 30 | + $this->set_has_feedback(true); |
|
| 31 | + $this->set_amount_minimum(0.01); |
|
| 32 | 32 | |
| 33 | 33 | // Client |
| 34 | 34 | $this->client = new Client(); |
| 35 | 35 | |
| 36 | 36 | $action_url = Client::ACTION_URL_PRODUCTION; |
| 37 | 37 | |
| 38 | - if ( Gateway::MODE_TEST === $config->mode ) { |
|
| 38 | + if (Gateway::MODE_TEST === $config->mode) { |
|
| 39 | 39 | $action_url = Client::ACTION_URL_TEST; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $this->client->set_action_url( $action_url ); |
|
| 43 | - $this->client->set_storename( $config->storename ); |
|
| 44 | - $this->client->set_secret( $config->secret ); |
|
| 42 | + $this->client->set_action_url($action_url); |
|
| 43 | + $this->client->set_storename($config->storename); |
|
| 44 | + $this->client->set_secret($config->secret); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -65,26 +65,26 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @param Payment $payment |
| 67 | 67 | */ |
| 68 | - public function start( Payment $payment ) { |
|
| 69 | - $payment->set_action_url( $this->client->get_action_url() ); |
|
| 68 | + public function start(Payment $payment) { |
|
| 69 | + $payment->set_action_url($this->client->get_action_url()); |
|
| 70 | 70 | |
| 71 | - $this->client->set_payment_id( $payment->get_id() ); |
|
| 72 | - $this->client->set_language( $payment->get_locale() ); |
|
| 73 | - $this->client->set_currency_numeric_code( $payment->get_currency_numeric_code() ); |
|
| 74 | - $this->client->set_order_id( Util::get_order_id( $this->config->order_id, $payment ) ); |
|
| 75 | - $this->client->set_return_url( home_url( '/' ) ); |
|
| 76 | - $this->client->set_notification_url( home_url( '/' ) ); |
|
| 77 | - $this->client->set_amount( $payment->get_amount()->get_amount() ); |
|
| 78 | - $this->client->set_issuer_id( $payment->get_issuer() ); |
|
| 71 | + $this->client->set_payment_id($payment->get_id()); |
|
| 72 | + $this->client->set_language($payment->get_locale()); |
|
| 73 | + $this->client->set_currency_numeric_code($payment->get_currency_numeric_code()); |
|
| 74 | + $this->client->set_order_id(Util::get_order_id($this->config->order_id, $payment)); |
|
| 75 | + $this->client->set_return_url(home_url('/')); |
|
| 76 | + $this->client->set_notification_url(home_url('/')); |
|
| 77 | + $this->client->set_amount($payment->get_amount()->get_amount()); |
|
| 78 | + $this->client->set_issuer_id($payment->get_issuer()); |
|
| 79 | 79 | |
| 80 | - $payment_method = PaymentMethods::transform( $payment->get_method() ); |
|
| 80 | + $payment_method = PaymentMethods::transform($payment->get_method()); |
|
| 81 | 81 | |
| 82 | - if ( null === $payment_method && '' !== $payment->get_method() ) { |
|
| 82 | + if (null === $payment_method && '' !== $payment->get_method()) { |
|
| 83 | 83 | // Leap of faith if the WordPress payment method could not transform to a EMS method? |
| 84 | 84 | $payment_method = $payment->get_method(); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $this->client->set_payment_method( $payment_method ); |
|
| 87 | + $this->client->set_payment_method($payment_method); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -102,40 +102,40 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @param Payment $payment |
| 104 | 104 | */ |
| 105 | - public function update_status( Payment $payment ) { |
|
| 106 | - $approval_code = filter_input( INPUT_POST, 'approval_code', FILTER_SANITIZE_STRING ); |
|
| 105 | + public function update_status(Payment $payment) { |
|
| 106 | + $approval_code = filter_input(INPUT_POST, 'approval_code', FILTER_SANITIZE_STRING); |
|
| 107 | 107 | |
| 108 | - $input_hash = filter_input( INPUT_POST, 'response_hash' ); |
|
| 108 | + $input_hash = filter_input(INPUT_POST, 'response_hash'); |
|
| 109 | 109 | |
| 110 | 110 | $hash_values = array( |
| 111 | 111 | $this->client->get_secret(), |
| 112 | 112 | $approval_code, |
| 113 | - filter_input( INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING ), |
|
| 114 | - filter_input( INPUT_POST, 'currency', FILTER_SANITIZE_STRING ), |
|
| 115 | - filter_input( INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING ), |
|
| 113 | + filter_input(INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING), |
|
| 114 | + filter_input(INPUT_POST, 'currency', FILTER_SANITIZE_STRING), |
|
| 115 | + filter_input(INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING), |
|
| 116 | 116 | $this->client->get_storename(), |
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | - if ( filter_has_var( INPUT_POST, 'notification_hash' ) ) { |
|
| 120 | - $input_hash = filter_input( INPUT_POST, 'notification_hash' ); |
|
| 119 | + if (filter_has_var(INPUT_POST, 'notification_hash')) { |
|
| 120 | + $input_hash = filter_input(INPUT_POST, 'notification_hash'); |
|
| 121 | 121 | |
| 122 | 122 | $hash_values = array( |
| 123 | - filter_input( INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING ), |
|
| 123 | + filter_input(INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING), |
|
| 124 | 124 | $this->client->get_secret(), |
| 125 | - filter_input( INPUT_POST, 'currency', FILTER_SANITIZE_STRING ), |
|
| 126 | - filter_input( INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING ), |
|
| 125 | + filter_input(INPUT_POST, 'currency', FILTER_SANITIZE_STRING), |
|
| 126 | + filter_input(INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING), |
|
| 127 | 127 | $this->client->get_storename(), |
| 128 | 128 | $approval_code, |
| 129 | 129 | ); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - $hash = Client::compute_hash( $hash_values ); |
|
| 132 | + $hash = Client::compute_hash($hash_values); |
|
| 133 | 133 | |
| 134 | 134 | // Check if the posted hash is equal to the calculated response or notification hash |
| 135 | - if ( 0 === strcasecmp( $input_hash, $hash ) ) { |
|
| 136 | - $response_code = substr( $approval_code, 0, 1 ); |
|
| 135 | + if (0 === strcasecmp($input_hash, $hash)) { |
|
| 136 | + $response_code = substr($approval_code, 0, 1); |
|
| 137 | 137 | |
| 138 | - switch ( $response_code ) { |
|
| 138 | + switch ($response_code) { |
|
| 139 | 139 | case 'Y' : |
| 140 | 140 | $status = Statuses::SUCCESS; |
| 141 | 141 | |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | case 'N': |
| 144 | 144 | $status = Statuses::FAILURE; |
| 145 | 145 | |
| 146 | - $fail_code = filter_input( INPUT_POST, 'fail_rc', FILTER_SANITIZE_NUMBER_INT ); |
|
| 146 | + $fail_code = filter_input(INPUT_POST, 'fail_rc', FILTER_SANITIZE_NUMBER_INT); |
|
| 147 | 147 | |
| 148 | - if ( '5993' === $fail_code ) { |
|
| 148 | + if ('5993' === $fail_code) { |
|
| 149 | 149 | $status = Statuses::CANCELLED; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -158,43 +158,43 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Set the status of the payment |
| 161 | - $payment->set_status( $status ); |
|
| 161 | + $payment->set_status($status); |
|
| 162 | 162 | |
| 163 | 163 | $labels = array( |
| 164 | - 'approval_code' => __( 'Approval code', 'pronamic_ideal' ), |
|
| 165 | - 'oid' => __( 'Order ID', 'pronamic_ideal' ), |
|
| 166 | - 'refnumber' => _x( 'Reference number', 'creditcard', 'pronamic_ideal' ), |
|
| 167 | - 'status' => __( 'Status', 'pronamic_ideal' ), |
|
| 168 | - 'txndate_processed' => __( 'Time of transaction processing', 'pronamic_ideal' ), |
|
| 169 | - 'tdate' => __( 'Identification for transaction', 'pronamic_ideal' ), |
|
| 170 | - 'fail_reason' => __( 'Fail reason', 'pronamic_ideal' ), |
|
| 171 | - 'response_hash' => __( 'Response hash', 'pronamic_ideal' ), |
|
| 172 | - 'processor_response_code' => __( 'Processor response code', 'pronamic_ideal' ), |
|
| 173 | - 'fail_rc' => __( 'Fail code', 'pronamic_ideal' ), |
|
| 174 | - 'terminal_id' => __( 'Terminal ID', 'pronamic_ideal' ), |
|
| 175 | - 'ccbin' => __( 'Creditcard issuing bank', 'pronamic_ideal' ), |
|
| 176 | - 'cccountry' => __( 'Creditcard country', 'pronamic_ideal' ), |
|
| 177 | - 'ccbrand' => __( 'Creditcard brand', 'pronamic_ideal' ), |
|
| 164 | + 'approval_code' => __('Approval code', 'pronamic_ideal'), |
|
| 165 | + 'oid' => __('Order ID', 'pronamic_ideal'), |
|
| 166 | + 'refnumber' => _x('Reference number', 'creditcard', 'pronamic_ideal'), |
|
| 167 | + 'status' => __('Status', 'pronamic_ideal'), |
|
| 168 | + 'txndate_processed' => __('Time of transaction processing', 'pronamic_ideal'), |
|
| 169 | + 'tdate' => __('Identification for transaction', 'pronamic_ideal'), |
|
| 170 | + 'fail_reason' => __('Fail reason', 'pronamic_ideal'), |
|
| 171 | + 'response_hash' => __('Response hash', 'pronamic_ideal'), |
|
| 172 | + 'processor_response_code' => __('Processor response code', 'pronamic_ideal'), |
|
| 173 | + 'fail_rc' => __('Fail code', 'pronamic_ideal'), |
|
| 174 | + 'terminal_id' => __('Terminal ID', 'pronamic_ideal'), |
|
| 175 | + 'ccbin' => __('Creditcard issuing bank', 'pronamic_ideal'), |
|
| 176 | + 'cccountry' => __('Creditcard country', 'pronamic_ideal'), |
|
| 177 | + 'ccbrand' => __('Creditcard brand', 'pronamic_ideal'), |
|
| 178 | 178 | ); |
| 179 | 179 | |
| 180 | 180 | $note = ''; |
| 181 | 181 | |
| 182 | 182 | $note .= '<p>'; |
| 183 | - $note .= __( 'EMS e-Commerce transaction data in response message:', 'pronamic_ideal' ); |
|
| 183 | + $note .= __('EMS e-Commerce transaction data in response message:', 'pronamic_ideal'); |
|
| 184 | 184 | $note .= '</p>'; |
| 185 | 185 | |
| 186 | 186 | $note .= '<dl>'; |
| 187 | 187 | |
| 188 | - foreach ( $labels as $key => $label ) { |
|
| 189 | - if ( filter_has_var( INPUT_POST, $key ) ) { |
|
| 190 | - $note .= sprintf( '<dt>%s</dt>', esc_html( $label ) ); |
|
| 191 | - $note .= sprintf( '<dd>%s</dd>', esc_html( filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING ) ) ); |
|
| 188 | + foreach ($labels as $key => $label) { |
|
| 189 | + if (filter_has_var(INPUT_POST, $key)) { |
|
| 190 | + $note .= sprintf('<dt>%s</dt>', esc_html($label)); |
|
| 191 | + $note .= sprintf('<dd>%s</dd>', esc_html(filter_input(INPUT_POST, $key, FILTER_SANITIZE_STRING))); |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | $note .= '</dl>'; |
| 196 | 196 | |
| 197 | - $payment->add_note( $note ); |
|
| 197 | + $payment->add_note($note); |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -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 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @param string $url an URL |
| 157 | 157 | */ |
| 158 | - public function set_action_url( $url ) { |
|
| 158 | + public function set_action_url($url) { |
|
| 159 | 159 | $this->action_url = $url; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * |
| 174 | 174 | * @param string $code |
| 175 | 175 | */ |
| 176 | - public function set_currency_numeric_code( $code ) { |
|
| 176 | + public function set_currency_numeric_code($code) { |
|
| 177 | 177 | $this->currency_numeric_code = $code; |
| 178 | 178 | } |
| 179 | 179 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @param string $storename |
| 193 | 193 | */ |
| 194 | - public function set_storename( $storename ) { |
|
| 194 | + public function set_storename($storename) { |
|
| 195 | 195 | $this->storename = $storename; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @param string $return_url |
| 213 | 213 | */ |
| 214 | - public function set_return_url( $return_url ) { |
|
| 214 | + public function set_return_url($return_url) { |
|
| 215 | 215 | $this->return_url = $return_url; |
| 216 | 216 | } |
| 217 | 217 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @return int |
| 231 | 231 | */ |
| 232 | 232 | public function get_formatted_amount() { |
| 233 | - return Util::amount_to_cents( $this->amount ); |
|
| 233 | + return Util::amount_to_cents($this->amount); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @param float $amount |
| 240 | 240 | */ |
| 241 | - public function set_amount( $amount ) { |
|
| 241 | + public function set_amount($amount) { |
|
| 242 | 242 | $this->amount = $amount; |
| 243 | 243 | } |
| 244 | 244 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * |
| 257 | 257 | * @param string $notification_url |
| 258 | 258 | */ |
| 259 | - public function set_notification_url( $notification_url ) { |
|
| 259 | + public function set_notification_url($notification_url) { |
|
| 260 | 260 | $this->notification_url = $notification_url; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @param string $language |
| 276 | 276 | */ |
| 277 | - public function set_language( $language ) { |
|
| 277 | + public function set_language($language) { |
|
| 278 | 278 | $this->language = $language; |
| 279 | 279 | } |
| 280 | 280 | |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * @param string $payment_method |
| 285 | 285 | */ |
| 286 | - public function set_payment_method( $payment_method ) { |
|
| 286 | + public function set_payment_method($payment_method) { |
|
| 287 | 287 | $this->payment_method = $payment_method; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * |
| 311 | 311 | * @param string $order_id |
| 312 | 312 | */ |
| 313 | - public function set_order_id( $order_id ) { |
|
| 313 | + public function set_order_id($order_id) { |
|
| 314 | 314 | $this->order_id = $order_id; |
| 315 | 315 | } |
| 316 | 316 | |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | * |
| 329 | 329 | * @param int $payment_id |
| 330 | 330 | */ |
| 331 | - public function set_payment_id( $payment_id ) { |
|
| 331 | + public function set_payment_id($payment_id) { |
|
| 332 | 332 | $this->payment_id = $payment_id; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -339,15 +339,15 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | * @return |
| 341 | 341 | */ |
| 342 | - public function get_transaction_datetime( $create_new = false ) { |
|
| 343 | - if ( null === $this->transaction_datetime || $create_new ) { |
|
| 344 | - $this->transaction_datetime = new DateTime( null, new DateTimeZone( 'UTC' ) ); |
|
| 342 | + public function get_transaction_datetime($create_new = false) { |
|
| 343 | + if (null === $this->transaction_datetime || $create_new) { |
|
| 344 | + $this->transaction_datetime = new DateTime(null, new DateTimeZone('UTC')); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | return $this->transaction_datetime; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - public function set_transaction_datetime( DateTime $datetime ) { |
|
| 350 | + public function set_transaction_datetime(DateTime $datetime) { |
|
| 351 | 351 | $this->transaction_datetime = $datetime; |
| 352 | 352 | } |
| 353 | 353 | |
@@ -363,11 +363,11 @@ discard block |
||
| 363 | 363 | // According the EMS documentation the timezone should be in `Area/Location` notation, but it seems like `UTC` is also working. |
| 364 | 364 | 'timezone' => 'UTC', |
| 365 | 365 | // In WordPress, PHP's `time()` will always return `UTC` and is the same as calling `current_time( 'timestamp', true )`. |
| 366 | - 'txndatetime' => $this->get_transaction_datetime()->format( 'Y:m:d-H:i:s' ), |
|
| 366 | + 'txndatetime' => $this->get_transaction_datetime()->format('Y:m:d-H:i:s'), |
|
| 367 | 367 | 'hash_algorithm' => 'SHA256', |
| 368 | 368 | 'storename' => $this->get_storename(), |
| 369 | 369 | 'mode' => 'payonly', |
| 370 | - 'chargetotal' => number_format( ( $this->get_formatted_amount() / 100 ), 2, '.', '' ), |
|
| 370 | + 'chargetotal' => number_format(($this->get_formatted_amount() / 100), 2, '.', ''), |
|
| 371 | 371 | 'currency' => $this->get_currency_numeric_code(), |
| 372 | 372 | ); |
| 373 | 373 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | ); |
| 385 | 385 | |
| 386 | 386 | // @see http://briancray.com/2009/04/25/remove-null-values-php-arrays/ |
| 387 | - $optional_fields = array_filter( $optional_fields ); |
|
| 387 | + $optional_fields = array_filter($optional_fields); |
|
| 388 | 388 | |
| 389 | 389 | // Data |
| 390 | 390 | $data = $required_fields + $optional_fields; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * |
| 407 | 407 | * @return string |
| 408 | 408 | */ |
| 409 | - public function set_secret( $secret ) { |
|
| 409 | + public function set_secret($secret) { |
|
| 410 | 410 | $this->secret = $secret; |
| 411 | 411 | } |
| 412 | 412 | |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | $secret, |
| 428 | 428 | ); |
| 429 | 429 | |
| 430 | - return self::compute_hash( $values ); |
|
| 430 | + return self::compute_hash($values); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -437,11 +437,11 @@ discard block |
||
| 437 | 437 | * |
| 438 | 438 | * @return string |
| 439 | 439 | */ |
| 440 | - public static function compute_hash( $values ) { |
|
| 441 | - $value = implode( '', $values ); |
|
| 442 | - $value = bin2hex( $value ); |
|
| 440 | + public static function compute_hash($values) { |
|
| 441 | + $value = implode('', $values); |
|
| 442 | + $value = bin2hex($value); |
|
| 443 | 443 | |
| 444 | - return hash( self::HASH_ALGORITHM_SHA256, $value ); |
|
| 444 | + return hash(self::HASH_ALGORITHM_SHA256, $value); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | return $fields; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - public function set_issuer_id( $issuer_id ) { |
|
| 461 | + public function set_issuer_id($issuer_id) { |
|
| 462 | 462 | $this->issuer_id = $issuer_id; |
| 463 | 463 | } |
| 464 | 464 | |
@@ -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 | } |