naka507/wehelper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

naka507/wehelper

Composer 安装命令:

composer require naka507/wehelper

包简介

WeChat, WeMini, WePay, AliPay SDK FOR PHP

README 文档

README

安装

composer require naka507/wehelper

微信

require __DIR__ . '/vendor/autoload.php';
use WeHelper\WeChat\User;

$config = [
    'token'          => '',
    'appid'          => '',
    'appsecret'      => '',
    'encodingaeskey' => '',
    'mch_id'         => "", // 配置商户支付参数
    'mch_key'        => '',
    // 配置商户支付双向证书目录 (p12 | key,cert 二选一,两者都配置时p12优先)
    'ssl_key'        => 'XXX.pem',
    'ssl_cer'        => 'XXX.pem',
    // 配置缓存目录,需要拥有写权限
    'cache_path'     => '',
];

$wechat = new User($config);
// 获取用户列表
$result = $wechat->getUserList();

// 批量获取用户资料
foreach (array_chunk($result['data']['openid'], 100) as $value) {
    $info = $wechat->getBatchUserInfo($value);
    var_export($info);
}

微信网页

//发起授权
$oauth = new Oauth($config);

$redirect_url = 'https://www.xxx.com/back';
// $scope = 'snsapi_base'; //静默授权 获取openid
$scope = 'snsapi_userinfo'; //主动授权 获取用户信息
$redirect = $oauth->getOauthRedirect($redirect_url,'debug',$scope);

header('Location: ' .$redirect);
//授权回调
$oauth = new Oauth($config);
//获取 access_token openid
$data = $oauth->getOauthAccessToken();


//主动授权 获取用户信息信息
$access_token = isset($data['access_token']) ? $data['access_token'] : '';
$openid = isset($data['openid']) ? $data['openid'] : '';
$user_info = $oauth->getUserInfo($access_token,$openid);

微信小程序

use WeHelper\WeMini\Crypt;

$iv = $_POST['iv'];
$code = $_POST['code'];
$encryptedData = $_POST['encryptedData'];

$config = [
    'appid'     => '',
    'appsecret' => '',
];

$mini = new Crypt($config);
$info = $mini->session($code);

$session_key = isset($info['session_key']) ? $info['session_key'] : '';
// 获取用户信息
$userinfo = $wechat->decode($iv, $session_key, $encryptedData);

微信支付

use WeHelper\WeChat\Pay;

$wechat = new Pay($config);

// 参数
$options = [
    'body'             => '测试商品',
    'out_trade_no'     => time(),
    'total_fee'        => '1',
    'openid'           => '',
    'trade_type'       => 'JSAPI',
    'notify_url'       => 'http://www.xxx.com/text.html',
    'spbill_create_ip' => '127.0.0.1',
];

// 生成预支付码
$result = $wechat->createOrder($options);

// 创建JSAPI参数签名
$options = $wechat->createParamsForJsApi($result['prepay_id']);

支付宝支付

use WeHelper\AliPay\Wap;

// 参数
$config = [
    'debug'       => true, // 沙箱模式
    'sign_type'   => "RSA2", // 签名类型(RSA|RSA2)
    'appid'       => '', // 应用ID
    'public_key'  => '', // 支付宝公钥 
    'private_key' => '', // 支付宝私钥 
    'app_cert'    => '', // 应用公钥证书(新版资金类接口转 app_cert_sn)
    'root_cert'   => '', // 支付宝根证书(新版资金类接口转 alipay_root_cert_sn)
    'notify_url'  => '', // 支付成功通知地址
    'return_url'  => '', // 网页支付回跳地址
];

// 参考公共参数  https://docs.open.alipay.com/203/107090/
$config['notify_url'] = 'http://www.xxxx.com/alipay-notify.php';
$config['return_url'] = 'http://www.xxxx.com/alipay-success.php';

$alipay = new Wap($config);

// 参考链接:https://docs.open.alipay.com/api_1/alipay.trade.wap.pay
$result = $alipay->apply([
    'out_trade_no' => time(), // 商户订单号
    'total_amount' => '1', // 支付金额
    'subject'      => '支付订单描述', // 支付订单描述
]);

企业微信

require __DIR__ . '/vendor/autoload.php';
use WeHelper\WeQiye\WeMini;

$config = [
    'token'          => '',
    'appid'          => '',
    'agentid'          => '',
    'appsecret'      => '',
    // 配置缓存目录,需要拥有写权限
    'cache_path'     => '',
];

$wx = new WeMini($config);
// 获取登录凭证
$result = $wx->session($code);

// 获取用户信息
$userInfo = $wx->userInfo($result['userid']);

naka507/wehelper 适用场景与选型建议

naka507/wehelper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 06 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 naka507/wehelper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 naka507/wehelper 我们能提供哪些服务?
定制开发 / 二次开发

基于 naka507/wehelper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-04