Test Failed
Push — refactor-icepaypayments ( 0502bc...2c8cbf )
by Kiet
01:54
created

CreateTransactionRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 6
Bugs 0 Features 0
Metric Value
eloc 37
c 6
b 0
f 0
dl 0
loc 62
ccs 0
cts 49
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 39 1
A sendData() 0 11 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
class CreateTransactionRequest extends AbstractRequest
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function getData(): array
16
    {
17
        $parentData = parent::getData();
18
        $data = [
19
            'ConsumerFootprint' => [
20
                'IPAddress' => '127.0.0.1',
21
                'TimeStampUTC' => '0',
22
            ],
23
            'Contract' => [
24
                'ContractProfileId' => $this->getContractProfileId(),
25
                'AmountInCents' => $this->getAmountInteger(),
26
                'CurrencyCode' => $this->getCurrencyCode(),
27
                'Reference' => $this->getTransactionId(),
28
            ],
29
            'Fulfillment' => [
30
                'PaymentMethod' => $this->getPaymentMethod(),
31
                'IssuerCode' => $this->getIssuerCode(),
32
                'AmountInCents' => $this->getAmountInteger(),
33
                'CurrencyCode' => $this->getCurrencyCode(),
34
                'Timestamp' => $this->getTimestamp()->format(self::TIMESTAMP_FORMAT),
35
                'LanguageCode' => $this->getLanguageCode(),
36
                'CountryCode' => $this->getCountryCode(),
37
                'Reference' => $this->getTransactionId(),
38
                'Description' => $this->getDescription(),
39
            ],
40
            'IntegratorFootprint' => [
41
                'IPAddress' => '127.0.0.1',
42
                'TimeStampUTC' => '0',
43
            ],
44
            'Postback' => [
45
                'UrlCompleted' => $this->getReturnUrl(),
46
                'UrlError' => $this->getCancelUrl(),
47
                'UrlsNotify' => [
48
                    $this->getNotifyUrl(),
49
                ],
50
            ],
51
        ];
52
53
        return array_merge($parentData, $data);
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     *
59
     * @see https://documentation.icepay.com/api/#operation/Transaction
60
     */
61
    public function sendData($data): ResponseInterface
62
    {
63
        $response = $this->sendRequest(
64
            Request::METHOD_POST,
65
            '/api/contract/transaction',
66
            $data
67
        );
68
69
        return new CreateTransactionResponse(
70
            $this,
71
            $this->getResponseBody($response)
72
        );
73
    }
74
}
75