Skip to content

Commit 65d25ee

Browse files
committed
PAymentMode enum
1 parent 937d860 commit 65d25ee

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

tests/test_yookassa_api.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ procedure TTestYooKassa.TestReceiptItemToJSON;
314314
aItem.AmountValue := 150.00;
315315
aItem.AmountCurrency := 'RUB';
316316
aItem.VatCode := 1;
317-
aItem.PaymentMode := 'full_prepayment';
317+
aItem.PaymentMode := pmFullPrepayment;
318318
aItem.PaymentSubject := 'commodity';
319319
aItem.Measure := 'piece';
320320

tests/test_yookassa_api_integration.pas

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class procedure TTestYooKassaIntegration.UpdateTestReceipt(TestReceipt: TYookass
126126
aItem.AmountValue := aAmount;
127127
aItem.AmountCurrency := aCurrency;
128128
aItem.VatCode := 1;
129-
aItem.PaymentMode := 'full_prepayment';
129+
aItem.PaymentMode := pmFullPrepayment;
130130
aItem.PaymentSubject := 'property_right';
131131

132132
aItem.Supplier.Name := 'Иванов И.П.';
@@ -263,7 +263,7 @@ procedure TTestYooKassaIntegration.TestCreatePaymentWithReceipt_Sandbox;
263263
aItem.AmountValue := FPaymentRequest.Amount;
264264
aItem.AmountCurrency := FPaymentRequest.Currency;
265265
aItem.VatCode := 1;
266-
aItem.PaymentMode := 'full_prepayment';
266+
aItem.PaymentMode := pmFullPrepayment;
267267
aItem.PaymentSubject := 'commodity';
268268
aReceipt.AddItem(aItem);
269269

@@ -356,7 +356,7 @@ procedure TTestYooKassaIntegration.TestCreateReceiptWithMarkCode_Sandbox;
356356
aItem.AmountValue := 200.00;
357357
aItem.AmountCurrency := 'RUB';
358358
aItem.VatCode := 2; // НДС 10%
359-
aItem.PaymentMode := 'full_prepayment';
359+
aItem.PaymentMode := pmFullPrepayment;
360360
aItem.PaymentSubject := 'commodity';
361361
aItem.MarkMode := 1; // The product is subject to labeling
362362
aItem.MarkCodeInfo := 'VGVzdE1hcmtDb2RlMTIzNDU2Nzg5MA=='; // Base64 test code
@@ -407,7 +407,7 @@ procedure TTestYooKassaIntegration.TestReceiptAfterPayment_Agent_Sandbox;
407407
aItem.AmountValue := FPaymentRequest.Amount;
408408
aItem.AmountCurrency := FPaymentRequest.Currency;
409409
aItem.VatCode := 1; // НДС 18%
410-
aItem.PaymentMode := 'full_prepayment';
410+
aItem.PaymentMode := pmFullPrepayment;
411411
aItem.PaymentSubject := 'commodity';
412412

413413
// supplier

yookassa_api.pas

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,18 @@ TYookassaSupplier = class(TYookassaAPIObject)
109109
atAgent // agent
110110
);
111111

112+
{ Признак способа расчета передается в параметре payment_mode }
113+
TPaymentMode = (
114+
pmNone,
115+
pmFullPrepayment, // Полная предоплата
116+
pmFullPayment // Полный расчет
117+
);
118+
112119
{ TYookassaReceiptItem }
113120
TYookassaReceiptItem = class(TYookassaAPIObject)
114121
private
115122
FAgentType: TYookassaAgentType;
123+
FPaymentMode: TPaymentMode;
116124
FSupplier: TYookassaSupplier;
117125
function GetAgentTypeString: string;
118126
function GetSupplier: TYookassaSupplier;
@@ -122,15 +130,15 @@ TYookassaReceiptItem = class(TYookassaAPIObject)
122130
AmountValue: Currency;
123131
AmountCurrency: string;
124132
VatCode: Integer;
125-
PaymentMode: string;
126133
PaymentSubject: string;
127134
MarkMode: Integer;
128135
MarkCodeInfo: string; // base64 gs_1m,
129136
Measure: string;
130137
constructor Create;
131138
destructor Destroy; override;
132139
function ToJSON: TJSONObject; override;
133-
property AgentType: TYookassaAgentType read FAgentType write FAgentType;
140+
property AgentType: TYookassaAgentType read FAgentType write FAgentType;
141+
property PaymentMode: TPaymentMode read FPaymentMode write FPaymentMode;
134142
property Supplier: TYookassaSupplier read GetSupplier;
135143
end;
136144

@@ -310,6 +318,16 @@ function ReceiptTypeToString(aType: TReceiptType): String;
310318
end;
311319
end;
312320

321+
function PaymentModeToString(aPaymentMode: TPaymentMode): String;
322+
begin
323+
case aPaymentMode of
324+
pmFullPrepayment: Result:='full_prepayment';
325+
pmFullPayment: Result:='full_payment';
326+
else
327+
Result:=EmptyStr;
328+
end;
329+
end;
330+
313331
{ TYookassaResponse }
314332

315333
constructor TYookassaResponse.Create(ARaw: TJSONObject);
@@ -574,7 +592,7 @@ function TYookassaReceiptItem.ToJSON: TJSONObject;
574592
aAmount.Add('currency', AmountCurrency);
575593
Result.Add('amount', aAmount);
576594
Result.Add('vat_code', VatCode);
577-
if PaymentMode <> EmptyStr then Result.Add('payment_mode', PaymentMode);
595+
if FPaymentMode <> pmNone then Result.Add('payment_mode', PaymentModeToString(FPaymentMode));
578596
if PaymentSubject <> EmptyStr then Result.Add('payment_subject', PaymentSubject);
579597
if MarkMode >= 0 then
580598
begin

0 commit comments

Comments
 (0)