Example #1
0
        $token = $client->getAccessToken($_GET['code']);
        $_SESSION['openid'] = $token['openid'];
    }
}
/**
 * 生成 JSSDK 配置文件
 */
$jssdk = new Jssdk($accessToken);
$jssdk->addApi('onMenuShareTimeline')->enableDebug();
$jssdkConfigJSON = $jssdk->getConfig();
/**
 * 生成支付配置文件
 */
$options = array('body' => 'iphone 6 plus', 'total_fee' => 1, 'out_trade_no' => date('YmdHis') . mt_rand(10000, 99999), 'notify_url' => 'http://----------YOUR NOTIFY URL----------/_example/payment-notify.php', 'openid' => $_SESSION['openid']);
$chooseWXPay = new JsChooseWXPay($wechat, $options);
$paymentConfigJSON = $chooseWXPay->getConfig();
?>
<!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>chooseWXPay 方式:</h4>
<button type="button" onclick="WXPayment()" style="font-size:16px;height:38px;">支付 ¥<?php 
echo $options['total_fee'] / 100;
Example #2
0
        $token = $client->getAccessToken($_GET['code']);
        $_SESSION['openid'] = $token['openid'];
    }
}
/**
 * 生成 JSSDK 配置文件
 */
$jssdk = new Jssdk($accessToken);
$jssdk->addApi('onMenuShareTimeline')->enableDebug();
$jssdkConfigJSON = $jssdk->getConfig();
/**
 * 生成支付配置文件
 */
$options = array('body' => 'iphone 6 plus', 'total_fee' => 1, 'out_trade_no' => date('YmdHis') . mt_rand(10000, 99999), 'notify_url' => EXAMPLE_URL . 'payment-notify.php', 'openid' => $_SESSION['openid']);
$o = new JsChooseWXPay($wechat, $options);
$paymentConfigJSON = $o->getConfig();
?>
<!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>chooseWXPay 方式:</h4>
<button type="button" onclick="WXPayment()" style="font-size:16px;height:38px;">支付 ¥<?php 
echo $options['total_fee'] / 100;