Skip to content

Commit 0dea1c9

Browse files
author
Pavel Chugunov
committed
DRAFT: Webhook: non required fields
1 parent c843103 commit 0dea1c9

File tree

7 files changed

+47
-47
lines changed

7 files changed

+47
-47
lines changed

src/CardDetails.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function setNumber(string $number): self
5555
/** @inheritDoc */
5656
public function getExpiryMonth(): ?int
5757
{
58-
return $this->expiryMonth;
58+
return $this->expiryMonth ?? null;
5959
}
6060

6161
/** @inheritDoc */
@@ -68,7 +68,7 @@ public function setExpiryMonth(int $expiryMonth): self
6868
/** @inheritDoc */
6969
public function getYear(): ?int
7070
{
71-
return $this->year;
71+
return $this->year ?? null;
7272
}
7373

7474
/** @inheritDoc */
@@ -85,7 +85,7 @@ public function setYear(int $year): self
8585
/** @inheritDoc */
8686
public function getExpiryYear(): ?int
8787
{
88-
return $this->expiryYear;
88+
return $this->expiryYear ?? null;
8989
}
9090

9191
/** @inheritDoc */
@@ -98,7 +98,7 @@ public function setExpiryYear(int $expiryYear): self
9898
/** @inheritDoc */
9999
public function getCvv(): ?string
100100
{
101-
return $this->cvv;
101+
return $this->cvv ?? null;
102102
}
103103

104104
/** @inheritDoc */
@@ -111,7 +111,7 @@ public function setCvv(string $cvv): self
111111
/** @inheritDoc */
112112
public function getOwner(): ?string
113113
{
114-
return $this->owner;
114+
return $this->owner ?? null;
115115
}
116116

117117
/** @inheritDoc */
@@ -124,7 +124,7 @@ public function setOwner(string $owner): self
124124
/** @inheritDoc */
125125
public function getTimeSpentTypingNumber(): ?int
126126
{
127-
return $this->timeSpentTypingNumber;
127+
return $this->timeSpentTypingNumber ?? null;
128128
}
129129

130130
/** @inheritDoc */
@@ -137,7 +137,7 @@ public function setTimeSpentTypingNumber(int $timeSpentTypingNumber): self
137137
/** @inheritDoc */
138138
public function getTimeSpentTypingOwner(): ?int
139139
{
140-
return $this->timeSpentTypingOwner;
140+
return $this->timeSpentTypingOwner ?? null;
141141
}
142142

143143
/** @inheritDoc */
@@ -150,7 +150,7 @@ public function setTimeSpentTypingOwner(int $timeSpentTypingOwner): self
150150
/** @inheritDoc */
151151
public function getBin(): ?int
152152
{
153-
return $this->bin;
153+
return $this->bin ?? null;
154154
}
155155

156156
/** @inheritDoc */
@@ -163,7 +163,7 @@ public function setBin(int $bin): self
163163
/** @inheritDoc */
164164
public function getPan(): ?string
165165
{
166-
return $this->pan;
166+
return $this->pan ?? null;
167167
}
168168

169169
/** @inheritDoc */
@@ -176,7 +176,7 @@ public function setPan(string $pan): self
176176
/** @inheritDoc */
177177
public function getType(): ?string
178178
{
179-
return $this->type;
179+
return $this->type ?? null;
180180
}
181181

182182
/** @inheritDoc */
@@ -189,7 +189,7 @@ public function setType(string $type): self
189189
/** @inheritDoc */
190190
public function getCardIssuerBank(): ?string
191191
{
192-
return $this->cardIssuerBank;
192+
return $this->cardIssuerBank ?? null;
193193
}
194194

195195
/** @inheritDoc */

src/OrderData.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class OrderData implements OrderDataInterface
3737
/** @inheritDoc */
3838
public function getOrderDate(): ?string
3939
{
40-
return $this->orderDate;
40+
return $this->orderDate ?? null;
4141
}
4242

4343
/** @inheritDoc */
@@ -59,7 +59,7 @@ public function setYpmnPaymentReference(string $ypmnPaymentReference): self
5959
/** @inheritDoc */
6060
public function getYpmnPaymentReference(): ?string
6161
{
62-
return $this->payUPaymentReference;
62+
return $this->payUPaymentReference ?? null;
6363
}
6464

6565
/** @inheritDoc */
@@ -73,13 +73,13 @@ public function setPayUPaymentReference(string $payUPaymentReference): self
7373
/** @inheritDoc */
7474
public function getPayUPaymentReference(): ?string
7575
{
76-
return $this->payUPaymentReference;
76+
return $this->payUPaymentReference ?? null;
7777
}
7878

