搜索
系统检测到您的用户名不符合规范:

微信支付相关源码

浏览:26759 发布日期:2014年07月21日 分类:技术分享 关键字: 微信支付
PHP函数public function weixin_goods_pay() {
header ( 'Content-Type: text/html; charset=UTF-8' );

// $price = I ( 'price' );
// $post_price = I ( 'post_price' );
// $buyNum = I ( 'buyNum' );

$id = I ( 'id' );
$model = new WeixinGoodsModel ();
$goodArray = $model->get_info_byid ( $id );

$price = $goodArray ['price'];
$post_price = $goodArray ['post_price'];
$buyNum = I ( 'buyNum' );

$total_fee_title = $price * $buyNum + $post_price;
$this->assign ( 'total_fee_title', $total_fee_title );
$total_fee = $total_fee_title * 100;
$body = $goodArray ['title'];

$IncludePath = C ( 'IncludePath' );
require_once $IncludePath . 'weixin/pay/' . 'CommonUtil.php';
require_once $IncludePath . 'weixin/pay/' . 'WxPayHelper.php';
$options = array (
'APPID' => C ( 'weixin_api_AppId' ),
'APPSERCERT' => C ( 'weixin_api_AppSecret' ),
'APPKEY' => C ( 'weixin_api_pay_PaySignKey' ),
'SIGNTYPE' => 'sha1',
'PARTNERKEY' => C ( 'weixin_api_pay_partnerKey' )
);
$commonUtil = new \CommonUtil ();
$wxPayHelper = new \WxPayHelper ( $options );
$wxPayHelper->setParameter ( "bank_type", "WX" );
$wxPayHelper->setParameter ( "body", $body );
$wxPayHelper->setParameter ( "partner", C ( 'weixin_api_pay_partnerId' ) );
$wxPayHelper->setParameter ( "out_trade_no", $commonUtil->create_noncestr () );
$wxPayHelper->setParameter ( "total_fee", $total_fee );
$wxPayHelper->setParameter ( "fee_type", "1" );
$wxPayHelper->setParameter ( "notify_url", C ( 'weixin_api_url_paySeccess' ) );
$wxPayHelper->setParameter ( "spbill_create_ip", get_client_ip () );
$wxPayHelper->setParameter ( "input_charset", "UTF-8" );
$package = $wxPayHelper->create_biz_package ();
$this->assign ( 'package', $package );

// 显示模板
$this->display ( 'ApiPay:weixin_goods_pay' );
}
前台页面HTML<include file="Public:public_header" />
<script language="javascript">
function callpay() {
WeixinJSBridge.invoke('getBrandWCPayRequest', {$package}, function(res) {
//WeixinJSBridge.log(res.err_msg);
//alert(res.err_code + res.err_desc + res.err_msg);
});
}
</script>

<div data-role="content" style="margin-top: 0px;">
<ul data-role="listview" data-inset="true">
<li data-role="list-divider" data-theme="f">
支付情况
</li>
<li data-icon="false" style="white-space:normal;">
您共需要支付{$total_fee_title}元!
</li>

</ul>

<a id="getBrandWCPayRequest" href="javascript:void(0);" onclick="callpay();" class="ui-btn ui-corner-all ui-btn-active">
我要支付
</a>

</div>
<include file="Public:public_footer_no" />
如下图


所用的支付接口类WxPayHelper.php,是基于微信官方提供的,但做了修改使之适合THINKPHP调用, 这儿我传不上来, 请移步到
http://www.abis.com.cn/thread-1175年1月1日.html
下载支付接口压缩文件
最佳答案
评论() 相关
后面还有条评论,
评论支持使用[code][/code]标签添加代码
您需要登录后才可以评论 登录 | 立即注册
收藏
abis
积分:6019 等级:LV5
热点推荐
(追記) (追記ここまで)
最新更新

我们

合作

网站

信息

ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。

AltStyle によって変換されたページ (->オリジナル) /