diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 0000000..31610f6 --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,19 @@ + + + CodeSniffer ruleset for SilverStripe coding conventions. + + src + + + + + + + + + + + + + + diff --git a/src/PaypalIPN.php b/src/PaypalIPN.php index 7f510ed..4583a46 100644 --- a/src/PaypalIPN.php +++ b/src/PaypalIPN.php @@ -22,7 +22,6 @@ class PaypalIPN /** Response from PayPal indicating validation failed */ const INVALID = 'INVALID'; - /** * Sets the IPN verification to sandbox mode (for use when testing, * should not be enabled in production). @@ -43,7 +42,6 @@ public function usePHPCerts() $this->useLocalCerts = false; } - /** * Determine endpoint to post the verification data to. * @return string @@ -57,7 +55,6 @@ public function getPaypalUri() } } - /** * Verification Function * Sends the incoming post data back to PayPal using the cURL library. @@ -65,7 +62,7 @@ public function getPaypalUri() * @return bool * @throws Exception */ - function verifyIPN() + public function verifyIPN() { if (!count($_POST)) { throw new Exception("Missing POST Data"); @@ -86,16 +83,8 @@ function verifyIPN() } } $req = 'cmd=_notify-validate'; - $get_magic_quotes_exists = false; - if (function_exists('get_magic_quotes_gpc')) { - $get_magic_quotes_exists = true; - } foreach ($myPost as $key => $value) { - if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { - $value = urlencode(stripslashes($value)); - } else { - $value = urlencode($value); - } + $value = urlencode($value); $req .= "&$key=$value"; } @@ -112,7 +101,10 @@ function verifyIPN() } curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); - curl_setopt($ch, CURLOPT_HTTPHEADER, ['Connection: Close']); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'User-Agent: PHP-IPN-Verification-Script', + 'Connection: Close', + ]); $res = curl_exec($ch); $info = curl_getinfo($ch); $http_code = $info['http_code']; @@ -135,4 +127,3 @@ function verifyIPN() } } } -