All Projects → Yurunsoft → Paysdk

Yurunsoft / Paysdk

Licence: mit
PHP 集成支付 SDK ,集成了支付宝、微信支付的支付接口和其它相关接口的操作。支持 php-fpm 和 Swoole,所有框架通用。宇润PHP全家桶技术支持群:17916227

Projects that are alternatives of or similar to Paysdk

Yurunhttp
YurunHttp 是开源的 PHP HTTP 客户端,支持链式操作,简单易用。完美支持Curl、Swoole 协程。QQ群:17916227
Stars: ✭ 197 (-72.75%)
Mutual labels:  coroutine, swoole
PHPMailer-Swoole
安装最新版Swoole,开启一键协程化,使用原版phpmailer就可以实现协程化了。本项目已经没有维护下去的意义。
Stars: ✭ 25 (-96.54%)
Mutual labels:  swoole, coroutine
ext-postgresql
🐘 Coroutine-based client for PostgreSQL
Stars: ✭ 62 (-91.42%)
Mutual labels:  swoole, coroutine
Guzzle Swoole
让基于 Guzzle 的项目完美无缝兼容 Swoole 协程,支持:Guzzle、Elasticsearch client——来自宇润 PHP 全家桶
Stars: ✭ 143 (-80.22%)
Mutual labels:  coroutine, swoole
Hyperf
🚀 A coroutine framework that focuses on hyperspeed and flexibility. Building microservice or middleware with ease.
Stars: ✭ 4,206 (+481.74%)
Mutual labels:  coroutine, swoole
Yii2 Swoole
make yii2 project runing on swoole
Stars: ✭ 161 (-77.73%)
Mutual labels:  coroutine, swoole
swoole-postgresql-doctrine-driver
🔌 A Doctrine DBAL Driver implementation on top of Swoole Coroutine PostgreSQL client
Stars: ✭ 15 (-97.93%)
Mutual labels:  swoole, coroutine
Mix
☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server / PHP 命令行模式开发框架,支持 Swoole、WorkerMan、FPM、CLI-Server
Stars: ✭ 1,753 (+142.46%)
Mutual labels:  coroutine, swoole
Yurunoauthlogin
PHP 第三方登录授权 SDK,集成了QQ、微信、微博、Github等常用接口。支持 php-fpm 和 Swoole,所有框架通用。QQ群:17916227
Stars: ✭ 330 (-54.36%)
Mutual labels:  coroutine, swoole
Shadowfax
Run Laravel on Swoole.
Stars: ✭ 325 (-55.05%)
Mutual labels:  coroutine, swoole
Aint Queue
🚀 An async-queue library built on top of swoole, flexable multi-consumer, coroutine supported. 基于 Swoole 的一个异步队列库,可弹性伸缩的工作进程池,工作进程协程支持。
Stars: ✭ 143 (-80.22%)
Mutual labels:  coroutine, swoole
Imi
imi 是基于 Swoole 的 PHP 协程开发框架,它支持 Http、Http2、WebSocket、TCP、UDP、MQTT 等主流协议的服务开发,特别适合互联网微服务、即时通讯聊天im、物联网等场景!。QQ群:17916227
Stars: ✭ 680 (-5.95%)
Mutual labels:  coroutine, swoole
Swoole Docker
See: https://github.com/swoole/docker-swoole
Stars: ✭ 132 (-81.74%)
Mutual labels:  coroutine, swoole
Hyperf Skeleton
🛠 A skeleton of Hyperf framework that provided by official team
Stars: ✭ 162 (-77.59%)
Mutual labels:  coroutine, swoole
Archer
基于协程Swoole的Task组件,支持多种模式。轻松实现协程Task的队列、并发、Defer、计时器等 | Swoole coroutine task kit - Swoole Humanization Library
Stars: ✭ 132 (-81.74%)
Mutual labels:  coroutine, swoole
zhamao-framework
协程、高性能、灵活的聊天机器人 & Web 开发框架(炸毛框架)
Stars: ✭ 99 (-86.31%)
Mutual labels:  swoole, coroutine
Ycsocket
基于swoole的socket框架,支持协程版MySQL、Redis连接池,已用于大型RPG游戏服务端
Stars: ✭ 77 (-89.35%)
Mutual labels:  coroutine, swoole
Yii2 Swoole
full solutions making yii2-framework run on swoole with coroutine.
Stars: ✭ 86 (-88.11%)
Mutual labels:  coroutine, swoole
Simps
🚀 A simple, lightweight and high-performance PHP coroutine framework.
Stars: ✭ 318 (-56.02%)
Mutual labels:  coroutine, swoole
Easyswoole
swoole,easyswoole,swoole framework
Stars: ✭ 4,409 (+509.82%)
Mutual labels:  coroutine, swoole

