Add Timeout Handling to verify()
Method with Custom Exception
#263
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
After meeting with the technical team of SnappPay, want to add a timeout of 60 seconds to the
verify()
method. If the timeout is reached, the method should then callGetPaymentStatus
(handled by the driver'sstatus()
method) to retrieve the payment status.on catch timeout, check status of transaction, if status is
VERIFY
return Receipt. else throw exception.To handle this scenario, a new exception named
TimeoutException
has been introduced. This exception extends fromPurchaseFailedException
, ensuring that the existing project logic does not require changes.Here's an example of how the exception can be used:
If
TimeoutException
is not caught, it will be handled byPurchaseFailedException
.How Has This Been Tested?
The method was tested using the
oauth()
function. When the timeout was set to0.01
, aGuzzleHttp\Exception\ConnectException
was thrown. When the timeout was set to 2 seconds, a driver-specific error was returned.Screenshots of the testing process are provided:
Types of Changes
Please put an
x
in the relevant boxes: