Fecshop 支持微信支付

Fecmall微信支付 · Fecmall · 于 4年前 发布 · 4311 次阅读

目前支持微信pc端扫码支付微信公众号JsApi支付(只能微信内部使用) 已经完成

pc测试产品: http://fecshop.appfront.fancyecommerce.com/weixin-test

html5测试产品: http://fecshop.apphtml5.fancyecommerce.com/weixin-test

vue 测试产品: http://demo.fancyecommerce.com/#/catalog/product/5d085e05bfb7ae1fd34b94d2

可以用这个几分钱的产品测试

注意:

1.html5vue入口,微信支付方式为公众号商城支付,使用的是微信JsApi支付方式,必须在微信内部打开,外部浏览器打开无法使用

2.pc入口可以使用电脑浏览器打开,进行扫码支付

支付截图:

1.下单

2.下单后,进入微信支付页面,进行授权

3.点击支付按钮,进行支付

代码和文档将会这几天整理出来,发一个新版本

共收到 7 条回复
2楼 已删除.
zgnmark#34年前 1 个赞

谢谢大佬,原来是粗心没有设置好appsecret 。主要是报错报的是openid 就没仔细检查。下次一定要注意了

yflwz#43年前 0 个赞

配置好微信支付后,在PC扫码支付时报错。

curl出错,错误码:60
1. in D:\wamp64\www\fecmall\vendor\fancyecommerce\fecshop\lib\wxpay\lib\WxPay.Api.phpat line 564
555556557558559560561562563564565566567568569570571572573        //运行curl
        $data = curl_exec($ch);
        //返回结果
        if($data){
            curl_close($ch);
            return $data;
        } else { 
            $error = curl_errno($ch);
            curl_close($ch);
            throw new WxPayException("curl出错,错误码:$error");
        }
    }
 
    /**
     * 获取毫秒级别的时间戳
     */
    private static function getMillisecond()
    {
        //获取毫秒的时间戳
2. in D:\wamp64\www\fecmall\vendor\fancyecommerce\fecshop\lib\wxpay\lib\WxPay.Api.php at line 62– WxPayApi::postXmlCurl('<xml><appid><![CDATA[wx0149f45b3...', 'https://api.mch.weixin.qq.com/pa...', false, 6)
56575859606162636465666768 
        //签名
        $inputObj->SetSign();
        $xml = $inputObj->ToXml();
 
        $startTimeStamp = self::getMillisecond();//请求开始时间
        $response = self::postXmlCurl($xml, $url, false, $timeOut);
        $result = WxPayResults::Init($response);
        self::reportCostTime($url, $startTimeStamp, $result);//上报请求花费时间
 
        return $result;
    }
 