PaySDK

Latest Version Php Version IMI Doc IMI License

介绍

PaySDK 是 PHP 集成支付 SDK ,集成了支付宝、微信支付的支付接口和其它相关接口的操作。

无框架依赖,支持所有框架,支持 Swoole 协程环境。

我们有完善的在线技术文档:http://doc.yurunsoft.com/PaySDK

API 文档:https://apidoc.gitee.com/yurunsoft/PaySDK

同时欢迎各位加入宇润 PHP 全家桶技术支持群:17916227 点击加群,如有问题可以及时解答和修复。

大家在开发中肯定会对接各种各样的支付平台,我个人精力有限,欢迎各位来 Github 提交 PR,一起完善 PaySDK ,让它能够支持更多的支付平台,更加稳定可靠好用。

支持的支付接口

支付宝

  • 即时到账-电脑网站支付(老)
  • 即时到账-手机网站支付(老)
  • 当面付
  • 手机网站支付
  • 电脑网站支付
  • APP支付服务端
  • 小程序支付
  • 单笔转账到支付宝账户
  • 海外支付(电脑网站、手机网站、APP、扫码)
  • 海关报关
  • 其它辅助交易接口(退款、查询等)

微信支付

  • 刷卡支付
  • 公众号支付
  • 扫码支付
  • APP支付
  • H5支付
  • 小程序支付
  • 企业付款到零钱
  • 企业付款到银行卡
  • 海外支付(刷卡、公众号、扫码、APP)
  • 海关报关
  • 其它辅助交易接口(退款、查询等)

安装

在您的composer.json中加入配置:

PHP >= 5.5

{
    "require": {
        "yurunsoft/pay-sdk": "~3.0"
    }
}

PHP >= 5.4

{
    "require": {
        "yurunsoft/pay-sdk": "~2.0"
    }
}

3.x 版本支持 PHP >= 5.5,持续迭代维护中

2.x 版本支持 PHP >= 5.4,支持长期 BUG 维护,保证稳定可用,停止功能性更新

然后执行composer update命令。

代码示例

支付宝即时到账

// SDK实例化,传入公共配置
$pay = new \Yurun\PaySDK\Alipay\SDK($params);

// 支付接口
$request = new \Yurun\PaySDK\Alipay\Params\Pay\Request;
$request->notify_url = ''; // 支付后通知地址(作为支付成功回调,这个可靠)
$request->return_url = ''; // 支付后跳转返回地址
$request->businessParams->seller_id = $GLOBALS['PAY_CONFIG']['appid']; // 卖家支付宝用户号
$request->businessParams->out_trade_no = 'test' . mt_rand(10000000,99999999); // 商户订单号
$request->businessParams->total_fee = 0.01; // 价格
$request->businessParams->subject = '测试商品'; // 商品标题

// 跳转到支付页面
// $pay->redirectExecute($request);

// 获取跳转url
$pay->prepareExecute($request, $url);
var_dump($url);

支付宝手机网站支付

// SDK实例化,传入公共配置
$pay = new \Yurun\PaySDK\AlipayApp\SDK($params);

