@@ -22,21 +22,21 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @param Config $config |
| 24 | 24 | */ |
| 25 | - public function __construct( Config $config ) { |
|
| 26 | - parent::__construct( $config ); |
|
| 25 | + public function __construct(Config $config) { |
|
| 26 | + parent::__construct($config); |
|
| 27 | 27 | |
| 28 | 28 | $this->supports = array( |
| 29 | 29 | 'payment_status_request', |
| 30 | 30 | ); |
| 31 | 31 | |
| 32 | - $this->set_method( Gateway::METHOD_HTTP_REDIRECT ); |
|
| 33 | - $this->set_has_feedback( true ); |
|
| 34 | - $this->set_amount_minimum( 0.01 ); |
|
| 32 | + $this->set_method(Gateway::METHOD_HTTP_REDIRECT); |
|
| 33 | + $this->set_has_feedback(true); |
|
| 34 | + $this->set_amount_minimum(0.01); |
|
| 35 | 35 | |
| 36 | 36 | // Client |
| 37 | 37 | $client = new Client(); |
| 38 | 38 | |
| 39 | - $client->set_acquirer_url( $config->get_payment_server_url() ); |
|
| 39 | + $client->set_acquirer_url($config->get_payment_server_url()); |
|
| 40 | 40 | |
| 41 | 41 | $client->merchant_id = $config->merchant_id; |
| 42 | 42 | $client->sub_id = $config->sub_id; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | public function get_issuers() { |
| 58 | 58 | $directory = $this->client->get_directory(); |
| 59 | 59 | |
| 60 | - if ( ! $directory ) { |
|
| 60 | + if ( ! $directory) { |
|
| 61 | 61 | $this->error = $this->client->get_error(); |
| 62 | 62 | |
| 63 | 63 | return array(); |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $groups = array(); |
| 67 | 67 | |
| 68 | - foreach ( $directory->get_countries() as $country ) { |
|
| 68 | + foreach ($directory->get_countries() as $country) { |
|
| 69 | 69 | $issuers = array(); |
| 70 | 70 | |
| 71 | - foreach ( $country->get_issuers() as $issuer ) { |
|
| 72 | - $issuers[ $issuer->get_id() ] = $issuer->get_name(); |
|
| 71 | + foreach ($country->get_issuers() as $issuer) { |
|
| 72 | + $issuers[$issuer->get_id()] = $issuer->get_name(); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $groups[] = array( |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | public function get_issuer_field() { |
| 85 | - if ( PaymentMethods::IDEAL === $this->get_payment_method() ) { |
|
| 85 | + if (PaymentMethods::IDEAL === $this->get_payment_method()) { |
|
| 86 | 86 | return array( |
| 87 | 87 | 'id' => 'pronamic_ideal_issuer_id', |
| 88 | 88 | 'name' => 'pronamic_ideal_issuer_id', |
| 89 | - 'label' => __( 'Choose your bank', 'pronamic_ideal' ), |
|
| 89 | + 'label' => __('Choose your bank', 'pronamic_ideal'), |
|
| 90 | 90 | 'required' => true, |
| 91 | 91 | 'type' => 'select', |
| 92 | 92 | 'choices' => $this->get_transient_issuers(), |
@@ -120,34 +120,34 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @see Pronamic_WP_Pay_Gateway::start() |
| 122 | 122 | */ |
| 123 | - public function start( Payment $payment ) { |
|
| 123 | + public function start(Payment $payment) { |
|
| 124 | 124 | // Purchase ID |
| 125 | - $purchase_id = $payment->format_string( $this->config->purchase_id ); |
|
| 125 | + $purchase_id = $payment->format_string($this->config->purchase_id); |
|
| 126 | 126 | |
| 127 | - $payment->set_meta( 'purchase_id', $purchase_id ); |
|
| 127 | + $payment->set_meta('purchase_id', $purchase_id); |
|
| 128 | 128 | |
| 129 | 129 | // Transaction |
| 130 | 130 | $transaction = new Transaction(); |
| 131 | - $transaction->set_purchase_id( $purchase_id ); |
|
| 132 | - $transaction->set_amount( $payment->get_amount()->get_amount() ); |
|
| 133 | - $transaction->set_currency( $payment->get_currency() ); |
|
| 134 | - $transaction->set_expiration_period( 'PT30M' ); |
|
| 135 | - $transaction->set_language( $payment->get_language() ); |
|
| 136 | - $transaction->set_description( $payment->get_description() ); |
|
| 137 | - $transaction->set_entrance_code( $payment->get_entrance_code() ); |
|
| 131 | + $transaction->set_purchase_id($purchase_id); |
|
| 132 | + $transaction->set_amount($payment->get_amount()->get_amount()); |
|
| 133 | + $transaction->set_currency($payment->get_currency()); |
|
| 134 | + $transaction->set_expiration_period('PT30M'); |
|
| 135 | + $transaction->set_language($payment->get_language()); |
|
| 136 | + $transaction->set_description($payment->get_description()); |
|
| 137 | + $transaction->set_entrance_code($payment->get_entrance_code()); |
|
| 138 | 138 | |
| 139 | - $result = $this->client->create_transaction( $transaction, $payment->get_return_url(), $payment->get_issuer() ); |
|
| 139 | + $result = $this->client->create_transaction($transaction, $payment->get_return_url(), $payment->get_issuer()); |
|
| 140 | 140 | |
| 141 | 141 | $error = $this->client->get_error(); |
| 142 | 142 | |
| 143 | - if ( is_wp_error( $error ) ) { |
|
| 144 | - $this->set_error( $error ); |
|
| 143 | + if (is_wp_error($error)) { |
|
| 144 | + $this->set_error($error); |
|
| 145 | 145 | |
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $payment->set_action_url( $result->issuer->get_authentication_url() ); |
|
| 150 | - $payment->set_transaction_id( $result->transaction->get_id() ); |
|
| 149 | + $payment->set_action_url($result->issuer->get_authentication_url()); |
|
| 150 | + $payment->set_transaction_id($result->transaction->get_id()); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -155,20 +155,20 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @param Payment $payment |
| 157 | 157 | */ |
| 158 | - public function update_status( Payment $payment ) { |
|
| 159 | - $result = $this->client->get_status( $payment->get_transaction_id() ); |
|
| 158 | + public function update_status(Payment $payment) { |
|
| 159 | + $result = $this->client->get_status($payment->get_transaction_id()); |
|
| 160 | 160 | |
| 161 | 161 | $error = $this->client->get_error(); |
| 162 | 162 | |
| 163 | - if ( is_wp_error( $error ) ) { |
|
| 164 | - $this->set_error( $error ); |
|
| 163 | + if (is_wp_error($error)) { |
|
| 164 | + $this->set_error($error); |
|
| 165 | 165 | } else { |
| 166 | 166 | $transaction = $result->transaction; |
| 167 | 167 | |
| 168 | - $payment->set_status( $transaction->get_status() ); |
|
| 169 | - $payment->set_consumer_name( $transaction->get_consumer_name() ); |
|
| 170 | - $payment->set_consumer_iban( $transaction->get_consumer_iban() ); |
|
| 171 | - $payment->set_consumer_bic( $transaction->get_consumer_bic() ); |
|
| 168 | + $payment->set_status($transaction->get_status()); |
|
| 169 | + $payment->set_consumer_name($transaction->get_consumer_name()); |
|
| 170 | + $payment->set_consumer_iban($transaction->get_consumer_iban()); |
|
| 171 | + $payment->set_consumer_bic($transaction->get_consumer_bic()); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @param string $id |
| 56 | 56 | */ |
| 57 | - public function set_id( $id ) { |
|
| 57 | + public function set_id($id) { |
|
| 58 | 58 | $this->id = $id; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param string $name |
| 74 | 74 | */ |
| 75 | - public function set_name( $name ) { |
|
| 75 | + public function set_name($name) { |
|
| 76 | 76 | $this->name = $name; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param string $authentication_url |
| 92 | 92 | */ |
| 93 | - public function set_authentication_url( $authentication_url ) { |
|
| 93 | + public function set_authentication_url($authentication_url) { |
|
| 94 | 94 | $this->authentication_url = $authentication_url; |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @param string $name |
| 49 | 49 | */ |
| 50 | - public function set_name( $name ) { |
|
| 50 | + public function set_name($name) { |
|
| 51 | 51 | $this->name = $name; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @param Issuer $issuer |
| 58 | 58 | */ |
| 59 | - public function add_issuer( Issuer $issuer ) { |
|
| 59 | + public function add_issuer(Issuer $issuer) { |
|
| 60 | 60 | $this->issuers[] = $issuer; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param DateTime $date |
| 42 | 42 | */ |
| 43 | - public function set_date( DateTime $date ) { |
|
| 43 | + public function set_date(DateTime $date) { |
|
| 44 | 44 | $this->date = $date; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @param Country $country |
| 51 | 51 | */ |
| 52 | - public function add_country( Country $country ) { |
|
| 52 | + public function add_country(Country $country) { |
|
| 53 | 53 | $this->countries[] = $country; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -16,25 +16,25 @@ |
||
| 16 | 16 | class ConfigFactory extends GatewayConfigFactory { |
| 17 | 17 | private $config_class; |
| 18 | 18 | |
| 19 | - public function __construct( $config_class = 'Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Config', $config_test_class = 'Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Config' ) { |
|
| 19 | + public function __construct($config_class = 'Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Config', $config_test_class = 'Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Config') { |
|
| 20 | 20 | $this->config_class = $config_class; |
| 21 | 21 | $this->config_test_class = $config_test_class; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function get_config( $post_id ) { |
|
| 25 | - $mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
| 24 | + public function get_config($post_id) { |
|
| 25 | + $mode = get_post_meta($post_id, '_pronamic_gateway_mode', true); |
|
| 26 | 26 | |
| 27 | - $config_class = ( 'test' === $mode ) ? $this->config_test_class : $this->config_class; |
|
| 27 | + $config_class = ('test' === $mode) ? $this->config_test_class : $this->config_class; |
|
| 28 | 28 | |
| 29 | 29 | $config = new $config_class(); |
| 30 | 30 | |
| 31 | - $config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_merchant_id', true ); |
|
| 32 | - $config->sub_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_sub_id', true ); |
|
| 33 | - $config->purchase_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_purchase_id', true ); |
|
| 31 | + $config->merchant_id = get_post_meta($post_id, '_pronamic_gateway_ideal_merchant_id', true); |
|
| 32 | + $config->sub_id = get_post_meta($post_id, '_pronamic_gateway_ideal_sub_id', true); |
|
| 33 | + $config->purchase_id = get_post_meta($post_id, '_pronamic_gateway_ideal_purchase_id', true); |
|
| 34 | 34 | |
| 35 | - $config->private_key = get_post_meta( $post_id, '_pronamic_gateway_ideal_private_key', true ); |
|
| 36 | - $config->private_key_password = get_post_meta( $post_id, '_pronamic_gateway_ideal_private_key_password', true ); |
|
| 37 | - $config->private_certificate = get_post_meta( $post_id, '_pronamic_gateway_ideal_private_certificate', true ); |
|
| 35 | + $config->private_key = get_post_meta($post_id, '_pronamic_gateway_ideal_private_key', true); |
|
| 36 | + $config->private_key_password = get_post_meta($post_id, '_pronamic_gateway_ideal_private_key_password', true); |
|
| 37 | + $config->private_certificate = get_post_meta($post_id, '_pronamic_gateway_ideal_private_certificate', true); |
|
| 38 | 38 | |
| 39 | 39 | return $config; |
| 40 | 40 | } |
@@ -17,14 +17,14 @@ discard block |
||
| 17 | 17 | class Settings extends GatewaySettings { |
| 18 | 18 | public function __construct() { |
| 19 | 19 | // Filters |
| 20 | - add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) ); |
|
| 20 | + add_filter('pronamic_pay_gateway_fields', array($this, 'fields')); |
|
| 21 | 21 | |
| 22 | 22 | // Actions |
| 23 | - add_action( 'current_screen', array( $this, 'maybe_download_private_certificate' ) ); |
|
| 24 | - add_action( 'current_screen', array( $this, 'maybe_download_private_key' ) ); |
|
| 23 | + add_action('current_screen', array($this, 'maybe_download_private_certificate')); |
|
| 24 | + add_action('current_screen', array($this, 'maybe_download_private_key')); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function fields( array $fields ) { |
|
| 27 | + public function fields(array $fields) { |
|
| 28 | 28 | /* |
| 29 | 29 | * Private Key and Certificate |
| 30 | 30 | */ |
@@ -32,83 +32,83 @@ discard block |
||
| 32 | 32 | // Private key and certificate information |
| 33 | 33 | $fields[] = array( |
| 34 | 34 | 'section' => 'ideal', |
| 35 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 36 | - 'title' => __( 'Private key and certificate', 'pronamic_ideal' ), |
|
| 35 | + 'methods' => array('ideal-advanced-v3'), |
|
| 36 | + 'title' => __('Private key and certificate', 'pronamic_ideal'), |
|
| 37 | 37 | 'type' => 'description', |
| 38 | - 'callback' => array( $this, 'field_security' ), |
|
| 38 | + 'callback' => array($this, 'field_security'), |
|
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | 41 | // Organization |
| 42 | 42 | $fields[] = array( |
| 43 | 43 | 'filter' => FILTER_SANITIZE_STRING, |
| 44 | 44 | 'section' => 'ideal', |
| 45 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 45 | + 'methods' => array('ideal-advanced-v3'), |
|
| 46 | 46 | 'group' => 'pk-cert', |
| 47 | 47 | 'meta_key' => '_pronamic_gateway_organization', |
| 48 | - 'title' => __( 'Organization', 'pronamic_ideal' ), |
|
| 48 | + 'title' => __('Organization', 'pronamic_ideal'), |
|
| 49 | 49 | 'type' => 'text', |
| 50 | - 'tooltip' => __( 'Organization name, e.g. Pronamic', 'pronamic_ideal' ), |
|
| 50 | + 'tooltip' => __('Organization name, e.g. Pronamic', 'pronamic_ideal'), |
|
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | 53 | // Organization Unit |
| 54 | 54 | $fields[] = array( |
| 55 | 55 | 'filter' => FILTER_SANITIZE_STRING, |
| 56 | 56 | 'section' => 'ideal', |
| 57 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 57 | + 'methods' => array('ideal-advanced-v3'), |
|
| 58 | 58 | 'group' => 'pk-cert', |
| 59 | 59 | 'meta_key' => '_pronamic_gateway_organization_unit', |
| 60 | - 'title' => __( 'Organization Unit', 'pronamic_ideal' ), |
|
| 60 | + 'title' => __('Organization Unit', 'pronamic_ideal'), |
|
| 61 | 61 | 'type' => 'text', |
| 62 | - 'tooltip' => __( 'Organization unit, e.g. Administration', 'pronamic_ideal' ), |
|
| 62 | + 'tooltip' => __('Organization unit, e.g. Administration', 'pronamic_ideal'), |
|
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | 65 | // Locality |
| 66 | 66 | $fields[] = array( |
| 67 | 67 | 'filter' => FILTER_SANITIZE_STRING, |
| 68 | 68 | 'section' => 'ideal', |
| 69 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 69 | + 'methods' => array('ideal-advanced-v3'), |
|
| 70 | 70 | 'group' => 'pk-cert', |
| 71 | 71 | 'meta_key' => '_pronamic_gateway_locality', |
| 72 | - 'title' => __( 'City', 'pronamic_ideal' ), |
|
| 72 | + 'title' => __('City', 'pronamic_ideal'), |
|
| 73 | 73 | 'type' => 'text', |
| 74 | - 'tooltip' => __( 'City, e.g. Amsterdam', 'pronamic_ideal' ), |
|
| 74 | + 'tooltip' => __('City, e.g. Amsterdam', 'pronamic_ideal'), |
|
| 75 | 75 | ); |
| 76 | 76 | |
| 77 | 77 | // State or Province |
| 78 | 78 | $fields[] = array( |
| 79 | 79 | 'filter' => FILTER_SANITIZE_STRING, |
| 80 | 80 | 'section' => 'ideal', |
| 81 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 81 | + 'methods' => array('ideal-advanced-v3'), |
|
| 82 | 82 | 'group' => 'pk-cert', |
| 83 | 83 | 'meta_key' => '_pronamic_gateway_state_or_province', |
| 84 | - 'title' => __( 'State / province', 'pronamic_ideal' ), |
|
| 84 | + 'title' => __('State / province', 'pronamic_ideal'), |
|
| 85 | 85 | 'type' => 'text', |
| 86 | - 'tooltip' => __( 'State or province, e.g. Friesland', 'pronamic_ideal' ), |
|
| 86 | + 'tooltip' => __('State or province, e.g. Friesland', 'pronamic_ideal'), |
|
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | 89 | // Country |
| 90 | - $locale = explode( '_', get_locale() ); |
|
| 90 | + $locale = explode('_', get_locale()); |
|
| 91 | 91 | |
| 92 | - $locale = array_pop( $locale ); |
|
| 92 | + $locale = array_pop($locale); |
|
| 93 | 93 | |
| 94 | 94 | $fields[] = array( |
| 95 | 95 | 'filter' => FILTER_SANITIZE_STRING, |
| 96 | 96 | 'section' => 'ideal', |
| 97 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 97 | + 'methods' => array('ideal-advanced-v3'), |
|
| 98 | 98 | 'group' => 'pk-cert', |
| 99 | 99 | 'meta_key' => '_pronamic_gateway_country', |
| 100 | - 'title' => __( 'Country', 'pronamic_ideal' ), |
|
| 100 | + 'title' => __('Country', 'pronamic_ideal'), |
|
| 101 | 101 | 'type' => 'text', |
| 102 | 102 | 'tooltip' => sprintf( |
| 103 | 103 | '%s %s (ISO-3166-1 alpha-2)', |
| 104 | - __( '2 letter country code, e.g.', 'pronamic_ideal' ), |
|
| 105 | - strtoupper( $locale ) |
|
| 104 | + __('2 letter country code, e.g.', 'pronamic_ideal'), |
|
| 105 | + strtoupper($locale) |
|
| 106 | 106 | ), |
| 107 | 107 | 'size' => 2, |
| 108 | 108 | 'description' => sprintf( |
| 109 | 109 | '%s %s', |
| 110 | - __( '2 letter country code, e.g.', 'pronamic_ideal' ), |
|
| 111 | - strtoupper( $locale ) |
|
| 110 | + __('2 letter country code, e.g.', 'pronamic_ideal'), |
|
| 111 | + strtoupper($locale) |
|
| 112 | 112 | ), |
| 113 | 113 | ); |
| 114 | 114 | |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | $fields[] = array( |
| 117 | 117 | 'filter' => FILTER_SANITIZE_STRING, |
| 118 | 118 | 'section' => 'ideal', |
| 119 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 119 | + 'methods' => array('ideal-advanced-v3'), |
|
| 120 | 120 | 'group' => 'pk-cert', |
| 121 | 121 | 'meta_key' => '_pronamic_gateway_email', |
| 122 | - 'title' => __( 'E-mail address', 'pronamic_ideal' ), |
|
| 122 | + 'title' => __('E-mail address', 'pronamic_ideal'), |
|
| 123 | 123 | 'tooltip' => sprintf( |
| 124 | 124 | /* translators: %s: admin email */ |
| 125 | - __( 'E-mail address, e.g. %s', 'pronamic_ideal' ), |
|
| 126 | - get_option( 'admin_email' ) |
|
| 125 | + __('E-mail address, e.g. %s', 'pronamic_ideal'), |
|
| 126 | + get_option('admin_email') |
|
| 127 | 127 | ), |
| 128 | 128 | 'type' => 'text', |
| 129 | 129 | ); |
@@ -132,66 +132,66 @@ discard block |
||
| 132 | 132 | $fields[] = array( |
| 133 | 133 | 'filter' => FILTER_SANITIZE_NUMBER_INT, |
| 134 | 134 | 'section' => 'ideal', |
| 135 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 135 | + 'methods' => array('ideal-advanced-v3'), |
|
| 136 | 136 | 'group' => 'pk-cert', |
| 137 | 137 | 'meta_key' => '_pronamic_gateway_number_days_valid', |
| 138 | - 'title' => __( 'Number Days Valid', 'pronamic_ideal' ), |
|
| 138 | + 'title' => __('Number Days Valid', 'pronamic_ideal'), |
|
| 139 | 139 | 'type' => 'text', |
| 140 | 140 | 'default' => 1825, |
| 141 | - 'tooltip' => __( 'Number of days the generated certificate will be valid for, e.g. 1825 days for the maximum duration of 5 years.', 'pronamic_ideal' ), |
|
| 141 | + 'tooltip' => __('Number of days the generated certificate will be valid for, e.g. 1825 days for the maximum duration of 5 years.', 'pronamic_ideal'), |
|
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | 144 | // Private Key Password |
| 145 | 145 | $fields[] = array( |
| 146 | 146 | 'filter' => FILTER_SANITIZE_STRING, |
| 147 | 147 | 'section' => 'ideal', |
| 148 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 148 | + 'methods' => array('ideal-advanced-v3'), |
|
| 149 | 149 | 'group' => 'pk-cert', |
| 150 | 150 | 'meta_key' => '_pronamic_gateway_ideal_private_key_password', |
| 151 | - 'title' => __( 'Private Key Password', 'pronamic_ideal' ), |
|
| 151 | + 'title' => __('Private Key Password', 'pronamic_ideal'), |
|
| 152 | 152 | 'type' => 'text', |
| 153 | - 'classes' => array( 'regular-text', 'code' ), |
|
| 153 | + 'classes' => array('regular-text', 'code'), |
|
| 154 | 154 | 'default' => wp_generate_password(), |
| 155 | - 'tooltip' => __( 'A random password which will be used for the generation of the private key and certificate.', 'pronamic_ideal' ), |
|
| 155 | + 'tooltip' => __('A random password which will be used for the generation of the private key and certificate.', 'pronamic_ideal'), |
|
| 156 | 156 | ); |
| 157 | 157 | |
| 158 | 158 | // Private Key |
| 159 | 159 | $fields[] = array( |
| 160 | 160 | 'filter' => FILTER_SANITIZE_STRING, |
| 161 | 161 | 'section' => 'ideal', |
| 162 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 162 | + 'methods' => array('ideal-advanced-v3'), |
|
| 163 | 163 | 'group' => 'pk-cert', |
| 164 | 164 | 'meta_key' => '_pronamic_gateway_ideal_private_key', |
| 165 | - 'title' => __( 'Private Key', 'pronamic_ideal' ), |
|
| 165 | + 'title' => __('Private Key', 'pronamic_ideal'), |
|
| 166 | 166 | 'type' => 'textarea', |
| 167 | - 'callback' => array( $this, 'field_private_key' ), |
|
| 168 | - 'classes' => array( 'code' ), |
|
| 169 | - 'tooltip' => __( 'The private key is used for secure communication with the payment provider. If left empty, the private key will be generated using the given private key password.', 'pronamic_ideal' ), |
|
| 167 | + 'callback' => array($this, 'field_private_key'), |
|
| 168 | + 'classes' => array('code'), |
|
| 169 | + 'tooltip' => __('The private key is used for secure communication with the payment provider. If left empty, the private key will be generated using the given private key password.', 'pronamic_ideal'), |
|
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | 172 | // Private Certificate |
| 173 | 173 | $fields[] = array( |
| 174 | 174 | 'filter' => FILTER_SANITIZE_STRING, |
| 175 | 175 | 'section' => 'ideal', |
| 176 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 176 | + 'methods' => array('ideal-advanced-v3'), |
|
| 177 | 177 | 'group' => 'pk-cert', |
| 178 | 178 | 'meta_key' => '_pronamic_gateway_ideal_private_certificate', |
| 179 | - 'title' => __( 'Private Certificate', 'pronamic_ideal' ), |
|
| 179 | + 'title' => __('Private Certificate', 'pronamic_ideal'), |
|
| 180 | 180 | 'type' => 'textarea', |
| 181 | - 'callback' => array( $this, 'field_private_certificate' ), |
|
| 182 | - 'classes' => array( 'code' ), |
|
| 183 | - 'tooltip' => __( 'The certificate is used for secure communication with the payment provider. If left empty, the certificate will be generated using the private key and given organization details.', 'pronamic_ideal' ), |
|
| 181 | + 'callback' => array($this, 'field_private_certificate'), |
|
| 182 | + 'classes' => array('code'), |
|
| 183 | + 'tooltip' => __('The certificate is used for secure communication with the payment provider. If left empty, the certificate will be generated using the private key and given organization details.', 'pronamic_ideal'), |
|
| 184 | 184 | ); |
| 185 | 185 | |
| 186 | 186 | // Transaction feedback |
| 187 | 187 | $fields[] = array( |
| 188 | 188 | 'section' => 'ideal', |
| 189 | - 'methods' => array( 'ideal-advanced-v3' ), |
|
| 190 | - 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
| 189 | + 'methods' => array('ideal-advanced-v3'), |
|
| 190 | + 'title' => __('Transaction feedback', 'pronamic_ideal'), |
|
| 191 | 191 | 'type' => 'description', |
| 192 | 192 | 'html' => sprintf( |
| 193 | 193 | '<span class="dashicons dashicons-yes"></span> %s', |
| 194 | - __( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' ) |
|
| 194 | + __('Payment status updates will be processed without any additional configuration.', 'pronamic_ideal') |
|
| 195 | 195 | ), |
| 196 | 196 | ); |
| 197 | 197 | |
@@ -204,25 +204,25 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @param array $field |
| 206 | 206 | */ |
| 207 | - public function field_security( $field ) { |
|
| 208 | - $certificate = get_post_meta( get_the_ID(), '_pronamic_gateway_ideal_private_certificate', true ); |
|
| 207 | + public function field_security($field) { |
|
| 208 | + $certificate = get_post_meta(get_the_ID(), '_pronamic_gateway_ideal_private_certificate', true); |
|
| 209 | 209 | |
| 210 | 210 | ?> |
| 211 | 211 | <p> |
| 212 | - <?php if ( empty( $certificate ) ) : ?> |
|
| 212 | + <?php if (empty($certificate)) : ?> |
|
| 213 | 213 | |
| 214 | 214 | <span |
| 215 | - class="dashicons dashicons-no"></span> <?php esc_html_e( 'The private key and certificate have not yet been configured.', 'pronamic_ideal' ); ?> |
|
| 215 | + class="dashicons dashicons-no"></span> <?php esc_html_e('The private key and certificate have not yet been configured.', 'pronamic_ideal'); ?> |
|
| 216 | 216 | <br/> |
| 217 | 217 | |
| 218 | 218 | <br/> |
| 219 | 219 | |
| 220 | - <?php esc_html_e( 'A private key and certificate are required for communication with the payment provider. Enter the organization details from the iDEAL account below to generate these required files.', 'pronamic_ideal' ); ?> |
|
| 220 | + <?php esc_html_e('A private key and certificate are required for communication with the payment provider. Enter the organization details from the iDEAL account below to generate these required files.', 'pronamic_ideal'); ?> |
|
| 221 | 221 | |
| 222 | 222 | <?php else : ?> |
| 223 | 223 | |
| 224 | 224 | <span |
| 225 | - class="dashicons dashicons-yes"></span> <?php esc_html_e( 'A private key and certificate have been configured. The certificate must be uploaded to the payment provider dashboard to complete configuration.', 'pronamic_ideal' ); ?> |
|
| 225 | + class="dashicons dashicons-yes"></span> <?php esc_html_e('A private key and certificate have been configured. The certificate must be uploaded to the payment provider dashboard to complete configuration.', 'pronamic_ideal'); ?> |
|
| 226 | 226 | <br/> |
| 227 | 227 | |
| 228 | 228 | <br/> |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | <?php |
| 231 | 231 | |
| 232 | 232 | submit_button( |
| 233 | - __( 'Download certificate', 'pronamic_ideal' ), |
|
| 233 | + __('Download certificate', 'pronamic_ideal'), |
|
| 234 | 234 | 'secondary', |
| 235 | 235 | 'download_private_certificate', |
| 236 | 236 | false |
@@ -238,37 +238,37 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | ?> |
| 240 | 240 | |
| 241 | - <a class="pronamic-pay-btn-link" href="#" id="pk-cert-fields-toggle"><?php esc_html_e( 'Show details…', 'pronamic_ideal' ); ?></a> |
|
| 241 | + <a class="pronamic-pay-btn-link" href="#" id="pk-cert-fields-toggle"><?php esc_html_e('Show details…', 'pronamic_ideal'); ?></a> |
|
| 242 | 242 | |
| 243 | 243 | <?php endif; ?> |
| 244 | 244 | </p> |
| 245 | 245 | <?php |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - public function field_private_key( $field ) { |
|
| 249 | - $private_key = get_post_meta( get_the_ID(), '_pronamic_gateway_ideal_private_key', true ); |
|
| 250 | - $private_key_password = get_post_meta( get_the_ID(), '_pronamic_gateway_ideal_private_key_password', true ); |
|
| 251 | - $number_days_valid = get_post_meta( get_the_ID(), '_pronamic_gateway_number_days_valid', true ); |
|
| 248 | + public function field_private_key($field) { |
|
| 249 | + $private_key = get_post_meta(get_the_ID(), '_pronamic_gateway_ideal_private_key', true); |
|
| 250 | + $private_key_password = get_post_meta(get_the_ID(), '_pronamic_gateway_ideal_private_key_password', true); |
|
| 251 | + $number_days_valid = get_post_meta(get_the_ID(), '_pronamic_gateway_number_days_valid', true); |
|
| 252 | 252 | |
| 253 | - $filename = __( 'ideal.key', 'pronamic_ideal' ); |
|
| 253 | + $filename = __('ideal.key', 'pronamic_ideal'); |
|
| 254 | 254 | |
| 255 | - if ( ! empty( $private_key_password ) && ! empty( $number_days_valid ) ) { |
|
| 255 | + if ( ! empty($private_key_password) && ! empty($number_days_valid)) { |
|
| 256 | 256 | $command = sprintf( |
| 257 | 257 | 'openssl genrsa -aes128 -out %s -passout pass:%s 2048', |
| 258 | - escapeshellarg( $filename ), |
|
| 259 | - escapeshellarg( $private_key_password ) |
|
| 258 | + escapeshellarg($filename), |
|
| 259 | + escapeshellarg($private_key_password) |
|
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | 262 | ?> |
| 263 | 263 | |
| 264 | - <p><?php esc_html_e( 'OpenSSL command', 'pronamic_ideal' ); ?></p> |
|
| 265 | - <input id="pronamic_ideal_openssl_command_key" name="pronamic_ideal_openssl_command_key" value="<?php echo esc_attr( $command ); ?>" type="text" class="large-text code" readonly="readonly"/> |
|
| 264 | + <p><?php esc_html_e('OpenSSL command', 'pronamic_ideal'); ?></p> |
|
| 265 | + <input id="pronamic_ideal_openssl_command_key" name="pronamic_ideal_openssl_command_key" value="<?php echo esc_attr($command); ?>" type="text" class="large-text code" readonly="readonly"/> |
|
| 266 | 266 | |
| 267 | 267 | <?php |
| 268 | 268 | } else { |
| 269 | 269 | printf( |
| 270 | 270 | '<p class="pronamic-pay-description description">%s</p>', |
| 271 | - esc_html__( 'Leave empty and save the configuration to generate the private key or view the OpenSSL command.', 'pronamic_ideal' ) |
|
| 271 | + esc_html__('Leave empty and save the configuration to generate the private key or view the OpenSSL command.', 'pronamic_ideal') |
|
| 272 | 272 | ); |
| 273 | 273 | } |
| 274 | 274 | |
@@ -276,9 +276,9 @@ discard block |
||
| 276 | 276 | <p> |
| 277 | 277 | <?php |
| 278 | 278 | |
| 279 | - if ( ! empty( $private_key ) ) { |
|
| 279 | + if ( ! empty($private_key)) { |
|
| 280 | 280 | submit_button( |
| 281 | - __( 'Download', 'pronamic_ideal' ), |
|
| 281 | + __('Download', 'pronamic_ideal'), |
|
| 282 | 282 | 'secondary', |
| 283 | 283 | 'download_private_key', |
| 284 | 284 | false |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | printf( |
| 291 | 291 | '<label class="pronamic-pay-form-control-file-button button">%s <input type="file" name="%s" /></label>', |
| 292 | - esc_html__( 'Upload', 'pronamic_ideal' ), |
|
| 292 | + esc_html__('Upload', 'pronamic_ideal'), |
|
| 293 | 293 | '_pronamic_gateway_ideal_private_key_file' |
| 294 | 294 | ); |
| 295 | 295 | |
@@ -298,79 +298,79 @@ discard block |
||
| 298 | 298 | <?php |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - public function field_private_certificate( $field ) { |
|
| 302 | - $certificate = get_post_meta( get_the_ID(), '_pronamic_gateway_ideal_private_certificate', true ); |
|
| 301 | + public function field_private_certificate($field) { |
|
| 302 | + $certificate = get_post_meta(get_the_ID(), '_pronamic_gateway_ideal_private_certificate', true); |
|
| 303 | 303 | |
| 304 | - $private_key_password = get_post_meta( get_the_ID(), '_pronamic_gateway_ideal_private_key_password', true ); |
|
| 305 | - $number_days_valid = get_post_meta( get_the_ID(), '_pronamic_gateway_number_days_valid', true ); |
|
| 304 | + $private_key_password = get_post_meta(get_the_ID(), '_pronamic_gateway_ideal_private_key_password', true); |
|
| 305 | + $number_days_valid = get_post_meta(get_the_ID(), '_pronamic_gateway_number_days_valid', true); |
|
| 306 | 306 | |
| 307 | - $filename_key = __( 'ideal.key', 'pronamic_ideal' ); |
|
| 308 | - $filename_cer = __( 'ideal.cer', 'pronamic_ideal' ); |
|
| 307 | + $filename_key = __('ideal.key', 'pronamic_ideal'); |
|
| 308 | + $filename_cer = __('ideal.cer', 'pronamic_ideal'); |
|
| 309 | 309 | |
| 310 | 310 | // @see http://www.openssl.org/docs/apps/req.html |
| 311 | 311 | $subj_args = array( |
| 312 | - 'C' => get_post_meta( get_the_ID(), '_pronamic_gateway_country', true ), |
|
| 313 | - 'ST' => get_post_meta( get_the_ID(), '_pronamic_gateway_state_or_province', true ), |
|
| 314 | - 'L' => get_post_meta( get_the_ID(), '_pronamic_gateway_locality', true ), |
|
| 315 | - 'O' => get_post_meta( get_the_ID(), '_pronamic_gateway_organization', true ), |
|
| 316 | - 'OU' => get_post_meta( get_the_ID(), '_pronamic_gateway_organization_unit', true ), |
|
| 317 | - 'CN' => get_post_meta( get_the_ID(), '_pronamic_gateway_organization', true ), |
|
| 318 | - 'emailAddress' => get_post_meta( get_the_ID(), '_pronamic_gateway_email', true ), |
|
| 312 | + 'C' => get_post_meta(get_the_ID(), '_pronamic_gateway_country', true), |
|
| 313 | + 'ST' => get_post_meta(get_the_ID(), '_pronamic_gateway_state_or_province', true), |
|
| 314 | + 'L' => get_post_meta(get_the_ID(), '_pronamic_gateway_locality', true), |
|
| 315 | + 'O' => get_post_meta(get_the_ID(), '_pronamic_gateway_organization', true), |
|
| 316 | + 'OU' => get_post_meta(get_the_ID(), '_pronamic_gateway_organization_unit', true), |
|
| 317 | + 'CN' => get_post_meta(get_the_ID(), '_pronamic_gateway_organization', true), |
|
| 318 | + 'emailAddress' => get_post_meta(get_the_ID(), '_pronamic_gateway_email', true), |
|
| 319 | 319 | ); |
| 320 | 320 | |
| 321 | - $subj_args = array_filter( $subj_args ); |
|
| 321 | + $subj_args = array_filter($subj_args); |
|
| 322 | 322 | |
| 323 | 323 | $subj = ''; |
| 324 | - foreach ( $subj_args as $type => $value ) { |
|
| 325 | - $subj .= '/' . $type . '=' . addslashes( $value ); |
|
| 324 | + foreach ($subj_args as $type => $value) { |
|
| 325 | + $subj .= '/' . $type . '=' . addslashes($value); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if ( ! empty( $subj ) ) { |
|
| 329 | - $command = trim( sprintf( |
|
| 328 | + if ( ! empty($subj)) { |
|
| 329 | + $command = trim(sprintf( |
|
| 330 | 330 | 'openssl req -x509 -sha256 -new -key %s -passin pass:%s -days %s -out %s %s', |
| 331 | - escapeshellarg( $filename_key ), |
|
| 332 | - escapeshellarg( $private_key_password ), |
|
| 333 | - escapeshellarg( $number_days_valid ), |
|
| 334 | - escapeshellarg( $filename_cer ), |
|
| 335 | - empty( $subj ) ? '' : sprintf( '-subj %s', escapeshellarg( $subj ) ) |
|
| 336 | - ) ); |
|
| 331 | + escapeshellarg($filename_key), |
|
| 332 | + escapeshellarg($private_key_password), |
|
| 333 | + escapeshellarg($number_days_valid), |
|
| 334 | + escapeshellarg($filename_cer), |
|
| 335 | + empty($subj) ? '' : sprintf('-subj %s', escapeshellarg($subj)) |
|
| 336 | + )); |
|
| 337 | 337 | |
| 338 | 338 | ?> |
| 339 | 339 | |
| 340 | - <p><?php esc_html_e( 'OpenSSL command', 'pronamic_ideal' ); ?></p> |
|
| 341 | - <input id="pronamic_ideal_openssl_command_certificate" name="pronamic_ideal_openssl_command_certificate" value="<?php echo esc_attr( $command ); ?>" type="text" class="large-text code" readonly="readonly"/> |
|
| 340 | + <p><?php esc_html_e('OpenSSL command', 'pronamic_ideal'); ?></p> |
|
| 341 | + <input id="pronamic_ideal_openssl_command_certificate" name="pronamic_ideal_openssl_command_certificate" value="<?php echo esc_attr($command); ?>" type="text" class="large-text code" readonly="readonly"/> |
|
| 342 | 342 | |
| 343 | 343 | <?php |
| 344 | 344 | } else { |
| 345 | 345 | printf( |
| 346 | 346 | '<p class="pronamic-pay-description description">%s</p>', |
| 347 | - esc_html__( 'Leave empty and save the configuration to generate the certificate or view the OpenSSL command.', 'pronamic_ideal' ) |
|
| 347 | + esc_html__('Leave empty and save the configuration to generate the certificate or view the OpenSSL command.', 'pronamic_ideal') |
|
| 348 | 348 | ); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - if ( ! empty( $certificate ) ) { |
|
| 352 | - $fingerprint = Security::get_sha_fingerprint( $certificate ); |
|
| 353 | - $fingerprint = str_split( $fingerprint, 2 ); |
|
| 354 | - $fingerprint = implode( ':', $fingerprint ); |
|
| 351 | + if ( ! empty($certificate)) { |
|
| 352 | + $fingerprint = Security::get_sha_fingerprint($certificate); |
|
| 353 | + $fingerprint = str_split($fingerprint, 2); |
|
| 354 | + $fingerprint = implode(':', $fingerprint); |
|
| 355 | 355 | |
| 356 | 356 | echo '<dl>'; |
| 357 | 357 | |
| 358 | - echo '<dt>', esc_html__( 'SHA Fingerprint', 'pronamic_ideal' ), '</dt>'; |
|
| 359 | - echo '<dd>', esc_html( $fingerprint ), '</dd>'; |
|
| 358 | + echo '<dt>', esc_html__('SHA Fingerprint', 'pronamic_ideal'), '</dt>'; |
|
| 359 | + echo '<dd>', esc_html($fingerprint), '</dd>'; |
|
| 360 | 360 | |
| 361 | - $info = openssl_x509_parse( $certificate ); |
|
| 361 | + $info = openssl_x509_parse($certificate); |
|
| 362 | 362 | |
| 363 | - if ( $info ) { |
|
| 364 | - $date_format = __( 'M j, Y @ G:i', 'pronamic_ideal' ); |
|
| 363 | + if ($info) { |
|
| 364 | + $date_format = __('M j, Y @ G:i', 'pronamic_ideal'); |
|
| 365 | 365 | |
| 366 | - if ( isset( $info['validFrom_time_t'] ) ) { |
|
| 367 | - echo '<dt>', esc_html__( 'Valid From', 'pronamic_ideal' ), '</dt>'; |
|
| 368 | - echo '<dd>', esc_html( date_i18n( $date_format, $info['validFrom_time_t'] ) ), '</dd>'; |
|
| 366 | + if (isset($info['validFrom_time_t'])) { |
|
| 367 | + echo '<dt>', esc_html__('Valid From', 'pronamic_ideal'), '</dt>'; |
|
| 368 | + echo '<dd>', esc_html(date_i18n($date_format, $info['validFrom_time_t'])), '</dd>'; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - if ( isset( $info['validTo_time_t'] ) ) { |
|
| 372 | - echo '<dt>', esc_html__( 'Valid To', 'pronamic_ideal' ), '</dt>'; |
|
| 373 | - echo '<dd>', esc_html( date_i18n( $date_format, $info['validTo_time_t'] ) ), '</dd>'; |
|
| 371 | + if (isset($info['validTo_time_t'])) { |
|
| 372 | + echo '<dt>', esc_html__('Valid To', 'pronamic_ideal'), '</dt>'; |
|
| 373 | + echo '<dd>', esc_html(date_i18n($date_format, $info['validTo_time_t'])), '</dd>'; |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | |
@@ -381,9 +381,9 @@ discard block |
||
| 381 | 381 | <p> |
| 382 | 382 | <?php |
| 383 | 383 | |
| 384 | - if ( ! empty( $certificate ) ) { |
|
| 384 | + if ( ! empty($certificate)) { |
|
| 385 | 385 | submit_button( |
| 386 | - __( 'Download', 'pronamic_ideal' ), |
|
| 386 | + __('Download', 'pronamic_ideal'), |
|
| 387 | 387 | 'secondary', |
| 388 | 388 | 'download_private_certificate', |
| 389 | 389 | false |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | |
| 395 | 395 | printf( |
| 396 | 396 | '<label class="pronamic-pay-form-control-file-button button">%s <input type="file" name="%s" /></label>', |
| 397 | - esc_html__( 'Upload', 'pronamic_ideal' ), |
|
| 397 | + esc_html__('Upload', 'pronamic_ideal'), |
|
| 398 | 398 | '_pronamic_gateway_ideal_private_certificate_file' |
| 399 | 399 | ); |
| 400 | 400 | |
@@ -407,16 +407,16 @@ discard block |
||
| 407 | 407 | * Download private certificate |
| 408 | 408 | */ |
| 409 | 409 | public function maybe_download_private_certificate() { |
| 410 | - if ( filter_has_var( INPUT_POST, 'download_private_certificate' ) ) { |
|
| 411 | - $post_id = filter_input( INPUT_POST, 'post_ID', FILTER_SANITIZE_STRING ); |
|
| 410 | + if (filter_has_var(INPUT_POST, 'download_private_certificate')) { |
|
| 411 | + $post_id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_STRING); |
|
| 412 | 412 | |
| 413 | - $filename = sprintf( 'ideal-private-certificate-%s.cer', $post_id ); |
|
| 413 | + $filename = sprintf('ideal-private-certificate-%s.cer', $post_id); |
|
| 414 | 414 | |
| 415 | - header( 'Content-Description: File Transfer' ); |
|
| 416 | - header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 417 | - header( 'Content-Type: application/x-x509-ca-cert; charset=' . get_option( 'blog_charset' ), true ); |
|
| 415 | + header('Content-Description: File Transfer'); |
|
| 416 | + header('Content-Disposition: attachment; filename=' . $filename); |
|
| 417 | + header('Content-Type: application/x-x509-ca-cert; charset=' . get_option('blog_charset'), true); |
|
| 418 | 418 | |
| 419 | - echo get_post_meta( $post_id, '_pronamic_gateway_ideal_private_certificate', true ); //xss ok |
|
| 419 | + echo get_post_meta($post_id, '_pronamic_gateway_ideal_private_certificate', true); //xss ok |
|
| 420 | 420 | |
| 421 | 421 | exit; |
| 422 | 422 | } |
@@ -426,16 +426,16 @@ discard block |
||
| 426 | 426 | * Download private key |
| 427 | 427 | */ |
| 428 | 428 | public function maybe_download_private_key() { |
| 429 | - if ( filter_has_var( INPUT_POST, 'download_private_key' ) ) { |
|
| 430 | - $post_id = filter_input( INPUT_POST, 'post_ID', FILTER_SANITIZE_STRING ); |
|
| 429 | + if (filter_has_var(INPUT_POST, 'download_private_key')) { |
|
| 430 | + $post_id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_STRING); |
|
| 431 | 431 | |
| 432 | - $filename = sprintf( 'ideal-private-key-%s.key', $post_id ); |
|
| 432 | + $filename = sprintf('ideal-private-key-%s.key', $post_id); |
|
| 433 | 433 | |
| 434 | - header( 'Content-Description: File Transfer' ); |
|
| 435 | - header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 436 | - header( 'Content-Type: application/pgp-keys; charset=' . get_option( 'blog_charset' ), true ); |
|
| 434 | + header('Content-Description: File Transfer'); |
|
| 435 | + header('Content-Disposition: attachment; filename=' . $filename); |
|
| 436 | + header('Content-Type: application/pgp-keys; charset=' . get_option('blog_charset'), true); |
|
| 437 | 437 | |
| 438 | - echo get_post_meta( $post_id, '_pronamic_gateway_ideal_private_key', true ); //xss ok |
|
| 438 | + echo get_post_meta($post_id, '_pronamic_gateway_ideal_private_key', true); //xss ok |
|
| 439 | 439 | |
| 440 | 440 | exit; |
| 441 | 441 | } |
@@ -444,41 +444,41 @@ discard block |
||
| 444 | 444 | /*** |
| 445 | 445 | * Save post. |
| 446 | 446 | */ |
| 447 | - public function save_post( $data ) { |
|
| 447 | + public function save_post($data) { |
|
| 448 | 448 | // Files |
| 449 | 449 | $files = array( |
| 450 | 450 | '_pronamic_gateway_ideal_private_key_file' => '_pronamic_gateway_ideal_private_key', |
| 451 | 451 | '_pronamic_gateway_ideal_private_certificate_file' => '_pronamic_gateway_ideal_private_certificate', |
| 452 | 452 | ); |
| 453 | 453 | |
| 454 | - foreach ( $files as $name => $meta_key ) { |
|
| 455 | - if ( isset( $_FILES[ $name ] ) && UPLOAD_ERR_OK === $_FILES[ $name ]['error'] ) { // WPCS: input var okay. |
|
| 456 | - $value = file_get_contents( $_FILES[ $name ]['tmp_name'] ); // WPCS: input var okay. // WPCS: sanitization ok. |
|
| 454 | + foreach ($files as $name => $meta_key) { |
|
| 455 | + if (isset($_FILES[$name]) && UPLOAD_ERR_OK === $_FILES[$name]['error']) { // WPCS: input var okay. |
|
| 456 | + $value = file_get_contents($_FILES[$name]['tmp_name']); // WPCS: input var okay. // WPCS: sanitization ok. |
|
| 457 | 457 | |
| 458 | - $data[ $meta_key ] = $value; |
|
| 458 | + $data[$meta_key] = $value; |
|
| 459 | 459 | } |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | // Generate private key and certificate |
| 463 | - if ( empty( $data['_pronamic_gateway_ideal_private_key_password'] ) ) { |
|
| 463 | + if (empty($data['_pronamic_gateway_ideal_private_key_password'])) { |
|
| 464 | 464 | // Without private key password we can't create private key and certifiate. |
| 465 | 465 | return $data; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if ( ! in_array( 'aes-128-cbc', openssl_get_cipher_methods(), true ) ) { |
|
| 468 | + if ( ! in_array('aes-128-cbc', openssl_get_cipher_methods(), true)) { |
|
| 469 | 469 | // Without AES-128-CBC ciphter method we can't create private key and certificate. |
| 470 | 470 | return $data; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | // Private key |
| 474 | - $pkey = openssl_pkey_get_private( $data['_pronamic_gateway_ideal_private_key'], $data['_pronamic_gateway_ideal_private_key_password'] ); |
|
| 474 | + $pkey = openssl_pkey_get_private($data['_pronamic_gateway_ideal_private_key'], $data['_pronamic_gateway_ideal_private_key_password']); |
|
| 475 | 475 | |
| 476 | - if ( false === $pkey ) { |
|
| 476 | + if (false === $pkey) { |
|
| 477 | 477 | // If we can't open the private key we will create a new private key and certificate. |
| 478 | 478 | |
| 479 | - if ( defined( 'OPENSSL_CIPHER_AES_128_CBC' ) ) { |
|
| 479 | + if (defined('OPENSSL_CIPHER_AES_128_CBC')) { |
|
| 480 | 480 | $cipher = OPENSSL_CIPHER_AES_128_CBC; |
| 481 | - } elseif ( defined( 'OPENSSL_CIPHER_3DES' ) ) { |
|
| 481 | + } elseif (defined('OPENSSL_CIPHER_3DES')) { |
|
| 482 | 482 | // @see https://www.pronamic.nl/wp-content/uploads/2011/12/iDEAL_Advanced_PHP_EN_V2.2.pdf |
| 483 | 483 | $cipher = OPENSSL_CIPHER_3DES; |
| 484 | 484 | } else { |
@@ -497,16 +497,16 @@ discard block |
||
| 497 | 497 | 'basicConstraints' => 'CA:true', |
| 498 | 498 | ); |
| 499 | 499 | |
| 500 | - $pkey = openssl_pkey_new( $args ); |
|
| 500 | + $pkey = openssl_pkey_new($args); |
|
| 501 | 501 | |
| 502 | - if ( false === $pkey ) { |
|
| 502 | + if (false === $pkey) { |
|
| 503 | 503 | return $data; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | // Export key |
| 507 | - $result = openssl_pkey_export( $pkey, $private_key, $data['_pronamic_gateway_ideal_private_key_password'], $args ); |
|
| 507 | + $result = openssl_pkey_export($pkey, $private_key, $data['_pronamic_gateway_ideal_private_key_password'], $args); |
|
| 508 | 508 | |
| 509 | - if ( false === $result ) { |
|
| 509 | + if (false === $result) { |
|
| 510 | 510 | return $data; |
| 511 | 511 | } |
| 512 | 512 | |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | // Certificate |
| 519 | - if ( empty( $data['_pronamic_gateway_ideal_private_certificate'] ) ) { |
|
| 519 | + if (empty($data['_pronamic_gateway_ideal_private_certificate'])) { |
|
| 520 | 520 | $required_keys = array( |
| 521 | 521 | 'countryName', |
| 522 | 522 | 'stateOrProvinceName', |
@@ -536,16 +536,16 @@ discard block |
||
| 536 | 536 | 'emailAddress' => $data['_pronamic_gateway_email'], |
| 537 | 537 | ); |
| 538 | 538 | |
| 539 | - $distinguished_name = array_filter( $distinguished_name ); |
|
| 539 | + $distinguished_name = array_filter($distinguished_name); |
|
| 540 | 540 | |
| 541 | 541 | // Create certificate only if distinguished name contains all required elements |
| 542 | 542 | // @see http://stackoverflow.com/questions/13169588/how-to-check-if-multiple-array-keys-exists |
| 543 | - if ( count( array_intersect_key( array_flip( $required_keys ), $distinguished_name ) ) === count( $required_keys ) ) { |
|
| 544 | - $csr = openssl_csr_new( $distinguished_name, $pkey ); |
|
| 543 | + if (count(array_intersect_key(array_flip($required_keys), $distinguished_name)) === count($required_keys)) { |
|
| 544 | + $csr = openssl_csr_new($distinguished_name, $pkey); |
|
| 545 | 545 | |
| 546 | - $cert = openssl_csr_sign( $csr, null, $pkey, $data['_pronamic_gateway_number_days_valid'], $args, time() ); |
|
| 546 | + $cert = openssl_csr_sign($csr, null, $pkey, $data['_pronamic_gateway_number_days_valid'], $args, time()); |
|
| 547 | 547 | |
| 548 | - openssl_x509_export( $cert, $certificate ); |
|
| 548 | + openssl_x509_export($cert, $certificate); |
|
| 549 | 549 | |
| 550 | 550 | $data['_pronamic_gateway_ideal_private_certificate'] = $certificate; |
| 551 | 551 | } |
@@ -219,10 +219,13 @@ |
||
| 219 | 219 | |
| 220 | 220 | <?php esc_html_e( 'A private key and certificate are required for communication with the payment provider. Enter the organization details from the iDEAL account below to generate these required files.', 'pronamic_ideal' ); ?> |
| 221 | 221 | |
| 222 | - <?php else : ?> |
|
| 222 | + <?php else { |
|
| 223 | + : ?> |
|
| 223 | 224 | |
| 224 | 225 | <span |
| 225 | - class="dashicons dashicons-yes"></span> <?php esc_html_e( 'A private key and certificate have been configured. The certificate must be uploaded to the payment provider dashboard to complete configuration.', 'pronamic_ideal' ); ?> |
|
| 226 | + class="dashicons dashicons-yes"></span> <?php esc_html_e( 'A private key and certificate have been configured. The certificate must be uploaded to the payment provider dashboard to complete configuration.', 'pronamic_ideal' ); |
|
| 227 | +} |
|
| 228 | +?> |
|
| 226 | 229 | <br/> |
| 227 | 230 | |
| 228 | 231 | <br/> |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @param string $code |
| 70 | 70 | */ |
| 71 | - public function set_code( $code ) { |
|
| 71 | + public function set_code($code) { |
|
| 72 | 72 | $this->code = $code; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @param string $message |
| 88 | 88 | */ |
| 89 | - public function set_message( $message ) { |
|
| 89 | + public function set_message($message) { |
|
| 90 | 90 | $this->message = $message; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @param string $detail |
| 106 | 106 | */ |
| 107 | - public function set_detail( $detail ) { |
|
| 107 | + public function set_detail($detail) { |
|
| 108 | 108 | $this->detail = $detail; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @param string $suggested_action |
| 124 | 124 | */ |
| 125 | - public function set_suggested_action( $suggested_action ) { |
|
| 125 | + public function set_suggested_action($suggested_action) { |
|
| 126 | 126 | $this->suggested_action = $suggested_action; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @param string $consumer_message |
| 142 | 142 | */ |
| 143 | - public function set_consumer_message( $consumer_message ) { |
|
| 143 | + public function set_consumer_message($consumer_message) { |
|
| 144 | 144 | $this->consumer_message = $consumer_message; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -23,11 +23,11 @@ |
||
| 23 | 23 | * |
| 24 | 24 | * @return ResponseMessage |
| 25 | 25 | */ |
| 26 | - public static function parse_create_date( SimpleXMLElement $xml, self $message ) { |
|
| 27 | - if ( $xml->createDateTimestamp ) { |
|
| 28 | - $date = new DateTime( (string) $xml->createDateTimestamp ); |
|
| 26 | + public static function parse_create_date(SimpleXMLElement $xml, self $message) { |
|
| 27 | + if ($xml->createDateTimestamp) { |
|
| 28 | + $date = new DateTime((string) $xml->createDateTimestamp); |
|
| 29 | 29 | |
| 30 | - $message->set_create_date( $date ); |
|
| 30 | + $message->set_create_date($date); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | return $message; |
@@ -19,5 +19,5 @@ |
||
| 19 | 19 | * |
| 20 | 20 | * @param SimpleXMLElement $xml |
| 21 | 21 | */ |
| 22 | - public static function parse( SimpleXMLElement $xml ); |
|
| 22 | + public static function parse(SimpleXMLElement $xml); |
|
| 23 | 23 | } |