This is a really tough problem to solve. I know Alibaba and WePay both have made solutions to try and handle it at scale
https://github.com/seata/seata
https://wecode.wepay.com/posts/waltz-a-distributed-write-ahe...
At the end of the day I don't think anyone should be coding distributed transactions into their app's. If you need use a solution that abstracts them for you. Eventually we will get one into Vitess ( https://vitess.io ) when we have figured out something general purpose enough to work for lots of workloads