File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -267,14 +267,25 @@ private function sendGetRequest(string $api): array
267267
268268    /** 
269269     * Отправка POST-запроса 
270-      * @param JsonSerializable $data запрос 
270+      * @param string| JsonSerializable $data запрос 
271271     * @param string $api адрес API (URI) 
272272     * @return array ответ сервера Ypmn 
273273     * @throws PaymentException 
274274     */ 
275-     private  function  sendPostRequest (JsonSerializable   $ data , string  $ api ): array 
275+     public  function  sendPostRequest ($ data , string  $ api ): array 
276276    {
277-         $ encodedJsonData  = $ data ->jsonSerialize ();
277+         if  ($ data  instanceof  JsonSerializable) {
278+             $ encodedJsonData  = $ data ->jsonSerialize ();
279+         } elseif  (is_string ($ data )) {
280+             if  (json_decode ($ data ) !== false ) {
281+                 $ encodedJsonData  = $ data ;
282+             } else  {
283+                 throw  new  PaymentException ('Incorrect request body type ' );
284+             }
285+         } else  {
286+             throw  new  PaymentException ('Incorrect request body JSON ' );
287+         }
288+ 
278289
279290        $ encodedJsonDataHash  = md5 ($ encodedJsonData );
280291
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments