@@ -257,11 +257,11 @@ private function setCert()
257
257
return $ this ;
258
258
}
259
259
260
- public function callbackAction (Closure $ processData ): string
260
+ public function callbackAction (Closure $ processData ): array
261
261
{
262
262
$ callback = new class ('' , '' , []) extends Action {
263
- public static $ checkSign ;
264
- public static $ processData ;
263
+ public $ checkSign ;
264
+ public $ processData ;
265
265
266
266
public function init ()
267
267
{
@@ -270,10 +270,10 @@ public function init()
270
270
}
271
271
parent ::init ();
272
272
$ this ->controller ->enableCsrfValidation = false ;
273
- if (empty (self :: $ processData )) {
273
+ if (empty ($ this -> processData )) {
274
274
throw new InvalidConfigException ('请配置处理函数 ' );
275
275
}
276
- if (!(self :: $ processData instanceof Closure)) {
276
+ if (!($ this -> processData instanceof Closure)) {
277
277
throw new InvalidConfigException ('处理函数必须是Closure ' );
278
278
}
279
279
//自动处理xml,将rawBody中的xml直接转换为Yii::$app->request->post()
@@ -298,18 +298,20 @@ public function init()
298
298
public function run ()
299
299
{
300
300
$ post = Yii::$ app ->request ->post ();
301
- if (call_user_func_array (self :: $ checkSign , [&$ post ])) {
302
- return call_user_func (self :: $ processData , $ post );
301
+ if (call_user_func_array ($ this -> checkSign , [&$ post ])) {
302
+ return call_user_func ($ this -> processData , $ post );
303
303
}
304
304
return [
305
305
'return_code ' => 'FAIL ' ,
306
306
'return_msg ' => '签名失败 ' ,
307
307
];
308
308
}
309
309
};
310
- $ callback ::$ checkSign = Closure::fromCallable ([$ this , 'checkDecodeSign ' ]);
311
- $ callback ::$ processData = $ processData ;
312
- return get_class ($ callback );
310
+ return [
311
+ 'class ' => get_class ($ callback ),
312
+ 'checkSign ' => Closure::fromCallable ([$ this , 'checkDecodeSign ' ]),
313
+ 'processData ' => $ processData ,
314
+ ];
313
315
}
314
316
315
317
private function checkDecodeSign (array &$ data , $ signKey = 'sign ' ): bool
0 commit comments