Security
Pagsmile includes a signature in the Pagsmile-Signature header of each event. This allows you to verify that the event was sent by Pagsmile instead of a third party. You can verify the signature to en
Signature
Verifying signatures manually
The approximate content of the Pagsmile-Signature header is as follows (here with line breaks for easy viewing, the actual content is all on one line):
The Pagsmile-Signature header contains a timestamp and a signature. The timestamp is prefixed by t=, followed by a UNIX timestamp; the signature is prefixed by v2=, followed by the signature content.
The notification sent uses the following format:
Step 1 : Extract the timestamp and signatures from the header
Split the header using the [,] character as the separator, to get a list of elements. Then split each element using the [=] character as the separator, to get a prefix and value pair.
The value for the prefix [t] corresponds to the timestamp, and [v2] corresponds to the signature. You can discard all other elements.
Step 2 : Prepare the original RequestBody string
Get all the content in the RequestBody. Please pay attention here. Please do not use the program's self-built structure to format and/or serialize the RequestBody content. If you have similar requirements, please do it after getting the original data for verification to avoid unnecessary sorting of fields and the addition of characters affect the signature.
Step 3 : Determine the expected signature
Compute an HMAC with the SHA256 hash function. Use the SecretKey get from The merchant dashboard as the key(salt), and use the original RequestBody string as the message.
Step 4 : Compare the signatures
Compare the signature in the header to the expected signature. For an equality match, compute the difference between the current timestamp and the received timestamp, then decide if the difference is within your tolerance.
Example of verifying codes in Java
}
Last updated