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

Avoid undefined indexes in notifications

Open twisted1919 opened this issue 7 years ago • 2 comments
trafficstars

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

Coverage Status

Coverage increased (+0.4%) to 64.858% when pulling b92c0c4386cfe6bb93df55d74d97841e0d3cce4b on twisted1919:master into c317aad071cddb0bd022fb9e3a6e87cad38de730 on collizo4sky:master.

coveralls avatar Jul 05 '18 09:07 coveralls

Please merge @w3guy

xwiz avatar Dec 07 '22 23:12 xwiz