getValidateBankAccountApiEndpointUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\AfterPay;
9
10
use Spryker\Zed\Kernel\AbstractBundleConfig;
11
use SprykerEco\Shared\AfterPay\AfterPayConfig as SharedAfterPayConfig;
12
use SprykerEco\Shared\AfterPay\AfterPayConstants;
13
14
class AfterPayConfig extends AbstractBundleConfig
15
{
16
    /**
17
     * @var string
18
     */
19
    protected const SALUTATION_DEFAULT = 'Mr';
20
21
    /**
22
     * @var array
23
     */
24
    protected const SALUTATION_MAP = [
25
        'Mr' => 'Mr',
26
        'Ms' => 'Miss',
27
        'Miss' => 'Miss',
28
        'Mrs' => 'Mrs',
29
        'Missis' => 'Mrs',
30
        'Dr' => 'Mr',
31
    ];
32
33
    /**
34
     * @api
35
     *
36
     * @param string $orderNumber
37
     *
38
     * @return string
39
     */
40
    public function getCaptureApiEndpointUrl(string $orderNumber): string
41
    {
42
        return $this->getApiEndpointUrl(
43
            sprintf(SharedAfterPayConfig::API_ENDPOINT_CAPTURE_PATH, $orderNumber),
44
        );
45
    }
46
47
    /**
48
     * @api
49
     *
50
     * @param string $orderNumber
51
     *
52
     * @return string
53
     */
54
    public function getRefundApiEndpointUrl(string $orderNumber): string
55
    {
56
        return $this->getApiEndpointUrl(
57
            sprintf(SharedAfterPayConfig::API_ENDPOINT_REFUND_PATH, $orderNumber),
58
        );
59
    }
60
61
    /**
62
     * @api
63
     *
64
     * @param string $orderNumber
65
     *
66
     * @return string
67
     */
68
    public function getCancelApiEndpointUrl(string $orderNumber): string
69
    {
70
        return $this->getApiEndpointUrl(
71
            sprintf(SharedAfterPayConfig::API_ENDPOINT_CANCEL_PATH, $orderNumber),
72
        );
73
    }
74
75
    /**
76
     * @api
77
     *
78
     * @return string
79
     */
80
    public function getAuthorizeApiEndpointUrl(): string
81
    {
82
        return $this->getApiEndpointUrl(
83
            SharedAfterPayConfig::API_ENDPOINT_AUTHORIZE_PATH,
84
        );
85
    }
86
87
    /**
88
     * @api
89
     *
90
     * @return string
91
     */
92
    public function getValidateAddressApiEndpointUrl(): string
93
    {
94
        return $this->getApiEndpointUrl(
95
            SharedAfterPayConfig::API_ENDPOINT_VALIDATE_ADDRESS_PATH,
96
        );
97
    }
98
99
    /**
100
     * @api
101
     *
102
     * @return string
103
     */
104
    public function getLookupCustomerApiEndpointUrl(): string
105
    {
106
        return $this->getApiEndpointUrl(
107
            SharedAfterPayConfig::API_ENDPOINT_LOOKUP_CUSTOMER_PATH,
108
        );
109
    }
110
111
    /**
112
     * @api
113
     *
114
     * @return string
115
     */
116
    public function getLookupInstallmentPlansApiEndpointUrl(): string
117
    {
118
        return $this->getApiEndpointUrl(
119
            SharedAfterPayConfig::API_ENDPOINT_LOOKUP_INSTALLMENT_PLANS_PATH,
120
        );
121
    }
122
123
    /**
124
     * @api
125
     *
126
     * @return string
127
     */
128
    public function getValidateBankAccountApiEndpointUrl(): string
129
    {
130
        return $this->getApiEndpointUrl(
131
            SharedAfterPayConfig::API_ENDPOINT_VALIDATE_BANK_ACCOUNT_PATH,
132
        );
133
    }
134
135
    /**
136
     * @api
137
     *
138
     * @return string
139
     */
140
    public function getStatusApiEndpointUrl(): string
141
    {
142
        return $this->getApiEndpointUrl(
143
            SharedAfterPayConfig::API_ENDPOINT_API_STATUS_PATH,
144
        );
145
    }
146
147
    /**
148
     * @api
149
     *
150
     * @return string
151
     */
152
    public function getVersionApiEndpointUrl(): string
153
    {
154
        return $this->getApiEndpointUrl(
155
            SharedAfterPayConfig::API_ENDPOINT_API_VERSION_PATH,
156
        );
157
    }
158
159
    /**
160
     * @api
161
     *
162
     * @return string
163
     */
164
    public function getAvailablePaymentMethodsApiEndpointUrl(): string
165
    {
166
        return $this->getApiEndpointUrl(
167
            SharedAfterPayConfig::API_ENDPOINT_AVAILABLE_PAYMENT_METHODS_PATH,
168
        );
169
    }
170
171
    /**
172
     * @api
173
     *
174
     * @return string
175
     */
176
    public function getApiCredentialsAuthKey(): string
177
    {
178
        return $this->get(AfterPayConstants::API_CREDENTIALS_AUTH_KEY);
179
    }
180
181
    /**
182
     * @api
183
     *
184
     * @return string
185
     */
186
    public function getAfterPayAuthorizeWorkflow(): string
187
    {
188
        return $this->get(AfterPayConstants::AFTERPAY_AUTHORIZE_WORKFLOW);
189
    }
190
191
    /**
192
     * @api
193
     *
194
     * @param string $paymentMethod
195
     *
196
     * @return string
197
     */
198
    public function getPaymentChannelId(string $paymentMethod): string
199
    {
200
        if ($paymentMethod === SharedAfterPayConfig::PAYMENT_METHOD_INVOICE) {
201
            return $this->get(AfterPayConstants::PAYMENT_INVOICE_CHANNEL_ID);
202
        }
203
204
        return $this->get(AfterPayConstants::PAYMENT_INVOICE_CHANNEL_ID);
205
    }
206
207
    /**
208
     * @api
209
     *
210
     * @return string
211
     */
212
    public function getPaymentAuthorizationFailedUrl(): string
213
    {
214
        return $this->get(AfterPayConstants::AFTERPAY_YVES_AUTHORIZE_PAYMENT_FAILED_URL);
215
    }
216
217
    /**
218
     * @api
219
     *
220
     * @param string $salutation
221
     *
222
     * @return string
223
     */
224
    public function getSalutation(string $salutation): string
225
    {
226
        return static::SALUTATION_MAP[$salutation] ?? static::SALUTATION_DEFAULT;
227
    }
228
229
    /**
230
     * @param string $endpointPath
231
     *
232
     * @return string
233
     */
234
    protected function getApiEndpointUrl(string $endpointPath): string
235
    {
236
        $endpointBaseUrl = $this->get(AfterPayConstants::API_ENDPOINT_BASE_URL);
237
238
        return $endpointBaseUrl . $endpointPath;
239
    }
240
}
241