|
/** |
|
* Field private key. |
|
* |
|
* @param array<string, mixed> $field Field. |
|
* @return void |
|
*/ |
|
public function field_private_key( $field ) { |
|
$post_id = (int) \get_the_ID(); |
|
|
|
$private_key = $this->get_meta( $post_id, 'ideal_private_key' ); |
|
$private_key_password = $this->get_meta( $post_id, 'ideal_private_key_password' ); |
|
$number_days_valid = $this->get_meta( $post_id, 'number_days_valid' ); |
|
|
|
if ( PronamicGateway::MODE_TEST === $this->get_mode() ) { |
|
$private_key = \file_get_contents( __DIR__ . '/../certificates/TestCertificatesiDEAL.2.0.key' ); |
|
} |
|
|
|
if ( PronamicGateway::MODE_TEST !== $this->get_mode() ) { |
|
if ( ! empty( $private_key_password ) && ! empty( $number_days_valid ) ) { |
|
if ( \function_exists( '\escapeshellarg' ) ) { |
|
$filename = __( 'ideal.key', 'pronamic-pay-worldline-open-banking-ideal-2' ); |
|
|
|
$command = sprintf( |
|
'openssl genrsa -aes128 -out %s -passout pass:%s 2048', |
|
\escapeshellarg( $filename ), |
|
\escapeshellarg( $private_key_password ) |
|
); |
|
|
|
?> |
|
|
|
<p><?php esc_html_e( 'OpenSSL command', 'pronamic-pay-worldline-open-banking-ideal-2' ); ?></p> |
|
<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"/> |
|
|
|
<?php |
|
} |
|
} else { |
|
printf( |
|
'<p class="pronamic-pay-description description">%s</p>', |
|
esc_html__( 'Leave empty and save the configuration to generate the secret key or view the OpenSSL command.', 'pronamic-pay-worldline-open-banking-ideal-2' ) |
|
); |
|
} |
|
} |
|
|
|
?> |
|
<p> |
|
<?php |
|
|
|
if ( ! empty( $private_key ) ) { |
|
\wp_nonce_field( 'pronamic_pay_download_secret_key', 'pronamic_pay_download_secret_key_nonce' ); |
|
|
|
\submit_button( |
|
__( 'Download', 'pronamic-pay-worldline-open-banking-ideal-2' ), |
|
'secondary', |
|
'download_secret_key', |
|
false |
|
); |
|
|
|
echo ' '; |
|
} |
|
|
|
if ( PronamicGateway::MODE_TEST !== $this->get_mode() ) { |
|
printf( |
|
'<label class="pronamic-pay-form-control-file-button button">%s <input type="file" name="%s" /></label>', |
|
esc_html__( 'Upload', 'pronamic-pay-worldline-open-banking-ideal-2' ), |
|
'_pronamic_gateway_ideal_private_key_file' |
|
); |
|
} |
|
|
|
?> |
|
</p> |
|
<?php |
|
} |