@@ -16,37 +16,46 @@ TYookassaResponse = class
1616 private
1717 FRaw: TJSONObject;
1818 function GetId : string; virtual ; abstract ;
19- function GetStatus : string; virtual ; abstract ;
2019 public
2120 constructor Create(ARaw: TJSONObject);
2221 destructor Destroy; override;
2322 property Raw: TJSONObject read FRaw;
2423 end ;
2524
25+ TPaymentStatus = (
26+ psNone, // Не указан
27+ psUnknown, // Не распознан (нет в этом списке статусов)
28+ psPending, // Платеж создан и ожидает действий от пользователя
29+ psWaitingForCapture, // Платеж оплачен, деньги авторизованы и ожидают списания
30+ psSucceeded, // Платеж успешно завершен
31+ psCanceled // Платеж отменен
32+ );
33+
2634 { TYookassaPaymentResponse }
2735 TYookassaPaymentResponse = class (TYookassaResponse)
2836 private
2937 function GetConfirmationURL : string;
3038 function GetAmount : Currency;
3139 function GetCurrency : String;
32- function GetId : string; override;
33- function GetStatus : string; override ;
40+ function GetId : string; override;
41+ function GetStatus : TPaymentStatus ;
3442 public
3543 property ConfirmationURL: string read GetConfirmationURL;
3644 property Amount: Currency read GetAmount;
3745 property Currency: String read GetCurrency;
3846 property ID: String read GetId;
39- property Status: String read GetStatus;
47+ property Status: TPaymentStatus read GetStatus;
4048 end ;
4149
4250 { TYookassaReceiptResponse }
4351 TYookassaReceiptResponse = class (TYookassaResponse)
4452 private
4553 function GetPaymentId : String;
4654 function GetId : string; override;
55+ function GetStatus : string;
4756 public
48- function GetStatus : string; override;
4957 property PaymentId: string read GetPaymentId;
58+ property Status: String read GetStatus;
5059 property ID: String read GetId;
5160 end ;
5261
@@ -373,6 +382,19 @@ function SettlementTypeToString(aSettlementType: TSettlementType): String;
373382 end ;
374383end ;
375384
385+ function StringToPaymentStatus (const aPaymentStatus: String): TPaymentStatus;
386+ begin
387+ case aPaymentStatus of
388+ ' ' : Result:=psNone;
389+ ' pending' : Result:=psPending;
390+ ' waiting_for_capture' : Result:=psWaitingForCapture;
391+ ' succeeded' : Result:=psSucceeded;
392+ ' canceled' : Result:=psCanceled;
393+ else
394+ Result:=psUnknown;
395+ end ;
396+ end ;
397+
376398{ TYookassaResponse }
377399
378400constructor TYookassaResponse.Create(ARaw: TJSONObject);
@@ -393,9 +415,9 @@ function TYookassaPaymentResponse.GetId: string;
393415 Result := Raw.Get(' id' , EmptyStr);
394416end ;
395417
396- function TYookassaPaymentResponse.GetStatus : string ;
418+ function TYookassaPaymentResponse.GetStatus : TPaymentStatus ;
397419begin
398- Result := Raw.Get(' status' , EmptyStr);
420+ Result := StringToPaymentStatus( Raw.Get(' status' , EmptyStr) );
399421end ;
400422
401423function TYookassaPaymentResponse.GetConfirmationURL : string;
@@ -749,7 +771,6 @@ function TYookassaReceipt.ToJSON: TJSONObject;
749771procedure TYookassaReceipt.AppendJSON (aJSON: TJSONObject);
750772var
751773 aItems: TJSONArray;
752- aCustomer: TJSONObject;
753774 Item: TYookassaReceiptItem;
754775begin
755776 if Assigned(FCustomer) then
0 commit comments