Inheritance: extends BaseService
Exemplo n.º 1
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$config = array('appId' => 'wx00e5904efes9', 'appSecret' => '419ffc73eb1fga846c6b04b', 'token' => '54b780cbe9047', 'encodingAesKey' => 'cz7NR8g4vk5yMydpG3g8amyFGbjavCuR33', 'mchId' => '1220633201', 'apiSecret' => 'b4944959c6eaed319a86e3a10d');
// 初始化SDK
\PFinal\Wechat\Kernel::init($config);
// 获取OpenID
$openid = \PFinal\Wechat\Service\OAuthService::getOpenid();
//$openid='oU3OCt5O46PumN7IE87WcoYZY9r0';
// JS签名
$signPackage = \PFinal\Wechat\Service\JsService::getSignPackage();
// 支付成功通知url
/* 收到支付成功通知时,请使用下面的方法,验证订单号和支付金额
    $info = \PFinal\Wechat\Service\PayService::notify();
    $info数组,内容如下
    [
         mch_id          //微信支付分配的商户号
         appid           //微信分配的公众账号ID
         openid          //用户在商户appid下的唯一标识
         transaction_id  //微信支付订单号
         out_trade_no    //商户订单号
         total_fee       //订单总金额单位默认为分,已转为元
         is_subscribe    //用户是否关注公众账号,Y-关注,N-未关注,仅在公众账号类型支付有效
         attach          //商家数据包,原样返回
         time_end        //支付完成时间
    ]
*/
$notifyUrl = 'http://xxx.com/index.php/wxpay/notify';
// 订单信息
$order = array('totalFee' => 0.01, 'tradeNo' => uniqid(), 'name' => '测试订单');
// 业务签名
Exemplo n.º 2
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use PFinal\Wechat\Kernel;
use PFinal\Wechat\Service\JsService;
//请复制 config-local.example 为 config-local.php
$config = (require __DIR__ . '/config-local.php');
Kernel::init($config);
$signPackage = JsService::getSignPackage();
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">

    <title>微信平台SDK</title>
</head>
<body>

<h1>微信平台SDK</h1>

<ul>
    <li><a href="mp.php?token">刷新accessToken</a></li>
    <li><a href="mp.php?openid">获取openid</a></li>
    <li><a href="mp.php?user">获取用户信息</a></li>
    <li><a href="mp.php?send">发客服消息</a></li>
    <li><a href="mp.php?preview">群发预览</a></li>
    <li><a href="mp.php?redpack">发红包</a></li>