Ejemplo n.º 1
0
$bag->set('mch_id', MCHID);
$bag->set('notify_url', NOTIFY_URL);
$bag->set('body', 'iphone 6 plus');
$bag->set('out_trade_no', date('YmdHis') . mt_rand(10000, 99999));
$bag->set('total_fee', 1);
// 单位为 “分”
$bag->set('trade_type', 'NATIVE');
// NATIVE 时不需要 Openid
/**
 * 统一下单
 */
$unifiedorder = new Unifiedorder($bag, MCHKEY);
/**
 * 获取支付 URL(模式 2)
 */
$payurl = Config::getTemporaryPayurl($unifiedorder);
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Wechat SDK</title>
</head>
<body ontouchstart="">

<h1>扫描支付模式二</h1>
<p>请在 PC 端扫描二给码,如果在手机上可长按识别二维码</p>

<img src="https://chart.googleapis.com/chart?cht=qr&chs=220x220&choe=UTF-8&chld=L|2&chl=<?php 
Ejemplo n.º 2
0
require './config.php';
use Thenbsp\Wechat\Config;
use Thenbsp\Wechat\Wechat;
/**
 * 只能在微信中打开
 */
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') === false) {
    exit('请在微信中打开');
}
/**
 * 生成 JSSDK 配置文件
 */
$wechat = new Wechat(APPID, APPSECRET);
$apis = array('onMenuShareTimeline', 'onMenuShareAppMessage');
$configJSON = Config::getJssdk($wechat, $apis, $debug = true, $asArray = false);
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>JSSDK DEMO</title>
</head>
<body ontouchstart="">

如果弹出 {"errMsg": "config:ok"} 说明配置成功!

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
Ejemplo n.º 3
0
 * https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4
 */
require './config.php';
use Thenbsp\Wechat\Config;
use Thenbsp\Wechat\Util\Bag;
/**
 * 配置订单参数
 */
$bag = new Bag();
$bag->set('appid', APPID);
$bag->set('mch_id', MCHID);
$bag->set('product_id', date('YmdHis') . mt_rand(10000, 99999));
/**
 * 获取支付 URL(模式 1)
 */
$payurl = Config::getForeverPayurl($bag, MCHKEY);
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Wechat SDK</title>
</head>
<body ontouchstart="">

<h1>扫描支付模式一</h1>
<p>请在 PC 端扫描二给码,如果在手机上可长按识别二维码</p>

<img src="https://chart.googleapis.com/chart?cht=qr&chs=220x220&choe=UTF-8&chld=L|2&chl=<?php 
Ejemplo n.º 4
0
$bag = new Bag();
$bag->set('appid', APPID);
$bag->set('mch_id', MCHID);
$bag->set('notify_url', NOTIFY_URL);
$bag->set('body', 'iphone 6 plus');
$bag->set('out_trade_no', date('YmdHis') . mt_rand(10000, 99999));
$bag->set('total_fee', 1);
$bag->set('openid', $_SESSION['openid']);
/**
 * 三、统一下单
 */
$unifiedorder = new Unifiedorder($bag, MCHKEY);
/**
 * 四、生成支付配置文件
 */
$configJSON = Config::getPaymentConfig($unifiedorder, $asArray = false);
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Wechat SDK</title>
</head>
<body ontouchstart="">

<h1>微信支付测试&nbsp;&nbsp;<a href="javascript:;" onclick="window.location.reload()">刷新</a></h1>

<h4>WeixinJSBridge invoke 方式:</h4>
<button type="button" onclick="WXPayment()" style="font-size:16px;height:38px;">支付 ¥<?php