public function actionIndex() { U::W([__METHOD__, $_GET, $_POST]); //$this->layout = false; $this->layout = 'wapy'; $alipay_config = Alipay::getAlipayConfig(); $alipayNotify = new AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyReturn(); if (!$verify_result) { Alipay::logResult(['Alipaycallback error', __METHOD__, $_GET, $_POST]); //return 'Alipaycallback error'; } $result = $_GET['result']; if ($result != 'success') { Alipay::logResult(['Pay error', __METHOD__, $_GET, $_POST]); return 'Pay error'; } $oid = $_GET['out_trade_no']; $model = MOrder::findOne($oid); if ($model === null) { U::W(['Invalid oid', $_GET, $_POST]); return "Invalid oid"; } $model->pay_kind = MOrder::PAY_KIND_ALIWAP; $model->aliwap_trade_no = $_GET['trade_no']; $model->status = MOrder::STATUS_SUCCEEDED; if (!$model->save(false)) { U::W(['save db error', $_GET, $_POST, $model->getErrors()]); return 'system error'; } //return 'Pay OK'; return $this->render('index', ['gh_id' => $model->gh_id, 'openid' => $model->openid]); }
public function actionIndex() { U::W([__METHOD__, $_GET, $_POST]); $this->layout = false; $alipay_config = Alipay::getAlipayConfig(); $alipayNotify = new AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); if (!$verify_result) { Alipay::logResult(['Alipaynotify sign error', __METHOD__, $_GET, $_POST]); return "fail"; } if ($alipay_config['sign_type'] == 'MD5') { $respObject = @simplexml_load_string($_POST['notify_data']); } else { if ($alipay_config['sign_type'] == '0001') { $respObject = @simplexml_load_string($alipayNotify->decrypt($_POST['notify_data'])); } else { Alipay::logResult(['Alipaynotify sign_type error', __METHOD__, $_GET, $_POST]); } } $arr = json_decode(json_encode($respObject), true); U::W($arr); $oid = $arr['out_trade_no']; $model = MOrder::findOne($oid); if ($model === null) { U::W(['Invalid oid', $_GET, $_POST, $arr]); return "success"; } $model->pay_kind = MOrder::PAY_KIND_ALIWAP; $model->aliwap_trade_no = $arr['trade_no']; $model->aliwap_total_fee = $arr['total_fee']; $model->aliwap_trade_status = $arr['trade_status']; $model->aliwap_buyer_email = $arr['buyer_email']; $model->aliwap_quantity = $arr['quantity']; $model->aliwap_gmt_payment = $arr['gmt_payment']; if ($arr['trade_status'] == 'TRADE_FINISHED' || $arr['trade_status'] == 'TRADE_SUCCESS') { $model->status = MOrder::STATUS_SUCCEEDED; } else { U::W(['trade_status is not TRADE_FINISHED', $_GET, $_POST, $arr]); } if (!$model->save(false)) { U::W(['save db error', $_GET, $_POST, $arr, $model->getErrors()]); } return "success"; }