/* * 充值方式支付 * $_POST['dosubmit'] //submit 按钮 * $_POST['code'] //验证码 * $_POST['pay_type'] //充值方式 1=支付宝 * param::get_cookie('trade_sn') //获取订单号 * * $_POST['info']['name'] //姓名 * $_POST['info']['usernote'] //备注 * $_POST['info']['price'] //金额 * $_POST['info']['telephone'] //电话 * $_POST['info']['email'] //邮箱 */ public function pay_recharge() { if(isset($_POST['dosubmit'])) { $code = isset($_POST['code']) && trim($_POST['code']) ? trim($_POST['code']) : showmessage(L('input_code'), HTTP_REFERER); if ($_SESSION['code'] != strtolower($code)) {//验证 判断是否验证码错误 showmessage(L('code_error'), HTTP_REFERER); } $pay_id = $_POST['pay_type']; if(!$pay_id) showmessage(L('illegal_pay_method'));//验证 没有选择支付方式 $payment = $this->handle->get_payment($pay_id);//获取充值方式信息 pay_payment表信息 $cfg = unserialize_config($payment['config']);//配置信息 $pay_name = ucwords($payment['pay_code']);//方式模块代码 if(!param::get_cookie('trade_sn')) {showmessage(L('illegal_creat_sn'));}// 验证 订单号生成错误 $trade_sn = param::get_cookie('trade_sn');//获取订单号 //备注 “姓名订单号-备注” $usernote = $_POST['info']['usernote'] ? $_POST['info']['name'].'['.$trade_sn.']'.'-'.new_html_special_chars(trim($_POST['info']['usernote'])) : $_POST['info']['name'].'['.$trade_sn.']'; $surplus = array( 'userid' => $this->_userid, 'username' => $this->_username, 'money' => trim(floatval($_POST['info']['price'])), 'quantity' => $_POST['quantity'] ? trim(intval($_POST['quantity'])) : 1,//*-* 'telephone' => trim($_POST['info']['telephone']), 'contactname' => $_POST['info']['name'] ? trim($_POST['info']['name']).L('recharge') : $this->_username.L('recharge'), 'email' => trim($_POST['info']['email']), 'addtime' => SYS_TIME,//获取系统时间 'ip' => ip(),//获取ip 'pay_type' => 'recharge',//*-* 'pay_id' => $payment['pay_id'],//id//auto_increment 'payment' => trim($payment['pay_name']),//方式模块名称 'ispay' => '1', 'usernote' => $usernote, 'trade_sn' => $trade_sn, ); $recordid = $this->handle->set_record($surplus);//生成流水记录//向pay_account表插入数据//返回数据id $factory_info = $this->handle->get_record($recordid);//获取流水记录 if(!$factory_info) showmessage(L('order_closed_or_finish'));//验证 订单已完成或该已经关闭 //返回订单手续费(订单价格 $amount ;手续费比率 $fee ;手续费方式 $method ) $pay_fee = pay_fee($factory_info['money'],$payment['pay_fee'],$payment['pay_method']); $logistics_fee = $factory_info['logistics_fee'];//*-* $discount = $factory_info['discount'];//折扣 // calculate amount $factory_info['price'] = $factory_info['money'] + $pay_fee + $logistics_fee + $discount;//计算总金额 // add order info $order_info['id'] = $factory_info['trade_sn']; $order_info['quantity'] = $factory_info['quantity']; $order_info['buyer_email'] = $factory_info['email']; $order_info['order_time'] = $factory_info['addtime']; //add product info $product_info['name'] = $factory_info['contactname']; $product_info['body'] = $factory_info['usernote']; $product_info['price'] = $factory_info['price']; //add set_customerinfo $customerinfo['telephone'] = $factory_info['telephone']; if($payment['is_online'] === '1') { pc_base::load_app_class('pay_factory','',0);//支付模块调用工厂 $payment_handler = new pay_factory($pay_name, $cfg);//(方式模块代码,配置信息) //*-* $payment_handler->set_productinfo($product_info)->set_orderinfo($order_info)->set_customerinfo($customer_info); $code = $payment_handler->get_code('value="'.L('confirm_pay').'" class="button"'); } else { $this->account_db->update(array('status'=>'waitting','pay_type'=>'offline'),array('id'=>$recordid)); $code = '<div class="point">'.L('pay_tip').'</div>'; } } include template('pay', 'payment_cofirm'); }
2013年6月20日星期四
phpcms ?m=pay&c=deposit&a=pay_recharge 自带支付宝付款方法详解
订阅:
博文评论 (Atom)
没有评论:
发表评论