How to perform Stampery.com's Merkle Proof?
You seem to be doing everything right. The problem here is that you are using the verification process from BTA v5 on a proof generated by BTA v6 (the LTS version of our API). The v6 whitepaper is here.

Put simply: you'll need to use SHA256 instead of SHA3:

r = SHA256(SHA256(mP[2]+SHA256(SHA256(hash+mP[0])+mP[1]))+mP[3]);


Also make sure your hash functions operate on a byte level, not on the hexadecimal representation of the hash digests.

Please don't hesitate to ask for clarification!