7979
/** @inheritDoc */
8080
public function getMerchantPaymentReference(): ?string
8181
{
82-
return $this->merchantPaymentReference;
82+
return $this->merchantPaymentReference ?? null;
8383
}
8484

8585
/** @inheritDoc */
@@ -93,7 +93,7 @@ public function setMerchantPaymentReference(string $merchantPaymentReference): s
9393
/** @inheritDoc */
9494
public function getStatus(): ?string
9595
{
96-
return $this->status;
96+
return $this->status ?? null;
9797
}
9898

9999
/** @inheritDoc */
@@ -107,7 +107,7 @@ public function setStatus(string $status): self
107107
/** @inheritDoc */
108108
public function getCurrency(): ?string
109109
{
110-
return $this->currency;
110+
return $this->currency ?? null;
111111
}
112112

113113
/** @inheritDoc */
@@ -121,7 +121,7 @@ public function setCurrency(string $currency): self
121121
/** @inheritDoc */
122122
public function getAmount(): ?float
123123
{
124-
return $this->amount;
124+
return $this->amount ?? null;
125125
}
126126

127127
/** @inheritDoc */
@@ -135,7 +135,7 @@ public function setAmount(float $amount): self
135135
/** @inheritDoc */
136136
public function getCommission(): ?float
137137
{
138-
return $this->commission;
138+
return $this->commission ?? null;
139139
}
140140

141141
/** @inheritDoc */
@@ -151,7 +151,7 @@ public function setCommission(float $commission): self
151151
/** @inheritDoc */
152152
public function getRefundRequestId(): ?string
153153
{
154-
return $this->refundRequestId;
154+
return $this->refundRequestId ?? null;
155155
}
156156

157157
/** @inheritDoc */
@@ -164,7 +164,7 @@ public function setRefundRequestId(string $refundRequestId): self
164164
/** @inheritDoc */
165165
public function getLoyaltyPointsAmount(): ?int
166166
{
167-
return $this->loyaltyPointsAmount;
167+
return $this->loyaltyPointsAmount ?? null;
168168
}
169169

170170
/** @inheritDoc */
@@ -178,7 +178,7 @@ public function setLoyaltyPointsAmount(int $loyaltyPointsAmount): self
178178
/** @inheritDoc */
179179
public function getLoyaltyPointsDetails(): ?array
180180
{
181-
return $this->loyaltyPointsDetails;
181+
return $this->loyaltyPointsDetails ?? null;
182182
}
183183

184184
/** @inheritDoc */

src/PaymentResult.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PaymentResult implements PaymentResultInterface
4343
/** @inheritDoc */
4444
public function getPaymentMethod(): ?string
4545
{
46-
return $this->paymentMethod;
46+
return $this->paymentMethod ?? null;
4747
}
4848

4949
/** @inheritDoc */
@@ -56,7 +56,7 @@ public function setPaymentMethod(string $paymentMethod): self
5656
/** @inheritDoc */
5757
public function getPaymentDate(): ?string
5858
{
59-
return $this->paymentDate;
59+
return $this->paymentDate ?? null;
6060
}
6161

6262
/** @inheritDoc */
@@ -69,7 +69,7 @@ public function setPaymentDate(string $paymentDate): self
6969
/** @inheritDoc */
7070
public function getCaptureDate(): ?string
7171
{
72-
return $this->captureDate;
72+
return $this->captureDate ?? null;
7373
}
7474

7575
/** @inheritDoc */
@@ -82,7 +82,7 @@ public function setCaptureDate(string $captureDate): self
8282
/** @inheritDoc */
8383
public function getCardProgramName(): ?string
8484
{
85-
return $this->cardProgramName;
85+
return $this->cardProgramName ?? null;
8686
}
8787

8888
/** @inheritDoc */
@@ -95,7 +95,7 @@ public function setCardProgramName(string $cardProgramName): self
9595
/** @inheritDoc */
9696
public function getAuthCode(): ?string
9797
{
98-
return $this->authCode;
98+
return $this->authCode ?? null;
9999
}
100100

101101
/** @inheritDoc */
@@ -108,7 +108,7 @@ public function setAuthCode(string $authCode): self
108108
/** @inheritDoc */
109109
public function getMerchantId(): ?string
110110
{
111-
return $this->merchantId;
111+
return $this->merchantId ?? null;
112112
}
113113

114114
/** @inheritDoc */
@@ -121,7 +121,7 @@ public function setMerchantId(string $merchantId): self
121121
/** @inheritDoc */
122122
public function getRrn(): ?int
123123
{
124-
return $this->rrn;
124+
return $this->rrn ?? null;
125125
}
126126

127127
/** @inheritDoc */
@@ -134,7 +134,7 @@ public function setRrn(int $rrn): self
134134
/** @inheritDoc */
135135
public function getInstallmentsNumber(): ?string
136136
{
137-
return $this->installmentsNumber;
137+
return $this->installmentsNumber ?? null;
138138
}
139139

