Code Monkey home page Code Monkey logo

paysdk's Introduction

PaySDK

PaySDK 是 PHP 集成支付 SDK ,集成了支付宝、微信支付的支付接口和其它相关接口的操作。可以轻松嵌入支持 PHP >= 5.3 的任何系统中。

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

同时欢迎各位加入技术支持群:74401592 点击加群,如有问题可以及时解答和修复。

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

有许多朋友表示不敢用这类 SDK ,在这我再声明一下: PaySDK 是基于 MIT 协议开源的,你可以阅读修改所有无压缩无加密的源代码,绝对不会留任何后门。

支持的支付接口

支付宝

  • 即时到账
  • 当面付
  • 手机网站支付
  • 电脑网站支付
  • 单笔转账到支付宝账户
  • 海外支付(电脑网站、手机网站、APP、扫码)
  • 海关报关

微信支付

  • 刷卡支付
  • 公众号支付
  • 扫码支付
  • APP支付
  • H5支付
  • 小程序支付
  • 企业付款到零钱
  • 企业付款到银行卡
  • 海外支付(刷卡、公众号、扫码、APP)
  • 海关报关

安装

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

{
    "require": {
        "yurunsoft/pay-sdk": "1.0.*"
    }
}

然后执行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);

支付宝手机网站支付

// 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);

微信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;

paysdk's People

Contributors

yurunsoft avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.