Passed
Push — master ( a8446e...164738 )
by
unknown
13:26
created

PayoneConfig::getAddressCheckType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
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;
9
10
use Generated\Shared\Transfer\PayonePaymentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PayonePaymentTransfer 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\PayoneStandardParameterTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...andardParameterTransfer 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 Orm\Zed\Sales\Persistence\SpySalesOrder;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Sales\Persistence\SpySalesOrder 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 Spryker\Shared\Kernel\Store;
14
use Spryker\Zed\Kernel\AbstractBundleConfig;
15
use Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject;
16
use SprykerEco\Shared\Payone\PayoneApiConstants;
17
use SprykerEco\Shared\Payone\PayoneConstants;
18
19
class PayoneConfig extends AbstractBundleConfig
20
{
21
    public const PROVIDER_NAME = 'Payone';
22
    public const PAYMENT_METHOD_CREDIT_CARD = 'payoneCreditCard';
23
    public const PAYMENT_METHOD_E_WALLET = 'payoneEWallet';
24
    public const PAYMENT_METHOD_DIRECT_DEBIT = 'payoneDirectDebit';
25
    public const PAYMENT_METHOD_ONLINE_TRANSFER = 'payoneOnlineTransfer';
26
    public const PAYMENT_METHOD_EPS_ONLINE_TRANSFER = 'payoneEpsOnlineTransfer';
27
    public const PAYMENT_METHOD_INSTANT_ONLINE_TRANSFER = 'payoneInstantOnlineTransfer';
28
    public const PAYMENT_METHOD_GIROPAY_ONLINE_TRANSFER = 'payoneGiropayOnlineTransfer';
29
    public const PAYMENT_METHOD_IDEAL_ONLINE_TRANSFER = 'payoneIdealOnlineTransfer';
30
    public const PAYMENT_METHOD_POSTFINANCE_EFINANCE_ONLINE_TRANSFER = 'payonePostfinanceEfinanceOnlineTransfer';
31
    public const PAYMENT_METHOD_POSTFINANCE_CARD_ONLINE_TRANSFER = 'payonePostfinanceCardOnlineTransfer';
32
    public const PAYMENT_METHOD_PRZELEWY24_ONLINE_TRANSFER = 'payonePrzelewy24OnlineTransfer';
33
    public const PAYMENT_METHOD_BANCONTACT_ONLINE_TRANSFER = 'payoneBancontactOnlineTransfer';
34
    public const PAYMENT_METHOD_PRE_PAYMENT = 'payonePrePayment';
35
    public const PAYMENT_METHOD_INVOICE = 'payoneInvoice';
36
    public const PAYMENT_METHOD_SECURITY_INVOICE = 'payoneSecurityInvoice';
37
    public const PAYMENT_METHOD_CASH_ON_DELIVERY = 'payoneCashOnDelivery';
38
    public const PAYMENT_METHOD_PAYPAL_EXPRESS_CHECKOUT = PayoneConstants::PAYMENT_METHOD_PAYPAL_EXPRESS_CHECKOUT_STATE_MACHINE;
39
    public const PAYMENT_METHOD_KLARNA = 'payoneKlarna';
40
41
    public const PAYONE_ADDRESS_CHECK_BASIC = 'BA';
42
    public const PAYONE_ADDRESS_CHECK_PERSON = 'PE';
43
    public const PAYONE_ADDRESS_CHECK_NOT_CARRY_OUT_ADDRESS_CHECK = 'NO';
44
45
    public const PAYONE_BONIVERSUM_ADDRESS_CHECK_BASIC = 'BB';
46
    public const PAYONE_BONIVERSUM_ADDRESS_CHECK_PERSON = 'PB';
47
48
    public const PAYONE_SCHUFA_ADDRESS_CHECK_BASIC_SHORT = 'BS';
49
50
    public const PAYONE_ARVATO_CONSUMER_SCORE_HARD_CRITERIA = 'IH';
51
    public const PAYONE_ARVATO_CONSUMER_SCORE_ALL_CRITERIA = 'IA';
52
    public const PAYONE_ARVATO_CONSUMER_SCORE_ALL_CRITERIA_BONUS = 'IB';
53
    public const PAYONE_ARVATO_CONSUMER_SCORE_ALL_CRITERIA_BONUS_INFORMATION = 'IF';
54
55
    public const PAYONE_BONIVERSUM_CONSUMER_SCORE = 'CE';
56
57
    public const PAYONE_SCHUFA_CONSUMER_SCORE_SHORT = 'SFS';
58
    public const PAYONE_SCHUFA_CONSUMER_SCORE_MIDDLE = 'SFM';
59
60
    protected const DEFAULT_PAYONE_PAYMENT_METHODS_WITH_OPTIONAL_PAYMENT_DATA = [
61
        PayoneApiConstants::PAYMENT_METHOD_E_WALLET,
62
        PayoneApiConstants::PAYMENT_METHOD_CREDITCARD_PSEUDO,
63
        PayoneApiConstants::PAYMENT_METHOD_ONLINE_BANK_TRANSFER,
64
    ];
65
66
    /**
67
     * Fetches API request mode from config (could be 'live' or 'test').
68
     *
69
     * @api
70
     *
71
     * @return string
72
     */
73
    public function getMode()
74
    {
75
        $settings = $this->get(PayoneConstants::PAYONE);
76
77
        return $settings[PayoneConstants::PAYONE_MODE];
78
    }
79
80
    /**
81
     * Fetches default value for sequencenumber request parameter.
82
     *
83
     * @api
84
     *
85
     * @return int
86
     */
87
    public function getEmptySequenceNumber()
88
    {
89
        $settings = $this->get(PayoneConstants::PAYONE);
90
91
        return $settings[PayoneConstants::PAYONE_EMPTY_SEQUENCE_NUMBER];
92
    }
93
94
    /**
95
     * Fetches parameters that are common for all requests to Payone API.
96
     *
97
     * @api
98
     *
99
     * @return \Generated\Shared\Transfer\PayoneStandardParameterTransfer
100
     */
101
    public function getRequestStandardParameter()
102
    {
103
        $settings = $this->get(PayoneConstants::PAYONE);
104
        $standardParameter = new PayoneStandardParameterTransfer();
105
106
        $standardParameter->setEncoding($settings[PayoneConstants::PAYONE_CREDENTIALS_ENCODING]);
107
        $standardParameter->setMid($settings[PayoneConstants::PAYONE_CREDENTIALS_MID]);
108
        $standardParameter->setAid($settings[PayoneConstants::PAYONE_CREDENTIALS_AID]);
109
        $standardParameter->setPortalId($settings[PayoneConstants::PAYONE_CREDENTIALS_PORTAL_ID]);
110
        $standardParameter->setKey($settings[PayoneConstants::PAYONE_CREDENTIALS_KEY]);
111
        $standardParameter->setPaymentGatewayUrl($settings[PayoneConstants::PAYONE_PAYMENT_GATEWAY_URL]);
112
113
        $standardParameter = $this->addLegacyParameters($standardParameter);
0 ignored issues
show
Deprecated Code introduced by
The function SprykerEco\Zed\Payone\Pa...::addLegacyParameters() has been deprecated: Will be removed when Dynamic Store is always enabled. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

113
        $standardParameter = /** @scrutinizer ignore-deprecated */ $this->addLegacyParameters($standardParameter);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
114
115
        $standardParameter->setRedirectSuccessUrl($settings[PayoneConstants::PAYONE_REDIRECT_SUCCESS_URL]);
116
        $standardParameter->setRedirectBackUrl($settings[PayoneConstants::PAYONE_REDIRECT_BACK_URL]);
117
        $standardParameter->setRedirectErrorUrl($settings[PayoneConstants::PAYONE_REDIRECT_ERROR_URL]);
118
119
        return $standardParameter;
120
    }
121
122
    /**
123
     * Fetches reference string to identify Payone payment.
124
     *
125
     * @api
126
     *
127
     * @param \Generated\Shared\Transfer\PayonePaymentTransfer $paymentTransfer
128
     * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity
129
     *
130
     * @return string
131
     */
132
    public function generatePayoneReference(PayonePaymentTransfer $paymentTransfer, SpySalesOrder $orderEntity)
0 ignored issues
show
Unused Code introduced by
The parameter $paymentTransfer is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

132
    public function generatePayoneReference(/** @scrutinizer ignore-unused */ PayonePaymentTransfer $paymentTransfer, SpySalesOrder $orderEntity)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
133
    {
134
        return $orderEntity->getOrderReference();
135
    }
136
137
    /**
138
     * Fetches text for account statements.
139
     *
140
     * @api
141
     *
142
     * @param array $orderItems
143
     * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity
144
     * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data
145
     *
146
     * @return string
147
     */
148
    public function getNarrativeText(array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data)
0 ignored issues
show
Unused Code introduced by
The parameter $orderItems is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

148
    public function getNarrativeText(/** @scrutinizer ignore-unused */ array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

148
    public function getNarrativeText(array $orderItems, SpySalesOrder $orderEntity, /** @scrutinizer ignore-unused */ ReadOnlyArrayObject $data)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
149
    {
150
        return $orderEntity->getOrderReference();
151
    }
152
153
    /**
154
     * @return string
155
     */
156
    protected function getYvesBaseUrl()
157
    {
158
        return $this->get(PayoneConstants::HOST_YVES);
159
    }
160
161
    /**
162
     * Returns path to glossary translations file.
163
     *
164
     * @api
165
     *
166
     * @deprecated No longer used. Will be removed without replacement.
167
     *
168
     * @return string
169
     */
170
    public function getTranslationFilePath()
171
    {
172
        return __DIR__ . DIRECTORY_SEPARATOR . PayoneConstants::GLOSSARY_FILE_PATH;
0 ignored issues
show
Deprecated Code introduced by
The constant SprykerEco\Shared\Payone...nts::GLOSSARY_FILE_PATH has been deprecated: No longer used. Will be removed without replacement. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

172
        return __DIR__ . DIRECTORY_SEPARATOR . /** @scrutinizer ignore-deprecated */ PayoneConstants::GLOSSARY_FILE_PATH;

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
173
    }
174
175
    /**
176
     * @api
177
     *
178
     * @return string
179
     */
180
    public function getBusinessRelation(): string
181
    {
182
        $settings = $this->get(PayoneConstants::PAYONE);
183
184
        return $settings[PayoneConstants::PAYONE_BUSINESS_RELATION];
185
    }
186
187
    /**
188
     * @api
189
     *
190
     * @return string[]
191
     */
192
    public function getGScoreAvailablePaymentMethods(): array
193
    {
194
        $settings = $this->get(PayoneConstants::PAYONE);
195
196
        return $settings[PayoneConstants::PAYONE_GREEN_SCORE_AVAILABLE_PAYMENT_METHODS];
197
    }
198
199
    /**
200
     * @api
201
     *
202
     * @return string[]
203
     */
204
    public function getYScoreAvailablePaymentMethods(): array
205
    {
206
        $settings = $this->get(PayoneConstants::PAYONE);
207
208
        return $settings[PayoneConstants::PAYONE_YELLOW_SCORE_AVAILABLE_PAYMENT_METHODS];
209
    }
210
211
    /**
212
     * @api
213
     *
214
     * @return string[]
215
     */
216
    public function getRScoreAvailablePaymentMethods(): array
217
    {
218
        $settings = $this->get(PayoneConstants::PAYONE);
219
220
        return $settings[PayoneConstants::PAYONE_RED_SCORE_AVAILABLE_PAYMENT_METHODS];
221
    }
222
223
    /**
224
     * @api
225
     *
226
     * @return string[]
227
     */
228
    public function getUScoreAvailablePaymentMethods(): array
229
    {
230
        $settings = $this->get(PayoneConstants::PAYONE);
231
232
        return $settings[PayoneConstants::PAYONE_UNKNOWN_SCORE_AVAILABLE_PAYMENT_METHODS];
233
    }
234
235
    /**
236
     * @api
237
     *
238
     * @return string
239
     */
240
    public function getAddressCheckType(): string
241
    {
242
        $settings = $this->get(PayoneConstants::PAYONE);
243
244
        return $settings[PayoneConstants::PAYONE_ADDRESS_CHECK_TYPE];
245
    }
246
247
    /**
248
     * @api
249
     *
250
     * @return string
251
     */
252
    public function getConsumerScoreType(): string
253
    {
254
        $settings = $this->get(PayoneConstants::PAYONE);
255
256
        return $settings[PayoneConstants::PAYONE_CONSUMER_SCORE_TYPE];
257
    }
258
259
    /**
260
     * @api
261
     *
262
     * @return string[]
263
     */
264
    public function getPaymentMethodsWithOptionalPaymentData(): array
265
    {
266
        $settings = $this->get(PayoneConstants::PAYONE);
267
268
        return $settings[PayoneConstants::PAYONE_PAYMENT_METHODS_WITH_OPTIONAL_PAYMENT_DATA] ?? static::DEFAULT_PAYONE_PAYMENT_METHODS_WITH_OPTIONAL_PAYMENT_DATA;
269
    }
270
271
    /**
272
     * @deprecated Will be removed when Dynamic Store is always enabled.
273
     *
274
     * @param \Generated\Shared\Transfer\PayoneStandardParameterTransfer $standardParameter
275
     *
276
     * @return \Generated\Shared\Transfer\PayoneStandardParameterTransfer
277
     */
278
    protected function addLegacyParameters(PayoneStandardParameterTransfer $standardParameter): PayoneStandardParameterTransfer
279
    {
280
        if (Store::isDynamicStoreMode()) {
281
            return $standardParameter;
282
        }
283
284
        $standardParameter->setCurrency(Store::getInstance()->getCurrencyIsoCode());
285
        $standardParameter->setLanguage(Store::getInstance()->getCurrentLanguage());
286
287
        return $standardParameter;
288
    }
289
}
290