首先,支付没有问题,演示地址测试微信支付都是没有问题的,这个应该更多的是您的配置问题,微信的东西配置繁杂,用起来还是得注意很多东西
1.这个应该是一个典型支付问题,您把标题改成fecyo微信内部h5支付(JsApi支付)付款成功,但商城订单状态仍为未支付
2.资料,微信支付文档:http://www.fecmall.com/doc/fecshop-guide/instructions/cn-2.0/guide-fecmall_payment_wx_method.html
您仔细看一下,仔细排查设置是否完成
3.当然不排除文档可能某些点没有描述清楚,这个需要您自己排查一下代码,定位问题,
需要注意的是,微信内部支付是Jsapi支付
4.微信支付controller文件:@fecyo\app\apphtml5\modules\Payment\controllers\WxpayjsapiController
@fecyo
的文件路径 addons/fecmall/fecyo
微信支付成功后,微信会给fecmall发送一个消息
发送消息的url,是在支付start已经将接收微信消息的url
作为参数传递给微信支付,
付款成功后,微信支付往这个url发送支付信息,更改fecmall订单状态,微信内部支付,这个url是payment/wxpayjsapi/ipn
,也就是这个controller的action方法
public function actionIpn()
{
Yii::$service->payment->wxpay->ipn();
}
3.1执行payment wxpay services
里面的ipn()
方法
打开文件@fecshop\services\payment\WxpayJsApi
/**
* 接收IPN消息的url,接收微信支付的异步消息,进而更改订单状态。
*/
public function ipn()
{
$notifyFile = Yii::getAlias('@fecshop/services/payment/wxpay/notify.php');
require_once($notifyFile);
\Yii::info('begin ipn', 'fecshop_debug');
$notify = new \PayNotifyCallBack();
$notify->Handle(false);
}
3.2打开文件@fecshop/services/payment/wxpay/notify.php
,下面的函数,是接收到微信支付付款消息,验证消息安全后执行的方法:
//重写回调处理函数
public function NotifyProcess($data, &$msg)
{
\Yii::info("call back:" . json_encode($data), 'fecshop_debug');
$notfiyOutput = [];
if (!array_key_exists("transaction_id", $data)) {
$msg = "输入参数不正确";
return false;
}
//查询订单,判断订单真实性
if (!$this->Queryorder($data["transaction_id"])) {
$msg = "订单查询失败";
return false;
}
$arr = $this->getDataArray($data);
return \Yii::$service->payment->wxpay->ipnUpdateOrder($arr);
}
3.3在上面的函数最后,执行\Yii::$service->payment->wxpay->ipnUpdateOrder($arr);
这个就是更新订单信息的函数
3.4打开文件@fecshop\services\payment\Wxpay
public function ipnUpdateOrder($data)
{
\Yii::info('ipn order process', 'fecshop_debug');
$incrementId = $data['out_trade_no'];
$transaction_id = $data['transaction_id'];
$total_fee = $data['total_fee'];
$fee_type = $data['fee_type'];
if ($incrementId && $transaction_id && $total_fee) {
$this->_order = Yii::$service->order->getByIncrementId($incrementId);
Yii::$service->payment->setPaymentMethod($this->_order['payment_method']);
$base_grand_total = $this->_order['base_grand_total'];
$order_total_amount = Yii::$service->page->currency->getCurrencyPrice($base_grand_total, 'CNY');
\Yii::info('check order totla amouont['.($order_total_amount * 100).' == '.$total_fee.']', 'fecshop_debug');
// 微信支付的人民币单位为分
if(bccomp($order_total_amount * 100, $total_fee) !== 0){
return false;
}
\Yii::info('updateOrderInfo', 'fecshop_debug');
// 更改订单状态
if ($this->updateOrderInfo($incrementId, $transaction_id, false)) { //支付成功调用服务执行订单状态改变,清空购物车和发送邮件操作
\Yii::info('updateOrderInfo Success', 'fecshop_debug');
return true;
}
}
}
函数updateOrderInfo
如下,也是该文件
/**
* 微信 支付成功后,对订单的状态进行修改
* 如果支付成功,则修改订单状态为支付成功状态。
* @param $out_trade_no | string , fecshop的订单编号 increment_id
* @param $trade_no | 微信支付交易号
* @param isClearCart | boolean 是否清空购物车
*
*/
protected function updateOrderInfo($out_trade_no, $trade_no, $isClearCart=true)
{
if (!empty($out_trade_no) && !empty($trade_no)) {
if ($this->paymentSuccess($out_trade_no, $trade_no)) {
// 清空购物车
if ($isClearCart) {
Yii::$service->cart->clearCartProductAndCoupon();
}
return true;
}
} else {
Yii::$service->helper->errors->add('wxpay payment fail,resultCode: {result_code}', ['result_code' => $resultCode]);
return false;
}
}
后面的代码您自己找吧,已经把微信支付涉及的文件给您贴清楚了。
!!一定改一下标题,后面遇到这个问题的童鞋可以参考这里排查具体问题