CreateTransactionRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 51
dl 0
loc 78
ccs 37
cts 37
cp 1
rs 10
c 5
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sendData() 0 11 1
A getData() 0 57 1
1
<?php
2
3
namespace Omnipay\IcepayPayments\Message;
4
5
use Omnipay\Common\Message\ResponseInterface;
6
use Symfony\Component\HttpFoundation\Request;
7
8
/**
9
 * The request for creating a transaction at Icepay.
10
 */
11
class CreateTransactionRequest extends AbstractRequest
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 1
    public function getData(): array
17
    {
18 1
        $parentData = parent::getData();
19
20
        $data = [
21 1
            'Contract' => [
22 1
                'ContractProfileId' => $this->getContractProfileId(),
23 1
                'AmountInCents' => $this->getAmountInteger(),
24 1
                'CurrencyCode' => $this->getCurrencyCode(),
25 1
                'Reference' => $this->getTransactionId(),
26
            ],
27
            'Postback' => [
28 1
                'UrlCompleted' => $this->getReturnUrl(),
29 1
                'UrlError' => $this->getCancelUrl(),
30
                'UrlsNotify' => [
31 1
                    $this->getNotifyUrl(),
32
                ],
33
            ],
34
            'IntegratorFootprint' => [
35
                'IPAddress' => '127.0.0.1',
36
                'TimeStampUTC' => '0',
37
            ],
38
            'ConsumerFootprint' => [
39
                'IPAddress' => '127.0.0.1',
40
                'TimeStampUTC' => '0',
41
            ],
42
            'Fulfillment' => [
43 1
                'PaymentMethod' => $this->getPaymentMethod(),
44 1
                'IssuerCode' => $this->getIssuerCode(),
45 1
                'AmountInCents' => $this->getAmountInteger(),
46 1
                'CurrencyCode' => $this->getCurrencyCode(),
47
                'Consumer' => [
48
                    'Address' => [
49
                        'CareOf' => null,
50 1
                        'City' => $this->getCity(),
51 1
                        'CountryCode' => $this->getCountryCode(),
52
                        'HouseNumber' => null,
53 1
                        'PostalCode' => $this->getPostalCode(),
54 1
                        'Street' => $this->getStreet(),
55
                    ],
56 1
                    'Category' => 'Person',
57
                ],
58 1
                'Timestamp' => $this->getTimestamp()->format(self::TIMESTAMP_FORMAT),
59 1
                'LanguageCode' => $this->getLanguageCode(),
60 1
                'CountryCode' => $this->getCountryCode(),
61 1
                'Reference' => $this->getTransactionId(),
62
                'Order' => [
63 1
                    'OrderNumber' => $this->getReference(),
64 1
                    'CurrencyCode' => $this->getCurrencyCode(),
65 1
                    'TotalGrossAmountCents' => $this->getAmountInteger(),
66 1
                    'TotalNetAmountCents' => $this->getAmountInteger(),
67
                ],
68 1
                'Description' => $this->getDescription(),
69
            ],
70
        ];
71
72 1
        return array_merge($parentData, $data);
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78 1
    public function sendData($data): ResponseInterface
79
    {
80 1
        $this->sendRequest(
81 1
            Request::METHOD_POST,
82 1
            '/contract/transaction',
83 1
            $data
84
        );
85
86 1
        return new CreateTransactionResponse(
87 1
            $this,
88 1
            $this->getResponseBody()
89
        );
90
    }
91
}
92