Skip to content

Commit

Permalink
Merge branch '1.1.0' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanPetakNeuralab committed Mar 22, 2024
2 parents dd2bd9c + 5db0ef0 commit ecc89d1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions includes/core/class-kekspay-connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function refund( $order, $amount ) {
'amount' => $refund_amount,
'epochtime' => $timestamp,
'hash' => $hash,
'algo' => Kekspay_Data::get_algo(),
'currency' => $refund_currency,
);

Expand Down
23 changes: 22 additions & 1 deletion includes/utilities/class-kekspay-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ class Kekspay_Data {
*/
private static $test_kekspay_api = 'https://kekspayuat.erstebank.hr/eretailer/';

/**
* Per Kekpay documentation, parametar "algo" needs to be sent with the requests that use hash.
* Value of "algo" tells Kekspay servers which cipher was used for hashing:
* 0 : 3DES
* 1 : AES
*
* @var string
*/
private static $algo;

/**
* Init data class.
*/
Expand Down Expand Up @@ -251,6 +261,15 @@ public static function get_order_id_by_bill_id( $bill_id ) {
return str_replace( self::get_settings( 'webshop-tid', true ) . '-', '', $bill_id );
}

/**
* Extract order id from kekspay bill id.
*
* @return string
*/
public static function get_algo() {
return self::$algo;
}

/**
* Gathers all data needed for payment and formats it as array.
*
Expand Down Expand Up @@ -296,12 +315,14 @@ public static function get_cipher( $key ) {

if ( ctype_xdigit( $key ) ) {
if ( $key_size === 24 ) {
self::$algo = 0;
return 'des-ede3-cbc';
} else {
throw new Exception( 'Secret key must be 24 bytes.' );
}
} else {
if ( in_array( $key_size, array( 16, 24, 32 ), true ) ) {
self::$algo = 1;
return 'aes-' . ( $key_size * 8 ) . '-cbc';
} else {
throw new Exception( 'Secret key must be 16, 24 or 32 bytes.' );
Expand Down Expand Up @@ -329,7 +350,7 @@ public static function get_hash( $order, $amount, $timestamp ) {
$payload_checksum = pack( 'H*', md5( $payload ) );
// Create 8 or 16 (depending on cipher) byte binary initialization vector.
$iv = str_repeat( pack( 'c', 0 ), false !== strpos( $cipher, 'aes' ) ? 16 : 8 );
// Encrypt data using 3DES CBC algorithm and convert it to hex.
// Encrypt data using 3DES or AES cipher and convert it to hex.
$hash = bin2hex( openssl_encrypt( $payload_checksum, $cipher, $key, OPENSSL_RAW_DATA, $iv ) );

return strtoupper( $hash );
Expand Down
10 changes: 5 additions & 5 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: kekspay, woocommerce, gateway, payment
Requires at least: 5.0
Tested up to: 6.5
Requires PHP: 7.2
Stable tag: 1.0.17
Stable tag: 1.1.0
License: GPL v3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -49,6 +49,10 @@ For more installation options check the [official WordPress documentation](https

== Changelog ==

= 1.1.0 =
* Add assets build
* Add AES cipher support

= 1.0.17 =
* Changes to plugin support info.

Expand All @@ -59,10 +63,6 @@ For more installation options check the [official WordPress documentation](https
* Add error log for refund request timeout.
* Increase timeout for refund request.

= 1.0.15 =
* Add error log for refund request timeout.
* Increase timeout for refund request.

= 1.0.14 =
* Changes to plugin support info.
* Fix typo in plugin description.
Expand Down
4 changes: 2 additions & 2 deletions woocommerce-gateway-kekspay.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: KEKS Pay for WooCommerce
* Plugin URI: https://www.kekspay.hr/
* Description: Incredibly fast and user friendly payment method created by Erste Bank Croatia.
* Version: 1.0.17
* Version: 1.1.0
* Requires at least: 5.0
* Requires PHP: 7.2
* Author: Erste bank Croatia
Expand Down Expand Up @@ -141,7 +141,7 @@ public static function register_constants() {
define( 'KEKSPAY_PLUGIN_ID', 'erste-kekspay-woocommerce' );
}
if ( ! defined( 'KEKSPAY_PLUGIN_VERSION' ) ) {
define( 'KEKSPAY_PLUGIN_VERSION', '1.0.17' );
define( 'KEKSPAY_PLUGIN_VERSION', '1.1.0' );
}
if ( ! defined( 'KEKSPAY_DIR_PATH' ) ) {
define( 'KEKSPAY_DIR_PATH', plugin_dir_path( __FILE__ ) );
Expand Down

0 comments on commit ecc89d1

Please sign in to comment.