|
|
@@ -765,38 +765,25 @@ class ShopController extends BaseController {
|
|
|
* @throws \Exception
|
|
|
*/
|
|
|
public function actionUpopWebhook() {
|
|
|
- if (\Yii::$app->request->isPost) {
|
|
|
- $data = \Yii::$app->request->post();
|
|
|
- $type = 'post';
|
|
|
- } elseif (\Yii::$app->request->isGet) {
|
|
|
- $data = \Yii::$app->request->get();
|
|
|
- $type = 'get';
|
|
|
- } else {
|
|
|
- $data = '.................';
|
|
|
- $type = '.................';
|
|
|
+ $rawPostData = \Yii::$app->request->post();
|
|
|
+ LoggerTool::debug(['UPOP - webhook: (init).', $rawPostData]);
|
|
|
+
|
|
|
+ // signData agencyId encryptKey encryptData
|
|
|
+ $agencyId = $rawPostData['agencyId'] ?? '';
|
|
|
+ $signData = $rawPostData['signData'] ?? '';
|
|
|
+ $encryptKey = $rawPostData['encryptKey'] ?? '';
|
|
|
+ $encryptData = $rawPostData['encryptData'] ?? '';
|
|
|
+ // 终端号
|
|
|
+ if (!$agencyId || $agencyId != \Yii::$app->params['UPOP']['agencyId']) {
|
|
|
+ LoggerTool::error([sprintf('UPOP - webhook: (error). agencyId {%s} does not exits or error.', $agencyId)]);
|
|
|
+
|
|
|
+ echo 'success';
|
|
|
+ return http_response_code(200);
|
|
|
}
|
|
|
+ // 解密
|
|
|
+ $response = (new PaySign())->decodeData($encryptKey, $signData, $encryptData);
|
|
|
+ LoggerTool::info([sprintf('UPOP - webhook: (error). agencyId {%s}', $response)]);
|
|
|
|
|
|
- LoggerTool::info(['actionUpopWebhook', $type, $data]);
|
|
|
-
|
|
|
-
|
|
|
- // 支付成功的webhook.
|
|
|
-// $rawPostData = file_get_contents('php://input');
|
|
|
-// LoggerTool::debug(['actionUpopWebhook', $rawPostData]);
|
|
|
-//
|
|
|
-// $data = [];
|
|
|
-// if (strlen($rawPostData) > 0) {
|
|
|
-// $rawPostArray = explode('&', $rawPostData);
|
|
|
-// foreach ($rawPostArray as $raw) {
|
|
|
-// $raw = explode('=', $raw);
|
|
|
-// if (count($raw) == 2)
|
|
|
-// $data[$raw[0]] = urldecode($raw[1]);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// LoggerTool::info(['actionUpopWebhook', $data]);
|
|
|
-
|
|
|
- // 支付webhook回调日志
|
|
|
- //Tool::approachOrderCall($data);
|
|
|
|
|
|
// try {
|
|
|
// // 订单状态
|