The merchant can verify the signature of the response or callback by following the steps below.
If the request signature of the verified merchant is correct, tokenpay includes the reply signature in the HTTP header of the reply. We recommend that merchants verify the response signature.
Similarly, tokenpay includes the signature of the callback packet in the HTTP header of the callback. The merchant must verify the signature of the callback to ensure that the callback was sent by tokenpay.
Concatenate
Firstly, the merchant obtains the following information from the response.
Reply timestamp in HTTP header TTPay-Timestamp.
Reply to a random string in the HTTP header TTPay-Nonce.
Response Body, check the interface according to the order returned by the interface. An incorrect order will cause the check failure.
The signature string has three lines, one parameter per action. The line ends with \n (line break, The ASCII encoding value is 0x0A), and don't add \n on the last line. If the parameter itself ends in \n , you also need to attach an \n.
Reply timestamp\n
Reply random string\n
Reply message body
The tokenpay reply signature is transmitted through the HTTP header TTPay-Signature. (Note: Example because typesetting may contain line breaks, the actual data should be on one line)
Judgment
Use the method of AES-256-ECB to generate signatures (You can reference signature generation). The generated signature is compared with the reply signature. If not, the data is tampered with.