Once you have retrieved the relevant information from your database, the next step is to check the integrity of the data that was sent back from Protx using the
MD5 Hash algorithm. This is commonly used in applications to check whether data received has not been tampered with. You will achieve this by generating your own MD5 Hash string and comparing this with the MD5 Hash string posted to your notification URL by Protx. The MD5 Hash string we return to you is in a field called VPSSignature. If the VPSSignature and your MD5Hash string do not match (and you have correctly implemented this aspect of the VSP Server integration) then this will suggest that the response returned to your notification URL has been tampered with. To give you an idea, the following is a simplified example of what an MD5 Hash string will look like:
E475BFB404E814FC5DDB382AA864B76F
The above hash string is a MD5 Hash of the word PROTX. It is important to note that the MD5 Hash algorithim is also case sensitive. For example, if we were to use the MD5 Hash algorithem for the word protx in lower case the string will be as follows:
D3F5D2C581D5C25BCE345D8BAD419F97
Therefore, in order to generate an MD5 Hash string to compare with the VPSSignature returned from Protx you need to generate a string with the same fields, in the same order and in the same case that Protx used to generate the VPSSignature. These fields are as follows:
- VPSTxId
- VendorTxCode
- Status
- TxAuthNo
- VendorName
- AVSCV2
- Security Key
- AddressResult
- PostCodeResult
- CV2Result
- GiftAid
- 3DSecureStatus
- CAVV
Like the following example, the values of these fields will be concatenated together in preparation for it to be hashed:
{48B881D2-C2C3-7G33-B12C-E722DBC91D00}PROTX1234OK9191myvendornameALL MATCHDGYTRDSN88MATCHEDMATCHEDMATCHED0OKHBGS765F9HJK23Y9VSW212
N.B: The 3DSecureStatus and the CAVV value will only make up the string if this is a 3D Secure transaction. You will only include values relevant to the transaction.
Note that in the above example the VSP Vendor name is in lower case, this is important as Protx will generate the VPSSignature with your VSP Vendor name in lower case. If you generate a string with the VSP Vendor name in upper case or mixed case, the VPSSignature will not match.
We can look to the ASP integration kit as an example;
In the ASP integration kit we supply an
MD5Hash.dll which you will need to register on your server. (Look to
'asp-server-readme.html' that comes with the kit for instructions). As MD5 is a widely-used cryptographic hash function you will find that the method of deployment will depend upon what technology you use to integrate VSP Server. For example, with PHP, the MD5 Hash function is inbuilt so there is no need to install additional components (
http://uk.php.net/md5). Here is how we perform the first step in ASP.