Paypal "pending" status is processed incorrectly
In some situations paypal returns "pending" status instead of "completed".
In most cases that happens because such transactions should be approved first by a facilitator.
However, the script says that transaction failed.
In order to resolve the issue the status of the transaction should stay 'pending' and after a facilitator approves the transaction at the paypal's end the status should be changed.
Need to look for a possible solution, probably, provided by paypal itself.