|
|
@@ -37,22 +37,6 @@ use Yii;
|
|
|
class ShopController extends BaseController {
|
|
|
public $modelClass = DecOrder::class;
|
|
|
|
|
|
-// public function beforeAction($action)
|
|
|
-// {
|
|
|
-// parent::beforeAction($action);
|
|
|
-//
|
|
|
-// // 指定接口不进行校验
|
|
|
-// $currentAction = $action->id;
|
|
|
-// LoggerTool::notice($currentAction);
|
|
|
-// if (in_array($currentAction, $this->_method_not_check)) {
|
|
|
-// $action->controller->enableCsrfValidation = false;
|
|
|
-// LoggerTool::notice($action->controller->enableCsrfValidation);
|
|
|
-// }
|
|
|
-// LoggerTool::notice($action->controller->enableCsrfValidation);
|
|
|
-//
|
|
|
-// return true;
|
|
|
-// }
|
|
|
-
|
|
|
/**
|
|
|
* 商品列表
|
|
|
* @return mixed
|
|
|
@@ -194,13 +178,42 @@ class ShopController extends BaseController {
|
|
|
* @throws \yii\web\HttpException
|
|
|
*/
|
|
|
public function actionVerifyApproachOrder() {
|
|
|
- LoggerTool::info('isPost => ' . \Yii::$app->request->isPost);
|
|
|
if (\Yii::$app->request->isPost) {
|
|
|
- $params = \Yii::$app->request->post();
|
|
|
- LoggerTool::info($params);
|
|
|
-// if (parent::edit(ApproachOrderForm::class, 'PayStack pay Success', 'verifyPayStack', ['verifyPayStack'])) {
|
|
|
-// return http_response_code(200);
|
|
|
-// }
|
|
|
+ $request = json_decode(\Yii::$app->request->post(), true);
|
|
|
+ LoggerTool::notice($request);
|
|
|
+ // TODO:支付webhook回调日志
|
|
|
+
|
|
|
+
|
|
|
+ $data = $request['data'];
|
|
|
+ $status = $request['data']['status'] ?? 'false';
|
|
|
+ // 订单状态
|
|
|
+ $orderStatus = ($status == 'success') ? \Yii::$app->params['orderStatus']['paid']['value'] : \Yii::$app->params['orderStatus']['failPaid']['value'];
|
|
|
+
|
|
|
+ $customFields = $request['data']['metadata']['custom_fields'] ?? [];
|
|
|
+ $oderSn = $customFields[0]['value'] ?? '';
|
|
|
+
|
|
|
+ $formModel = new ApproachOrderForm();
|
|
|
+ $formModel['sn'] = $oderSn;
|
|
|
+ $formModel['status'] = $orderStatus;
|
|
|
+ $formModel['note'] = [
|
|
|
+ 'id' => $data['id'],
|
|
|
+ 'domain' => $data['domain'],
|
|
|
+ 'status' => $data['status'],
|
|
|
+ 'reference' => $data['reference'],
|
|
|
+ 'amount' => $data['amount'],
|
|
|
+ 'created_at' => $data['created_at'],
|
|
|
+ 'paid_at' => $data['paid_at'],
|
|
|
+ 'channel' => $data['channel'],
|
|
|
+ 'currency' => $data['currency'],
|
|
|
+ 'ip_address' => $data['ip_address'],
|
|
|
+ 'metadata' => $data['metadata'],
|
|
|
+ 'customer' => $data['customer'],
|
|
|
+ 'email' => $data['customer']['email'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ if (parent::edit(ApproachOrderForm::class, 'PayStack pay Success', 'verifyPayStack', ['verifyPayStack'])) {
|
|
|
+ return http_response_code(200);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return http_response_code(500);
|