Passed
Pull Request — master (#20)
by Kiet
02:29
created

RefundRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
eloc 16
c 4
b 0
f 1
dl 0
loc 35
ccs 0
cts 16
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sendData() 0 14 1
A getData() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Omnipay\IcepayPayments\Message;
6
7
use Omnipay\Common\Message\ResponseInterface;
8
use Symfony\Component\HttpFoundation\Request;
9
10
/**
11
 * Do note: refunds implementation has not been tested.
12
 */
13
class RefundRequest extends AbstractRequest
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function getData(): array
19
    {
20
        return [
21
            'ContractProfileId' => $this->getContractProfileId(),
22
            'AmountInCents' => $this->getAmountInteger(),
23
            'CurrencyCode' => $this->getCurrencyCode(),
24
            'Reference' => $this->getTransactionId(),
25
            'Timestamp' => $this->getTimestamp(),
26
        ];
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     *
32
     * @see https://documentation.icepay.com/api/#operation/Refund
33
     */
34
    public function sendData($data): ResponseInterface
35
    {
36
        $response = $this->sendRequest(
37
            Request::METHOD_POST,
38
            sprintf(
39
                '/api/transaction/%s/refund',
40
                $this->getTransactionReference()
41
            ),
42
            $data
43
        );
44
45
        return new RefundResponse(
46
            $this,
47
            $this->getResponseBody($response)
48
        );
49
    }
50
}
51