These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * PayPal driver for Omnipay PHP payment library |
||
5 | * |
||
6 | * @link https://github.com/hiqdev/omnipay-paypal |
||
7 | * @package omnipay-paypal |
||
8 | * @license MIT |
||
9 | * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
||
10 | */ |
||
11 | |||
12 | namespace hiqdev\php\merchant\paypal; |
||
13 | |||
14 | class Merchant extends \hiqdev\php\merchant\Merchant |
||
15 | { |
||
16 | protected static $_defaults = [ |
||
17 | 'system' => 'paypal', |
||
18 | 'label' => 'PayPal', |
||
19 | 'actionUrl' => 'https://www.paypal.com/cgi-bin/webscr', |
||
20 | # 'actionUrl' => 'https://sandbox.paypal.com/cgi-bin/webscr', |
||
0 ignored issues
–
show
|
|||
21 | ]; |
||
22 | |||
23 | public function getInputs() |
||
24 | { |
||
25 | return [ |
||
26 | 'cmd' => '_xclick', |
||
27 | 'bn' => 'PP-BuyNowBF:btn_paynowCC_LG.gif:NonHostedGuest', |
||
28 | 'item_name' => $this->invoiceDescription, |
||
29 | 'amount' => $this->invoiceTotal, |
||
30 | 'business' => $this->purse, |
||
31 | 'notify_url' => $this->confirmUrl, |
||
32 | 'return' => $this->successUrl, |
||
33 | 'item_number' => 1, |
||
34 | ]; |
||
35 | } |
||
36 | |||
37 | public function prepareFrom($data) |
||
38 | { |
||
39 | $from = "$data[address_name]/$data[payer_email]"; |
||
40 | $charset = strtoupper($data['charset']); |
||
41 | if ($charset !== 'UTF-8') { |
||
42 | $from = iconv($charset, 'UTF-8//IGNORE', $from); |
||
43 | } |
||
44 | |||
45 | return $from; |
||
46 | } |
||
47 | |||
48 | public function validateConfirmation($data) |
||
49 | { |
||
50 | if ($data['payment_status'] !== 'Completed') { |
||
51 | return 'Not Completed'; |
||
52 | } |
||
53 | $raw_post_data = 'cmd=_notify-validate&' . file_get_contents('php://input'); |
||
54 | $result = static::curl($this->actionUrl, $raw_post_data); |
||
55 | if ($result !== 'VERIFIED') { |
||
56 | return "Not VERIFIED: $result"; |
||
57 | } |
||
58 | $this->mset([ |
||
59 | 'paymentTotal' => $data['payment_gross'], |
||
60 | 'paymentFee' => $data['payment_fee'], |
||
61 | 'paymentId' => $data['txn_id'], |
||
62 | 'paymentFrom' => $this->prepareFrom($data), |
||
63 | 'paymentTime' => $this->formatDatetime($data['payment_date']), |
||
64 | 'paymentCurrency' => strtolower($data['mc_currency']), |
||
65 | ]); |
||
66 | |||
67 | return; |
||
68 | } |
||
69 | } |
||
70 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.