手机浏览器只有支付宝wap支付,微信浏览器中出现支付宝wap支付和微信JSAPI公众号支付,其中支付宝wap在线支付没有在新窗口打开(兼容大部分手机),Thinkphp3.2公众号支付
下载资源
下载积分:
998
积分
授权域名【公众号设置->功能设置】 https://mp.weixin.qq.com
支付路径【产品中心->开发配置】 https://pay.weixin.qq.com/index.php/extend/pay_setting
在 https://mp.weixin.qq.com【基本设置】获取开发者ID(AppID)、开发者密码(AppSecret)
商户ID(MCHID):https://pay.weixin.qq.com/index.php/core/account/info
API密钥key
你填写的微信支付路径就是你看到微信支付按钮的当前链接
第一步:数据库配置Application/common/conf/config.php $host = $_SERVER['HTTP_HOST'];
$arr = array(
'DB_TYPE' => 'mysql',
'DB_HOST' => "localhost",
'DB_NAME' => 'demo',
'DB_USER' => "root",
'DB_PWD' => "root",
'DB_PORT' => 3306,
'DB_PREFIX' => '',
'DB_CHARSET' => 'utf8',
);
第二步:配置支付信息Application/Home/conf/config.php $arr = array(
'URL_ROUTER_ON' => true,
/* 支付设置 */
'payment' => array(
'alipay' => array(
// 收款账号邮箱
'email' => 'xuanhani@126.com',
// 加密key,开通支付宝账户后给予
'key' => 'ggo084pb84gl43qnw82a39n9b7r1jq2m',
// 合作者ID,支付宝有该配置,开通易宝账户后给予
'partner' => '2088901006538525',
//收款支付宝账号,以2088开头由16位纯数字组成的字符串,一般情况下收款账号就是签约账号
'seller_id' => '2088901006538525',
//签名方式
'sign_type' => strtoupper('MD5'),
//字符编码格式 目前支持utf-8
'input_charset' => strtolower('utf-8'),
// 产品类型,无需修改
'service' => 'alipay.wap.create.direct.pay.by.user',
// 支付类型 ,无需修改
'payment_type' => '1',
),
'wechatjspai' => array(
'APPID' => 'wx4221260b6bbfcfc',
'MCHID' => '1349825901',
'KEY' => '2088901006538525',
'APPSECRET' => '45843e705995a12106155f4c26f716dc',
),
)
);
微信浏览器支付宝wap支付 public function alipay_jump($data) {
header("Content-type: text/html; charset=utf-8");
require dirname(dirname(dirname(__FILE__))) . '/Common/Org/zfbPay/alipay.config.php';
require dirname(dirname(dirname(__FILE__))) . '/Common/Org/zfbPay/lib/alipay_submit.class.php';
#获取支付配置信息
$alipay_config = C('payment.alipay');
//构造要请求的参数数组,无需改动
$parameter = array(
"service" => $alipay_config['service'],
"partner" => $alipay_config['partner'],
"seller_id" => $alipay_config['seller_id'],
"payment_type" => $alipay_config['payment_type'],
"notify_url" => $data['url_notify'],
"return_url" => $data['url_return'],
"_input_charset" => $alipay_config['input_charset'],
"out_trade_no" => $data['order_no'],
"subject" => $data['title'],
"total_fee" => $data['order_money'],
"show_url" => $data['url_return'],
//"app_pay" => "Y",//启用此参数能唤起钱包APP支付宝
"body" => $data['body'],
//其他业务参数根据在线开发文档,添加参数.文档地址:https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.2Z6TSk&treeId=60&articleId=103693&docType=1
//如"参数名" => "参数值" 注:上一个参数末尾需要“,”逗号。
);
//建立请求
$alipaySubmit = new \alipay_submit($alipay_config);
#判断是微信浏览器支付还是非微信浏览器支付
$is_weixin = is_weixin();
if ($is_weixin == 0) {
$html_text = $alipaySubmit->buildRequestForm($parameter, "get", "确认");
echo $html_text;
} else {
$html_text = $alipaySubmit->getHtml($parameter);
$content = '';
$this->assign('content', $content);
$this->display('pay');
}
}
支付宝和微信通知回调 public function pay_weixin() {
$simple = json_decode(json_encode(simplexml_load_string($GLOBALS['HTTP_RAW_POST_DATA'], 'SimpleXMLElement', LIBXML_NOCDATA)), true);
$notify_data['order_no'] = $notify_data['trade_no'] = $simple['out_trade_no'];
$notify_data['third_id'] = $simple['transaction_id'];
$notify_data['pay_money'] = $simple['total_fee'];
$notify_data['payment_method'] = 'weixin';
// $sign = $simple['sign'];
// file_put_contents('ac_simple.txt', json_encode($simple));
// file_put_contents('ac_notify_data.txt', json_encode($notify_data));
$this->order_pay($notify_data);
}
public function pay_alipay() {
$notify_data['order_no'] = $notify_data['trade_no'] = I("post.out_trade_no");
$notify_data['third_id'] = I("post.trade_no");
$notify_data['pay_money'] = I("post.total_fee");
$notify_data['payment_method'] = 'alipay';
$this->order_pay($notify_data);
file_put_contents('ac_notify_data.txt', json_encode($_REQUEST));
}
压缩包里附带支付订单表 CREATE TABLE IF NOT EXISTS `order` (
`id` int(11) unsigned NOT NULL,
`order_no` varchar(30) NOT NULL,
`trade_no` varchar(150) DEFAULT NULL COMMENT '交易号',
`order_money` decimal(10,2) DEFAULT '0.00',
`unit_name` varchar(10) NOT NULL,
`pay_type` varchar(20) DEFAULT NULL COMMENT '支付方式',
`state` int(2) NOT NULL DEFAULT '0',
`addtime` int(10) NOT NULL,
`update_time` int(10) DEFAULT '0'
) ENGINE=MyISAM AUTO_INCREMENT=36 DEFAULT CHARSET=utf8;