Passed
Pull Request — master (#28)
by Volodymyr
05:26
created

sendConsumerScoreRequestAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Payone\Communication\Controller;
9
10
use Generated\Shared\Transfer\AddressCheckResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ssCheckResponseTransfer 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...
11
use Generated\Shared\Transfer\ConsumerScoreResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...erScoreResponseTransfer 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\PayoneBankAccountCheckTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ankAccountCheckTransfer 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\PayoneCancelRedirectTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...eCancelRedirectTransfer 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\PayoneGetFileTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PayoneGetFileTransfer 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\PayoneGetInvoiceTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PayoneGetInvoiceTransfer 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\PayoneGetPaymentDetailTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...etPaymentDetailTransfer 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 Generated\Shared\Transfer\PayoneGetSecurityInvoiceTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...SecurityInvoiceTransfer 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 Generated\Shared\Transfer\PayoneInitPaypalExpressCheckoutRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...CheckoutRequestTransfer 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 Generated\Shared\Transfer\PayoneManageMandateTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...neManageMandateTransfer 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
use Generated\Shared\Transfer\PayoneTransactionStatusUpdateTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ionStatusUpdateTransfer 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...
21
use Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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...
22
use Orm\Zed\Sales\Persistence\Base\SpySalesOrderQuery;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Sales\Persistence\Base\SpySalesOrderQuery 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...
23
use Orm\Zed\Sales\Persistence\SpySalesOrderItemQuery;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Sales\Persistence\SpySalesOrderItemQuery 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...
24
use Spryker\Zed\Kernel\Communication\Controller\AbstractGatewayController;
25
use SprykerEco\Shared\Payone\PayoneConstants;
26
27
/**
28
 * @method \SprykerEco\Zed\Payone\Business\PayoneFacadeInterface getFacade()
29
 * @method \SprykerEco\Zed\Payone\Communication\PayoneCommunicationFactory getFactory()
30
 */
31
class GatewayController extends AbstractGatewayController
32
{
33
    /**
34
     * @param \Generated\Shared\Transfer\PayoneTransactionStatusUpdateTransfer $transactionStatusUpdateTransfer
35
     *
36
     * @return \Generated\Shared\Transfer\PayoneTransactionStatusUpdateTransfer
37
     */
38
    public function statusUpdateAction(PayoneTransactionStatusUpdateTransfer $transactionStatusUpdateTransfer)
39
    {
40
        $transactionStatusUpdateTransfer = $this
41
            ->getFacade()
42
            ->processTransactionStatusUpdate($transactionStatusUpdateTransfer);
43
44
        $this->triggerEventsOnSuccess($transactionStatusUpdateTransfer);
45
46
        return $transactionStatusUpdateTransfer;
47
    }
48
49
    /**
50
     * @param \Generated\Shared\Transfer\PayoneCancelRedirectTransfer $cancelRedirectTransfer
51
     *
52
     * @return \Generated\Shared\Transfer\PayoneCancelRedirectTransfer
53
     */
54
    public function cancelRedirectAction(PayoneCancelRedirectTransfer $cancelRedirectTransfer)
55
    {
56
        $urlHmacGenerator = $this->getFactory()->createUrlHmacGenerator();
57
        $hash = $urlHmacGenerator->hash(
58
            $cancelRedirectTransfer->getOrderReference(),
59
            $this->getFactory()->getConfig()->getRequestStandardParameter()->getKey()
60
        );
61
62
        if ($cancelRedirectTransfer->getUrlHmac() === $hash) {
63
            $orderItems = SpySalesOrderItemQuery::create()
64
                ->useOrderQuery()
65
                ->filterByOrderReference($cancelRedirectTransfer->getOrderReference())
66
                ->endUse()
67
                ->find();
68
69
            $this->getFactory()->getOmsFacade()->triggerEvent('cancel redirect', $orderItems, []);
70
        }
71
72
        return $cancelRedirectTransfer;
73
    }
74
75
    /**
76
     * @param \Generated\Shared\Transfer\PayoneInitPaypalExpressCheckoutRequestTransfer $requestTransfer
77
     *
78
     * @return \Generated\Shared\Transfer\PayonePaypalExpressCheckoutGenericPaymentResponseTransfer
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...PaymentResponseTransfer 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...
79
     */
80
    public function initPaypalExpressCheckoutAction(PayoneInitPaypalExpressCheckoutRequestTransfer $requestTransfer)
81
    {
82
        return $this->getFacade()->initPaypalExpressCheckout($requestTransfer);
83
    }
84
85
    /**
86
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
87
     *
88
     * @return \Generated\Shared\Transfer\PayonePaypalExpressCheckoutGenericPaymentResponseTransfer
89
     */
90
    public function getPaypalExpressCheckoutDetailsAction(QuoteTransfer $quoteTransfer)
91
    {
92
        return $this->getFacade()->getPaypalExpressCheckoutDetails($quoteTransfer);
93
    }
94
95
    /**
96
     * @internal param TransactionStatusResponse $response
97
     *
98
     * @param \Generated\Shared\Transfer\PayoneTransactionStatusUpdateTransfer $transactionStatusUpdateTransfer
99
     *
100
     * @return void
101
     */
102
    protected function triggerEventsOnSuccess(PayoneTransactionStatusUpdateTransfer $transactionStatusUpdateTransfer)
103
    {
104
        if (!$transactionStatusUpdateTransfer->getIsSuccess()) {
105
            return;
106
        }
107
108
        $orderItems = SpySalesOrderItemQuery::create()
109
            ->useOrderQuery()
110
            ->useSpyPaymentPayoneQuery()
111
            ->filterByTransactionId($transactionStatusUpdateTransfer->getTxid())
112
            ->endUse()
113
            ->endUse()
114
            ->find();
115
        $this->getFactory()->getOmsFacade()->triggerEvent('PaymentNotificationReceived', $orderItems, []);
116
117
        if ($transactionStatusUpdateTransfer->getTxaction() === PayoneConstants::PAYONE_TXACTION_APPOINTED) {
118
            $this->getFactory()->getOmsFacade()->triggerEvent('RedirectResponseAppointed', $orderItems, []);
119
        }
120
    }
121
122
    /**
123
     * @param \Generated\Shared\Transfer\PayoneBankAccountCheckTransfer $bankAccountCheck
124
     *
125
     * @return \Generated\Shared\Transfer\PayoneBankAccountCheckTransfer
126
     */
127
    public function bankAccountCheckAction(PayoneBankAccountCheckTransfer $bankAccountCheck)
128
    {
129
        return $this->getFacade()->bankAccountCheck($bankAccountCheck);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getFacade(...heck($bankAccountCheck) returns the type SprykerEco\Zed\Payone\Bu...tCheckResponseContainer which is incompatible with the documented return type Generated\Shared\Transfe...ankAccountCheckTransfer.
Loading history...
130
    }
131
132
    /**
133
     * @param \Generated\Shared\Transfer\PayoneManageMandateTransfer $manageMandateTransfer
134
     *
135
     * @return \Generated\Shared\Transfer\PayoneManageMandateTransfer
136
     */
137
    public function manageMandateAction(PayoneManageMandateTransfer $manageMandateTransfer)
138
    {
139
        return $this->getFacade()->manageMandate($manageMandateTransfer);
140
    }
141
142
    /**
143
     * @param \Generated\Shared\Transfer\PayoneGetFileTransfer $getFileTransfer
144
     *
145
     * @return \Generated\Shared\Transfer\PayoneGetFileTransfer
146
     */
147
    public function getFileAction(PayoneGetFileTransfer $getFileTransfer)
148
    {
149
        return $this->getFacade()->getFile($getFileTransfer);
150
    }
151
152
    /**
153
     * @param \Generated\Shared\Transfer\PayoneGetInvoiceTransfer $getInvoiceTransfer
154
     *
155
     * @return \Generated\Shared\Transfer\PayoneGetInvoiceTransfer
156
     */
157
    public function getInvoiceAction(PayoneGetInvoiceTransfer $getInvoiceTransfer)
158
    {
159
        return $this->getFacade()->getInvoice($getInvoiceTransfer);
160
    }
161
162
    /**
163
     * @param \Generated\Shared\Transfer\PayoneGetSecurityInvoiceTransfer $getSecurityInvoiceTransfer
164
     *
165
     * @return \Generated\Shared\Transfer\PayoneGetSecurityInvoiceTransfer
166
     */
167
    public function getSecurityInvoiceAction(PayoneGetSecurityInvoiceTransfer $getSecurityInvoiceTransfer): PayoneGetSecurityInvoiceTransfer
168
    {
169
        return $this->getFacade()->getSecurityInvoice($getSecurityInvoiceTransfer);
170
    }
171
172
    /**
173
     * @param \Generated\Shared\Transfer\PayoneGetPaymentDetailTransfer $getPaymentDetailTransfer
174
     *
175
     * @return \Generated\Shared\Transfer\PayoneGetPaymentDetailTransfer
176
     */
177
    public function getPaymentDetailAction(PayoneGetPaymentDetailTransfer $getPaymentDetailTransfer)
178
    {
179
        if (!empty($getPaymentDetailTransfer->getOrderReference())) {
180
            $order = SpySalesOrderQuery::create()
181
                ->filterByOrderReference($getPaymentDetailTransfer->getOrderReference())
182
                ->findOne();
183
            $getPaymentDetailTransfer->setOrderId($order->getIdSalesOrder());
184
        }
185
        $response = $this->getFacade()->getPaymentDetail($getPaymentDetailTransfer->getOrderId());
186
        $getPaymentDetailTransfer->setPaymentDetail($response);
187
        return $getPaymentDetailTransfer;
188
    }
189
190
    /**
191
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
192
     *
193
     * @return \Generated\Shared\Transfer\AddressCheckResponseTransfer
194
     */
195
    public function sendAddressCheckRequestAction(QuoteTransfer $quoteTransfer): AddressCheckResponseTransfer
196
    {
197
        return $this->getFacade()->sendAddressCheckRequest($quoteTransfer);
198
    }
199
200
    /**
201
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
202
     *
203
     * @return \Generated\Shared\Transfer\ConsumerScoreResponseTransfer
204
     */
205
    public function sendConsumerScoreRequestAction(QuoteTransfer $quoteTransfer): ConsumerScoreResponseTransfer
206
    {
207
        return $this->getFacade()->sendConsumerScoreRequest($quoteTransfer);
208
    }
209
}
210