31选7开奖结果查询 www.vk1c.com.cn 31选7开奖结果查询 > 上网技巧 > 电脑小技巧 > EasyWechat开发微信支付/小程序支付/H5支付/App...

EasyWechat开发微信支付/小程序支付/H5支付/App支付代码实例

时间:2018-06-16 15:11 作者:QQ地带 我要评论

代码实例:
 
$tradeType = "支付场景,APP/JSAPI";
$accountPayment = [
    'APP' => [
        'app_id' => 'app_id',
        'mch_id' => 'mch_id',
        'key' => 'XXXXXXXXXXXXXXXXXXXXXXX',
        'cert_path' => app_path('resources/cert/apiclient_cert.pem'),
        'key_path' => app_path('resources/cert/apiclient_key.pem'),
        'notify_url' => route('weChatNotifyUrl'),
    ],
    'JSAPI' => [
        'app_id' => 'app_id',
        'mch_id' => 'mch_id',
        'key' => 'XXXXXXXXXXXXXXXXXXXXXXX',
        'cert_path' => app_path('resources/cert2/apiclient_cert.pem'),
        'key_path' => app_path('resources/cert2/apiclient_key.pem'),
        'notify_url' => route('weChatNotifyUrl'),
    ],
];
 
$app = Factory::payment($accountPayment[$tradeType]);
 
$order_info = [
    'body' => $title,
    'out_trade_no' => $order_number,
    'total_fee' => $amount,
    'trade_type' => $tradeType, // 交易类型 JSAPI | NATIVE |APP | WAP
];
 
$result = $app->order->unify($order_info);
if ($tradeType == 'JSAPI') { // 微信内H5/小程序支付
    $jssdk = $app->jssdk;
    $config = $jssdk->bridgeConfig($result['prepay_id'], false);
} else { // APP支付
    $config = $app->jssdk->appConfig($result['prepay_id']);
}
微信内H5/小程序支付$config信息
 
"config": {
    "appId": "wxfd3ca09bb10e3a63",
    "timeStamp": "1527846324",
    "nonceStr": "5b1115b465d95",
    "package": "prepay_id=wx01174524358388e762240d961371110515",
    "signType": "MD5",
    "paySign": "96B18F3E55A9F09123C007074C62849C"
}
APP支付$config信息
 
"config": {
    "appid": "wxaba67d5bcd2c0a6c",
    "partnerid": "1494244042",
    "prepayid": "wx0117351453138316e25af7282351919901",
    "noncestr": "5b11135296ddf",
    "timestamp": 1527845714,
    "package": "Sign=WXPay",
    "sign": "93A42757183D28CBCB7BF8A408C8675F"
}

标签: 微信支付
顶一下
(0)
0%
踩一下
(0)
0%

Google提供的广告

729| 134| 266| 820| 857| 116| 818| 31| 416| 203|