Skip to content

Commit

Permalink
GNSkd: Certificado sendo recriado em caso de deleção
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoliveiraGN committed Feb 16, 2023
1 parent f9a7130 commit 5d0fe0c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion includes/lib/class-gerencianet-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,28 @@ public function get_credentials( $paymentMethod ) {
);

if ( $paymentMethod == GERENCIANET_PIX_ID ) {

$gn_credentials['headers'] = array( 'x-skip-mtls-checking' => $wcSettings['gn_pix_mtls'] == 'yes' ? 'false' : 'true' );
$gn_credentials['pix_cert'] = $wcSettings['gn_pix_file'];

$certificatePath = get_temp_dir(). $wcSettings['gn_pix_file_name'];

if(!file_exists($certificatePath)){
try {
$file = fopen( $certificatePath, 'w+' );
if ( $file ) {
$a = fwrite( $file, $wcSettings['gn_pix_file'] );
$b = fclose( $file );
}

$wcSettings['gn_pix_file_path'] = $certificatePath;
update_option('woocommerce_' . GERENCIANET_PIX_ID . '_settings', $pixSettings);

} catch (Error $e) {
return self::result_api('<div class="error"><p><strong> Falha ao encontrar Certificado Pix, entre em contato com o administrador da loja. </strong></div>', false);
}

}
$gn_credentials['pix_cert'] = $certificatePath;
}
return $gn_credentials;
}
Expand Down

0 comments on commit 5d0fe0c

Please sign in to comment.