Boudy Posted May 28, 2023 Share Posted May 28, 2023 Hello, Could any one help me fix this I don't know what's the problem I added the digital signing in the attached file unfortunately we still receive the invalid signature error Any suggestion or help will be appreciated - this module is used in Opencart platform this is the line code – line 193 in the attached file and main integration file attached. $data['fawry_signature'] = hash('sha256', $data['fawry_merchant_code'] . $data['fawry_merchantRefNumber'] . $data['fawry_customer']['customerProfileId'] . $product['productSKU'] . $product['quantity'] . $product['price'] . $payment_fawry_security_key); Line 226 $signature = hash('sha256', $this->config->get('payment_fawry_merchant_code') . $data['fawry_merchant_code'] . $data['fawry_merchantRefNumber'] . $data['fawry_customer']['customerProfileId'] . $product['productSKU'] . $product['quantity'] . $product['price'] . $this->config->get('payment_fawry_security_key')); and this is the request from the API documentation If you’re using the old plugin You need to send signature element in the request by hashing the below concatenating string in Sha256 Case of 1 charge item: merchantCode + merchantrefNumber + customerProfileId(if exist) + productSKU + quantity + price(in two decimal format) + secure Key Case of multiple charge items should be sorted first by sku: merchantCode + merchantrefNumber + customerProfileId(if exist) + productSKU(of item-1) + quantity(of item-1) + price(of item-1 in two decimal format) + productSKU(of item-2) + quantity(of item-2) + price(of item-2 in two decimal format) + secure Key fawry.txt Quote Link to comment https://forums.phpfreaks.com/topic/316352-digital-signing-by-hashing-the-concatenating-string-in-sha256/ Share on other sites More sharing options...
requinix Posted May 29, 2023 Share Posted May 29, 2023 Your description doesn't say whether the signature is raw bytes in base 64-encoding or hexadecimal bytes, so you need to confirm which is those is desired. Otherwise, for the first line of code, my guess is you're not formatting the price with the correct "two decimal format". For the second, you seem to be using the merchant code value twice. Seems pretty clear to be just by looking at that line... Quote Link to comment https://forums.phpfreaks.com/topic/316352-digital-signing-by-hashing-the-concatenating-string-in-sha256/#findComment-1608711 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.