// 支付接口
$request = new \Yurun\PaySDK\AlipayApp\Wap\Params\Pay\Request;
$request->notify_url = ''; // 支付后通知地址(作为支付成功回调,这个可靠)
$request->return_url = ''; // 支付后跳转返回地址
$request->businessParams->out_trade_no = 'test' . mt_rand(10000000,99999999); // 商户订单号
$request->businessParams->total_amount = 0.01; // 价格
$request->businessParams->subject = '小米手机9黑色陶瓷尊享版'; // 商品标题

// 跳转到支付页面
// $pay->redirectExecute($request);

// 获取跳转url
$pay->prepareExecute($request, $url);
var_dump($url);

微信H5支付

// SDK实例化,传入公共配置
$pay = new \Yurun\PaySDK\Weixin\SDK($params);

// 支付接口
$request = new \Yurun\PaySDK\Weixin\H5\Params\Pay\Request;
$request->body = 'test'; // 商品描述
$request->out_trade_no = 'test' . mt_rand(10000000,99999999); // 订单号
$request->total_fee = 1; // 订单总金额,单位为:分
$request->spbill_create_ip = '127.0.0.1'; // 客户端ip
$request->notify_url = ''; // 异步通知地址

// 调用接口
$result = $pay->execute($request);
if($pay->checkResult())
{
    // 跳转支付界面
    header('Location: ' . $result['mweb_url']);
}
else
{
    var_dump($pay->getErrorCode() . ':' . $pay->getError());
}
exit;

Swoole 协程环境支持

在支付、退款异步通知中,需要赋值 SwooleRequestResponse 对象,或者遵循 PSR-7 标准的对象即可。

主流框架的 RequestResponse 对象,一般都遵循 PSR-7 标准,可以直接使用。

imi 框架中使用

imi 是基于 PHP Swoole 的高性能协程应用开发框架,它支持 HttpApi、WebSocket、TCP、UDP 服务的开发。

在 Swoole 的加持下,相比 php-fpm 请求响应能力,I/O密集型场景处理能力,有着本质上的提升。

imi 框架拥有丰富的功能组件,可以广泛应用于互联网、移动通信、企业软件、云计算、网络游戏、物联网(IOT)、车联网、智能家居等领域。可以使企业 IT 研发团队的效率大大提升,更加专注于开发创新产品。

https://www.imiphp.com/

/**
 * 这是一个在控制器中的动作方法
 * @Action
 */
public function test()
{
    $payNotify = new class extends \Yurun\PaySDK\Weixin\Notify\Pay
    {
        /**
         * 后续执行操作
         * @return void
         */
        protected function __exec()
        {

        }
    };
    $context = RequestContext::getContext();
    // 下面两行很关键
    $payNotify->swooleRequest = $context['request'];
    $payNotify->swooleResponse = $context['response'];

    $sdk->notify($payNotify);

    // 这句话必须填写
    return $payNotify->swooleResponse;
}

其它框架(Swoole 对象)

$payNotify = new class extends \Yurun\PaySDK\Weixin\Notify\Pay
{
    /**
     * 后续执行操作
     * @return void
     */
    protected function __exec()
    {

    }
};
// 下面两行很关键,$request、$response 从 request 中获取
// 或者查阅如何从你使用的框架中获取
$payNotify->swooleRequest = $request;
$payNotify->swooleResponse = $response;

$sdk->notify($payNotify);

其它框架(PSR-7 对象)

$payNotify = new class extends \Yurun\PaySDK\Weixin\Notify\Pay
{
    /**
     * 后续执行操作
     * @return void
     */
    protected function __exec()
    {

    }
};
// 目前主流 Swoole 基本都支持 PSR-7 标准的对象
// 所以可以直接传入,如何获取请查阅对应框架的文档
$payNotify->swooleRequest = $request;
$payNotify->swooleResponse = $response;

$sdk->notify($payNotify);

// 处理完成后需要将 $response 从控制器返回或者赋值给上下文
// 不同框架的操作不同,请自行查阅对应框架的文档
return $payNotify->swooleResponse;

商业服务

服务内容:

  • 问题排查及咨询
  • 代接支付
  • 其它合作

如有需要加QQ:369124067(注明来意)

捐赠

开源不求盈利,多少都是心意,生活不易,随缘随缘……

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].