Skip to content

Commit c1fce0e

Browse files
14.5 Updated gopay/payments-sdk-php (#4366)
Co-authored-by: Martin Grossmann <martin@vyvoj.net>
1 parent cf5b7c0 commit c1fce0e

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"elasticsearch/elasticsearch": "^7.6.1",
5757
"fakerphp/faker": "^1.19.0",
5858
"friendsofsymfony/ckeditor-bundle": "^2.1",
59-
"gopay/payments-sdk-php": ">=1.4 <1.7",
59+
"gopay/payments-sdk-php": "^1.10",
6060
"gedmo/doctrine-extensions": "^3.5",
6161
"gordalina/cachetool": "^8.5",
6262
"guzzlehttp/guzzle": "^7.5",

src/Model/GoPay/GoPayClient.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class GoPayClient
2020
{
21-
public const RESPONSE_STATUS_CODE_OK = 200;
21+
protected const int RESPONSE_STATUS_CODE_OK = 200;
2222

2323
protected GoPay $goPay;
2424

@@ -56,9 +56,9 @@ protected function sendApiRequest(
5656
if ($token->token) {
5757
return $this->goPay->call(
5858
$urlPath,
59-
$contentType,
6059
'Bearer ' . $token->token,
6160
$method,
61+
$contentType,
6262
$data,
6363
);
6464
}
@@ -98,11 +98,11 @@ public function getStatus(string $id): Response
9898

9999
$response = $this->sendApiRequest($urlPath, GoPay::FORM, RequestMethods::GET);
100100

101-
if ((int)$response->statusCode !== (int)self::RESPONSE_STATUS_CODE_OK) {
101+
if ((int)$response->statusCode !== self::RESPONSE_STATUS_CODE_OK) {
102102
throw new GoPayPaymentDownloadException(
103103
$this->goPay->buildUrl($urlPath),
104104
RequestMethods::GET,
105-
self::RESPONSE_STATUS_CODE_OK,
105+
static::RESPONSE_STATUS_CODE_OK,
106106
null,
107107
$response,
108108
);
@@ -130,11 +130,11 @@ public function refundTransaction(string $id, int $amount): Response
130130
$body,
131131
);
132132

133-
if ((int)$response->statusCode !== (int)self::RESPONSE_STATUS_CODE_OK) {
133+
if ((int)$response->statusCode !== self::RESPONSE_STATUS_CODE_OK) {
134134
throw new GoPayPaymentDownloadException(
135135
$this->goPay->buildUrl($urlPath),
136136
RequestMethods::POST,
137-
self::RESPONSE_STATUS_CODE_OK,
137+
static::RESPONSE_STATUS_CODE_OK,
138138
$body,
139139
$response,
140140
);
@@ -157,17 +157,17 @@ public function downloadGoPayPaymentMethodsByCurrency(Currency $currency): array
157157
RequestMethods::GET,
158158
);
159159

160-
if ((int)$response->statusCode !== (int)self::RESPONSE_STATUS_CODE_OK) {
160+
if ((int)$response->statusCode !== self::RESPONSE_STATUS_CODE_OK) {
161161
throw new GoPayPaymentDownloadException(
162162
$this->goPay->buildUrl($urlPath),
163163
RequestMethods::GET,
164-
self::RESPONSE_STATUS_CODE_OK,
164+
static::RESPONSE_STATUS_CODE_OK,
165165
null,
166166
$response,
167167
);
168168
}
169169

170-
return $response->json['enabledPaymentInstruments'];
170+
return $response->json['enabledPaymentInstruments'] ?? [];
171171
}
172172

173173
/**

src/Model/GoPay/GoPayClientFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
class GoPayClientFactory
1010
{
11+
protected const string PRODUCTION_URL = 'https://gate.gopay.cz/api';
12+
protected const string TEST_URL = 'https://gw.sandbox.gopay.com/api';
13+
1114
/**
1215
* @param array $config
1316
*/
@@ -41,6 +44,8 @@ protected function getConfigByLocale(string $locale): array
4144
throw new GoPayNotConfiguredException();
4245
}
4346

47+
$this->config['gatewayUrl'] = $this->config['isProductionMode'] ? static::PRODUCTION_URL : static::TEST_URL;
48+
4449
return $this->config;
4550
}
4651
}

0 commit comments

Comments
 (0)