Commit 8ed28c17 authored by xiabin's avatar xiabin

添加支付宝支付的return url

parent b80a2293
......@@ -3,7 +3,9 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\data\Pagination;
use yii\db\ActiveRecord;
/**
* This is the model class for table "member".
......
......@@ -403,12 +403,13 @@ class HomeController extends \yii\web\Controller
"subject" => "购买课程-{$courseBaseInfo['name']}",//订单名称
"total_fee" => $price,//付款金额
"body" => '云崖购买',//商品描述
'return_url' => Yii::$app->request->hostInfo . '/pay/alipay-return-url'
);
if (Yii::$app->deviceDetect->isMobile()) {
$parameter['service'] = \Yii::$app->params['alipay']['wap_service'];
$parameter['app_pay'] = 'Y';
$parameter['return_rul'] = Url::base() . 'home/video?courseId=' . $courseId;
}
$html_text = $alipay->buildRequestForm($parameter, "get", "确认");
echo $html_text;
......@@ -499,7 +500,7 @@ class HomeController extends \yii\web\Controller
'device_info' => "WEB",
'nonce_str' => Yii::$app->security->generateRandomString(16),
'sign' => '',
'body' => '最课堂-课程购买',
'body' => '最课堂 - 课程购买',
'out_trade_no' => $order_id,
'total_fee' => 1,
'spbill_create_ip' => $_SERVER['SERVER_ADDR'],
......@@ -508,7 +509,7 @@ class HomeController extends \yii\web\Controller
];
$xml['sign'] = WeixinPay::makeWeixinPaySign($xml, $weixinpay['key']);
$xml = Utils::assocArrayToXML('xml', $xml);
$reponse = $client->request('POST', $uri, ['Content-Type' => 'text/xml; charset=UTF8', 'body' => $xml]);
$reponse = $client->request('POST', $uri, ['Content - Type' => 'text / xml; charset = UTF8', 'body' => $xml]);
$reponse = $reponse->getBody();
$result = ((string)$reponse);
$result = Utils::xmlToArray($result);
......
......@@ -27,6 +27,44 @@ class PayController extends Controller
public $enableCsrfValidation = FALSE;
/**
* return Url
*/
public function actionAlipayReturnUrl()
{
//计算得出通知验证结果
$alipayNotify = new AlipayNotify();
$verify_result = $alipayNotify->verifyReturn();
if ($verify_result) {//验证成功
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//请在这里加上商户的业务逻辑程序代
//——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
//获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表
//商户订单号
$out_trade_no = $_GET['out_trade_no'];
$order = Orders::findOne(['number' => $out_trade_no]);
if ($order !== NULL) {
//交易状态
$this->redirect(\Yii::$app->request->hostInfo . '/home/video?courseId=' . $order->course_id);
}
//——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} else {
//验证失败
$this->redirect(\Yii::$app->request->hostInfo);
//调试用,写文本函数记录程序运行情况是否正常
//logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
}
}
public function actionAlipayNotify()
{
//计算得出通知验证结果
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment