Passed
Push — feature/eco-2295/eco-2344-crea... ( 3ef933...cd4fd8 )
by Aleksey
01:10
created

createRequestCallTransfer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 34
dl 0
loc 39
rs 9.376
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\CrefoPayApi\Communication\Console;
9
10
use ArrayObject;
11
use Generated\Shared\Transfer\CrefoPayApiAddressTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...foPayApiAddressTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Generated\Shared\Transfer\CrefoPayApiAmountTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...efoPayApiAmountTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Generated\Shared\Transfer\CrefoPayApiBasketItemTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ayApiBasketItemTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Generated\Shared\Transfer\CrefoPayApiCreateTransactionRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...nsactionRequestTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Generated\Shared\Transfer\CrefoPayApiPersonTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...efoPayApiPersonTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Generated\Shared\Transfer\CrefoPayApiRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...foPayApiRequestTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Spryker\Zed\Kernel\Communication\Console\Console;
0 ignored issues
show
Bug introduced by
The type Spryker\Zed\Kernel\Communication\Console\Console was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Symfony\Component\Console\Input\InputInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Input\InputInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use Symfony\Component\Console\Output\OutputInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Output\OutputInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
21
/**
22
 * @method \SprykerEco\Zed\CrefoPayApi\Business\CrefoPayApiFacadeInterface getFacade()
23
 * @method \SprykerEco\Zed\CrefoPayApi\Communication\CrefoPayApiCommunicationFactory getFactory()
24
 */
25
class CreateTransactionCallConsole extends Console
26
{
27
    public const COMMAND_NAME = 'crefo-pay-api:create-transaction';
28
    public const COMMAND_DESCRIPTION = 'Perform CreateTransaction API call to CrefoPay';
29
30
    /**
31
     * @return void
32
     */
33
    protected function configure()
34
    {
35
        parent::configure();
36
        $this
37
            ->setName(static::COMMAND_NAME)
38
            ->setDescription(static::COMMAND_DESCRIPTION)
39
            ->setHelp('<info>' . static::COMMAND_NAME . ' -h</info>');
40
    }
41
42
    /**
43
     * @param \Symfony\Component\Console\Input\InputInterface $input
44
     * @param \Symfony\Component\Console\Output\OutputInterface $output
45
     *
46
     * @return void
47
     */
48
    public function execute(InputInterface $input, OutputInterface $output)
49
    {
50
        $response = $this->getFacade()->performCreateTransactionApiCall($this->createRequestTransfer());
51
        echo json_encode($response->toArray(true, true), JSON_PRETTY_PRINT);
52
    }
53
54
    /**
55
     * @return \Generated\Shared\Transfer\CrefoPayApiRequestTransfer
56
     */
57
    protected function createRequestTransfer(): CrefoPayApiRequestTransfer
58
    {
59
        $request = new CrefoPayApiRequestTransfer();
60
        $request->setCreateTransactionRequest($this->createRequestCallTransfer());
61
62
        return $request;
63
    }
64
65
    protected function createRequestCallTransfer()
66
    {
67
        return (new CrefoPayApiCreateTransactionRequestTransfer())
68
            ->setMerchantID(265)
69
            ->setStoreID('sprykerdevelEUR')
70
            ->setOrderID('test-order-id')
71
            ->setUserID('user-id')
72
            ->setIntegrationType('API')
73
            ->setAutoCapture(false)
74
            ->setMerchantReference('reference')
75
            ->setContext('ONLINE')
76
            ->setUserType('PRIVATE')
77
            ->setUserRiskClass(0)
78
            ->setUserIpAddress('127.0.0.1')
79
            ->setUserData(
80
                (new CrefoPayApiPersonTransfer())
81
                    ->setSalutation('M')
82
                    ->setName('Aleksey')
83
                    ->setSurname('Kotsuba')
84
                    ->setDateOfBirth('1988-10-22')
85
                    ->setEmail('[email protected]')
86
                    ->setPhoneNumber('0380937880368')
87
            )
88
            ->setBillingAddress(
89
                (new CrefoPayApiAddressTransfer())
90
                    ->setZip('123456')
91
                    ->setCountry('DE')
92
                    ->setCity('Berlin')
93
                    ->setStreet('Test street')
94
                    ->setNo('12')
95
            )
96
            ->setAmount(
97
                (new CrefoPayApiAmountTransfer())
98
                    ->setAmount(1922)
99
                    ->setVatAmount(19)
100
                    ->setVatRate(10.00)
101
            )
102
            ->setBasketItems($this->createBasket())
103
            ->setLocale('EN');
104
    }
105
106
    protected function createBasket()
107
    {
108
        $basket = new ArrayObject();
109
        $basket->append(
110
                (new CrefoPayApiBasketItemTransfer())
111
                    ->setBasketItemAmount(
112
                        (new CrefoPayApiAmountTransfer())
113
                            ->setAmount(1922)
114
                            ->setVatAmount(19)
115
                            ->setVatRate(10.00)
116
                    )
117
                    ->setBasketItemCount(1)
118
                    ->setBasketItemID('sku')
119
                    ->setBasketItemText('Description')
120
                    ->setBasketItemRiskClass(0)
121
                    ->setBasketItemType('DEFAULT')
122
            );
123
124
        return $basket;
125
    }
126
}
127