Issues (43)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Payload/RefundCapturedReservation.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Loevgaard\AltaPay\Payload;
3
4
use Assert\Assert;
5
use Loevgaard\AltaPay;
6
use Money\Money;
7
8
class RefundCapturedReservation extends Payload implements RefundCapturedReservationInterface
9
{
10
    use OrderLineArrayTrait;
11
12
    /**
13
     * @var string
14
     */
15
    private $transactionId;
16
17
    /**
18
     * @var int
19
     */
20
    private $amountValue;
21
22
    /**
23
     * @var string
24
     */
25
    private $amountCurrency;
26
27
    /**
28
     * @var string
29
     */
30
    private $reconciliationIdentifier;
31
32
    /**
33
     * @var boolean
34
     */
35
    private $allowOverRefund;
36
37
    /**
38
     * @var string
39
     */
40
    private $invoiceNumber;
41
42 9
    public function __construct(string $transactionId)
43
    {
44 9
        $this->transactionId = $transactionId;
45 9
        $this->orderLines = [];
46 9
    }
47
48
    /**
49
     * @return array
50
     */
51 6
    public function getPayload() : array
52
    {
53 6
        $this->validate();
54
55
        $payload = [
56 6
            'transaction_id' => $this->transactionId,
57 6
            'amount' => AltaPay\floatFromMoney($this->getAmount()),
58 6
            'reconciliation_identifier' => $this->reconciliationIdentifier,
59 6
            'allow_over_refund' => is_bool($this->allowOverRefund) ? intval($this->allowOverRefund) : null,
60 6
            'invoice_number' => $this->invoiceNumber,
61 6
            'orderLines' => $this->orderLines,
62
        ];
63
64 6
        return static::simplePayload($payload);
65
    }
66
67 6
    public function validate()
68
    {
69 6
        Assert::that($this->transactionId)->string();
70 6
        Assert::thatNullOr($this->getAmount())->isInstanceOf(Money::class);
71 6
        Assert::thatNullOr($this->reconciliationIdentifier)->string();
72 6
        Assert::thatNullOr($this->allowOverRefund)->boolean();
73 6
        Assert::thatNullOr($this->invoiceNumber)->string();
74 6
        Assert::thatNullOr($this->orderLines)->isArray();
75 6
    }
76
77
    /**
78
     * @return string
79
     */
80 3
    public function getTransactionId(): string
81
    {
82 3
        return $this->transactionId;
83
    }
84
85
    /**
86
     * @param string $transactionId
87
     * @return RefundCapturedReservation
88
     */
89 3
    public function setTransactionId(string $transactionId) : self
90
    {
91 3
        $this->transactionId = $transactionId;
92 3
        return $this;
93
    }
94
95
    /**
96
     * @return Money
97
     */
98 9
    public function getAmount(): ?Money
99
    {
100 9
        return AltaPay\createMoney((string)$this->amountCurrency, (int)$this->amountValue);
101
    }
102
103
    /**
104
     * @param Money $amount
105
     * @return RefundCapturedReservation
106
     */
107 6
    public function setAmount(Money $amount) : self
108
    {
109 6
        $this->amountCurrency = $amount->getCurrency()->getCode();
110 6
        $this->amountValue = $amount->getAmount();
0 ignored issues
show
Documentation Bug introduced by
The property $amountValue was declared of type integer, but $amount->getAmount() is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
111
112 6
        return $this;
113
    }
114
115
    /**
116
     * @return string
117
     */
118 3
    public function getReconciliationIdentifier(): ?string
119
    {
120 3
        return $this->reconciliationIdentifier;
121
    }
122
123
    /**
124
     * @param string $reconciliationIdentifier
125
     * @return RefundCapturedReservation
126
     */
127 6
    public function setReconciliationIdentifier(string $reconciliationIdentifier) : self
128
    {
129 6
        $this->reconciliationIdentifier = $reconciliationIdentifier;
130 6
        return $this;
131
    }
132
133
    /**
134
     * @return bool
135
     */
136 3
    public function isAllowOverRefund(): ?bool
137
    {
138 3
        return $this->allowOverRefund;
139
    }
140
141
    /**
142
     * @param bool $allowOverRefund
143
     * @return RefundCapturedReservation
144
     */
145 6
    public function setAllowOverRefund(bool $allowOverRefund) : self
146
    {
147 6
        $this->allowOverRefund = $allowOverRefund;
148 6
        return $this;
149
    }
150
151
    /**
152
     * @return string
153
     */
154 3
    public function getInvoiceNumber(): ?string
155
    {
156 3
        return $this->invoiceNumber;
157
    }
158
159
    /**
160
     * @param string $invoiceNumber
161
     * @return RefundCapturedReservation
162
     */
163 6
    public function setInvoiceNumber(string $invoiceNumber) : self
164
    {
165 6
        $this->invoiceNumber = $invoiceNumber;
166 6
        return $this;
167
    }
168
}
169