140140
/** @inheritDoc */
@@ -154,13 +154,13 @@ public function setCardDetails(CardDetailsInterface $cardDetails): self
154154
/** @inheritDoc */
155155
public function getCardDetails() : CardDetailsInterface
156156
{
157-
return $this->cardDetails;
157+
return $this->cardDetails ?? new CardDetails();
158158
}
159159

160160
/** @inheritDoc */
161161
public function getPaymentBankShortName(): ?string
162162
{
163-
return $this->paymentBankShortName;
163+
return $this->paymentBankShortName ?? null;
164164
}
165165

166166
/** @inheritDoc */
@@ -173,7 +173,7 @@ public function setPaymentBankShortName(string $paymentBankShortName): self
173173
/** @inheritDoc */
174174
public function getServiceProcessingType(): ?string
175175
{
176-
return $this->serviceProcessingType;
176+
return $this->serviceProcessingType ?? null;
177177
}
178178

179179
/** @inheritDoc */

src/Webhook.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function catchJsonRequest(): self
5050
}
5151

5252
if (!empty($request['orderData']['amount'])) {
53-
$this->orderData->setAmount($request['orderData']['amount']);
53+
$this->orderData->setAmount((float) $request['orderData']['amount']);
5454
}
5555

5656
if (isset($request['orderData']['commission'])) {
@@ -69,7 +69,7 @@ public function catchJsonRequest(): self
6969
$cardDetails = new CardDetails;
7070

7171
if (!empty($request['paymentResult']['cardDetails']['bin'])) {
72-
$cardDetails->setBin($request['paymentResult']['cardDetails']['bin']);
72+
$cardDetails->setBin((int) $request['paymentResult']['cardDetails']['bin']);
7373
}
7474

7575
if (!empty($request['paymentResult']['cardDetails']['owner'])) {
@@ -213,7 +213,7 @@ public function catchJsonRequest(): self
213213
/** @inheritDoc */
214214
public function getPaymentResult(): PaymentResultInterface
215215
{
216-
return $this->paymentResult;
216+
return $this->paymentResult ?? new PaymentResult();
217217
}
218218

219219
/** @inheritDoc */
@@ -226,7 +226,7 @@ public function setPaymentResult(PaymentResultInterface $paymentResult): self
226226
/** @inheritDoc */
227227
public function getOrderData(): OrderDataInterface
228228
{
229-
return $this->orderData;
229+
return $this->orderData ?? new OrderData();
230230
}
231231

232232
/** @inheritDoc */
@@ -246,6 +246,6 @@ public function setAuthorization(WebhookAuthorizationInterface $authorization):
246246
/** @inheritDoc */
247247
public function getAuthorization(): WebhookAuthorizationInterface
248248
{
249-
return $this->authorization;
249+
return $this->authorization ?? new WebhookAuthorization();
250250
}
251251
}

src/WebhookAuthorization.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public function setStoredCredentials(WebhookStoredCredentialsInterface $storedCr
1616
/** @inheritDoc */
1717
public function getStoredCredentials(): WebhookStoredCredentialsInterface
1818
{
19-
return $this->storedCredentials;
19+
return $this->storedCredentials ?? new WebhookStoredCredentials();
2020
}
2121
}

src/WebhookStoredCredentials.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public function setYpmnBindingId(string $ypmnBindingId): self
1313
return $this;
1414
}
1515

16-
public function getYpmnBindingId(): string
16+
public function getYpmnBindingId(): ?string
1717
{
18-
return $this->ypmnBindingId;
18+
return $this->ypmnBindingId ?? null;
1919
}
2020

2121
public function setUseId(string $useId): self
@@ -24,8 +24,8 @@ public function setUseId(string $useId): self
2424
return $this;
2525
}
2626

27-
public function getUseId(): string
27+
public function getUseId(): ?string
2828
{
29-
return $this->useId;
29+
return $this->useId ?? null;
3030
}
3131
}

src/WebhookStoredCredentialsInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public function setYpmnBindingId(string $ypmnBindingId): self;
1313

1414
/**
1515
* Получить токен подписки SberPay
16-
* @return string
16+
* @return string|null
1717
*/
18-
public function getYpmnBindingId(): string;
18+
public function getYpmnBindingId(): ?string;
1919

2020
/**
2121
* Установить идентификатор первоначальной операции
@@ -26,7 +26,7 @@ public function setUseId(string $useId): self;
2626

2727
/**
2828
* Получить идентификатор первоначальной операции
29-
* @return string
29+
* @return string|null
3030
*/
31-
public function getUseId(): string;
31+
public function getUseId(): ?string;
3232
}

0 commit comments

Comments
 (0)