Skip to content

Commit

Permalink
change hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
carlHandy committed Jul 18, 2024
1 parent 1ed88d9 commit 99204c2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions includes/class-mmg-checkout-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public function generate_checkout_url() {
'secretKey' => get_option('mmg_secret_key'),
'amount' => $amount,
'merchantId' => get_option('mmg_merchant_id'),
'merchantTransactionId' => $order_id,
'merchantTransactionId' => (string)time(),
'productDescription' => $description,
'requestInitiationTime' => (string) round(microtime(true) * 1000),
'requestInitiationTime' => time(),
'merchantName' => get_option('mmg_merchant_name', get_bloginfo('name')),
);

Expand All @@ -86,7 +86,11 @@ private function get_checkout_url() {
private function encrypt_and_encode($data) {
$json = json_encode($data);
$public_key = openssl_pkey_get_public(get_option('mmg_rsa_public_key'));
openssl_public_encrypt($json, $encrypted, $public_key);

// Use OAEP padding with SHA-256
openssl_public_encrypt($json, $encrypted, $public_key, OPENSSL_PKCS1_OAEP_PADDING);

// Use URL-safe Base64 encoding
return rtrim(strtr(base64_encode($encrypted), '+/', '-_'), '=');
}

Expand Down

0 comments on commit 99204c2

Please sign in to comment.