Ticketpark / SaferpayJsonApi

A php library to use the Saferpay Json API
MIT License
32 stars 26 forks source link

Add retry mechanism via request header #96

Closed DF-Dave closed 3 months ago

DF-Dave commented 3 months ago

Hi,

I'm currently working to retry an AuthorizeRequest after the first response indicates that the customer cannot approve at this time and returns a behavior of RETRY_LATER. I searched a little bit in the Saferpay documentation and in this article I found the information https://docs.saferpay.com/home/integration-guide/licences-and-interfaces/error-handling#the-requestid-and-retryindicator

You can signal the retry by setting the requestId with the identical value of the first try and increase the retryIndicator in the requestHeader. This sounds straight forward but unfortunately the requestHeader cannot be modified in the current release because the getter in the Request.php always returns a new instance and only set the customerId and so with every call the requestIndicator is zero and the requestId is a new uuid.

I modified your RequestConfig.php to support the requestId and retryIndicator because in your current design every modification to the request is set via the config. Thats the reason why I did not implement it in the Request.php directly. But I'm pleased to recieve your feedback.

sprain commented 3 months ago

Sorry for the premature merge. I messed this up. The feature is good and I will work towards merging it. Thank you! A few questions in code comments.

DF-Dave commented 3 months ago

Sorry for the premature merge. I messed this up. The feature is good and I will work towards merging it. Thank you! A few questions in code comments.

It's ok, it can happen to anyone 🙂

Thanks for your feedback. I will implement it and then open another pull request.