Verifying Paymob payment callbacks in Laravel with HMAC-SHA512 signatures
Payment callback endpoints are public, so without signature verification anyone who finds the URL could mark an order as paid. Paymob sends the HMAC signature as a query parameter and the transaction data in the JSON body, and the signature is an HMAC-SHA512 over 20 specific transaction fields joined in a fixed order with strict stringification rules. The author has packaged this as laravel-paymob-hmac, which provides middleware returning 401 for invalid signatures and a constant-time verifier class. Because valid signatures do not prevent duplicate deliveries, the article recommends an idempotent handler using a unique constraint on the transaction ID. The package treats null fields as empty strings and currently excludes card-token and GET response callbacks.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in