Skip to content

Commit 08d28e0

Browse files
committed
Update yookassa_api.pas
1 parent 8f291e8 commit 08d28e0

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

yookassa_api.pas

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -311,20 +311,20 @@ destructor TYookassaResponse.Destroy;
311311

312312
function TYookassaPaymentResponse.GetId: string;
313313
begin
314-
Result := Raw.Get('id', '');
314+
Result := Raw.Get('id', EmptyStr);
315315
end;
316316

317317
function TYookassaPaymentResponse.GetStatus: string;
318318
begin
319-
Result := Raw.Get('status', '');
319+
Result := Raw.Get('status', EmptyStr);
320320
end;
321321

322322
function TYookassaPaymentResponse.GetConfirmationURL: string;
323323
begin
324324
if Assigned(Raw.Find('confirmation')) then
325-
Result := Raw.Objects['confirmation'].Get('confirmation_url', '')
325+
Result := Raw.Objects['confirmation'].Get('confirmation_url', EmptyStr)
326326
else
327-
Result := '';
327+
Result := EmptyStr;
328328
end;
329329

330330
function TYookassaPaymentResponse.GetAmount: Currency;
@@ -351,7 +351,7 @@ function TYookassaReceiptResponse.GetId: string;
351351

352352
function TYookassaReceiptResponse.GetStatus: string;
353353
begin
354-
Result := Raw.Get('status', '');
354+
Result := Raw.Get('status', EmptyStr);
355355
end;
356356

357357
{ TYookassaRequest }
@@ -498,9 +498,9 @@ function TYookassaSupplier.ToJSON: TJSONObject;
498498
begin
499499
Result := TJSONObject.Create;
500500
try
501-
if FName <> '' then Result.Add('name', FName);
502-
if FPhone <> '' then Result.Add('phone', FPhone);
503-
if FInn <> '' then Result.Add('inn', FInn);
501+
if FName <> EmptyStr then Result.Add('name', FName);
502+
if FPhone <> EmptyStr then Result.Add('phone', FPhone);
503+
if FInn <> EmptyStr then Result.Add('inn', FInn);
504504
except
505505
FreeAndNil(Result);
506506
raise;
@@ -533,6 +533,7 @@ function TYookassaReceiptItem.GetSupplier: TYookassaSupplier;
533533

534534
constructor TYookassaReceiptItem.Create;
535535
begin
536+
inherited Create;
536537
MarkMode := -1; // -1 = not specified
537538
end;
538539

@@ -557,14 +558,14 @@ function TYookassaReceiptItem.ToJSON: TJSONObject;
557558
aAmount.Add('currency', AmountCurrency);
558559
Result.Add('amount', aAmount);
559560
Result.Add('vat_code', VatCode);
560-
if PaymentMode <> '' then Result.Add('payment_mode', PaymentMode);
561-
if PaymentSubject <> '' then Result.Add('payment_subject', PaymentSubject);
561+
if PaymentMode <> EmptyStr then Result.Add('payment_mode', PaymentMode);
562+
if PaymentSubject <> EmptyStr then Result.Add('payment_subject', PaymentSubject);
562563
if MarkMode >= 0 then
563564
begin
564565
Result.Add('mark_mode', MarkMode);
565566

566567
// check MarkCodeInfo
567-
if MarkCodeInfo = '' then
568+
if MarkCodeInfo = EmptyStr then
568569
raise EYooKassaValidationError.Create('MarkCodeInfo is required when MarkMode is set');
569570

570571
if not IsValidBase64(MarkCodeInfo) then
@@ -586,7 +587,7 @@ function TYookassaReceiptItem.ToJSON: TJSONObject;
586587
Result.Add('mark_code_info', aMarkCodeInfo);
587588
end;
588589

589-
if Measure <> '' then
590+
if Measure <> EmptyStr then
590591
Result.Add('measure', Measure);
591592

592593
// agent_type (ФФД 1.1)
@@ -640,10 +641,10 @@ procedure TYookassaReceipt.AppendJSON(aJSON: TJSONObject);
640641
Item: TYookassaReceiptItem;
641642
begin
642643
// customer
643-
if (CustomerEmail <> '') or (CustomerPhone <> '') then begin
644+
if (CustomerEmail <> EmptyStr) or (CustomerPhone <> EmptyStr) then begin
644645
aCustomer := TJSONObject.Create;
645-
if CustomerEmail <> '' then aCustomer.Add('email', CustomerEmail);
646-
if CustomerPhone <> '' then aCustomer.Add('phone', CustomerPhone);
646+
if CustomerEmail <> EmptyStr then aCustomer.Add('email', CustomerEmail);
647+
if CustomerPhone <> EmptyStr then aCustomer.Add('phone', CustomerPhone);
647648
aJson.Add('customer', aCustomer);
648649
end;
649650

@@ -679,7 +680,7 @@ function TYookassaSettlement.ToJSON: TJSONObject;
679680
begin
680681
Result := TJSONObject.Create;
681682
try
682-
if FType <> '' then
683+
if FType <> EmptyStr then
683684
Result.Add('type', FType);
684685

685686
aAmount := TJSONObject.Create;
@@ -734,7 +735,7 @@ function TYookassaCreateReceiptRequest.ToJSON: TJSONObject;
734735
EYooKassaValidationError.RaiseIfFalse(FReceipt.Items.Count > 0, 'Receipt must have at least one item');
735736

736737
if FReceiptType = 'refund' then
737-
EYooKassaValidationError.RaiseIfFalse((FPaymentId <> '') or (FRefundId <> ''),
738+
EYooKassaValidationError.RaiseIfFalse((FPaymentId <> EmptyStr) or (FRefundId <> EmptyStr),
738739
'For refund receipt, either PaymentId or RefundId must be specified');
739740
// receipt type (payment/refund)
740741
Result.Add('type', FReceiptType);
@@ -748,9 +749,9 @@ function TYookassaCreateReceiptRequest.ToJSON: TJSONObject;
748749

749750
// The refund receipt requires a payment_id or a refund_id.
750751
if FReceiptType = 'refund' then begin
751-
if FPaymentId <> '' then
752+
if FPaymentId <> EmptyStr then
752753
Result.Add('payment_id', FPaymentId)
753-
else if FRefundId <> '' then
754+
else if FRefundId <> EmptyStr then
754755
Result.Add('refund_id', FRefundId);
755756
end
756757
else
@@ -944,7 +945,7 @@ function TYookassaCreatePaymentRequest.ToJSON: TJSONObject;
944945
Result.Add('description', FDescription);
945946
Result.Add('confirmation', BuildConfirmationJSON);
946947
Result.Add('capture', True);
947-
if FMetaOrderId <> '' then
948+
if FMetaOrderId <> EmptyStr then
948949
Result.Add('metadata', BuildMetadataJSON);
949950
if Assigned(FReceipt) then
950951
Result.Add('receipt', FReceipt.ToJSON);

0 commit comments

Comments
 (0)