| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Yansongda\Pay\Plugin\Douyin\V1\Pay; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Closure; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Psr\Http\Message\ResponseInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Yansongda\Artful\Contract\PluginInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Yansongda\Artful\Exception\InvalidResponseException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Yansongda\Artful\Logger; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Yansongda\Artful\Rocket; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Yansongda\Pay\Exception\Exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | class ResponsePlugin implements PluginInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * @throws InvalidResponseException | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 19 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |     public function assembly(Rocket $rocket, Closure $next): Rocket | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |         /* @var Rocket $rocket */ | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |         $rocket = $next($rocket); | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |         Logger::debug('[Douyin][V1][Pay][ResponsePlugin] 插件开始装载', ['rocket' => $rocket]); | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |         $this->validateResponse($rocket); | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |         Logger::info('[Douyin][V1][Pay][ResponsePlugin] 插件装载完毕', ['rocket' => $rocket]); | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |         return $rocket; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @throws InvalidResponseException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     protected function validateResponse(Rocket $rocket): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         $destination = $rocket->getDestination(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $response = $rocket->getDestinationOrigin(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         if ($response instanceof ResponseInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             && ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             throw new InvalidResponseException(Exception::RESPONSE_CODE_WRONG, '抖音返回状态码异常,请检查参数是否错误', $destination); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         if (0 !== $destination->get('err_no')) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             throw new InvalidResponseException(Exception::RESPONSE_BUSINESS_CODE_WRONG, '抖音返回业务异常: '.$destination->get('err_tips'), $destination); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 51 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 52 |  |  |  | 
            
                        
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.