Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not verify payment signature. Error: invalid signature passed #369

Open
Whip opened this issue Jan 6, 2024 · 0 comments
Open

Can not verify payment signature. Error: invalid signature passed #369

Whip opened this issue Jan 6, 2024 · 0 comments

Comments

@Whip
Copy link

Whip commented Jan 6, 2024

Steps to reproduce the behavior

  1. Complete a normal test payment with callback_url
  2. On the callback_url page, use the following code to verify the signature of the payment

Expected behavior

Signature should match

Actual behavior

It returns error: Invalid signature passed

Code snippets

use \Razorpay\Api\Api;

if(isset($_POST['razorpay_payment_id'])){
	$rzApi = new Api(RZ_KEY, RZ_SECRET);

	try {
		$generatedSignature = $rzApi->utility->verifyPaymentSignature([ // source of error
			'razorpay_order_id' => $_POST['razorpay_order_id'],
			'razorpay_payment_id' => $_POST['razorpay_payment_id'],
			'razorpay_signature' => RZ_SECRET // This is a constant holding my secret key
		]);
        } catch (Exception $e) {
		echo $e->getMessage(); // Invalid signature passed
		exit;
	}
}

Php version

v8.2

Library version

v2.9.0

Additional Information

For now I'm using this code which works fine

$generatedSignature = hash_hmac('sha256', $_POST['razorpay_order_id'].'|'.$_POST['razorpay_payment_id'], RZ_SECRET);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant