From 63c2ef5e6887c0b5577a687ab9196f01c8479ab7 Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 5 Nov 2019 10:21:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BE=AE=E4=BF=A1=E4=BB=98?= =?UTF-8?q?=E6=AC=BE=E7=A0=81=E6=94=AF=E4=BB=98=E5=8F=8A=E9=9D=99=E6=80=81?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 一、增加刷卡支付接口 #30 二、增加静态实例调用 --- WeChat/Contracts/BasicAliPay.php | 18 +++++++++ WeChat/Contracts/BasicWeChat.php | 18 +++++++++ WeChat/Contracts/BasicWePay.php | 17 +++++++++ WeChat/Pay.php | 61 +++++++++++++----------------- WePay/Order.php | 13 +++++++ _test/alipay-app.php | 3 +- _test/alipay-bill.php | 4 +- _test/alipay-notify.php | 4 +- _test/alipay-pos.php | 5 ++- _test/alipay-refund.php | 5 ++- _test/alipay-scan.php | 5 ++- _test/alipay-transfer.php | 7 +++- _test/alipay-wap.php | 5 ++- _test/alipay-web.php | 5 ++- _test/mini-login.php | 6 ++- _test/mini-qrc.php | 8 ++-- _test/pay-download-bill.php | 4 +- _test/pay-order-close.php | 4 +- _test/pay-order-create.php | 4 +- _test/pay-order-notify.php | 4 +- _test/pay-order-query.php | 4 +- _test/pay-redpack-create.php | 4 +- _test/pay-refund-create.php | 4 +- _test/pay-refund-query.php | 4 +- _test/pay-transfers-create.php | 4 +- _test/pay-transfersbank-create.php | 4 +- _test/wechat-jssdk-sign.php | 4 +- _test/wechat-menu-get.php | 6 ++- _test/wechat-qrcode-create.php | 4 +- _test/wechat-user-get.php | 4 +- 30 files changed, 178 insertions(+), 64 deletions(-) diff --git a/WeChat/Contracts/BasicAliPay.php b/WeChat/Contracts/BasicAliPay.php index ec2b6ef..732cac0 100644 --- a/WeChat/Contracts/BasicAliPay.php +++ b/WeChat/Contracts/BasicAliPay.php @@ -43,6 +43,12 @@ abstract class BasicAliPay */ protected $params; + /** + * 静态缓存 + * @var static + */ + private static $cache; + /** * 正常请求网关 * @var string @@ -88,6 +94,18 @@ abstract class BasicAliPay } } + /** + * 静态创建对象 + * @param array $config + * @return static + */ + public static function instance(array $config) + { + $key = md5(get_called_class() . serialize($config)); + if (isset(self::$cache[$key])) return self::$cache[$key]; + return self::$cache[$key] = new static($config); + } + /** * 查询支付宝订单状态 * @param string $out_trade_no diff --git a/WeChat/Contracts/BasicWeChat.php b/WeChat/Contracts/BasicWeChat.php index 0f9f8b8..5d4a1c0 100644 --- a/WeChat/Contracts/BasicWeChat.php +++ b/WeChat/Contracts/BasicWeChat.php @@ -48,6 +48,12 @@ class BasicWeChat */ protected $isTry = false; + /** + * 静态缓存 + * @var static + */ + private static $cache; + /** * 注册代替函数 * @var string @@ -75,6 +81,18 @@ class BasicWeChat $this->config = new DataArray($options); } + /** + * 静态创建对象 + * @param array $config + * @return static + */ + public static function instance(array $config) + { + $key = md5(get_called_class() . serialize($config)); + if (isset(self::$cache[$key])) return self::$cache[$key]; + return self::$cache[$key] = new static($config); + } + /** * 获取访问accessToken * @return string diff --git a/WeChat/Contracts/BasicWePay.php b/WeChat/Contracts/BasicWePay.php index 1f0f096..25b3f3b 100644 --- a/WeChat/Contracts/BasicWePay.php +++ b/WeChat/Contracts/BasicWePay.php @@ -36,6 +36,11 @@ class BasicWePay */ protected $params; + /** + * 静态缓存 + * @var static + */ + private static $cache; /** * WeChat constructor. @@ -71,6 +76,18 @@ class BasicWePay } } + /** + * 静态创建对象 + * @param array $config + * @return static + */ + public static function instance(array $config) + { + $key = md5(get_called_class() . serialize($config)); + if (isset(self::$cache[$key])) return self::$cache[$key]; + return self::$cache[$key] = new static($config); + } + /** * 获取微信支付通知 * @return array diff --git a/WeChat/Pay.php b/WeChat/Pay.php index dbbd4a1..3e3fbad 100644 --- a/WeChat/Pay.php +++ b/WeChat/Pay.php @@ -18,7 +18,6 @@ use WeChat\Contracts\BasicWePay; use WeChat\Exceptions\InvalidResponseException; use WePay\Bill; use WePay\Order; -use WePay\Refund; use WePay\Transfers; use WePay\TransfersBank; @@ -39,10 +38,20 @@ class Pay extends BasicWePay */ public function createOrder(array $options) { - $pay = new Order($this->config->get()); - return $pay->create($options); + return Order::instance($this->config->get())->create($options); } + /** + * 刷卡支付 + * @param array $options + * @return array + * @throws Exceptions\LocalCacheException + * @throws InvalidResponseException + */ + public function createMicropay($options) + { + return Order::instance($this->config->get())->micropay($options); + } /** * 创建JsApi及H5支付参数 @@ -51,8 +60,7 @@ class Pay extends BasicWePay */ public function createParamsForJsApi($prepay_id) { - $pay = new Order($this->config->get()); - return $pay->jsapiParams($prepay_id); + return Order::instance($this->config->get())->jsapiParams($prepay_id); } /** @@ -62,8 +70,7 @@ class Pay extends BasicWePay */ public function createParamsForApp($prepay_id) { - $pay = new Order($this->config->get()); - return $pay->appParams($prepay_id); + return Order::instance($this->config->get())->appParams($prepay_id); } /** @@ -73,8 +80,7 @@ class Pay extends BasicWePay */ public function createParamsForRuleQrc($product_id) { - $pay = new Order($this->config->get()); - return $pay->qrcParams($product_id); + return Order::instance($this->config->get())->qrcParams($product_id); } /** @@ -86,8 +92,7 @@ class Pay extends BasicWePay */ public function queryOrder(array $options) { - $pay = new Order($this->config->get()); - return $pay->query($options); + return Order::instance($this->config->get())->query($options); } /** @@ -99,8 +104,7 @@ class Pay extends BasicWePay */ public function closeOrder($out_trade_no) { - $pay = new Order($this->config->get()); - return $pay->close($out_trade_no); + return Order::instance($this->config->get())->close($out_trade_no); } /** @@ -112,8 +116,7 @@ class Pay extends BasicWePay */ public function createRefund(array $options) { - $pay = new Refund($this->config->get()); - return $pay->create($options); + return Order::instance($this->config->get())->create($options); } /** @@ -125,8 +128,7 @@ class Pay extends BasicWePay */ public function queryRefund(array $options) { - $pay = new Refund($this->config->get()); - return $pay->query($options); + return Order::instance($this->config->get())->query($options); } /** @@ -138,8 +140,7 @@ class Pay extends BasicWePay */ public function report(array $options) { - $pay = new Order($this->config->get()); - return $pay->report($options); + return Order::instance($this->config->get())->report($options); } /** @@ -151,8 +152,7 @@ class Pay extends BasicWePay */ public function queryAuthCode($authCode) { - $pay = new Order($this->config->get()); - return $pay->queryAuthCode($authCode); + return Order::instance($this->config->get())->queryAuthCode($authCode); } /** @@ -165,11 +165,9 @@ class Pay extends BasicWePay */ public function billDownload(array $options, $outType = null) { - $pay = new Bill($this->config->get()); - return $pay->download($options, $outType); + return Bill::instance($this->config->get())->download($options, $outType); } - /** * 拉取订单评价数据 * @param array $options @@ -179,8 +177,7 @@ class Pay extends BasicWePay */ public function billCommtent(array $options) { - $pay = new Bill($this->config->get()); - return $pay->comment($options); + return Bill::instance($this->config->get())->comment($options); } /** @@ -192,8 +189,7 @@ class Pay extends BasicWePay */ public function createTransfers(array $options) { - $pay = new Transfers($this->config->get()); - return $pay->create($options); + return Transfers::instance($this->config->get())->create($options); } /** @@ -205,8 +201,7 @@ class Pay extends BasicWePay */ public function queryTransfers($partner_trade_no) { - $pay = new Transfers($this->config->get()); - return $pay->query($partner_trade_no); + return Transfers::instance($this->config->get())->query($partner_trade_no); } /** @@ -219,8 +214,7 @@ class Pay extends BasicWePay */ public function createTransfersBank(array $options) { - $pay = new TransfersBank($this->config->get()); - return $pay->create($options); + return TransfersBank::instance($this->config->get())->create($options); } /** @@ -232,7 +226,6 @@ class Pay extends BasicWePay */ public function queryTransFresBank($partner_trade_no) { - $pay = new TransfersBank($this->config->get()); - return $pay->query($partner_trade_no); + return TransfersBank::instance($this->config->get())->query($partner_trade_no); } } \ No newline at end of file diff --git a/WePay/Order.php b/WePay/Order.php index 2b4a1f5..1d93288 100644 --- a/WePay/Order.php +++ b/WePay/Order.php @@ -38,6 +38,19 @@ class Order extends BasicWePay return $this->callPostApi($url, $options, false, 'MD5'); } + /** + * 刷卡支付 + * @param array $options + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function micropay(array $options) + { + $url = 'https://api.mch.weixin.qq.com/pay/micropay'; + return $this->callPostApi($url, $options, false, 'MD5'); + } + /** * 查询订单 * @param array $options diff --git a/_test/alipay-app.php b/_test/alipay-app.php index bbfe18e..0070eb3 100644 --- a/_test/alipay-app.php +++ b/_test/alipay-app.php @@ -20,8 +20,9 @@ $config = include "./alipay.php"; try { // 实例支付对象 - $pay = \We::AliPayApp($config); + // $pay = \We::AliPayApp($config); // $pay = new \AliPay\App($config); + $pay = \AliPay\App::instance($config); // 请参考(请求参数):https://docs.open.alipay.com/api_1/alipay.trade.app.pay $result = $pay->apply([ diff --git a/_test/alipay-bill.php b/_test/alipay-bill.php index 3ed1109..af5c493 100644 --- a/_test/alipay-bill.php +++ b/_test/alipay-bill.php @@ -20,8 +20,10 @@ $config = include "./alipay.php"; try { // 实例支付对象 - $pay = \We::AliPayBill($config); // $pay = new \AliPay\Bill($config); + // $pay = \We::AliPayBill($config); + $pay = \AliPay\Bill::instance($config); + // 请参考(请求参数):https://docs.open.alipay.com/api_15/alipay.data.dataservice.bill.downloadurl.query $result = $pay->apply([ 'bill_date' => '2018-10-03', // 账单时间(日账单yyyy-MM-dd,月账单 yyyy-MM) diff --git a/_test/alipay-notify.php b/_test/alipay-notify.php index 311cb6a..0d59116 100644 --- a/_test/alipay-notify.php +++ b/_test/alipay-notify.php @@ -20,8 +20,10 @@ $config = include "./alipay.php"; try { // 实例支付对象 - $pay = \We::AliPayApp($config); + // $pay = \We::AliPayApp($config); // $pay = new \AliPay\App($config); + $pay = \AliPay\App::instance($config); + $data = $pay->notify(); if (in_array($data['trade_status'], ['TRADE_SUCCESS', 'TRADE_FINISHED'])) { // @todo 更新订单状态,支付完成 diff --git a/_test/alipay-pos.php b/_test/alipay-pos.php index 4900374..e55c4e2 100644 --- a/_test/alipay-pos.php +++ b/_test/alipay-pos.php @@ -20,8 +20,10 @@ $config = include "./alipay.php"; try { // 实例支付对象 - $pay = We::AliPayPos($config); + // $pay = We::AliPayPos($config); // $pay = new \AliPay\Pos($config); + $pay = \AliPay\Pos::instance($config); + // 参数链接:https://docs.open.alipay.com/api_1/alipay.trade.pay $result = $pay->apply([ 'out_trade_no' => '4312412343', // 订单号 @@ -29,6 +31,7 @@ try { 'subject' => '订单商品标题', // 订单商品标题 'auth_code' => '123456', // 授权码 ]); + echo '
';
     var_export($result);
 } catch (Exception $e) {
diff --git a/_test/alipay-refund.php b/_test/alipay-refund.php
index 57fb0bf..487ca7b 100644
--- a/_test/alipay-refund.php
+++ b/_test/alipay-refund.php
@@ -25,10 +25,13 @@ $refund_fee = '1.00';
 
 try {
     // 实例支付对象
-    $pay = We::AliPayApp($config);
+    // $pay = We::AliPayApp($config);
     // $pay = new \AliPay\App($config);
+    $pay = \AliPay\App::instance($config);
+
     // 参考链接:https://docs.open.alipay.com/api_1/alipay.trade.refund
     $result = $pay->refund($out_trade_no, $refund_fee);
+    
     echo '
';
     var_export($result);
 } catch (Exception $e) {
diff --git a/_test/alipay-scan.php b/_test/alipay-scan.php
index 0a11076..2bc8806 100644
--- a/_test/alipay-scan.php
+++ b/_test/alipay-scan.php
@@ -20,14 +20,17 @@ $config = include "./alipay.php";
 
 try {
     // 实例支付对象
-    $pay = We::AliPayScan($config);
+    // $pay = We::AliPayScan($config);
     // $pay = new \AliPay\Scan($config);
+    $pay = \AliPay\Scan::instance($config);
+
     // 参考链接:https://docs.open.alipay.com/api_1/alipay.trade.precreate
     $result = $pay->apply([
         'out_trade_no' => '14321412', // 订单号
         'total_amount' => '13', // 订单金额,单位:元
         'subject'      => '订单商品标题', // 订单商品标题
     ]);
+
     echo '
';
     var_export($result);
 } catch (Exception $e) {
diff --git a/_test/alipay-transfer.php b/_test/alipay-transfer.php
index 16b56aa..4eaf6fb 100644
--- a/_test/alipay-transfer.php
+++ b/_test/alipay-transfer.php
@@ -20,8 +20,10 @@ $config = include "./alipay.php";
 
 try {
     // 实例支付对象
-    $pay = We::AliPayTransfer($config);
-    // $pay = new \AliPay\Scan($config);
+    // $pay = We::AliPayTransfer($config);
+    // $pay = new \AliPay\Transfer($config);
+    $pay = \AliPay\Transfer::instance($config);
+
     // 参考链接:https://docs.open.alipay.com/api_28/alipay.fund.trans.toaccount.transfer
     $result = $pay->apply([
         'out_biz_no'      => time(), // 订单号
@@ -32,6 +34,7 @@ try {
         'payee_real_name' => '张三', // 收款方真实姓名
         'remark'          => '张三', // 转账备注
     ]);
+
     echo '
';
     var_export($result);
 } catch (Exception $e) {
diff --git a/_test/alipay-wap.php b/_test/alipay-wap.php
index 3b63833..ac04021 100644
--- a/_test/alipay-wap.php
+++ b/_test/alipay-wap.php
@@ -23,14 +23,17 @@ $config['return_url'] = 'http://pay.thinkadmin.top/test/alipay-success.php';
 
 try {
     // 实例支付对象
-    $pay = We::AliPayWap($config);
+    // $pay = We::AliPayWap($config);
     // $pay = new \AliPay\Wap($config);
+    $pay = \AliPay\Wap::instance($config);
+
     // 参考链接:https://docs.open.alipay.com/api_1/alipay.trade.wap.pay
     $result = $pay->apply([
         'out_trade_no' => time(), // 商户订单号
         'total_amount' => '1', // 支付金额
         'subject'      => '支付订单描述', // 支付订单描述
     ]);
+
     echo $result;
 } catch (Exception $e) {
     echo $e->getMessage();
diff --git a/_test/alipay-web.php b/_test/alipay-web.php
index e0e3b86..46f0efc 100644
--- a/_test/alipay-web.php
+++ b/_test/alipay-web.php
@@ -24,14 +24,17 @@ $config['return_url'] = 'http://pay.thinkadmin.top/test/alipay-success.php';
 
 try {
     // 实例支付对象
-    $pay = We::AliPayWeb($config);
+    // $pay = We::AliPayWeb($config);
     // $pay = new \AliPay\Web($config);
+    $pay = \AliPay\Web::instance($config);
+
     // 参考链接:https://docs.open.alipay.com/api_1/alipay.trade.page.pay
     $result = $pay->apply([
         'out_trade_no' => time(), // 商户订单号
         'total_amount' => '1', // 支付金额
         'subject'      => '支付订单描述', // 支付订单描述
     ]);
+
     echo $result;
 } catch (Exception $e) {
     echo $e->getMessage();
diff --git a/_test/mini-login.php b/_test/mini-login.php
index 2f3bab3..c6f56ba 100644
--- a/_test/mini-login.php
+++ b/_test/mini-login.php
@@ -13,7 +13,11 @@ $iv = 'ltM/wT7hsAl0TijEBI4v/g==';
 $code = '013LyiTR0TwjC92QjJRR0mEsTR0LyiT3';
 $decode = 'eIoVtIC2YzLCnrwiIs1IBbXMvC0vyL8bo1IhD38fUQIRbk3lgTWa0Hdw/Ty7NTs3iu7YlqqZBti+cxd6dCfeXBUQwTO2QpbHg0WTeDAdrihsHRHm4dCWdfTx8rzDloGbNOIsKdRElIhUH5YFdiTr5AYiufUDb34cwJ4GNWLAUq4bR0dmFeVEi+3nfwe2MAjGYDl4aq719VLsHodOggK6lXZvM5wjoDyuZsK2dPqJr3/Ji30Z0mdyFq32R4uR3rtJH/h+Rj0+/QmE9QYG7Y6Z48hgPE8cpnhRQNwH49jnC/zKZ9wtDkQ/J8J3Ed2i58zcuY01v8IV+pZ8oBUKXfO5ha+APOxtBSTzyHraU/2RGo8UWtOF6h64OQZhd/UQQy362eyc/qoq8sF9JnEFRP0mRmTDJ+u9oyDhxswCu6x8V73ERWaJeEGSCyjiGpep7/DxZ6eSSBq36OB0BWBkJqsq9Q==';
 $sessionKey = 'OetNxl86B/yMpbwG6wtMEw==';
-$mini = new WeMini\Crypt($config);
+
+// $mini = \We::WeMiniCrypt($config);
+// $mini = new WeMini\Crypt($config);
+$mini = \WeMini\Crypt::instance($config);
+
 echo '
';
 //print_r($mini->session($code));
 print_r($mini->decode($iv, $sessionKey, $decode));
diff --git a/_test/mini-qrc.php b/_test/mini-qrc.php
index ce62ae1..84ca9d6 100644
--- a/_test/mini-qrc.php
+++ b/_test/mini-qrc.php
@@ -10,13 +10,13 @@ $config = [
 
 //We::config($config);
 
-$mini = We::WeMiniQrcode($config);
-
-//$mini = new WeMini\Qrcode($config);
+// $mini = We::WeMiniQrcode($config);
+// $mini = new WeMini\Qrcode($config);
+$mini = \WeMini\Qrcode::instance($config);
 
 //echo '
';
 try {
-    header('Content-type:image/jpeg');//输出的类型
+    header('Content-type:image/jpeg'); //输出的类型
 //    echo $mini->createDefault('pages/index?query=1');
 //    echo $mini->createMiniScene('432432', 'pages/index/index');
     echo $mini->createMiniPath('pages/index?query=1');
diff --git a/_test/pay-download-bill.php b/_test/pay-download-bill.php
index c0181fb..ffac45b 100644
--- a/_test/pay-download-bill.php
+++ b/_test/pay-download-bill.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\Pay($config);
+    // $wechat = new \WeChat\Pay($config);
+    // $wechat = \We::WeChatPay($config);
+    $wechat = \WeChat\Pay::instance($config);
 
     // 4. 组装参数,可以参考官方商户文档
     $options = [
diff --git a/_test/pay-order-close.php b/_test/pay-order-close.php
index 3a31ddc..eeead4a 100644
--- a/_test/pay-order-close.php
+++ b/_test/pay-order-close.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\Pay($config);
+    // $wechat = new \WeChat\Pay($config);
+    // $wechat = \We::WeChatPay($config);
+    $wechat = \WeChat\Pay::instance($config);
 
     // 4. 组装参数,可以参考官方商户文档
     $options = '1217752501201407033233368018';
diff --git a/_test/pay-order-create.php b/_test/pay-order-create.php
index e130bb1..e9c9f20 100644
--- a/_test/pay-order-create.php
+++ b/_test/pay-order-create.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\Pay($config);
+    // $wechat = new \WeChat\Pay($config);
+    // $wechat = \We::WeChatPay($config);
+    $wechat = \WeChat\Pay::instance($config);
 
     // 4. 组装参数,可以参考官方商户文档
     $options = [
diff --git a/_test/pay-order-notify.php b/_test/pay-order-notify.php
index 7b8267a..7484aac 100644
--- a/_test/pay-order-notify.php
+++ b/_test/pay-order-notify.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\Pay($config);
+    // $wechat = new \WeChat\Pay($config);
+    // $wechat = \We::WeChatPay($config);
+    $wechat = \WeChat\Pay::instance($config);
 
     // 4. 获取通知参数
     $data = $wechat->getNotify();
diff --git a/_test/pay-order-query.php b/_test/pay-order-query.php
index d993488..b7edf34 100644
--- a/_test/pay-order-query.php
+++ b/_test/pay-order-query.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\Pay($config);
+    // $wechat = new \WeChat\Pay($config);
+    // $wechat = \We::WeChatPay($config);
+    $wechat = \WeChat\Pay::instance($config);
 
     // 4. 组装参数,可以参考官方商户文档
     $options = [
diff --git a/_test/pay-redpack-create.php b/_test/pay-redpack-create.php
index 3df5fb6..c45dade 100644
--- a/_test/pay-redpack-create.php
+++ b/_test/pay-redpack-create.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WePay\Redpack($config);
+    // $wechat = new \WePay\Redpack($config);
+    // $wechat = \We::WePayRedpack($config);
+    $wechat = \WePay\Redpack::instance($config);
 
     // 4. 组装参数,可以参考官方商户文档
     $options = [
diff --git a/_test/pay-refund-create.php b/_test/pay-refund-create.php
index 02b554b..8e3df01 100644
--- a/_test/pay-refund-create.php
+++ b/_test/pay-refund-create.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\Pay($config);
+    // $wechat = new \WeChat\Pay($config);
+    // $wechat = \We::WeChatPay($config);
+    $wechat = \WeChat\Pay::instance($config);
 
     // 4. 组装参数,可以参考官方商户文档
     $options = [
diff --git a/_test/pay-refund-query.php b/_test/pay-refund-query.php
index a812ac4..fa63acc 100644
--- a/_test/pay-refund-query.php
+++ b/_test/pay-refund-query.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\Pay($config);
+    // $wechat = new \WeChat\Pay($config);
+    // $wechat = \We::WeChatPay($config);
+    $wechat = \WeChat\Pay::instance($config);
 
     // 4. 组装参数,可以参考官方商户文档
     $options = [
diff --git a/_test/pay-transfers-create.php b/_test/pay-transfers-create.php
index 77d70b0..659d888 100644
--- a/_test/pay-transfers-create.php
+++ b/_test/pay-transfers-create.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\Pay($config);
+    // $wechat = new \WeChat\Pay($config);
+    // $wechat = \We::WeChatPay($config);
+    $wechat = \WeChat\Pay::instance($config);
 
     // 4. 组装参数,可以参考官方商户文档
     $options = [
diff --git a/_test/pay-transfersbank-create.php b/_test/pay-transfersbank-create.php
index 92147af..ca3979e 100644
--- a/_test/pay-transfersbank-create.php
+++ b/_test/pay-transfersbank-create.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\Pay($config);
+    // $wechat = new \WeChat\Pay($config);
+    // $wechat = \We::WeChatPay($config);
+    $wechat = \WeChat\Pay::instance($config);
 
     // 4. 组装参数,可以参考官方商户文档
     $options = [
diff --git a/_test/wechat-jssdk-sign.php b/_test/wechat-jssdk-sign.php
index 8986cf2..6a3b698 100644
--- a/_test/wechat-jssdk-sign.php
+++ b/_test/wechat-jssdk-sign.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\Script($config);
+    // $wechat = \We::WeChatScript($config);
+    // $wechat = new \WeChat\Script($config);
+    $wechat = \WeChat\Script::instance($config);
 
     // 4. 获取JSSDK网址签名配置
     $result = $wechat->getJsSign('http://a.com/test.php');
diff --git a/_test/wechat-menu-get.php b/_test/wechat-menu-get.php
index 31f18b0..5447aad 100644
--- a/_test/wechat-menu-get.php
+++ b/_test/wechat-menu-get.php
@@ -21,11 +21,13 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $menu = new \WeChat\Menu($config);
+    // $menu = \We::WeChatMenu($config);
+    // $menu = new \WeChat\Menu($config);
+    $menu = \WeChat\Menu::instance($config);
 
     // 4. 获取菜单数据
     $result = $menu->get();
-    
+
     var_export($result);
 
 } catch (Exception $e) {
diff --git a/_test/wechat-qrcode-create.php b/_test/wechat-qrcode-create.php
index e7daa79..256e30a 100644
--- a/_test/wechat-qrcode-create.php
+++ b/_test/wechat-qrcode-create.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\Qrcode($config);
+    // $wechat = \We::WeChatQrcode($config);
+    // $wechat = new \WeChat\Qrcode($config);
+    $wechat = \WeChat\Qrcode::instance($config);
 
     // 4. 获取用户列表
     $result = $wechat->create('场景内容');
diff --git a/_test/wechat-user-get.php b/_test/wechat-user-get.php
index ad94e3a..d42cb56 100644
--- a/_test/wechat-user-get.php
+++ b/_test/wechat-user-get.php
@@ -21,7 +21,9 @@ try {
     $config = include "./config.php";
 
     // 3. 创建接口实例
-    $wechat = new \WeChat\User($config);
+    // $wechat = \We::WeChatUser($config);
+    // $wechat = new \WeChat\User($config);
+    $wechat = \WeChat\User::instance($config);
 
     // 4. 获取用户列表
     $result = $wechat->getUserList();