Beispiel #1
0
    }
}
//微信支付方式提交充值申请
if ('wechat' == $opera) {
    $amount = getPOST('amount');
    $amount = floatval($amount);
    $mch_id = $config['mch_id'];
    //商户编号
    $mch_key = $config['mch_key'];
    //商户API密钥
    $_SESSION['payment'] = 'wechat';
    if ($amount <= 0) {
        $response['errmsg'] = '充值金额必须大于0';
    } else {
        $total_fee = $amount;
        $recharge_sn = add_recharge($_SESSION['account'], $total_fee, 0, '微信支付', 'wechat');
        if ($recharge_sn) {
            $response['price'] = '¥' . sprintf('%.2f', $total_fee);
            $detail = '充值流水号:' . $recharge_sn;
            $body = $config['site_name'] . '充值';
            $body = $detail;
            $out_trade_no = $recharge_sn;
            $res = create_prepay($config['appid'], $mch_id, $mch_key, $_SESSION['openid'], $total_fee, $body, $detail, $out_trade_no);
            $res = simplexml_load_string($res);
            if ($res->prepay_id) {
                $response['errno'] = 0;
            } else {
                $response['errmsg'] = $res->return_code . ',' . $res->return_msg;
            }
            $nonce_str = get_nonce_str();
            $response['nonce_str'] = $nonce_str;
Beispiel #2
0
$opera = check_action($operation, getPOST('opera'));
//支付方式变更时生成支付代码
if ('wechat' == $opera) {
    $amount = getPOST('amount');
    $amount = floatval($amount);
    $mch_id = '1259544101';
    //商户编号
    $mch_key = 'WinsenCeciliaWrhLtx2015KWANSONCC';
    //商户API密钥
    $response = array('error' => 1, 'msg' => '');
    $_SESSION['payment'] = 'wechat';
    if ($amount <= 0) {
        $response['msg'] = '充值金额必须大于0';
    } else {
        $total_fee = $amount;
        $recharge_sn = add_recharge($_SESSION['account'], $total_fee);
        if ($recharge_sn) {
            $response['price'] = '¥' . sprintf('%.2f', $total_fee);
            $detail = '充值流水号:' . $recharge_sn;
            $body = $config['site_name'] . '充值';
            $body = $detail;
            $out_trade_no = $recharge_sn;
            $res = create_prepay($config['appid'], $mch_id, $mch_key, $_SESSION['openid'], $total_fee, $body, $detail, $out_trade_no);
            $res = simplexml_load_string($res);
            if ($res->prepay_id) {
                $response['error'] = 0;
            } else {
                $response['msg'] = $res->return_code . ',' . $res->return_msg;
            }
            $nonce_str = get_nonce_str();
            $response['nonce_str'] = $nonce_str;