omnipay-2checkout icon indicating copy to clipboard operation
omnipay-2checkout copied to clipboard

Avoid undefined indexes in notifications

Open twisted1919 opened this issue 6 years ago • 2 comments

If you have a webhook waiting information, with code similar to :

/* parse the incoming request in a meaningful response */
$response = app()->paymentManager->getProvider('2checkout')->getGateway()->acceptNotification()->send();

And someone does a post request without any data, it will trigger warnings like Undefined index: sale_id because there is basically no check made to see if the given array keys do exist.

This pull request checks using isset to make sure the array keys do exist before trying to fetch their value. Initially i thought to set the values to empty strings if they are not set, but in my second commit i used null as it makes more sense in this context. I also included a test for it.

Please keep in mind i am not familiar at all with how your library works internally, so please review the changes carefully.

Thank you.

twisted1919 avatar Jul 05 '18 09:07 twisted1919