srmklive /
laravel-paypal
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Srmklive\PayPal\Traits; |
||||
| 4 | |||||
| 5 | trait PayPalVerifyIPN |
||||
| 6 | { |
||||
| 7 | protected $webhook_id; |
||||
| 8 | |||||
| 9 | public function setWebHookID(string $webhook_id): \Srmklive\PayPal\Services\PayPal |
||||
| 10 | { |
||||
| 11 | $this->webhook_id = $webhook_id; |
||||
| 12 | |||||
| 13 | return $this; |
||||
| 14 | } |
||||
| 15 | |||||
| 16 | /** |
||||
| 17 | * Verify incoming IPN through a web hook id. |
||||
| 18 | * |
||||
| 19 | * @throws \Throwable |
||||
| 20 | * |
||||
| 21 | * @return array|\Psr\Http\Message\StreamInterface|string |
||||
| 22 | */ |
||||
| 23 | public function verifyIPN(\Illuminate\Http\Request $request) |
||||
|
0 ignored issues
–
show
|
|||||
| 24 | { |
||||
| 25 | $headers = array_change_key_case($request->headers->all(), CASE_UPPER); |
||||
| 26 | |||||
| 27 | if (!isset($headers['PAYPAL-AUTH-ALGO'][0]) || |
||||
| 28 | !isset($headers['PAYPAL-TRANSMISSION-ID'][0]) || |
||||
| 29 | !isset($headers['PAYPAL-CERT-URL'][0]) || |
||||
| 30 | !isset($headers['PAYPAL-TRANSMISSION-SIG'][0]) || |
||||
| 31 | !isset($headers['PAYPAL-TRANSMISSION-TIME'][0]) || |
||||
| 32 | !isset($this->webhook_id) |
||||
| 33 | ) { |
||||
| 34 | \Log::error('Invalid headers or webhook id supplied for paypal webhook'); |
||||
| 35 | |||||
| 36 | return ['error' => 'Invalid headers or webhook id provided']; |
||||
| 37 | } |
||||
| 38 | |||||
| 39 | $params = json_decode($request->getContent()); |
||||
| 40 | |||||
| 41 | $payload = [ |
||||
| 42 | 'auth_algo' => $headers['PAYPAL-AUTH-ALGO'][0], |
||||
| 43 | 'cert_url' => $headers['PAYPAL-CERT-URL'][0], |
||||
| 44 | 'transmission_id' => $headers['PAYPAL-TRANSMISSION-ID'][0], |
||||
| 45 | 'transmission_sig' => $headers['PAYPAL-TRANSMISSION-SIG'][0], |
||||
| 46 | 'transmission_time' => $headers['PAYPAL-TRANSMISSION-TIME'][0], |
||||
| 47 | 'webhook_id' => $this->webhook_id, |
||||
| 48 | 'webhook_event' => $params, |
||||
| 49 | ]; |
||||
| 50 | |||||
| 51 | return $this->verifyWebHook($payload); |
||||
|
0 ignored issues
–
show
It seems like
verifyWebHook() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 52 | } |
||||
| 53 | } |
||||
| 54 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths