I'll be happy to troubleshoot your point of sale app and fix it to work as expected.
Good that you have shared the code, once we agree to work with each other, we will begin our work.
Please let us know the error messages or the exact behaviour when transaction failure occurs.
That will give us more insight about the root cause of the issue.