Ejemplo n.º 1
0
 */
if (!isset($_SESSION['openid'])) {
    $client = new Client($wechat);
    if (!isset($_GET['code'])) {
        $callback = 'http://----------YOUR CALLBACK URL----------/_example/payment-brandwcpayrequest.php';
        header('Location: ' . $client->getAuthorizeUrl($callback));
    } else {
        $token = $client->getAccessToken($_GET['code']);
        $_SESSION['openid'] = $token['openid'];
    }
}
/**
 * 获取 getBrandWCPayRequest 配置文件
 */
$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']);
$o = new JsBrandWCPayRequest($wechat, $options);
$configJSON = $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>getBrandWCPayRequest 方式:</h4>
<button type="button" onclick="WXPayment()" style="font-size:16px;height:38px;">支付 ¥<?php 
Ejemplo n.º 2
0
 /**
  * 构造方法
  */
 public function __construct(Wechat $wechat, array $optionsOfUnifiedorder)
 {
     parent::__construct($wechat, $optionsOfUnifiedorder);
 }