Passed
Push — refactor-icepaypayments ( e2af7d...78b375 )
by Kiet
01:51
created

CreateTransactionRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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