Code Duplication    Length = 38-38 lines in 2 locations

src/Message/CaptureRequest.php 1 location

@@ 11-48 (lines=38) @@
8
/**
9
 * @method Response send()
10
 */
11
class CaptureRequest extends AbstractRequest
12
{
13
    use HasGateway, HasGatewaySpecificFields;
14
15
    /**
16
     * @return array|null
17
     * @throws \Omnipay\Common\Exception\InvalidRequestException
18
     */
19
    public function getData()
20
    {
21
        $data = array();
22
23
        $this->validate('transactionReference');
24
25
        $data = $this->fillGatewaySpecificFields($data);
26
27
        if ($this->parameters->has('amount')) {
28
            $this->validate('amount', 'currency');
29
30
            $data = $this->fillExistingParameters($data, array(
31
                'amount' => 'amount_integer',
32
                'currency_code' => 'currency',
33
            ));
34
35
            return array('transaction' => $data);
36
        }
37
38
        return count($data) ? $data : null;
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    public function getEndpoint()
45
    {
46
        return $this->endpoint . 'transactions/' . $this->getTransactionReference() . '/capture';
47
    }
48
}
49

src/Message/RefundRequest.php 1 location

@@ 11-48 (lines=38) @@
8
/**
9
 * @method Response send()
10
 */
11
class RefundRequest extends AbstractRequest
12
{
13
    use HasGateway, HasGatewaySpecificFields;
14
15
    /**
16
     * @return array|null
17
     * @throws \Omnipay\Common\Exception\InvalidRequestException
18
     */
19
    public function getData()
20
    {
21
        $data = array();
22
23
        $this->validate('transactionReference');
24
25
        $data = $this->fillGatewaySpecificFields($data);
26
27
        if ($this->parameters->has('amount')) {
28
            $this->validate('amount', 'currency');
29
30
            $data = $this->fillExistingParameters($data, array(
31
                'amount' => 'amount_integer',
32
                'currency_code' => 'currency',
33
            ));
34
35
            return array('transaction' => $data);
36
        }
37
38
        return null;
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    public function getEndpoint()
45
    {
46
        return $this->endpoint . 'transactions/' . $this->getTransactionReference() . '/credit';
47
    }
48
}
49