3. in D:\wamp64\www\fecmall\vendor\fancyecommerce\fecshop\lib\wxpay\example\WxPay.NativePay.php at line 52– WxPayApi::unifiedOrder(WxPayUnifiedOrder)
4647484950515253545556     * @param UnifiedOrderInput $input
     */
    public function GetPayUrl($input)
    {
        if($input->GetTrade_type() == "NATIVE")
        {
            $result = WxPayApi::unifiedOrder($input);
            return $result;
        }
    }
}
4. in D:\wamp64\www\fecmall\vendor\fancyecommerce\fecshop\services\payment\Wxpay.php at line 191– NativePay::GetPayUrl(WxPayUnifiedOrder)
185186187188189190191192193194195196197        $input->SetTime_start(date("YmdHis"));
 
        $input->SetTime_expire($this->getShangHaiExpireTime($this->expireTime));
        $input->SetNotify_url($notify_url); //通知地址 改成自己接口通知的接口,要有公网域名,测试时直接行动此接口会产生日志
        $input->SetTrade_type($this->tradeType);
        $input->SetProduct_id($trade_info['product_ids']); //此为二维码中包含的商品ID
        $result = $notify->GetPayUrl($input);
        /**
         * var_dump($result);
         * array(11) {
         *     ["appid"]=> string(18) "wx426b3015555a46be"
         *     ["code_url"]=> string(35) "weixin://wxpay/bizpayurl?pr=Pnu1DAZ"
         *     ["device_info"]=> string(3) "WEB"
5. in D:\wamp64\www\fecmall\vendor\fancyecommerce\fecshop\app\appfront\modules\Payment\controllers\wxpay\StandardController.php at line 40– fecshop\services\payment\Wxpay::getScanCodeStart()
34353637383940414243444546         *   'total_amount'   => $trade_info['total_amount'],
         *   'subject'   => $trade_info['subject'],
         *   'coupon_code'   => $trade_info['coupon_code'],
         *   'product_ids'   => $trade_info['product_ids'],
         *];
         */
        $startData = Yii::$service->payment->wxpay->getScanCodeStart();
        //echo $startData;exit;
        if(!$startData){
            //Yii::$service->url->redirectByUrlKey('/checkout/onepage');
            return;
        }
        if(!Yii::$app->user->isGuest){
6. fecshop\app\appfront\modules\Payment\controllers\wxpay\StandardController::actionStart()
7. in D:\wamp64\www\fecmall\vendor\yiisoft\yii2\base\InlineAction.php at line 57– call_user_func_array([fecshop\app\appfront\modules\Payment\controllers\wxpay\StandardController, 'actionStart'], [])
8. in D:\wamp64\www\fecmall\vendor\yiisoft\yii2\base\Controller.php at line 180– yii\base\InlineAction::runWithParams(['/payment/wxpay/standard/start' => ''])
9. in D:\wamp64\www\fecmall\vendor\yiisoft\yii2\base\Module.php at line 528– yii\base\Controller::runAction('start', ['/payment/wxpay/standard/start' => ''])
10. in D:\wamp64\www\fecmall\vendor\yiisoft\yii2\web\Application.php at line 103– yii\base\Module::runAction('payment/wxpay/standard/start', ['/payment/wxpay/standard/start' => ''])
11. in D:\wamp64\www\fecmall\vendor\yiisoft\yii2\base\Application.php at line 386– yii\web\Application::handleRequest(fecshop\yii\web\Request)
12. in D:\wamp64\www\fecmall\appfront\web\index.php at line 66– yii\base\Application::run()
60616263646566 * 使用方法:Yii::$service->cms->article;
 * 上面的例子就是获取cms服务的子服务article。
 */
new fecshop\services\Application($config);
 
$application = new yii\web\Application($config);
$application->run();
$_GET = [
    '/payment/wxpay/standard/start' => '',
];

$_COOKIE = [
    'PHPSESSID' => 'ofpqa5rbaj11lpork46r1e6v2v',
    '_identity' => '3c1f7c3eb0ba4461e58c188976697d069ddf4e608580e0f0a608669eba157234a:2:{i:0;s:9:"_identity";i:1;s:44:"[1,"pyrFSl57bhWeKsruQUu--I9X7O3kDWNw",86400]";}',
    '_csrf' => 'f465d1dea20f8d0a776f2ba3e37a10f287daa233f10d445f76271f14385ebfafa:2:{i:0;s:5:"_csrf";i:1;s:32:"nIJ3DDPBGHh-ft-A-e44q0hWb2IEoR3r";}',
];

$_SESSION = [
    '__flash' => [],
    'currency_current' => 'CNY',
    'FBRLH_state' => 'eabaaebf851531a695922f59db3a92d4',
    '__id' => 1,
    'current_session_cart_id' => 1,
    'current_order_increament_id' => 1100000005,
];
Yii Framework
2020-07-15, 17:24:19
yflwz#53年前 0 个赞

后面支付的已经配置,微信支付商户上的也已经按文档弄好了的。

yflwz#63年前 0 个赞

把解决问题的方法发上来,请指教。 修改D:\wamp64\www\fecmall\vendor\fancyecommerce\fecshop\lib\wxpay\lib\WxPay.Api.php第537和538行代码

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);//严格校验

修改为

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);//严格校验
7楼 已删除.
select#83年前 0 个赞

@yflwz #6楼 遇到过相同问题,原因为Windows 环境没有安装openssl证书。安装方法看链接:https://www.cnblogs.com/jackiebao/p/5996770.html

Fecmall#93年前 0 个赞

@yflwz #6楼 @select #8楼

遇到新问题,发个新的帖子讨论,后面的人可以通过搜索找到。

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics