1 | <?php |
||||
2 | |||||
3 | namespace ByTIC\Payments\Actions\GatewayNotifications; |
||||
4 | |||||
5 | use ByTIC\Omnipay\Librapay\Message\ServerCompletePurchaseResponse; |
||||
0 ignored issues
–
show
|
|||||
6 | use ByTIC\Payments\Utility\PaymentsModels; |
||||
7 | use Omnipay\Common\Message\AbstractResponse; |
||||
8 | |||||
9 | /** |
||||
10 | * Class CreateOrUpdateTransactionFromResponse |
||||
11 | * @package ByTIC\Payments\Actions\GatewayNotifications |
||||
12 | * @internal |
||||
13 | */ |
||||
14 | class CreateOrUpdateTransactionFromResponse |
||||
15 | { |
||||
16 | /** |
||||
17 | * @param $response |
||||
18 | * @param $model |
||||
19 | * @param $type |
||||
20 | * @return \ByTIC\Payments\Models\Transactions\TransactionTrait|\Nip\Records\AbstractModels\Record |
||||
21 | */ |
||||
22 | public static function handle(NotificationData $notification) |
||||
23 | { |
||||
24 | $notification->transaction = PaymentsModels::transactions()->findOrCreateForPurchase($notification->purchase); |
||||
25 | |||||
26 | static::updateFromResponse($notification->response, $notification->transaction); |
||||
0 ignored issues
–
show
It seems like
$notification->response can also be of type ByTIC\Payments\Gateways\...sModelProcessedResponse ; however, parameter $response of ByTIC\Payments\Actions\G...e::updateFromResponse() does only seem to accept Omnipay\Common\Message\AbstractResponse , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
27 | $notification->transaction->status = $notification->purchase->getStatus(); |
||||
28 | |||||
29 | $notification->transaction->update(); |
||||
30 | |||||
31 | return $notification->transaction; |
||||
32 | } |
||||
33 | |||||
34 | |||||
35 | /** |
||||
36 | * @param AbstractResponse|ServerCompletePurchaseResponse $response |
||||
37 | * @param $transaction |
||||
38 | */ |
||||
39 | protected static function updateFromResponse(AbstractResponse $response, $transaction) |
||||
40 | { |
||||
41 | static::setPropertyFromResponse($response, $transaction, 'getCode', 'code'); |
||||
42 | static::setPropertyFromResponse($response, $transaction, 'getTransactionReference', 'reference'); |
||||
43 | static::setPropertyFromResponse($response, $transaction, 'getCardMasked', 'card'); |
||||
44 | } |
||||
45 | |||||
46 | /** |
||||
47 | * @param $response |
||||
48 | * @param $transaction |
||||
49 | * @param $method |
||||
50 | * @param $property |
||||
51 | */ |
||||
52 | protected static function setPropertyFromResponse($response, $transaction, $method, $property) |
||||
53 | { |
||||
54 | if (!method_exists($response, $method)) { |
||||
55 | return; |
||||
56 | } |
||||
57 | $value = $response->{$method}(); |
||||
58 | if ($value === null || $value === '') { |
||||
59 | return; |
||||
60 | } |
||||
61 | $transaction->{$property} = $value; |
||||
62 | } |
||||
63 | } |
||||
64 |
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