@@ -2,6 +2,7 @@
namespace app\admin\controller\dispatch;
+use app\admin\model\Message;
use app\common\controller\Backend;
use think\Db;
/**
@@ -121,6 +122,16 @@ class Skillauth extends Backend
if($result === false || (isset($params["status"]) && $params["status"] == 1 && !$res)) {
$this->error(__('审核失败!'));
}
+ if (isset($params['status'])) {
+ $skill = new \app\admin\model\dispatch\Skill();
+ $skillData = $skill->where(['id'=>$row['skill_id']])->find();
+ $skillName = isset($skillData['name']) ? $skillData['name'] : '';
+ if ($params['status'] == 1) {//审核通过
+ Message::addMessage($row["user_id"],'技能认证申请通知','您申请的技能'.$skillName.'认证申请,审核通过。');
+ } elseif ($params['status'] == -1) {//未通过
+ Message::addMessage($row["user_id"],'技能认证申请通知','您申请的技能'.$skillName.'认证申请,审核未通过。');
+ }
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
namespace app\admin\controller\guild;
@@ -74,4 +75,52 @@ class Guild extends Backend
return $this->view->fetch();
+ /**
+ * 编辑
+ */
+ public function edit($ids = null)
+ {
+ $row = $this->model->get($ids);
+ if (!$row) {
+ $this->error(__('No Results were found'));
+ $adminIds = $this->getDataLimitAdminIds();
+ if (is_array($adminIds)) {
+ if (!in_array($row[$this->dataLimitField], $adminIds)) {
+ $this->error(__('You have no permission'));
+ if ($this->request->isPost()) {
+ $params = $this->request->post("row/a");
+ if (!$params) {
+ $this->error(__('Parameter %s can not be empty', ''));
+ $params = $this->preExcludeFields($params);
+ $result = false;
+ try {
+ //是否采用模型验证
+ if ($this->modelValidate) {
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
+ $row->validateFailException(true)->validate($validate);
+ if ($params['status'] == 1) {
+ Message::addMessage($row['user_id'],'家族申请通知','您申请的家族'.$row['name'].'已审核通过');
+ } elseif ($params['status'] == -1) {
+ Message::addMessage($row['user_id'],'家族申请通知','您申请的家族'.$row['name'].'已被拒绝');
+ $result = $row->allowField(true)->save($params);
+ } catch (ValidateException|PDOException|Exception $e) {
+ $this->error($e->getMessage());
+ if ($result == false) {
+ $this->error(__('No rows were updated'));
+ $this->success();
+ $this->view->assign("row", $row);
+ return $this->view->fetch();
@@ -117,7 +117,7 @@ class Anchor extends Backend
\app\common\model\User::update($data, ["id" => $row["user_id"]]);
// +message
$params["status"] == 1 && \app\common\model\Message::addMessage($row["user_id"], "主播申请通知", "恭喜,您的主播申请审核已通过,快去开通直播间吧!");
-
+ $params["status"] == 2 && \app\common\model\Message::addMessage($row["user_id"], "主播申请通知", "您的主播申请已被审核拒绝。");
//是否采用模型验证
if ($this->modelValidate) {
@@ -1805,4 +1805,38 @@ class Money extends Common
$this->error($e->getMessage());
+
+ //提现转账(新版2020-01-01)
+ public function withdrawTransfer() {
+ $info = [
+ 'money' => 0.10,
+ 'alipay_account' => '13651955934'
+ ];
+ $data['out_biz_no'] = getMillisecond() . mt_rand(1, 1000); //商户订单号
+ $data['trans_amount'] = $info['money']; //订单总金额,单位为元,精确到小数点后两位
+ $data['product_code'] = 'TRANS_ACCOUNT_NO_PWD';//业务产品码,收发现金红包固定为:STD_RED_PACKET;单笔无密转账到支付宝账户固定为:TRANS_ACCOUNT_NO_PWD;单笔无密转账到银行卡固定为:TRANS_BANKCARD_NO_PWD
+ $data['biz_scene'] = 'DIRECT_TRANSFER'; //描述特定的业务场景,可传的参数如下:PERSONAL_COLLECTION:C2C现金红包-领红包;DIRECT_TRANSFER:B2C现金红包、单笔无密转账到支付宝/银行卡
+ $data['order_title'] = 'GG语音提现'; //转账业务的标题,用于在支付宝用户的账单里显示
+ $data['payee_info']['identity'] = $info['alipay_account'];//收款方支付宝id或支付宝账户
+ /*if ($info['alipay_type'] == 1) { //支付宝账户
+ $data['payee_info']['identity_type'] = 'ALIPAY_LOGON_ID';
+ //收款支付宝账号真实姓名, 不为空时支付宝会验证
+ $data['payee_info']['name'] = $info['name'];
+ } else { //支付宝id
+ $data['payee_info']['identity_type'] = 'ALIPAY_USER_ID';
+ $data['payee_info']['name'] = '';
+ }*/
+ //支付宝id
+ //转账备注(支持200个英文/100个汉字)。当付款方为企业账户,且转账金额达到(大于等于)50000元,remark不能为空。收款方可见,会展示在收款用户的收支详情中。
+ $data['remark'] = 'GG语音提现';
+ require_once("../extend/AliPay/AliPay.php");
+ $alipay =new \AliPay();
+ $result =$alipay->AliPayWithdraw($data);
+ return $result;
@@ -420,4 +420,11 @@ return [
'app_secret' => '4yku6nam6YK0TGdlEemkmMbBR4catDVU',
'app_code' => '3f4fc2408a0143509e5be5c20eb97c5b',
],
+ //支付宝 rsa公钥 私钥 支付宝公钥
+ 'ali_app_id' => '2021004103620776', //appid
+ 'ali_sign_type' => 'RSA2', //签名
+ 'notify_url' => 'https://ggyuyin.huxiukeji.cn/api/notify/alipaynotify',
+ 'public_key' => 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl0wxorB0arbCOoPzAfGBwF+xZs/J+1ICyusfjBSuPP7+vdKA9Mg6xCQI1uGEQHohBv1IldOQLFKZwiuISY0U9sYJzYLc/cWBihSxTQLAyoY5jA4ZCqJGfujQqk4qqnoMR0MAgL8C9b06NufuroBcfAI+er3epV2+1QZC/h5EgGO/DFJaeptlwn3i9DEeEplyKgPc4vfkku5V45mPK+HuVp9rVEy/5FBHZ3/Y7UMd+axxhXEZLkLuYIXPE97HW6ref4rLtSq5xofUMd2qihgzJWJMB0G4t0FhStCZp3OmFUgvPrqMj5cUz4ZImjgEU0FKn+4jRNDcvCN89j00Nyul5QIDAQAB',
+ 'private_key' => 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCXTDGisHRqtsI6g/MB8YHAX7Fmz8n7UgLK6x+MFK48/v690oD0yDrEJAjW4YRAeiEG/UiV05AsUpnCK4hJjRT2xgnNgtz9xYGKFLFNAsDKhjmMDhkKokZ+6NCqTiqqegxHQwCAvwL1vTo25+6ugFx8Aj56vd6lXb7VBkL+HkSAY78MUlp6m2XCfeL0MR4SmXIqA9zi9+SS7lXjmY8r4e5Wn2tUTL/kUEdnf9jtQx35rHGFcRkuQu5ghc8T3sdbqt5/isu1KrnGh9Qx3aqKGDMlYkwHQbi3QWFK0Jmnc6YVSC8+uoyPlxTPhkiaOARTQUqf7iNE0Ny8I3z2PTQ3K6XlAgMBAAECggEBAJF/BHyflFTLTB1ZpufHiC+n1sI4MNUvGOBrG/tqJ+Ugk3mYZcsAgwL8ZEPAu54F1J0UFil/OrZk+NhxZK7WrcJi0CqCHmMs/FX9cEPO0ffw/IZjSFGhnImO+pvMb9thY01kcadeCUqonsMOZ8oIRug6gDspPGNqs4nIa8RU9ys/RXie09GDcDwPjDpzE0M1pofNu+3TeGuu/nnII5PwCXkGx3rtachFcKxyherHKqF9Y81Xp9VQBXizq9vaBx83b6k1w+rDic/O8t/JW0NskrgUhKAlbOVPLN0AuT4RnXtGoUg+2MoZsNH3b12bzgPYVp5ygIUedwYIZ/bBFPjO4kECgYEA0/6E6CtKz6PAnkcXXTBuC56HS3ox48h82whyN2CojrPbBoWX1hKDnlvlJf0eMymr+BoR4Fe75ujWixO5pbRGGt6MTdCessG5GmT8nu2sz3hMHpJPLyaOuPWQ707jf9nU85P0gEv7Q1UKZKdXxZmsYfyo/X8CyGn6TbwRMiJvvm8CgYEAtrQ6MO1ooEK+y1y1nIclURuvPvQd6SMw5wfXODlejxuFBn+XtpVcYmRvJTQSX2+3qaoKtmnD8nCg4lIj0c6ncxouNPh4Dnqqcyj8nydnVb/GUR41XDkKc6QHGQfdcR1XsNnC/Tb9hULysFNHA4T6YeI1nm4i1+0Jehm0YHkQiusCgYBFgSo0MJV7lHW/rxFC9XDvEE/NeEfJJd+BtLg13dQFzYQfFEfe4P0UO47asK1pGt2OH4YC5uDtaSOGP7ZbVMqzXonjrWWKuCcnNzr4JHbHIuraDyA1FlAu5hxZyaSfM101ayn7sm2z+rrIm3EUkTjKe5swWacg7FYrjGCa7l1yswKBgH12Te+DWDGVJAfqZhxTAeEsra8BW/jY3aAI1lYZr0F+mF7aB4iuEH7QkTJvC57VzL2Js0mIX7KAfTptRYOx8XMtK0XcyjTHL31dS/zOxjswMjNKF0J5OSAoJ2ec6wfeKnWbVDcmJ/n2+0jyJvXXv0iwWjmtT+gPMk7Sj/cfq6h5AoGAM65IF5cC2LpmTyYhdBnxb8CFV4dwEk12LZrCQTJrzCdGsPDGDdb8+8wVvkUjBS90Iy3Loll48ogvxBUuVku50O60URo+sEQMy72fXHFyE/773cRf+8h69zLXakMUbi7h7hgY6G24mbyWQRdUBcrasIZMk4e+WvtYUndOruEWRIs=',
+ 'ali_public_key' => '/addons/epay/certs/alipayCertPublicKey.crt',
];
@@ -0,0 +1,351 @@
+<?php
+/**
+ * 支付宝插件 使用方法请查看同文件夹下的demo
+ * 目前已经支持电脑网站支付,手机APP支付,支付回调校验,用户提现等功能,如需拓展请联系作者
+ * @author Jack_YanTC <627495692@qq.com>
+class AliPay {
+ private $appId;
+ private $rsaPrivateKey;
+ private $signType;
+ private $alipayrsaPublicKey;
+ private $notifyUrl;
+ private $returnUrl;
+ * 初始化参数
+ *
+ * C('ALI_PAY') Api Config中的配置
+ * @param array $options
+ * @param $options ['appId'] 应用ID,在支付宝上获取
+ * @param $options ['rsaPrivateKey'] 应用密钥,与应用公钥一组,公钥填写到支付宝
+ * @param $options ['signType'] 签名方式
+ * @param $options ['alipayrsaPublicKey'] 支付宝公钥,在支付宝上获取
+ * @param $options ['notifyUrl'] 支付宝回调地址
+ * @param $options ['returnUrl'] 用于web支付返回地址
+ public function __construct($options = null) {
+ $this->appId = isset ($options['appId']) ? $options['appId'] : config('ali_app_id');
+ $this->rsaPrivateKey = isset ($options['private_key_path']) ? $options['private_key_path'] : config('private_key');
+ $this->signType = isset ($options['sign_type']) ? $options['sign_type'] : config('ali_sign_type');
+ $this->notifyUrl = isset ($options['notify_url']) ? $options['notify_url'] : config('notify_url');
+ $this->alipayrsaPublicKey = isset ($options['ali_public_key_path']) ? $options['ali_public_key_path'] : config('ali_public_key');
+// $this->returnUrl = isset ($options ['returnUrl']) ? $options ['returnUrl'] : C('ALI_PAY')['returnUrl'];
+ * 支付宝app支付 需要签约 APP支付
+ * @param string $data 业务参数 body subject out_trade_no total_amount
+ * @param string $data['out_trade_no'] 订单号 必填
+ * @param string $data['total_amount'] 订单金额 必填
+ * @param string $data['subject'] 订单标题 必填
+ * @param string $data['body'] 订单详情 可选
+ * @return $response 返回app所需字符串
+ public function AliPayApp($data) {
+ if (empty($this->appId))
+ return false;
+ $aliPayPath = './Plugins/AliPay/alipay-sdk/';
+ require_once($aliPayPath . "aop/AopClient.php");
+ require_once($aliPayPath . 'aop/request/AlipayTradeAppPayRequest.php');
+ $aop = new \AopClient;
+ $aop->gatewayUrl = "https://openapi.alipay.com/gateway.do";
+ $aop->appId = $this->appId;
+ $aop->rsaPrivateKey = $this->rsaPrivateKey;
+ $aop->format = "json";
+ $aop->charset = "UTF-8";
+ $aop->signType = $this->signType;
+ $aop->alipayrsaPublicKey = $this->alipayrsaPublicKey;
+ //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
+ $request = new \AlipayTradeAppPayRequest();
+ //SDK已经封装掉了公共参数,这里只需要传入业务参数
+ $bizcontent = json_encode([
+ 'body' => $data['body'],
+ 'subject' => $data['subject'],
+ 'out_trade_no' => $data['out_trade_no'],//此订单号为商户唯一订单号
+ 'total_amount' => $data['total_amount'],//保留两位小数
+ 'timeout_express' => '30m',
+ 'passback_params' => urlencode($data['pass_back_params']), //区分安卓ios支付
+ 'product_code' => 'QUICK_MSECURITY_PAY'
+ ]);
+ $request->setNotifyUrl($this->notifyUrl);
+ $request->setBizContent($bizcontent);
+ //这里和普通的接口调用不同,使用的是sdkExecute
+ $response = $aop->sdkExecute($request);
+ //htmlspecialchars是为了输出到页面时防止被浏览器将关键参数html转义,实际打印到日志以及http传输不会有这个问题
+ //return htmlspecialchars($response);//就是orderString 可以直接给客户端请求,无需再做处理。
+ //返回app所需字符串
+ return $response;
+ * 支付宝web支付 需要签约 电脑网站支付
+ * @param string $data 业务参数
+ * @return $result 返回form表单,插入到当前网页即跳转到支付宝付款界面
+ public function AliPayWeb($data) {
+ require_once($aliPayPath . 'aop/request/AlipayTradePagePayRequest.php');
+ $aop = new \AopClient();
+ $aop->apiVersion = '1.0';
+ $aop->postCharset = 'UTF-8';
+ $aop->format = 'json';
+ $request = new \AlipayTradePagePayRequest();
+ 'product_code' => 'FAST_INSTANT_TRADE_PAY'
+ $request->setReturnUrl($this->returnUrl);
+ $result = $aop->pageExecute($request);
+ //返回form提交表单
+ * 支付宝MobileWeb支付 需要签约 手机网站支付
+ public function AliPayMobileWeb($data) {
+ require_once($aliPayPath . 'aop/request/AlipayTradeWapPayRequest.php');
+ $request = new \AlipayTradeWapPayRequest ();
+ 'timeout_express' => '90m',
+ 'product_code' => 'QUICK_WAP_WAY'
+ * 支付宝支付回调签名验证
+ * @return bool
+ public function AliPayNotifyCheck() {
+ //此处验签方式必须与下单时的签名方式一致
+ $flag = $aop->rsaCheckV1($_POST, NULL, $this->signType);
+ return $flag;
+ * 支付宝提现转账 需要签约 单笔转账到支付宝账户接口
+ * @param $data['out_biz_no'] 订单号 必填
+ * @param $data['amount'] 提现金额 必填 金额不小于0.1元,单日转出累计额度为100万元,转账给个人支付宝账户,单笔最高5万元;转账给企业支付宝账户,单笔最高10万元。
+ * @param $data['payee_account'] 收款支付宝账号 必填
+ * @param $data['payee_real_name'] 收款支付宝账号真实姓名 最好填上 填上会验证账号是否正确
+ * @param $data['payer_show_name'] 付款方姓名 可选
+ * @param $data['remark'] 转账提现备注 可选
+ public function AliPayWithdrawOld($data) {
+ if ($data['amount']<0.1)
+ require_once($aliPayPath . 'aop/request/AlipayFundTransToaccountTransferRequest.php');
+ $request = new \AlipayFundTransToaccountTransferRequest ();
+ 'out_biz_no' => $data['out_biz_no'],//此订单号为商户唯一订单号
+ 'payee_type' => 'ALIPAY_LOGONID',//默认登录账号,后期可拓展
+ 'payee_account' => $data['payee_account'],
+ 'amount' => $data['amount'],
+ 'payee_real_name' => $data['payee_real_name'],
+ 'payer_show_name' => $data['payer_show_name'],
+ 'remark' => $data['remark'],
+ $result = $aop->execute($request);
+ $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
+ $resultCode = $result->$responseNode->code;
+ if(!empty($resultCode)&&$resultCode == 10000){
+ //echo "成功"; 提现成功
+ return true;
+ } else {
+ //echo "失败";
+ * 支付宝提现转账 需要签约 单笔转账到支付宝账户接口(新版2022-11-21)
+ public function AliPayWithdraw($data) {
+ if ($data['trans_amount'] < 0.1)
+ $aliPayPath = '../extend/AliPay/aop/';
+ require_once $aliPayPath . 'AopClient.php';
+ require_once $aliPayPath . 'AopCertClient.php';
+ require_once $aliPayPath . 'AopCertification.php';
+ require_once $aliPayPath . 'AlipayConfig.php';
+ require_once $aliPayPath . 'request/AlipayFundTransUniTransferRequest.php';
+ $privateKey = $this->rsaPrivateKey;//"<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->";
+ $alipayConfig = new AlipayConfig();
+ $alipayConfig->setPrivateKey($privateKey);
+ $alipayConfig->setServerUrl("https://openapi.alipay.com/gateway.do");
+ $alipayConfig->setAppId($this->appId); //"<-- 请填写您的AppId,例如:2019091767145019 -->"
+ $alipayConfig->setCharset("UTF-8");
+ $alipayConfig->setSignType("RSA2");
+ $alipayConfig->setEncryptKey("");
+ $alipayConfig->setFormat("json");
+ $alipayConfig->setAppCertPath('../extend/AliPay/cert/appCertPublicKey.crt');//"<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->"
+ $alipayConfig->setAlipayPublicCertPath('../extend/AliPay/cert/alipayCertPublicKey.crt');//"<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->"
+ $alipayConfig->setRootCertPath('../extend/AliPay/cert/alipayRootCert.crt');//"<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt -->"
+ $alipayClient = new AopCertClient($alipayConfig);
+ $alipayClient->isCheckAlipayPublicCert = true;
+ $request = new AlipayFundTransUniTransferRequest();
+ $data = json_encode($data);
+ $request->setBizContent($data);
+ $responseResult = $alipayClient->execute($request);
+ $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
+ $responsecode = $responseResult->$responseApiName->code;echo '<pre>';var_dump($responseResult);exit;
+ if(!empty($responsecode)&&$responsecode==10000){
+// echo("调用成功");
+ } else{
+// echo("调用失败");
+ * 支付宝身份认证初始化服务
+ public function userCertifyInitialize($data) {
+ require_once($aliPayPath . 'aop/request/AlipayUserCertifyOpenInitializeRequest.php');
+ $aop->postCharset = "UTF-8";
+ $request = new \AlipayUserCertifyOpenInitializeRequest();
+ $request->setBizContent(json_encode($data));
+ $result = $aop->execute ($request);
+ $result = json_decode(json_encode($result), true);
+ return $result['alipay_user_certify_open_initialize_response'];
+ * 支付宝身份认证开始认证
+ public function userCertify($data) {
+ require_once($aliPayPath . 'aop/request/AlipayUserCertifyOpenCertifyRequest.php');
+ $request = new \AlipayUserCertifyOpenCertifyRequest();
+ $result = $aop->pageExecute ($request, 'GET');
+// $result = json_decode($result, true); p($result);die;
+// return $result['alipay_user_certify_open_certify_response'];
+ * 支付宝身份认证状态查询
+ public function userCertifyState($data) {
+ require_once($aliPayPath . 'aop/request/AlipayUserCertifyOpenQueryRequest.php');
+ $request = new \AlipayUserCertifyOpenQueryRequest();
+ return $result['alipay_user_certify_open_query_response'];
+}
@@ -0,0 +1,110 @@
+ * 支付宝插件Demo
+class Demo {
+ function __construct(){
+ $config['appId']='135';
+ $config['rsaPrivateKey']='135';
+ $config['signType']='135';
+ $config['alipayrsaPublicKey']='135';
+ $this -> config = $config;
+ public function index() {
+ $data['body']='订单详情';
+ $data['subject']='订单';
+ $data['out_trade_no']='201705201314';
+ $data['total_amount']='0.01';
+ require_once("./Plugins/AliPay/AliPay.php");
+ //可传入$options自己的appid
+ //$alipay =new \AliPay($this -> config);
+ //配置到config的话,不许传递参数
+ $result['app'] =$alipay->AliPayApp($data);
+ $result['web'] =$alipay->AliPayWeb($data);
+ $result['check']=$alipay->AliPayNotifyCheck();
+ p($result['web']);
+ //jsonReturn(0, 1, $result);
+ //app支付 示例
+ public function appPay() {
+ require_once("Plugins/AliPay/AliPay.php");
+ $result =$alipay->AliPayApp($data);
+ //web支付 示例
+ public function webPay() {
+ $result =$alipay->AliPayWeb($data);
+ //移动web支付 示例
+ public function mobileWebPay() {
+ $result =$alipay->AliPayMobileWeb($data);
+ //支付回调地址 示例
+ public function alipayNotify() {
+ //验证是否是支付宝发送
+ $flag=$alipay->AliPayNotifyCheck();
+ if ($flag) {
+ if ($_POST['trade_status'] == 'TRADE_FINISHED' || $_POST['trade_status'] == 'TRADE_SUCCESS') {
+ $out_trade_no = trim($_POST['out_trade_no']); //商户订单号
+ //成功后的业务逻辑处理
+ $result = D('Common/Order')->notify($out_trade_no);
+ if ($result) {
+ echo "success"; //告诉支付宝支付成功
+ die;
+ echo "fail"; //验证失败
+ //提现转账 示例
+ public function withdraw() {
+ $data['out_biz_no']='201705201314';//订单号
+ $data['payee_account'] ='627495692@qq.com';//收款支付宝账号
+ $data['payee_real_name'] ='颜廷超';//收款支付宝账号真实姓名
+ $data['amount'] ='0.01';//金额
+ $data['payer_show_name']='科技转账';
+ $data['remark'] = '备注';
@@ -0,0 +1,231 @@
+ * 多媒体文件客户端
+ * @author yikai.hu
+ * @version $Id: AlipayMobilePublicMultiMediaClient.php, v 0.1 Aug 15, 2014 10:19:01 AM yikai.hu Exp $
+//namespace alipay\api ;
+include("AlipayMobilePublicMultiMediaExecute.php");
+class AlipayMobilePublicMultiMediaClient{
+ private $DEFAULT_CHARSET = 'UTF-8';
+ private $METHOD_POST = "POST";
+ private $METHOD_GET = "GET";
+ private $SIGN = 'sign'; //get name
+ private $timeout = 10 ;// 超时时间
+ private $serverUrl;
+ private $privateKey;
+ private $prodCode;
+ private $format = 'json'; //todo
+ private $sign_type = 'RSA'; //todo
+ private $charset;
+ private $apiVersion = "1.0";
+ private $apiMethodName = "alipay.mobile.public.multimedia.download";
+ private $media_id = "L21pZnMvVDFQV3hYWGJKWFhYYUNucHJYP3Q9YW13ZiZ4c2lnPTU0MzRhYjg1ZTZjNWJmZTMxZGJiNjIzNDdjMzFkNzkw575";
+ //此处写死的,实际开发中,请传入
+ private $connectTimeout = 3000;
+ private $readTimeout = 15000;
+ function __construct($serverUrl = '', $appId = '', $partner_private_key = '', $format = '', $charset = 'GBK'){
+ $this -> serverUrl = $serverUrl;
+ $this -> appId = $appId;
+ $this -> privateKey = $partner_private_key;
+ $this -> format = $format;
+ $this -> charset = $charset;
+ * getContents 获取网址内容
+ * @param $request
+ * @return text | bin
+ public function getContents(){
+ //自己的服务器如果没有 curl,可用:fsockopen() 等
+ //1:
+ //2: 私钥格式
+ $datas = array(
+ "app_id" => $this -> appId,
+ "method" => $this -> METHOD_POST,
+ "sign_type" => $this -> sign_type,
+ "version" => $this -> apiVersion,
+ "timestamp" => date('Y-m-d H:i:s') ,//yyyy-MM-dd HH:mm:ss
+ "biz_content" => '{"mediaId":"'. $this -> media_id .'"}',
+ "charset" => $this -> charset
+ );
+ //要提交的数据
+ $data_sign = $this -> buildGetUrl( $datas );
+ $post_data = $data_sign;
+ //初始化 curl
+ $ch = curl_init();
+ //设置目标服务器
+ curl_setopt($ch, CURLOPT_URL, $this -> serverUrl );
+ curl_setopt($ch, CURLOPT_HEADER, TRUE);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ //超时时间
+ curl_setopt($ch, CURLOPT_TIMEOUT, $this-> timeout);
+ if( $this-> METHOD_POST == 'POST'){
+ // post数据
+ curl_setopt($ch, CURLOPT_POST, 1);
+ // post的变量
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
+ $output = curl_exec($ch);
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close($ch);
+ echo $output;
+ //分离头部
+ //list($header, $body) = explode("\r\n\r\n", $output, 2);
+ $datas = explode("\r\n\r\n", $output, 2);
+ $header = $datas[0];
+ if( $httpCode == '200'){
+ $body = $datas[1];
+ }else{
+ $body = '';
+ return $this -> execute( $header, $body, $httpCode );
+ public function execute( $header = '', $body = '', $httpCode = '' ){
+ $exe = new AlipayMobilePublicMultiMediaExecute( $header, $body, $httpCode );
+ return $exe;
+ public function buildGetUrl( $query = array() ){
+ if( ! is_array( $query ) ){
+ //exit;
+ //排序参数,
+ $data = $this -> buildQuery( $query );
+ // 私钥密码
+ $passphrase = '';
+ $key_width = 64;
+ //私钥
+ $privateKey = $this -> privateKey;
+ $p_key = array();
+ //如果私钥是 1行
+ if( ! stripos( $privateKey, "\n" ) ){
+ $i = 0;
+ while( $key_str = substr( $privateKey , $i * $key_width , $key_width) ){
+ $p_key[] = $key_str;
+ $i ++ ;
+ //echo '一行?';
+ $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" . implode("\n", $p_key) ;
+ $privateKey = $privateKey ."\n-----END RSA PRIVATE KEY-----";
+// echo "\n\n私钥:\n";
+// echo( $privateKey );
+// echo "\n\n\n";
+ $private_id = openssl_pkey_get_private( $privateKey , $passphrase);
+ // 签名
+ $signature = '';
+ if("RSA2"==$this->sign_type){
+ openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA256 );
+ openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA1 );
+ openssl_free_key( $private_id );
+ //加密后的内容通常含有特殊字符,需要编码转换下
+ $signature = base64_encode($signature);
+ $signature = urlencode( $signature );
+ //$signature = 'XjUN6YM1Mc9HXebKMv7GTLy7gmyhktyOgKk2/Jf+cz4DtP6udkzTdpkjW2j/Z4ZSD7xD6CNYI1Spz4yS93HPT0a5X9LgFWYY8SaADqe+ArXg+FBSiTwUz49SE//Xd9+LEiIRsSFkbpkuiGoO6mqJmB7vXjlD5lx6qCM3nb41wb8=';
+ $out = $data .'&'. $this -> SIGN .'='. $signature;
+// echo "\n\n 加密后:\n";
+// echo( $out );
+ return $out ;
+ /*
+ * 查询参数排序 a-z
+ * */
+ public function buildQuery( $query ){
+ if ( !$query ) {
+ return null;
+//将要 参数 排序
+ ksort( $query );
+ //重新组装参数
+ $params = array();
+ foreach($query as $key => $value){
+ $params[] = $key .'='. $value ;
+ $data = implode('&', $params);
+ return $data;
@@ -0,0 +1,108 @@
+ * @author yuanwai.wang
+ * @version $Id: AlipayMobilePublicMultiMediaExecute.php, v 0.1 Aug 15, 2014 10:19:01 AM yuanwai.wang Exp $
+class AlipayMobilePublicMultiMediaExecute{
+ private $code = 200 ;
+ private $msg = '';
+ private $body = '';
+ private $params = '';
+ private $fileSuffix = array(
+ "image/jpeg" => 'jpg', //+
+ "text/plain" => 'text'
+ * @$header : 头部
+ function __construct( $header, $body, $httpCode ){
+ $this -> code = $httpCode;
+ $this -> msg = '';
+ $this -> params = $header ;
+ $this -> body = $body;
+ public function getCode(){
+ return $this -> code ;
+ public function getMsg(){
+ return $this -> msg ;
+ public function getType(){
+ $subject = $this -> params ;
+ $pattern = '/Content\-Type:([^;]+)/';
+ preg_match($pattern, $subject, $matches);
+ if( $matches ){
+ $type = $matches[1];
+ $type = 'application/download';
+ return str_replace( ' ', '', $type );
+ public function getContentLength(){
+ $pattern = '/Content-Length:\s*([^\n]+)/';
+ return (int)( isset($matches[1] ) ? $matches[1] : '' );
+ public function getFileSuffix( $fileType ){
+ $type = isset( $this -> fileSuffix[ $fileType ] ) ? $this -> fileSuffix[ $fileType ] : 'text/plain' ;
+ if( !$type ){
+ $type = 'json';
+ return $type;
+ public function getBody(){
+ //header('Content-type: image/jpeg');
+ return $this -> body ;
+ * 获取参数
+ public function getParams(){
+ return $this -> params ;
@@ -0,0 +1,1214 @@
+require_once 'AopEncrypt.php';
+class AopClient {
+ //应用ID
+ public $appId;
+ //私钥文件路径
+ public $rsaPrivateKeyFilePath;
+ //私钥值
+ public $rsaPrivateKey;
+ //网关
+ public $gatewayUrl = "https://openapi.alipay.com/gateway.do";
+ //返回数据格式
+ public $format = "json";
+ //api版本
+ public $apiVersion = "1.0";
+ // 表单提交字符集编码
+ public $postCharset = "UTF-8";
+ //使用文件读取文件格式,请只传递该值
+ public $alipayPublicKey = null;
+ //使用读取字符串格式,请只传递该值
+ public $alipayrsaPublicKey;
+ public $debugInfo = false;
+ private $fileCharset = "UTF-8";
+ private $RESPONSE_SUFFIX = "_response";
+ private $ERROR_RESPONSE = "error_response";
+ private $SIGN_NODE_NAME = "sign";
+ //加密XML节点名称
+ private $ENCRYPT_XML_NODE_NAME = "response_encrypted";
+ private $needEncrypt = false;
+ //签名类型
+ public $signType = "RSA";
+ //加密密钥和类型
+ public $encryptKey;
+ public $encryptType = "AES";
+ protected $alipaySdkVersion = "alipay-sdk-php-20180705";
+ public function generateSign($params, $signType = "RSA") {
+ return $this->sign($this->getSignContent($params), $signType);
+ public function rsaSign($params, $signType = "RSA") {
+ public function getSignContent($params) {
+ ksort($params);
+ $stringToBeSigned = "";
+ foreach ($params as $k => $v) {
+ if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) {
+ // 转换成目标字符集
+ $v = $this->characet($v, $this->postCharset);
+ if ($i == 0) {
+ $stringToBeSigned .= "$k" . "=" . "$v";
+ $stringToBeSigned .= "&" . "$k" . "=" . "$v";
+ $i++;
+ unset ($k, $v);
+ return $stringToBeSigned;
+ //此方法对value做urlencode
+ public function getSignContentUrlencode($params) {
+ $stringToBeSigned .= "$k" . "=" . urlencode($v);
+ $stringToBeSigned .= "&" . "$k" . "=" . urlencode($v);
+ protected function sign($data, $signType = "RSA") {
+ if ($this->checkEmpty($this->rsaPrivateKeyFilePath)) {
+ $priKey = $this->rsaPrivateKey;
+ $res = "-----BEGIN RSA PRIVATE KEY-----\n" .
+ wordwrap($priKey, 64, "\n", true) .
+ "\n-----END RSA PRIVATE KEY-----";
+ $priKey = file_get_contents($this->rsaPrivateKeyFilePath);
+ $res = openssl_get_privatekey($priKey);
+ ($res) or die('您使用的私钥格式错误,请检查RSA私钥配置');
+ if ("RSA2" == $signType) {
+ openssl_sign($data, $sign, $res, OPENSSL_ALGO_SHA256);
+ openssl_sign($data, $sign, $res);
+ if (!$this->checkEmpty($this->rsaPrivateKeyFilePath)) {
+ openssl_free_key($res);
+ $sign = base64_encode($sign);
+ return $sign;
+ * RSA单独签名方法,未做字符串处理,字符串处理见getSignContent()
+ * @param $data 待签名字符串
+ * @param $privatekey 商户私钥,根据keyfromfile来判断是读取字符串还是读取文件,false:填写私钥字符串去回车和空格 true:填写私钥文件路径
+ * @param $signType 签名方式,RSA:SHA1 RSA2:SHA256
+ * @param $keyfromfile 私钥获取方式,读取字符串还是读文件
+ * @return string
+ * @author mengyu.wh
+ public function alonersaSign($data, $privatekey, $signType = "RSA", $keyfromfile = false) {
+ if (!$keyfromfile) {
+ $priKey = $privatekey;
+ $priKey = file_get_contents($privatekey);
+ if ($keyfromfile) {
+ protected function curl($url, $postFields = null) {
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_FAILONERROR, false);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ $postBodyString = "";
+ $encodeArray = Array();
+ $postMultipart = false;
+ if (is_array($postFields) && 0 < count($postFields)) {
+ foreach ($postFields as $k => $v) {
+ if ("@" != substr($v, 0, 1)) //判断是不是文件上传
+ $postBodyString .= "$k=" . urlencode($this->characet($v, $this->postCharset)) . "&";
+ $encodeArray[$k] = $this->characet($v, $this->postCharset);
+ } else //文件上传用multipart/form-data,否则用www-form-urlencoded
+ $postMultipart = true;
+ $encodeArray[$k] = new \CURLFile(substr($v, 1));
+ curl_setopt($ch, CURLOPT_POST, true);
+ if ($postMultipart) {
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $encodeArray);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString, 0, -1));
+ $headers = array('content-type: multipart/form-data;charset=' . $this->postCharset . ';boundary=' . $this->getMillisecond());
+ $headers = array('content-type: application/x-www-form-urlencoded;charset=' . $this->postCharset);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ $reponse = curl_exec($ch);
+ if (curl_errno($ch)) {
+ throw new Exception(curl_error($ch), 0);
+ $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ if (200 !== $httpStatusCode) {
+ throw new Exception($reponse, $httpStatusCode);
+ return $reponse;
+ protected function getMillisecond() {
+ list($s1, $s2) = explode(' ', microtime());
+ return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
+ protected function logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt) {
+ $localIp = isset ($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : "CLI";
+ $logger = new LtLogger;
+ $logger->conf["log_file"] = rtrim(AOP_SDK_WORK_DIR, '\\/') . '/' . "logs/aop_comm_err_" . $this->appId . "_" . date("Y-m-d") . ".log";
+ $logger->conf["separator"] = "^_^";
+ $logData = array(
+ date("Y-m-d H:i:s"),
+ $apiName,
+ $this->appId,
+ $localIp,
+ PHP_OS,
+ $this->alipaySdkVersion,
+ $requestUrl,
+ $errorCode,
+ str_replace("\n", "", $responseTxt)
+ $logger->log($logData);
+ * 生成用于调用收银台SDK的字符串
+ * @param $request SDK接口的请求参数对象
+ * @author guofa.tgf
+ public function sdkExecute($request) {
+ $this->setupCharsets($request);
+ $params['app_id'] = $this->appId;
+ $params['method'] = $request->getApiMethodName();
+ $params['format'] = $this->format;
+ $params['sign_type'] = $this->signType;
+ $params['timestamp'] = date("Y-m-d H:i:s");
+ $params['alipay_sdk'] = $this->alipaySdkVersion;
+ $params['charset'] = $this->postCharset;
+ $version = $request->getApiVersion();
+ $params['version'] = $this->checkEmpty($version) ? $this->apiVersion : $version;
+ if ($notify_url = $request->getNotifyUrl()) {
+ $params['notify_url'] = $notify_url;
+ $dict = $request->getApiParas();
+ $params['biz_content'] = $dict['biz_content'];
+ $params['sign'] = $this->generateSign($params, $this->signType);
+ foreach ($params as &$value) {
+ $value = $this->characet($value, $params['charset']);
+ return http_build_query($params);
+ 页面提交执行方法
+ @param:跳转类接口的request; $httpmethod 提交方式。两个值可选:post、get
+ @return:构建好的、签名后的最终跳转URL(GET)或String形式的form(POST)
+ auther:笙默
+ public function pageExecute($request, $httpmethod = "POST") {
+ if (strcasecmp($this->fileCharset, $this->postCharset)) {
+ // writeLog("本地文件字符集编码与表单提交编码不一致,请务必设置成一样,属性名分别为postCharset!");
+ throw new Exception("文件编码:[" . $this->fileCharset . "] 与表单提交编码:[" . $this->postCharset . "]两者不一致!");
+ $iv = null;
+ if (!$this->checkEmpty($request->getApiVersion())) {
+ $iv = $request->getApiVersion();
+ $iv = $this->apiVersion;
+ //组装系统参数
+ $sysParams["app_id"] = $this->appId;
+ $sysParams["version"] = $iv;
+ $sysParams["format"] = $this->format;
+ $sysParams["sign_type"] = $this->signType;
+ $sysParams["method"] = $request->getApiMethodName();
+ $sysParams["timestamp"] = date("Y-m-d H:i:s");
+ $sysParams["alipay_sdk"] = $this->alipaySdkVersion;
+ $sysParams["terminal_type"] = $request->getTerminalType();
+ $sysParams["terminal_info"] = $request->getTerminalInfo();
+ $sysParams["prod_code"] = $request->getProdCode();
+ $sysParams["notify_url"] = $request->getNotifyUrl();
+ $sysParams["return_url"] = $request->getReturnUrl();
+ $sysParams["charset"] = $this->postCharset;
+ //获取业务参数
+ $apiParams = $request->getApiParas();
+ if (method_exists($request, "getNeedEncrypt") && $request->getNeedEncrypt()) {
+ $sysParams["encrypt_type"] = $this->encryptType;
+ if ($this->checkEmpty($apiParams['biz_content'])) {
+ throw new Exception(" api request Fail! The reason : encrypt request is not supperted!");
+ if ($this->checkEmpty($this->encryptKey) || $this->checkEmpty($this->encryptType)) {
+ throw new Exception(" encryptType and encryptKey must not null! ");
+ if ("AES" != $this->encryptType) {
+ throw new Exception("加密类型只支持AES");
+ // 执行加密
+ $enCryptContent = encrypt($apiParams['biz_content'], $this->encryptKey);
+ $apiParams['biz_content'] = $enCryptContent;
+ //print_r($apiParams);
+ $totalParams = array_merge($apiParams, $sysParams);
+ //待签名字符串
+ $preSignStr = $this->getSignContent($totalParams);
+ //签名
+ $totalParams["sign"] = $this->generateSign($totalParams, $this->signType);
+ if ("GET" == strtoupper($httpmethod)) {
+ //value做urlencode
+ $preString = $this->getSignContentUrlencode($totalParams);
+ //拼接GET请求串
+ $requestUrl = $this->gatewayUrl . "?" . $preString;
+ return $requestUrl;
+ //拼接表单字符串
+ return $this->buildRequestForm($totalParams);
+ * 建立请求,以表单HTML形式构造(默认)
+ * @param $para_temp 请求参数数组
+ * @return 提交表单HTML文本
+ protected function buildRequestForm($para_temp) {
+ $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='" . $this->gatewayUrl . "?charset=" . trim($this->postCharset) . "' method='POST'>";
+ while (list ($key, $val) = each($para_temp)) {
+ if (false === $this->checkEmpty($val)) {
+ //$val = $this->characet($val, $this->postCharset);
+ $val = str_replace("'", "'", $val);
+ //$val = str_replace("\"",""",$val);
+ $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>";
+ //submit按钮控件请不要含有name属性
+ $sHtml = $sHtml . "<input type='submit' value='ok' style='display:none;''></form>";
+ $sHtml = $sHtml . "<script>document.forms['alipaysubmit'].submit();</script>";
+ return $sHtml;
+ public function execute($request, $authToken = null, $appInfoAuthtoken = null) {
+ // // 如果两者编码不一致,会出现签名验签或者乱码
+ $sysParams["auth_token"] = $authToken;
+ $sysParams["app_auth_token"] = $appInfoAuthtoken;
+ $sysParams["sign"] = $this->generateSign(array_merge($apiParams, $sysParams), $this->signType);
+ //系统参数放入GET请求串
+ $requestUrl = $this->gatewayUrl . "?";
+ foreach ($sysParams as $sysParamKey => $sysParamValue) {
+ $requestUrl .= "$sysParamKey=" . urlencode($this->characet($sysParamValue, $this->postCharset)) . "&";
+ $requestUrl = substr($requestUrl, 0, -1);
+ //发起HTTP请求
+ $resp = $this->curl($requestUrl, $apiParams);
+ } catch (Exception $e) {
+ $this->logCommunicationError($sysParams["method"], $requestUrl, "HTTP_ERROR_" . $e->getCode(), $e->getMessage());
+ //解析AOP返回结果
+ $respWellFormed = false;
+ // 将返回结果转换本地文件编码
+ $r = iconv($this->postCharset, $this->fileCharset . "//IGNORE", $resp);
+ $signData = null;
+ if ("json" == $this->format) {
+ $respObject = json_decode($r);
+ if (null !== $respObject) {
+ $respWellFormed = true;
+ $signData = $this->parserJSONSignData($request, $resp, $respObject);
+ } else if ("xml" == $this->format) {
+ $disableLibxmlEntityLoader = libxml_disable_entity_loader(true);
+ $respObject = @ simplexml_load_string($resp);
+ if (false !== $respObject) {
+ $signData = $this->parserXMLSignData($request, $resp);
+ libxml_disable_entity_loader($disableLibxmlEntityLoader);
+ //返回的HTTP文本不是标准JSON或者XML,记下错误日志
+ if (false === $respWellFormed) {
+ $this->logCommunicationError($sysParams["method"], $requestUrl, "HTTP_RESPONSE_NOT_WELL_FORMED", $resp);
+ // 验签
+ $this->checkResponseSign($request, $signData, $resp, $respObject);
+ // 解密
+ $resp = $this->encryptJSONSignSource($request, $resp);
+ $resp = $this->encryptXMLSignSource($request, $resp);
+ $respObject = @ simplexml_load_string($r);
+ return $respObject;
+ * 转换字符集编码
+ * @param $data
+ * @param $targetCharset
+ function characet($data, $targetCharset) {
+ if (!empty($data)) {
+ $fileType = $this->fileCharset;
+ if (strcasecmp($fileType, $targetCharset) != 0) {
+ $data = mb_convert_encoding($data, $targetCharset, $fileType);
+ // $data = iconv($fileType, $targetCharset.'//IGNORE', $data);
+ public function exec($paramsArray) {
+ if (!isset ($paramsArray["method"])) {
+ trigger_error("No api name passed");
+ $inflector = new LtInflector;
+ $inflector->conf["separator"] = ".";
+ $requestClassName = ucfirst($inflector->camelize(substr($paramsArray["method"], 7))) . "Request";
+ if (!class_exists($requestClassName)) {
+ trigger_error("No such api: " . $paramsArray["method"]);
+ $session = isset ($paramsArray["session"]) ? $paramsArray["session"] : null;
+ $req = new $requestClassName;
+ foreach ($paramsArray as $paraKey => $paraValue) {
+ $inflector->conf["separator"] = "_";
+ $setterMethodName = $inflector->camelize($paraKey);
+ $setterMethodName = "set" . $inflector->camelize($setterMethodName);
+ if (method_exists($req, $setterMethodName)) {
+ $req->$setterMethodName ($paraValue);
+ return $this->execute($req, $session);
+ * 校验$value是否非空
+ * if not set ,return true;
+ * if is null , return true;
+ **/
+ protected function checkEmpty($value) {
+ if (!isset($value))
+ if ($value === null)
+ if (trim($value) === "")
+ /** rsaCheckV1 & rsaCheckV2
+ * 验证签名
+ * 在使用本方法前,必须初始化AopClient且传入公钥参数。
+ * 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。
+ public function rsaCheckV1($params, $rsaPublicKeyFilePath, $signType = 'RSA') {
+ $sign = $params['sign'];
+ $params['sign_type'] = null;
+ $params['sign'] = null;
+ return $this->verify($this->getSignContent($params), $sign, $rsaPublicKeyFilePath, $signType);
+ public function rsaCheckV2($params, $rsaPublicKeyFilePath, $signType = 'RSA') {
+ function verify($data, $sign, $rsaPublicKeyFilePath, $signType = 'RSA') {
+ if ($this->checkEmpty($this->alipayPublicKey)) {
+ $pubKey = $this->alipayrsaPublicKey;
+ $res = "-----BEGIN PUBLIC KEY-----\n" .
+ wordwrap($pubKey, 64, "\n", true) .
+ "\n-----END PUBLIC KEY-----";
+ //读取公钥文件
+ $pubKey = file_get_contents($rsaPublicKeyFilePath);
+ //转换为openssl格式密钥
+ $res = openssl_get_publickey($pubKey);
+ ($res) or die('支付宝RSA公钥错误。请检查公钥文件格式是否正确');
+ //调用openssl内置方法验签,返回bool值
+ $result = FALSE;
+ $result = (openssl_verify($data, base64_decode($sign), $res, OPENSSL_ALGO_SHA256) === 1);
+ $result = (openssl_verify($data, base64_decode($sign), $res) === 1);
+ if (!$this->checkEmpty($this->alipayPublicKey)) {
+ //释放资源
+ * 在使用本方法前,必须初始化AopClient且传入公私钥参数。
+ public function checkSignAndDecrypt($params, $rsaPublicKeyPem, $rsaPrivateKeyPem, $isCheckSign, $isDecrypt, $signType = 'RSA') {
+ $charset = $params['charset'];
+ $bizContent = $params['biz_content'];
+ if ($isCheckSign) {
+ if (!$this->rsaCheckV2($params, $rsaPublicKeyPem, $signType)) {
+ echo "<br/>checkSign failure<br/>";
+ exit;
+ if ($isDecrypt) {
+ return $this->rsaDecrypt($bizContent, $rsaPrivateKeyPem, $charset);
+ return $bizContent;
+ public function encryptAndSign($bizContent, $rsaPublicKeyPem, $rsaPrivateKeyPem, $charset, $isEncrypt, $isSign, $signType = 'RSA') {
+ // 加密,并签名
+ if ($isEncrypt && $isSign) {
+ $encrypted = $this->rsaEncrypt($bizContent, $rsaPublicKeyPem, $charset);
+ $sign = $this->sign($encrypted, $signType);
+ $response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$encrypted</response><encryption_type>RSA</encryption_type><sign>$sign</sign><sign_type>$signType</sign_type></alipay>";
+ // 加密,不签名
+ if ($isEncrypt && (!$isSign)) {
+ $response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$encrypted</response><encryption_type>$signType</encryption_type></alipay>";
+ // 不加密,但签名
+ if ((!$isEncrypt) && $isSign) {
+ $sign = $this->sign($bizContent, $signType);
+ $response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$bizContent</response><sign>$sign</sign><sign_type>$signType</sign_type></alipay>";
+ // 不加密,不签名
+ $response = "<?xml version=\"1.0\" encoding=\"$charset\"?>$bizContent";
+ public function rsaEncrypt($data, $rsaPublicKeyPem, $charset) {
+ //读取字符串
+ $blocks = $this->splitCN($data, 0, 30, $charset);
+ $chrtext = null;
+ $encodes = array();
+ foreach ($blocks as $n => $block) {
+ if (!openssl_public_encrypt($block, $chrtext , $res)) {
+ echo "<br/>" . openssl_error_string() . "<br/>";
+ $encodes[] = $chrtext ;
+ $chrtext = implode(",", $encodes);
+ return base64_encode($chrtext);
+ public function rsaDecrypt($data, $rsaPrivateKeyPem, $charset) {
+ //读字符串
+ $decodes = explode(',', $data);
+ $strnull = "";
+ $dcyCont = "";
+ foreach ($decodes as $n => $decode) {
+ if (!openssl_private_decrypt($decode, $dcyCont, $res)) {
+ $strnull .= $dcyCont;
+ return $strnull;
+ function splitCN($cont, $n = 0, $subnum, $charset) {
+ //$len = strlen($cont) / 3;
+ $arrr = array();
+ for ($i = $n; $i < strlen($cont); $i += $subnum) {
+ $res = $this->subCNchar($cont, $i, $subnum, $charset);
+ if (!empty ($res)) {
+ $arrr[] = $res;
+ return $arrr;
+ function subCNchar($str, $start = 0, $length, $charset = "gbk") {
+ if (strlen($str) <= $length) {
+ return $str;
+ $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";
+ $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/";
+ $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/";
+ $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/";
+ preg_match_all($re[$charset], $str, $match);
+ $slice = join("", array_slice($match[0], $start, $length));
+ return $slice;
+ function parserResponseSubCode($request, $responseContent, $respObject, $format) {
+ if ("json" == $format) {
+ $apiName = $request->getApiMethodName();
+ $rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;
+ $errorNodeName = $this->ERROR_RESPONSE;
+ $rootIndex = strpos($responseContent, $rootNodeName);
+ $errorIndex = strpos($responseContent, $errorNodeName);
+ if ($rootIndex > 0) {
+ // 内部节点对象
+ $rInnerObject = $respObject->$rootNodeName;
+ } elseif ($errorIndex > 0) {
+ $rInnerObject = $respObject->$errorNodeName;
+ // 存在属性则返回对应值
+ if (isset($rInnerObject->sub_code)) {
+ return $rInnerObject->sub_code;
+ } elseif ("xml" == $format) {
+ // xml格式sub_code在同一层级
+ return $respObject->sub_code;
+ function parserJSONSignData($request, $responseContent, $responseJSON) {
+ $aliPayPath = '../extend/AliPay/alipay-sdk/';
+ require_once($aliPayPath . "aop/SignData.php");
+ $signData = new SignData();
+ $signData->sign = $this->parserJSONSign($responseJSON);
+ $signData->signSourceData = $this->parserJSONSignSource($request, $responseContent);
+ return $signData;
+ function parserJSONSignSource($request, $responseContent) {
+ $errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);
+ return $this->parserJSONSource($responseContent, $rootNodeName, $rootIndex);
+ } else if ($errorIndex > 0) {
+ return $this->parserJSONSource($responseContent, $this->ERROR_RESPONSE, $errorIndex);
+ function parserJSONSource($responseContent, $nodeName, $nodeIndex) {
+ $signDataStartIndex = $nodeIndex + strlen($nodeName) + 2;
+ $signIndex = strrpos($responseContent, "\"" . $this->SIGN_NODE_NAME . "\"");
+ // 签名前-逗号
+ $signDataEndIndex = $signIndex - 1;
+ $indexLen = $signDataEndIndex - $signDataStartIndex;
+ if ($indexLen < 0) {
+ return substr($responseContent, $signDataStartIndex, $indexLen);
+ function parserJSONSign($responseJSon) {
+ return $responseJSon->sign;
+ function parserXMLSignData($request, $responseContent) {
+ $signData->sign = $this->parserXMLSign($responseContent);
+ $signData->signSourceData = $this->parserXMLSignSource($request, $responseContent);
+ function parserXMLSignSource($request, $responseContent) {
+ // $this->echoDebug("<br/>rootNodeName:" . $rootNodeName);
+ // $this->echoDebug("<br/> responseContent:<xmp>" . $responseContent . "</xmp>");
+ return $this->parserXMLSource($responseContent, $rootNodeName, $rootIndex);
+ return $this->parserXMLSource($responseContent, $this->ERROR_RESPONSE, $errorIndex);
+ function parserXMLSource($responseContent, $nodeName, $nodeIndex) {
+ $signDataStartIndex = $nodeIndex + strlen($nodeName) + 1;
+ $signIndex = strrpos($responseContent, "<" . $this->SIGN_NODE_NAME . ">");
+ $indexLen = $signDataEndIndex - $signDataStartIndex + 1;
+ function parserXMLSign($responseContent) {
+ $signNodeName = "<" . $this->SIGN_NODE_NAME . ">";
+ $signEndNodeName = "</" . $this->SIGN_NODE_NAME . ">";
+ $indexOfSignNode = strpos($responseContent, $signNodeName);
+ $indexOfSignEndNode = strpos($responseContent, $signEndNodeName);
+ if ($indexOfSignNode < 0 || $indexOfSignEndNode < 0) {
+ $nodeIndex = ($indexOfSignNode + strlen($signNodeName));
+ $indexLen = $indexOfSignEndNode - $nodeIndex;
+ return substr($responseContent, $nodeIndex, $indexLen);
+ * 验签
+ * @param $signData
+ * @param $resp
+ * @param $respObject
+ * @throws Exception
+ public function checkResponseSign($request, $signData, $resp, $respObject) {
+ if (!$this->checkEmpty($this->alipayPublicKey) || !$this->checkEmpty($this->alipayrsaPublicKey)) {
+ if ($signData == null || $this->checkEmpty($signData->sign) || $this->checkEmpty($signData->signSourceData)) {
+ throw new Exception(" check sign Fail! The reason : signData is Empty");
+ // 获取结果sub_code
+ $responseSubCode = $this->parserResponseSubCode($request, $resp, $respObject, $this->format);
+ if (!$this->checkEmpty($responseSubCode) || ($this->checkEmpty($responseSubCode) && !$this->checkEmpty($signData->sign))) {
+ $checkResult = $this->verify($signData->signSourceData, $signData->sign, $this->alipayPublicKey, $this->signType);
+ if (!$checkResult) {
+ if (strpos($signData->signSourceData, "\\/") > 0) {
+ $signData->signSourceData = str_replace("\\/", "/", $signData->signSourceData);
+ throw new Exception("check sign Fail! [sign=" . $signData->sign . ", signSourceData=" . $signData->signSourceData . "]");
+ private function setupCharsets($request) {
+ if ($this->checkEmpty($this->postCharset)) {
+ $this->postCharset = 'UTF-8';
+ $str = preg_match('/[\x80-\xff]/', $this->appId) ? $this->appId : print_r($request, true);
+ $this->fileCharset = mb_detect_encoding($str, "UTF-8, GBK") == 'UTF-8' ? 'UTF-8' : 'GBK';
+ // 获取加密内容
+ private function encryptJSONSignSource($request, $responseContent) {
+ $parsetItem = $this->parserEncryptJSONSignSource($request, $responseContent);
+ $bodyIndexContent = substr($responseContent, 0, $parsetItem->startIndex);
+ $bodyEndContent = substr($responseContent, $parsetItem->endIndex, strlen($responseContent) + 1 - $parsetItem->endIndex);
+ $bizContent = decrypt($parsetItem->encryptContent, $this->encryptKey);
+ return $bodyIndexContent . $bizContent . $bodyEndContent;
+ private function parserEncryptJSONSignSource($request, $responseContent) {
+ return $this->parserEncryptJSONItem($responseContent, $rootNodeName, $rootIndex);
+ return $this->parserEncryptJSONItem($responseContent, $this->ERROR_RESPONSE, $errorIndex);
+ private function parserEncryptJSONItem($responseContent, $nodeName, $nodeIndex) {
+ $signIndex = strpos($responseContent, "\"" . $this->SIGN_NODE_NAME . "\"");
+ if ($signDataEndIndex < 0) {
+ $signDataEndIndex = strlen($responseContent) - 1;
+ $encContent = substr($responseContent, $signDataStartIndex + 1, $indexLen - 2);
+ $encryptParseItem = new EncryptParseItem();
+ $encryptParseItem->encryptContent = $encContent;
+ $encryptParseItem->startIndex = $signDataStartIndex;
+ $encryptParseItem->endIndex = $signDataEndIndex;
+ return $encryptParseItem;
+ private function encryptXMLSignSource($request, $responseContent) {
+ $parsetItem = $this->parserEncryptXMLSignSource($request, $responseContent);
+ private function parserEncryptXMLSignSource($request, $responseContent) {
+ return $this->parserEncryptXMLItem($responseContent, $rootNodeName, $rootIndex);
+ return $this->parserEncryptXMLItem($responseContent, $this->ERROR_RESPONSE, $errorIndex);
+ private function parserEncryptXMLItem($responseContent, $nodeName, $nodeIndex) {
+ $xmlStartNode = "<" . $this->ENCRYPT_XML_NODE_NAME . ">";
+ $xmlEndNode = "</" . $this->ENCRYPT_XML_NODE_NAME . ">";
+ $indexOfXmlNode = strpos($responseContent, $xmlEndNode);
+ if ($indexOfXmlNode < 0) {
+ $item = new EncryptParseItem();
+ $item->encryptContent = null;
+ $item->startIndex = 0;
+ $item->endIndex = 0;
+ return $item;
+ $startIndex = $signDataStartIndex + strlen($xmlStartNode);
+ $bizContentLen = $indexOfXmlNode - $startIndex;
+ $bizContent = substr($responseContent, $startIndex, $bizContentLen);
+ $encryptParseItem->encryptContent = $bizContent;
+ $encryptParseItem->endIndex = $indexOfXmlNode + strlen($xmlEndNode);
+ function echoDebug($content) {
+ if ($this->debugInfo) {
+ echo "<br/>" . $content;
@@ -0,0 +1,71 @@
+ * 加密工具类
+ * User: jiehua
+ * Date: 16/3/30
+ * Time: 下午3:25
+ * 加密方法
+ * @param string $str
+ function encrypt($str,$screct_key){
+ //AES, 128 模式加密数据 CBC
+ $screct_key = base64_decode($screct_key);
+ $str = trim($str);
+ $str = addPKCS7Padding($str);
+ $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);
+ $encrypt_str = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);
+ return base64_encode($encrypt_str);
+ * 解密方法
+ function decrypt($str,$screct_key){
+ $str = base64_decode($str);
+ $encrypt_str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);
+ $encrypt_str = trim($encrypt_str);
+ $encrypt_str = stripPKSC7Padding($encrypt_str);
+ return $encrypt_str;
+ * 填充算法
+ * @param string $source
+function addPKCS7Padding($source){
+ $source = trim($source);
+ $block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
+ $pad = $block - (strlen($source) % $block);
+ if ($pad <= $block) {
+ $char = chr($pad);
+ $source .= str_repeat($char, $pad);
+ return $source;
+ * 移去填充算法
+function stripPKSC7Padding($source){
+ $char = substr($source, -1);
+ $num = ord($char);
+ if($num==62)return $source;
+ $source = substr($source,0,-$num);
@@ -0,0 +1,19 @@
+ * TODO 补充说明
+ * Time: 下午8:55
+class EncryptParseItem {
+ public $startIndex;
+ public $endIndex;
+ public $encryptContent;
@@ -0,0 +1,18 @@
+ * Time: 下午8:51
+class EncryptResponseData {
+ public $realContent;
+ public $returnContent;
@@ -0,0 +1,16 @@
+ * Created by PhpStorm.
+ * Date: 15/5/2
+ * Time: 下午6:21
+class SignData {
+ public $signSourceData=null;
+ public $sign=null;
@@ -0,0 +1,118 @@
+ * ALIPAY API: alipay.account.exrate.advice.accept request
+ * @author auto create
+ * @since 1.0, 2016-05-23 14:55:42
+class AlipayAccountExrateAdviceAcceptRequest
+{
+ * 标准的兑换交易受理接口
+ private $bizContent;
+ private $apiParas = array();
+ private $terminalType;
+ private $terminalInfo;
+ private $apiVersion="1.0";
+ private $needEncrypt=false;
+ public function setBizContent($bizContent)
+ $this->bizContent = $bizContent;
+ $this->apiParas["biz_content"] = $bizContent;
+ public function getBizContent()
+ return $this->bizContent;
+ public function getApiMethodName()
+ return "alipay.account.exrate.advice.accept";
+ public function setNotifyUrl($notifyUrl)
+ $this->notifyUrl=$notifyUrl;
+ public function getNotifyUrl()
+ return $this->notifyUrl;
+ public function setReturnUrl($returnUrl)
+ $this->returnUrl=$returnUrl;
+ public function getReturnUrl()
+ return $this->returnUrl;
+ public function getApiParas()
+ return $this->apiParas;
+ public function getTerminalType()
+ return $this->terminalType;
+ public function setTerminalType($terminalType)
+ $this->terminalType = $terminalType;
+ public function getTerminalInfo()
+ return $this->terminalInfo;
+ public function setTerminalInfo($terminalInfo)
+ $this->terminalInfo = $terminalInfo;
+ public function getProdCode()
+ return $this->prodCode;
+ public function setProdCode($prodCode)
+ $this->prodCode = $prodCode;
+ public function setApiVersion($apiVersion)
+ $this->apiVersion=$apiVersion;
+ public function getApiVersion()
+ return $this->apiVersion;
+ public function setNeedEncrypt($needEncrypt)
+ $this->needEncrypt=$needEncrypt;
+ public function getNeedEncrypt()
+ return $this->needEncrypt;
+ * ALIPAY API: alipay.account.exrate.allclientrate.query request
+ * @since 1.0, 2018-04-12 19:07:12
+class AlipayAccountExrateAllclientrateQueryRequest
+ * 查询客户的所有币种对最新有效汇率
+ return "alipay.account.exrate.allclientrate.query";
+ * ALIPAY API: alipay.account.exrate.ratequery request
+ * @since 1.0, 2017-03-27 18:11:27
+class AlipayAccountExrateRatequeryRequest
+ * 对于部分签约境内当面付的商家,为了能够在境外进行推广,因此需要汇率进行币种之间的转换,本接口提供此业务场景下的汇率查询服务
+ return "alipay.account.exrate.ratequery";
+ * ALIPAY API: alipay.account.exrate.traderequest.create request
+ * @since 1.0, 2018-04-13 17:35:02
+class AlipayAccountExrateTraderequestCreateRequest
+ * 受理外汇交易请求
+ return "alipay.account.exrate.traderequest.create";
@@ -0,0 +1,171 @@
+ * ALIPAY API: alipay.acquire.cancel request
+ * @since 1.0, 2014-06-12 17:17:06
+class AlipayAcquireCancelRequest
+ * 操作员ID。
+ private $operatorId;
+ * 操作员的类型:
+0:支付宝操作员
+1:商户的操作员
+如果传入其它值或者为空,则默认设置为1
+ private $operatorType;
+ * 支付宝合作商户网站唯一订单号。
+ private $outTradeNo;
+ * 该交易在支付宝系统中的交易流水号。
+最短16位,最长64位。
+如果同时传了out_trade_no和trade_no,则以trade_no为准。
+ private $tradeNo;
+ public function setOperatorId($operatorId)
+ $this->operatorId = $operatorId;
+ $this->apiParas["operator_id"] = $operatorId;
+ public function getOperatorId()
+ return $this->operatorId;
+ public function setOperatorType($operatorType)
+ $this->operatorType = $operatorType;
+ $this->apiParas["operator_type"] = $operatorType;
+ public function getOperatorType()
+ return $this->operatorType;
+ public function setOutTradeNo($outTradeNo)
+ $this->outTradeNo = $outTradeNo;
+ $this->apiParas["out_trade_no"] = $outTradeNo;
+ public function getOutTradeNo()
+ return $this->outTradeNo;
+ public function setTradeNo($tradeNo)
+ $this->tradeNo = $tradeNo;
+ $this->apiParas["trade_no"] = $tradeNo;
+ public function getTradeNo()
+ return $this->tradeNo;
+ return "alipay.acquire.cancel";
@@ -0,0 +1,152 @@
+ * ALIPAY API: alipay.acquire.close request
+class AlipayAcquireCloseRequest
+ * 卖家的操作员ID
+ * 支付宝合作商户网站唯一订单号
+如果同时传了out_trade_no和trade_no,则以trade_no为准
+ return "alipay.acquire.close";
@@ -0,0 +1,550 @@
+ * ALIPAY API: alipay.acquire.createandpay request
+ * @since 1.0, 2018-06-15 16:56:59
+class AlipayAcquireCreateandpayRequest
+ * 证书签名
+ private $alipayCaRequest;
+ * 对一笔交易的具体描述信息。如果是多种商品,请将商品描述字符串累加传给body。
+ private $body;
+ * 买家支付宝账号,可以为email或者手机号。
+ private $buyerEmail;
+ * 买家支付宝账号对应的支付宝唯一用户号。
+以2088开头的纯16位数字。
+ private $buyerId;
+ * 描述多渠道收单的渠道明细信息,json格式,具体请参见“4.5 渠道明细说明”。
+ private $channelParameters;
+ * 订单金额币种。
+目前只支持传入156(人民币)。
+如果为空,则默认设置为156。
+ private $currency;
+ * 动态ID。
+ private $dynamicId;
+ * 动态ID类型:
+􀁺
+soundwave:声波
+qrcode:二维码
+barcode:条码
+wave_code:声波,等同soundwave
+qr_code:二维码,等同qrcode
+bar_code:条码,等同barcode
+建议取值wave_code、qr_code、bar_code。
+ private $dynamicIdType;
+ * 用于商户的特定业务信息的传递,只有商户与支付宝约定了传递此参数且约定了参数含义,此参数才有效。
+比如可传递声波支付场景下的门店ID等信息,以json格式传输,具体请参见“4.7 业务扩展参数说明”。
+ private $extendParams;
+ * xml或json
+ private $formatType;
+ * 描述商品明细信息,json格式,具体请参见“4.3 商品明细说明”。
+ private $goodsDetail;
+ * 设置未付款交易的超时时间,一旦超时,该笔交易就会自动被关闭。
+取值范围:1m~15d。
+m-分钟,h-小时,d-天,1c-当天(无论交易何时创建,都在0点关闭)。
+该参数数值不接受小数点,如1.5h,可转换为90m。
+该功能需要联系支付宝配置关闭时间。
+ private $itBPay;
+ * 描述预付卡相关的明细信息,json格式,具体请参见“4.8 预付卡明细参数说明”。
+ private $mcardParameters;
+ * 卖家的操作员ID。
+如果传入其它值或者为空,则默认设置为1。
+ * 订单中商品的单价。
+如果请求时传入本参数,则必须满足total_fee=price×quantity的条件。
+ private $price;
+ * 订单中商品的数量。
+ private $quantity;
+ * 业务关联ID集合,用于放置商户的订单号、支付流水号等信息,json格式,具体请参见“4.6 业务关联ID集合说明”。
+ private $refIds;
+ * 描述分账明细信息,json格式,具体请参见“4.4 分账明细说明”。
+ private $royaltyParameters;
+ * 卖家的分账类型,目前只支持传入ROYALTY(普通分账类型)。
+ private $royaltyType;
+ * 卖家支付宝账号,可以为email或者手机号。
+如果seller_id不为空,则以seller_id的值作为卖家账号,忽略本参数。
+ private $sellerEmail;
+ * 卖家支付宝账号对应的支付宝唯一用户号。
+如果和seller_email同时为空,则本参数默认填充partner的值。
+ private $sellerId;
+ * 收银台页面上,商品展示的超链接。
+ private $showUrl;
+ * 商品的标题/交易标题/订单标题/订单关键字等。
+该参数最长为128个汉字。
+ private $subject;
+ * 该笔订单的资金总额,取值范围[0.01,100000000],精确到小数点后2位。
+ private $totalFee;
+ public function setAlipayCaRequest($alipayCaRequest)
+ $this->alipayCaRequest = $alipayCaRequest;
+ $this->apiParas["alipay_ca_request"] = $alipayCaRequest;
+ public function getAlipayCaRequest()
+ return $this->alipayCaRequest;
+ public function setBody($body)
+ $this->body = $body;
+ $this->apiParas["body"] = $body;
+ public function getBody()
+ return $this->body;
+ public function setBuyerEmail($buyerEmail)
+ $this->buyerEmail = $buyerEmail;
+ $this->apiParas["buyer_email"] = $buyerEmail;
+ public function getBuyerEmail()
+ return $this->buyerEmail;
+ public function setBuyerId($buyerId)
+ $this->buyerId = $buyerId;
+ $this->apiParas["buyer_id"] = $buyerId;
+ public function getBuyerId()
+ return $this->buyerId;
+ public function setChannelParameters($channelParameters)
+ $this->channelParameters = $channelParameters;
+ $this->apiParas["channel_parameters"] = $channelParameters;
+ public function getChannelParameters()
+ return $this->channelParameters;
+ public function setCurrency($currency)
+ $this->currency = $currency;
+ $this->apiParas["currency"] = $currency;
+ public function getCurrency()
+ return $this->currency;
+ public function setDynamicId($dynamicId)
+ $this->dynamicId = $dynamicId;
+ $this->apiParas["dynamic_id"] = $dynamicId;
+ public function getDynamicId()
+ return $this->dynamicId;
+ public function setDynamicIdType($dynamicIdType)
+ $this->dynamicIdType = $dynamicIdType;
+ $this->apiParas["dynamic_id_type"] = $dynamicIdType;
+ public function getDynamicIdType()
+ return $this->dynamicIdType;
+ public function setExtendParams($extendParams)
+ $this->extendParams = $extendParams;
+ $this->apiParas["extend_params"] = $extendParams;
+ public function getExtendParams()
+ return $this->extendParams;
+ public function setFormatType($formatType)
+ $this->formatType = $formatType;
+ $this->apiParas["format_type"] = $formatType;
+ public function getFormatType()
+ return $this->formatType;
+ public function setGoodsDetail($goodsDetail)
+ $this->goodsDetail = $goodsDetail;
+ $this->apiParas["goods_detail"] = $goodsDetail;
+ public function getGoodsDetail()
+ return $this->goodsDetail;
+ public function setItBPay($itBPay)
+ $this->itBPay = $itBPay;
+ $this->apiParas["it_b_pay"] = $itBPay;
+ public function getItBPay()
+ return $this->itBPay;
+ public function setMcardParameters($mcardParameters)
+ $this->mcardParameters = $mcardParameters;
+ $this->apiParas["mcard_parameters"] = $mcardParameters;
+ public function getMcardParameters()
+ return $this->mcardParameters;
+ public function setPrice($price)
+ $this->price = $price;
+ $this->apiParas["price"] = $price;
+ public function getPrice()
+ return $this->price;
+ public function setQuantity($quantity)
+ $this->quantity = $quantity;
+ $this->apiParas["quantity"] = $quantity;
+ public function getQuantity()
+ return $this->quantity;
+ public function setRefIds($refIds)
+ $this->refIds = $refIds;
+ $this->apiParas["ref_ids"] = $refIds;
+ public function getRefIds()
+ return $this->refIds;
+ public function setRoyaltyParameters($royaltyParameters)
+ $this->royaltyParameters = $royaltyParameters;
+ $this->apiParas["royalty_parameters"] = $royaltyParameters;
+ public function getRoyaltyParameters()
+ return $this->royaltyParameters;
+ public function setRoyaltyType($royaltyType)
+ $this->royaltyType = $royaltyType;
+ $this->apiParas["royalty_type"] = $royaltyType;
+ public function getRoyaltyType()
+ return $this->royaltyType;
+ public function setSellerEmail($sellerEmail)
+ $this->sellerEmail = $sellerEmail;
+ $this->apiParas["seller_email"] = $sellerEmail;
+ public function getSellerEmail()
+ return $this->sellerEmail;
+ public function setSellerId($sellerId)
+ $this->sellerId = $sellerId;
+ $this->apiParas["seller_id"] = $sellerId;
+ public function getSellerId()
+ return $this->sellerId;
+ public function setShowUrl($showUrl)
+ $this->showUrl = $showUrl;
+ $this->apiParas["show_url"] = $showUrl;
+ public function getShowUrl()
+ return $this->showUrl;
+ public function setSubject($subject)
+ $this->subject = $subject;
+ $this->apiParas["subject"] = $subject;
+ public function getSubject()
+ return $this->subject;
+ public function setTotalFee($totalFee)
+ $this->totalFee = $totalFee;
+ $this->apiParas["total_fee"] = $totalFee;
+ public function getTotalFee()
+ return $this->totalFee;
+ return "alipay.acquire.createandpay";
@@ -0,0 +1,402 @@
+ * ALIPAY API: alipay.acquire.precreate request
+ * @since 1.0, 2018-05-22 11:49:56
+class AlipayAcquirePrecreateRequest
+ * 对一笔交易的具体描述信息。如果是多种商品,请将商品描述字符串累加传给body
+ * 描述多渠道收单的渠道明细信息,json格式
+ * 订单金额币种。目前只支持传入156(人民币)。
+如果为空,则默认设置为156
+ * 公用业务扩展信息。用于商户的特定业务信息的传递,只有商户与支付宝约定了传递此参数且约定了参数含义,此参数才有效。
+比如可传递二维码支付场景下的门店ID等信息,以json格式传输。
+ * 描述商品明细信息,json格式。
+ * 订单支付超时时间。设置未付款交易的超时时间,一旦超时,该笔交易就会自动被关闭。
+ private $operatorCode;
+如果请求时传入本参数,则必须满足total_fee=price×quantity的条件
+ * 分账信息。
+描述分账明细信息,json格式
+ * 分账类型。卖家的分账类型,目前只支持传入ROYALTY(普通分账类型)
+ * 卖家支付宝账号,可以为email或者手机号。如果seller_id不为空,则以seller_id的值作为卖家账号,忽略本参数
+ * 卖家支付宝账号对应的支付宝唯一用户号,以2088开头的纯16位数字。如果和seller_email同时为空,则本参数默认填充partner的值
+ * 收银台页面上,商品展示的超链接
+ * 商品购买
+ * 订单金额。该笔订单的资金总额,取值范围[0.01,100000000],精确到小数点后2位。
+ public function setOperatorCode($operatorCode)
+ $this->operatorCode = $operatorCode;
+ $this->apiParas["operator_code"] = $operatorCode;
+ public function getOperatorCode()
+ return $this->operatorCode;
+ return "alipay.acquire.precreate";
@@ -0,0 +1,136 @@
+ * ALIPAY API: alipay.acquire.query request
+ * @since 1.0, 2018-04-18 17:54:57
+class AlipayAcquireQueryRequest
+ return "alipay.acquire.query";
@@ -0,0 +1,236 @@
+ * ALIPAY API: alipay.acquire.refund request
+ * @since 1.0, 2014-06-12 17:17:03
+class AlipayAcquireRefundRequest
+ * 商户退款请求单号,用以标识本次交易的退款请求。
+如果不传入本参数,则以out_trade_no填充本参数的值。同时,认为本次请求为全额退款,要求退款金额和交易支付金额一致。
+ private $outRequestNo;
+ * 商户网站唯一订单号
+ * 业务关联ID集合,用于放置商户的退款单号、退款流水号等信息,json格式
+ * 退款金额;退款金额不能大于订单金额,全额退款必须与订单金额一致。
+ private $refundAmount;
+ * 退款原因说明。
+ private $refundReason;
+ public function setOutRequestNo($outRequestNo)
+ $this->outRequestNo = $outRequestNo;
+ $this->apiParas["out_request_no"] = $outRequestNo;
+ public function getOutRequestNo()
+ return $this->outRequestNo;
+ public function setRefundAmount($refundAmount)
+ $this->refundAmount = $refundAmount;
+ $this->apiParas["refund_amount"] = $refundAmount;
+ public function getRefundAmount()
+ return $this->refundAmount;
+ public function setRefundReason($refundReason)
+ $this->refundReason = $refundReason;
+ $this->apiParas["refund_reason"] = $refundReason;
+ public function getRefundReason()
+ return $this->refundReason;
+ return "alipay.acquire.refund";
+ * ALIPAY API: alipay.app.token.get request
+ * @since 1.0, 2017-04-13 19:13:06
+class AlipayAppTokenGetRequest
+ * 应用安全码
+ private $secret;
+ public function setSecret($secret)
+ $this->secret = $secret;
+ $this->apiParas["secret"] = $secret;
+ public function getSecret()
+ return $this->secret;
+ return "alipay.app.token.get";
@@ -0,0 +1,103 @@
+ * ALIPAY API: alipay.asset.point.balance.query request
+ * @since 1.0, 2017-04-14 19:00:47
+class AlipayAssetPointBalanceQueryRequest
+ return "alipay.asset.point.balance.query";
+ * ALIPAY API: alipay.asset.point.budget.query request
+ * @since 1.0, 2017-04-14 18:58:03
+class AlipayAssetPointBudgetQueryRequest
+ return "alipay.asset.point.budget.query";
+ * ALIPAY API: alipay.asset.point.order.create request
+ * @since 1.0, 2017-04-14 18:53:05
+class AlipayAssetPointOrderCreateRequest
+ * 商户在采购完集分宝后可以通过此接口发放集分宝
+ return "alipay.asset.point.order.create";
+ * ALIPAY API: alipay.asset.point.order.query request
+ * @since 1.0, 2017-04-14 19:02:42
+class AlipayAssetPointOrderQueryRequest
+ * 商户在调用集分宝发放接口后可以通过此接口查询发放情况
+ return "alipay.asset.point.order.query";
+ * ALIPAY API: alipay.boss.cs.channel.query request
+ * @since 1.0, 2016-02-23 20:04:44
+class AlipayBossCsChannelQueryRequest
+ * 云客服热线数据查询,云客服会有很多外部客服,他们需要查询落地在站内的自己公司的服务数据。
+ return "alipay.boss.cs.channel.query";
+ * ALIPAY API: alipay.boss.fnc.xwbtest.ret.modify request
+ * @since 1.0, 2017-11-17 11:35:26
+class AlipayBossFncXwbtestRetModifyRequest
+ return "alipay.boss.fnc.xwbtest.ret.modify";
+ * ALIPAY API: alipay.boss.prod.arrangement.offline.query request
+ * @since 1.0, 2017-04-14 21:06:47
+class AlipayBossProdArrangementOfflineQueryRequest
+ * 签约销售方案的主站产品码,目前只支持ONLINE_TRADE_PAY(在线购买签约)和FACE_TO_FACE_PAYMENT(当面付)两个常量值,不允许传入其他值,否则报SYSTEM_ERROR异常。不传值时,默认查询FACE_TO_FACE_PAYM(当面付产品)。
+ private $productCode;
+ public function setProductCode($productCode)
+ $this->productCode = $productCode;
+ $this->apiParas["product_code"] = $productCode;
+ public function getProductCode()
+ return $this->productCode;
+ return "alipay.boss.prod.arrangement.offline.query";
+ * ALIPAY API: alipay.commerce.air.xfg.dsg.modify request
+ * @since 1.0, 2018-01-18 15:28:48
+class AlipayCommerceAirXfgDsgModifyRequest
+ * 吃饭更好
+ return "alipay.commerce.air.xfg.dsg.modify";
+ * ALIPAY API: alipay.commerce.cityfacilitator.city.query request
+ * @since 1.0, 2015-12-15 11:19:13
+class AlipayCommerceCityfacilitatorCityQueryRequest
+ return "alipay.commerce.cityfacilitator.city.query";
+ * ALIPAY API: alipay.commerce.cityfacilitator.deposit.cancel request
+ * @since 1.0, 2015-12-18 21:35:58
+class AlipayCommerceCityfacilitatorDepositCancelRequest
+ * 合作渠道可通过该接口补登扣款取消请求,以帮助支付宝将用户的资金退给用户
+ return "alipay.commerce.cityfacilitator.deposit.cancel";
+ * ALIPAY API: alipay.commerce.cityfacilitator.deposit.confirm request
+ * @since 1.0, 2015-12-18 21:36:24
+class AlipayCommerceCityfacilitatorDepositConfirmRequest
+ * 合作渠道可通过该接口补登单笔圈存确认扣款请求,以帮助支付宝将用户的资金结算给指定的渠道,不支持单笔拆分
+ return "alipay.commerce.cityfacilitator.deposit.confirm";
+ * ALIPAY API: alipay.commerce.cityfacilitator.deposit.query request
+ * @since 1.0, 2015-12-15 11:37:56
+class AlipayCommerceCityfacilitatorDepositQueryRequest
+ * 商户查询用户的充值转账记录
+ return "alipay.commerce.cityfacilitator.deposit.query";
+ * ALIPAY API: alipay.commerce.cityfacilitator.function.query request
+ * @since 1.0, 2015-12-15 11:19:03
+class AlipayCommerceCityfacilitatorFunctionQueryRequest
+ * 基于设备和城市查询当前支持的功能
+ return "alipay.commerce.cityfacilitator.function.query";
+ * ALIPAY API: alipay.commerce.cityfacilitator.script.query request
+ * @since 1.0, 2015-12-09 16:24:55
+class AlipayCommerceCityfacilitatorScriptQueryRequest
+ * 查询城市一卡通的判卡、读卡脚本
+ return "alipay.commerce.cityfacilitator.script.query";
+ * ALIPAY API: alipay.commerce.cityfacilitator.station.query request
+ * @since 1.0, 2016-08-03 16:10:49
+class AlipayCommerceCityfacilitatorStationQueryRequest
+ * 地铁购票站点查询
+ return "alipay.commerce.cityfacilitator.station.query";
+ * ALIPAY API: alipay.commerce.cityfacilitator.voucher.batchquery request
+ * @since 1.0, 2016-08-03 16:11:01
+class AlipayCommerceCityfacilitatorVoucherBatchqueryRequest
+ * 地铁购票订单批量查询
+ return "alipay.commerce.cityfacilitator.voucher.batchquery";
+ * ALIPAY API: alipay.commerce.cityfacilitator.voucher.cancel request
+ * @since 1.0, 2017-06-21 15:07:46
+class AlipayCommerceCityfacilitatorVoucherCancelRequest
+ * 钱包中地铁票购票,获得核销码,线下渠道商凭核销码撤销该笔交易
+ return "alipay.commerce.cityfacilitator.voucher.cancel";
+ * ALIPAY API: alipay.commerce.cityfacilitator.voucher.confirm request
+ * @since 1.0, 2017-06-21 15:08:33
+class AlipayCommerceCityfacilitatorVoucherConfirmRequest
+ * 钱包中地铁票购票,获得核销码,线下地铁自助购票机上凭核销码取票,购票确认
+ return "alipay.commerce.cityfacilitator.voucher.confirm";
+ * ALIPAY API: alipay.commerce.cityfacilitator.voucher.generate request
+ * @since 1.0, 2016-08-03 16:10:34
+class AlipayCommerceCityfacilitatorVoucherGenerateRequest
+ * 地铁购票核销码发码
+ return "alipay.commerce.cityfacilitator.voucher.generate";
+ * ALIPAY API: alipay.commerce.cityfacilitator.voucher.query request
+ * @since 1.0, 2017-06-21 15:04:33
+class AlipayCommerceCityfacilitatorVoucherQueryRequest
+ * 钱包中地铁票购票,获得核销码,线下地铁自助购票机上凭核销码取票,渠道商凭用户输入的核销码调接口查询核销码的有效性。
+ return "alipay.commerce.cityfacilitator.voucher.query";
+ * ALIPAY API: alipay.commerce.cityfacilitator.voucher.refund request
+ * @since 1.0, 2016-08-03 16:10:56
+class AlipayCommerceCityfacilitatorVoucherRefundRequest
+ * 地铁购票发码退款
+ return "alipay.commerce.cityfacilitator.voucher.refund";
+ * ALIPAY API: alipay.commerce.cityfacilitator.voucher.upload request
+ * @since 1.0, 2017-06-21 15:05:13
+class AlipayCommerceCityfacilitatorVoucherUploadRequest
+ * 钱包中地铁票购票,获得核销码,线下地铁自助购票机上凭核销码取票,票号上传接口
+ return "alipay.commerce.cityfacilitator.voucher.upload";
+ * ALIPAY API: alipay.commerce.data.monitordata.sync request
+ * @since 1.0, 2018-01-04 10:37:50
+class AlipayCommerceDataMonitordataSyncRequest
+ * 自助监控服务接口
+ return "alipay.commerce.data.monitordata.sync";
+ * ALIPAY API: alipay.commerce.educate.studentinfo.share request
+ * @since 1.0, 2016-07-19 14:49:22
+class AlipayCommerceEducateStudentinfoShareRequest
+ return "alipay.commerce.educate.studentinfo.share";
+ * ALIPAY API: alipay.commerce.iot.deviceservice.cancel request
+ * @since 1.0, 2017-11-24 15:20:44
+class AlipayCommerceIotDeviceserviceCancelRequest
+ * 撤销指定的设备服务
+ return "alipay.commerce.iot.deviceservice.cancel";
+ * ALIPAY API: alipay.commerce.lottery.present.send request
+ * @since 1.0, 2018-03-30 14:30:00
+class AlipayCommerceLotteryPresentSendRequest
+ * 商家给用户赠送彩票,由亚博科技提供服务
+ return "alipay.commerce.lottery.present.send";
+ * ALIPAY API: alipay.commerce.lottery.presentlist.query request
+ * @since 1.0, 2018-03-30 15:00:00
+class AlipayCommerceLotteryPresentlistQueryRequest
+ * 查询调用者指定时间范围内的彩票赠送列表,由亚博科技提供服务
+ return "alipay.commerce.lottery.presentlist.query";
+ * ALIPAY API: alipay.commerce.lottery.typelist.query request
+ * @since 1.0, 2018-03-30 15:10:00
+class AlipayCommerceLotteryTypelistQueryRequest
+ return "alipay.commerce.lottery.typelist.query";
+ * ALIPAY API: alipay.commerce.transport.offlinepay.key.query request
+ * @since 1.0, 2017-09-04 17:13:35
+class AlipayCommerceTransportOfflinepayKeyQueryRequest
+ return "alipay.commerce.transport.offlinepay.key.query";
+ * ALIPAY API: alipay.commerce.transport.offlinepay.record.verify request
+ * @since 1.0, 2017-09-04 17:14:03
+class AlipayCommerceTransportOfflinepayRecordVerifyRequest
+ * 支付宝脱机操作信息验证
+ return "alipay.commerce.transport.offlinepay.record.verify";
+ * ALIPAY API: alipay.commerce.transport.offlinepay.userblacklist.query request
+ * @since 1.0, 2017-09-04 17:13:07
+class AlipayCommerceTransportOfflinepayUserblacklistQueryRequest
+ * 脱机交易黑名单列表
+ return "alipay.commerce.transport.offlinepay.userblacklist.query";
+ * ALIPAY API: alipay.daowei.order.cancel request
+ * @since 1.0, 2018-03-23 13:21:44
+class AlipayDaoweiOrderCancelRequest
+ * 到位订单取消
+ return "alipay.daowei.order.cancel";
+ * ALIPAY API: alipay.daowei.order.confirm request
+ * @since 1.0, 2018-03-23 13:23:44
+class AlipayDaoweiOrderConfirmRequest
+ * 订单确认接口
+ return "alipay.daowei.order.confirm";
+ * ALIPAY API: alipay.daowei.order.modify request
+ * @since 1.0, 2018-03-23 13:23:16
+class AlipayDaoweiOrderModifyRequest
+ * 服务订单修改接口
+ return "alipay.daowei.order.modify";
+ * ALIPAY API: alipay.daowei.order.query request
+ * @since 1.0, 2018-03-23 13:23:59
+class AlipayDaoweiOrderQueryRequest
+ * 到位订单查询接口
+ return "alipay.daowei.order.query";
+ * ALIPAY API: alipay.daowei.order.refund request
+ * @since 1.0, 2018-03-23 13:22:08
+class AlipayDaoweiOrderRefundRequest
+ * 订单退款接口
+ return "alipay.daowei.order.refund";
+ * ALIPAY API: alipay.daowei.order.refuse request
+ * @since 1.0, 2018-03-23 13:24:12
+class AlipayDaoweiOrderRefuseRequest
+ * 到位的单笔订单拒绝接口
+ return "alipay.daowei.order.refuse";
+ * ALIPAY API: alipay.daowei.order.sp.modify request
+ * @since 1.0, 2018-03-23 13:23:29
+class AlipayDaoweiOrderSpModifyRequest
+ * 订单服务者变更接口
+ return "alipay.daowei.order.sp.modify";
+ * ALIPAY API: alipay.daowei.order.transfer request
+ * @since 1.0, 2018-03-23 13:22:57
+class AlipayDaoweiOrderTransferRequest
+ * 订单状态推进接口
+ return "alipay.daowei.order.transfer";
+ * ALIPAY API: alipay.daowei.service.modify request
+ * @since 1.0, 2018-06-26 14:23:36
+class AlipayDaoweiServiceModifyRequest
+ * 创建或更新服务信息接口
+ return "alipay.daowei.service.modify";
+ * ALIPAY API: alipay.daowei.sp.modify request
+ * @since 1.0, 2017-03-10 16:06:09
+class AlipayDaoweiSpModifyRequest
+ * 创建或更新服务者信息接口
+ return "alipay.daowei.sp.modify";
+ * ALIPAY API: alipay.daowei.sp.schedule.modify request
+ * @since 1.0, 2017-03-10 16:05:46
+class AlipayDaoweiSpScheduleModifyRequest
+ * 更新服务者可用时间接口
+ return "alipay.daowei.sp.schedule.modify";
@@ -0,0 +1,134 @@
+ * ALIPAY API: alipay.data.bill.downloadurl.get request
+ * @since 1.0, 2017-04-14 11:43:02
+class AlipayDataBillDownloadurlGetRequest
+ * 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM
+ private $billDate;
+ * 账单类型,目前支持的类型由:trade、air、air_b2b;trade指商户通过接口所获取的账单,或商户经开放平台授权后其所属服务商通过接口所获取的账单;air、air_b2b是航旅行业定制的账单,一般商户没有此账单;
+ private $billType;
+ public function setBillDate($billDate)
+ $this->billDate = $billDate;
+ $this->apiParas["bill_date"] = $billDate;
+ public function getBillDate()
+ return $this->billDate;
+ public function setBillType($billType)
+ $this->billType = $billType;
+ $this->apiParas["bill_type"] = $billType;
+ public function getBillType()
+ return $this->billType;
+ return "alipay.data.bill.downloadurl.get";
+ * ALIPAY API: alipay.data.dataexchange.sfasdf request
+ * @since 1.0, 2016-03-18 20:58:13
+class AlipayDataDataexchangeSfasdfRequest
+ * 1232456374
+ return "alipay.data.dataexchange.sfasdf";
+ * ALIPAY API: alipay.data.dataservice.bill.downloadurl.query request
+ * @since 1.0, 2018-06-07 15:50:00
+class AlipayDataDataserviceBillDownloadurlQueryRequest
+ * 无授权模式的查询对账单下载地址
+ return "alipay.data.dataservice.bill.downloadurl.query";
+ * ALIPAY API: alipay.data.dataservice.chinaremodel.query request
+ * @since 1.0, 2018-01-22 10:27:48
+class AlipayDataDataserviceChinaremodelQueryRequest
+ * 中再核保结果查询
+ return "alipay.data.dataservice.chinaremodel.query";
+ * ALIPAY API: alipay.data.dataservice.code.reco request
+ * @since 1.0, 2018-01-22 10:26:43
+class AlipayDataDataserviceCodeRecoRequest
+ * 改api为数立提供验证码识别服务。isv可以通过该接口,使用我们的图片识别能力。
+ return "alipay.data.dataservice.code.reco";
+ * ALIPAY API: alipay.data.dataservice.sdfsdf request
+ * @since 1.0, 2016-03-30 20:51:14
+class AlipayDataDataserviceSdfsdfRequest
+ return "alipay.data.dataservice.sdfsdf";
+ * ALIPAY API: alipay.data.dataservice.shoppingmallrec.shop.query request
+ * @since 1.0, 2017-08-15 19:53:06
+class AlipayDataDataserviceShoppingmallrecShopQueryRequest
+ * 商场店铺推荐
+ return "alipay.data.dataservice.shoppingmallrec.shop.query";
+ * ALIPAY API: alipay.data.dataservice.shoppingmallrec.voucher.query request
+ * @since 1.0, 2017-08-15 19:53:24
+class AlipayDataDataserviceShoppingmallrecVoucherQueryRequest
+ * 商场券推荐
+ return "alipay.data.dataservice.shoppingmallrec.voucher.query";
+ * ALIPAY API: alipay.data.dataservice.userlevel.zrank.get request
+ * @since 1.0, 2018-01-22 10:27:27
+class AlipayDataDataserviceUserlevelZrankGetRequest
+ * 通用的活跃高价值用户等级,支持EMAIL,PHONE,BANKCARD,CERTNO,IMEI,MAC,TBID维度查询用户活跃高价值等级。等级从Z0-Z7,等级越高价值越高,Z0表示未实名认证或者用户信息不全。
+ return "alipay.data.dataservice.userlevel.zrank.get";
@@ -0,0 +1,326 @@
+ * ALIPAY API: alipay.ebpp.bill.add request
+ * @since 1.0, 2018-01-22 21:21:47
+class AlipayEbppBillAddRequest
+ * 外部订单号
+ private $bankBillNo;
+ * 账单的账期,例如201203表示2012年3月的账单。
+ * 账单单据号,例如水费单号,手机号,电费号,信用卡卡号。没有唯一性要求。
+ private $billKey;
+ * 支付宝给每个出账机构指定了一个对应的英文短名称来唯一表示该收费单位。
+ private $chargeInst;
+ * 扩展属性
+ private $extendField;
+ * 输出机构的业务流水号,需要保证唯一性
+ private $merchantOrderNo;
+ * 用户的手机号
+ private $mobile;
+ * 支付宝订单类型。公共事业缴纳JF,信用卡还款HK
+ private $orderType;
+ * 拥有该账单的用户姓名
+ private $ownerName;
+ * 缴费金额。用户支付的总金额。单位为:RMB Yuan。取值范围为[0.01,100000000.00],精确到小数点后两位。
+ private $payAmount;
+ * 账单的服务费。
+ private $serviceAmount;
+ * 子业务类型是业务类型的下一级概念,例如:WATER表示JF下面的水费,ELECTRIC表示JF下面的电费,GAS表示JF下面的燃气费。
+ private $subOrderType;
+ * 交通违章地点,sub_order_type=TRAFFIC时填写。
+ private $trafficLocation;
+ * 违章行为,sub_order_type=TRAFFIC时填写。
+ private $trafficRegulations;
+ public function setBankBillNo($bankBillNo)
+ $this->bankBillNo = $bankBillNo;
+ $this->apiParas["bank_bill_no"] = $bankBillNo;
+ public function getBankBillNo()
+ return $this->bankBillNo;
+ public function setBillKey($billKey)
+ $this->billKey = $billKey;
+ $this->apiParas["bill_key"] = $billKey;
+ public function getBillKey()
+ return $this->billKey;
+ public function setChargeInst($chargeInst)
+ $this->chargeInst = $chargeInst;
+ $this->apiParas["charge_inst"] = $chargeInst;
+ public function getChargeInst()
+ return $this->chargeInst;
+ public function setExtendField($extendField)
+ $this->extendField = $extendField;
+ $this->apiParas["extend_field"] = $extendField;
+ public function getExtendField()
+ return $this->extendField;
+ public function setMerchantOrderNo($merchantOrderNo)
+ $this->merchantOrderNo = $merchantOrderNo;
+ $this->apiParas["merchant_order_no"] = $merchantOrderNo;
+ public function getMerchantOrderNo()
+ return $this->merchantOrderNo;
+ public function setMobile($mobile)
+ $this->mobile = $mobile;
+ $this->apiParas["mobile"] = $mobile;
+ public function getMobile()
+ return $this->mobile;
+ public function setOrderType($orderType)
+ $this->orderType = $orderType;
+ $this->apiParas["order_type"] = $orderType;
+ public function getOrderType()
+ return $this->orderType;
+ public function setOwnerName($ownerName)
+ $this->ownerName = $ownerName;
+ $this->apiParas["owner_name"] = $ownerName;
+ public function getOwnerName()
+ return $this->ownerName;
+ public function setPayAmount($payAmount)
+ $this->payAmount = $payAmount;
+ $this->apiParas["pay_amount"] = $payAmount;
+ public function getPayAmount()
+ return $this->payAmount;
+ public function setServiceAmount($serviceAmount)
+ $this->serviceAmount = $serviceAmount;
+ $this->apiParas["service_amount"] = $serviceAmount;
+ public function getServiceAmount()
+ return $this->serviceAmount;
+ public function setSubOrderType($subOrderType)
+ $this->subOrderType = $subOrderType;
+ $this->apiParas["sub_order_type"] = $subOrderType;
+ public function getSubOrderType()
+ return $this->subOrderType;
+ public function setTrafficLocation($trafficLocation)
+ $this->trafficLocation = $trafficLocation;
+ $this->apiParas["traffic_location"] = $trafficLocation;
+ public function getTrafficLocation()
+ return $this->trafficLocation;
+ public function setTrafficRegulations($trafficRegulations)
+ $this->trafficRegulations = $trafficRegulations;
+ $this->apiParas["traffic_regulations"] = $trafficRegulations;
+ public function getTrafficRegulations()
+ return $this->trafficRegulations;
+ return "alipay.ebpp.bill.add";
+ * ALIPAY API: alipay.ebpp.bill.get request
+ * @since 1.0, 2017-06-30 10:54:34
+class AlipayEbppBillGetRequest
+ * 输出机构的业务流水号,需要保证唯一性。
+ return "alipay.ebpp.bill.get";
@@ -0,0 +1,215 @@
+ * ALIPAY API: alipay.ebpp.bill.search request
+ * @since 1.0, 2017-04-07 17:13:40
+class AlipayEbppBillSearchRequest
+ * 账单流水
+ * 出账机构
+ * 销账机构
+ private $chargeoffInst;
+ * 销账机构给出账机构分配的id
+ private $companyId;
+ * 必须以key value形式定义,转为json为格式:{"key1":"value1","key2":"value2","key3":"value3","key4":"value4"}
+ 后端会直接转换为MAP对象,转换异常会报参数格式错误
+ private $extend;
+ * 业务类型
+ * 子业务类型
+ public function setChargeoffInst($chargeoffInst)
+ $this->chargeoffInst = $chargeoffInst;
+ $this->apiParas["chargeoff_inst"] = $chargeoffInst;
+ public function getChargeoffInst()
+ return $this->chargeoffInst;
+ public function setCompanyId($companyId)
+ $this->companyId = $companyId;
+ $this->apiParas["company_id"] = $companyId;
+ public function getCompanyId()
+ return $this->companyId;
+ public function setExtend($extend)
+ $this->extend = $extend;
+ $this->apiParas["extend"] = $extend;
+ public function getExtend()
+ return $this->extend;
+ return "alipay.ebpp.bill.search";
+ * ALIPAY API: alipay.ebpp.invoice.apply.result.sync request
+ * @since 1.0, 2018-06-21 14:45:00
+class AlipayEbppInvoiceApplyResultSyncRequest
+ * 同步发票申请结果
+ return "alipay.ebpp.invoice.apply.result.sync";
+ * ALIPAY API: alipay.ebpp.invoice.info.send request
+ * @since 1.0, 2018-07-02 10:29:18
+class AlipayEbppInvoiceInfoSendRequest
+ * 发票信息回传接口(新版)
+ return "alipay.ebpp.invoice.info.send";
+ * ALIPAY API: alipay.ebpp.invoice.merchantlist.enter.apply request
+ * @since 1.0, 2018-07-02 10:31:06
+class AlipayEbppInvoiceMerchantlistEnterApplyRequest
+ * 商户批量入驻申请接口
+ return "alipay.ebpp.invoice.merchantlist.enter.apply";
+ * ALIPAY API: alipay.ebpp.invoice.title.dynamic.get request
+ * @since 1.0, 2018-07-02 10:30:28
+class AlipayEbppInvoiceTitleDynamicGetRequest
+ * 根据条形码获取抬头
+ return "alipay.ebpp.invoice.title.dynamic.get";
+ * ALIPAY API: alipay.ebpp.invoice.title.list.get request
+ * @since 1.0, 2018-07-02 10:28:56
+class AlipayEbppInvoiceTitleListGetRequest
+ * 蚂蚁电子发票平台用户发票抬头列表获取
+ return "alipay.ebpp.invoice.title.list.get";
+ * ALIPAY API: alipay.ebpp.merchant.config.get request
+ * @since 1.0, 2017-04-07 17:12:49
+class AlipayEbppMerchantConfigGetRequest
+ return "alipay.ebpp.merchant.config.get";
+ * ALIPAY API: alipay.ebpp.pdeduct.bill.pay.status request
+ * @since 1.0, 2017-08-04 11:19:05
+class AlipayEbppPdeductBillPayStatusRequest
+ * 支付宝用户ID
+ private $agreementId;
+ * 商户代扣业务流水
+ private $outOrderNo;
+ public function setAgreementId($agreementId)
+ $this->agreementId = $agreementId;
+ $this->apiParas["agreement_id"] = $agreementId;
+ public function getAgreementId()
+ return $this->agreementId;
+ public function setOutOrderNo($outOrderNo)
+ $this->outOrderNo = $outOrderNo;
+ $this->apiParas["out_order_no"] = $outOrderNo;
+ public function getOutOrderNo()
+ return $this->outOrderNo;
+ return "alipay.ebpp.pdeduct.bill.pay.status";
@@ -0,0 +1,297 @@
+ * ALIPAY API: alipay.ebpp.pdeduct.pay request
+ * @since 1.0, 2018-05-18 17:15:00
+class AlipayEbppPdeductPayRequest
+ * 渠道码,如用户通过机构通过服务窗进来签约则是PUBLICFORM,此值可随意传,只要不空就行
+ private $agentChannel;
+ * 二级渠道码,预留字段
+ private $agentCode;
+ * 支付宝代扣协议Id
+ * 账期
+ * 户号,缴费单位用于标识每一户的唯一性的
+ * 扩展参数。必须以key value形式定义,
+转为json为格式:{"key1":"value1","key2":"value2",
+"key3":"value3","key4":"value4"}
+ * 滞纳金
+ private $fineAmount;
+ * 备注信息
+ private $memo;
+ * 商户外部业务流水号
+ * 扣款金额,支付总金额,包含滞纳金
+ * 商户PartnerId
+ private $pid;
+ * 用户ID
+ private $userId;
+ public function setAgentChannel($agentChannel)
+ $this->agentChannel = $agentChannel;
+ $this->apiParas["agent_channel"] = $agentChannel;
+ public function getAgentChannel()
+ return $this->agentChannel;
+ public function setAgentCode($agentCode)
+ $this->agentCode = $agentCode;
+ $this->apiParas["agent_code"] = $agentCode;
+ public function getAgentCode()
+ return $this->agentCode;
+ public function setFineAmount($fineAmount)
+ $this->fineAmount = $fineAmount;
+ $this->apiParas["fine_amount"] = $fineAmount;
+ public function getFineAmount()
+ return $this->fineAmount;
+ public function setMemo($memo)
+ $this->memo = $memo;
+ $this->apiParas["memo"] = $memo;
+ public function getMemo()
+ return $this->memo;
+ public function setPid($pid)
+ $this->pid = $pid;
+ $this->apiParas["pid"] = $pid;
+ public function getPid()
+ return $this->pid;
+ public function setUserId($userId)
+ $this->userId = $userId;
+ $this->apiParas["user_id"] = $userId;
+ public function getUserId()
+ return $this->userId;
+ return "alipay.ebpp.pdeduct.pay";
@@ -0,0 +1,416 @@
+ * ALIPAY API: alipay.ebpp.pdeduct.sign.add request
+ * @since 1.0, 2018-05-16 11:50:00
+class AlipayEbppPdeductSignAddRequest
+ * 机构签约代扣来源渠道
+PUBLICPLATFORM:服务窗
+ * 从服务窗发起则为publicId的值
+ * 户号,机构针对于每户的水、电都会有唯一的标识户号
+ * 业务类型。
+JF:缴水、电、燃气、固话宽带、有线电视、交通罚款费用
+WUYE:缴物业费
+HK:信用卡还款
+TX:手机充值
+IND: 保险
+ private $bizType;
+ * 支付宝缴费系统中的出账机构ID
+ * 代扣产品码, 由技术同学分配。 目前在缴费业务场景中,传入INST_DIRECT_DEDUCT; 在保险业务场景中, 传入INSURANCE_MERCHANT_DEDUCT
+ private $deductProdCode;
+ * 签约类型可为空
+ private $deductType;
+ * 外部用户实名认证相关信息, 用于做签约时的实名校验。
+注:
+name: 姓名
+cert_type: 身份证:IDENTITY_CARD、护照:PASSPORT、军官证:OFFICER_CARD、士兵证:SOLDIER_CARD、户口本:HOKOU等
+cert_no: 证件号码
+need_check_info取值 T/F,只有为T时才做强制校验。
+mobile:手机号,目前暂不使用此字段做校验
+min_age: 允许的最小买家年龄,min_age为整数,必须大于等于0.
+ private $extUserInfo;
+ * 扩展字段
+ * 通知方式设置,可为空
+ private $notifyConfig;
+ * 外部产生的协议ID
+ private $outAgreementId;
+ * 户名,户主真实姓名
+ * 支付工具设置,目前可为空
+ private $payConfig;
+ * 用户签约时,跳转到支付宝独立密码校验页面,校验成功后会将token和对应的用户ID缓存下来,然后跳回到机构页面生成token带回给机构,机构签约时必须传入token
+ private $payPasswordToken;
+ * 商户ID
+ * 签约到期时间。空表示无限期,一期固定传空。
+ private $signExpireDate;
+ * 业务子类型。
+WATER:缴水费
+ELECTRIC:缴电费
+GAS:缴燃气费
+COMMUN:缴固话宽带
+CATV:缴有线电视费
+TRAFFIC:缴交通罚款
+CZ:手机充值
+CAR:车险
+LIFE:寿险
+HEALTH:健康险
+ private $subBizType;
+ public function setBizType($bizType)
+ $this->bizType = $bizType;
+ $this->apiParas["biz_type"] = $bizType;
+ public function getBizType()
+ return $this->bizType;
+ public function setDeductProdCode($deductProdCode)
+ $this->deductProdCode = $deductProdCode;
+ $this->apiParas["deduct_prod_code"] = $deductProdCode;
+ public function getDeductProdCode()
+ return $this->deductProdCode;
+ public function setDeductType($deductType)
+ $this->deductType = $deductType;
+ $this->apiParas["deduct_type"] = $deductType;
+ public function getDeductType()
+ return $this->deductType;
+ public function setExtUserInfo($extUserInfo)
+ $this->extUserInfo = $extUserInfo;
+ $this->apiParas["ext_user_info"] = $extUserInfo;
+ public function getExtUserInfo()
+ return $this->extUserInfo;
+ public function setNotifyConfig($notifyConfig)
+ $this->notifyConfig = $notifyConfig;
+ $this->apiParas["notify_config"] = $notifyConfig;
+ public function getNotifyConfig()
+ return $this->notifyConfig;
+ public function setOutAgreementId($outAgreementId)
+ $this->outAgreementId = $outAgreementId;
+ $this->apiParas["out_agreement_id"] = $outAgreementId;
+ public function getOutAgreementId()
+ return $this->outAgreementId;
+ public function setPayConfig($payConfig)
+ $this->payConfig = $payConfig;
+ $this->apiParas["pay_config"] = $payConfig;
+ public function getPayConfig()
+ return $this->payConfig;
+ public function setPayPasswordToken($payPasswordToken)
+ $this->payPasswordToken = $payPasswordToken;
+ $this->apiParas["pay_password_token"] = $payPasswordToken;
+ public function getPayPasswordToken()
+ return $this->payPasswordToken;
+ public function setSignExpireDate($signExpireDate)
+ $this->signExpireDate = $signExpireDate;
+ $this->apiParas["sign_expire_date"] = $signExpireDate;
+ public function getSignExpireDate()
+ return $this->signExpireDate;
+ public function setSubBizType($subBizType)
+ $this->subBizType = $subBizType;
+ $this->apiParas["sub_biz_type"] = $subBizType;
+ public function getSubBizType()
+ return $this->subBizType;
+ return "alipay.ebpp.pdeduct.sign.add";
@@ -0,0 +1,182 @@
+ * ALIPAY API: alipay.ebpp.pdeduct.sign.cancel request
+ * @since 1.0, 2017-08-04 11:19:20
+class AlipayEbppPdeductSignCancelRequest
+ * 此值只是供代扣中心做最后的渠道统计用,并不做值是什么的强校验,只要不为空就可以
+ * 标识发起方的ID,从服务窗发起则为appId的值,appId即开放平台分配给接入ISV的id,此处也可以随便真其它值,只要能标识唯一即可
+ * 支付宝代扣协议ID
+ * 需要用户首先处于登陆态,然后访问https://ebppprod.alipay.com/deduct/enterMobileicPayPassword.htm?cb=自己指定的回跳连接地址,访问页面后会进到独立密码校验页,用户输入密码校验成功后,会生成token回调到指定的回跳地址,如果设置cb=www.baidu.com则最后回调的内容是www.baidu.com?token=312314ADFDSFAS,然后签约时直接取得地址后token的值即可
+ return "alipay.ebpp.pdeduct.sign.cancel";
+ * ALIPAY API: alipay.ebpp.pdeduct.sign.query request
+ * @since 1.0, 2018-01-02 20:27:24
+class AlipayEbppPdeductSignQueryRequest
+ * 直连代扣协议查询接口
+ return "alipay.ebpp.pdeduct.sign.query";
+ * ALIPAY API: alipay.ebpp.pdeduct.sign.validate request
+ * @since 1.0, 2017-08-04 11:19:34
+class AlipayEbppPdeductSignValidateRequest
+ * 缴费直连代扣签约前置校验
+ return "alipay.ebpp.pdeduct.sign.validate";
+ * ALIPAY API: alipay.ecapiprod.credit.get request
+ * @since 1.0, 2015-04-02 16:44:25
+class AlipayEcapiprodCreditGetRequest
+ * 授信编号
+ private $creditNo;
+ * 身份证号码
+ private $entityCode;
+ * 客户的姓名
+ private $entityName;
+ * 每一个对接融资平台的系统提供商都有一个机构号
+ private $isvCode;
+ * 融资平台分配给小贷公司的机构编码
+ private $orgCode;
+ public function setCreditNo($creditNo)
+ $this->creditNo = $creditNo;
+ $this->apiParas["credit_no"] = $creditNo;
+ public function getCreditNo()
+ return $this->creditNo;
+ public function setEntityCode($entityCode)
+ $this->entityCode = $entityCode;
+ $this->apiParas["entity_code"] = $entityCode;
+ public function getEntityCode()
+ return $this->entityCode;
+ public function setEntityName($entityName)
+ $this->entityName = $entityName;
+ $this->apiParas["entity_name"] = $entityName;
+ public function getEntityName()
+ return $this->entityName;
+ public function setIsvCode($isvCode)
+ $this->isvCode = $isvCode;
+ $this->apiParas["isv_code"] = $isvCode;
+ public function getIsvCode()
+ return $this->isvCode;
+ public function setOrgCode($orgCode)
+ $this->orgCode = $orgCode;
+ $this->apiParas["org_code"] = $orgCode;
+ public function getOrgCode()
+ return $this->orgCode;
+ return "alipay.ecapiprod.credit.get";
@@ -0,0 +1,246 @@
+ * ALIPAY API: alipay.ecapiprod.data.put request
+ * @since 1.0, 2015-04-02 16:45:23
+class AlipayEcapiprodDataPutRequest
+ * 数据类型
+ private $category;
+ * 数据字符编码,默认UTF-8
+ private $charSet;
+ * 数据采集平台生成的采集任务编号
+ private $collectingTaskId;
+ * 身份证,工商注册号等
+ * 姓名或公司名等,name和code不能同时为空
+ * 人或公司等
+ private $entityType;
+ * 渠道商
+ * 数据主体,以json格式传输的数据
+ private $jsonData;
+ * 数据合作方
+ public function setCategory($category)
+ $this->category = $category;
+ $this->apiParas["category"] = $category;
+ public function getCategory()
+ return $this->category;
+ public function setCharSet($charSet)
+ $this->charSet = $charSet;
+ $this->apiParas["char_set"] = $charSet;
+ public function getCharSet()
+ return $this->charSet;
+ public function setCollectingTaskId($collectingTaskId)
+ $this->collectingTaskId = $collectingTaskId;
+ $this->apiParas["collecting_task_id"] = $collectingTaskId;
+ public function getCollectingTaskId()
+ return $this->collectingTaskId;
+ public function setEntityType($entityType)
+ $this->entityType = $entityType;
+ $this->apiParas["entity_type"] = $entityType;
+ public function getEntityType()
+ return $this->entityType;
+ public function setJsonData($jsonData)
+ $this->jsonData = $jsonData;
+ $this->apiParas["json_data"] = $jsonData;
+ public function getJsonData()
+ return $this->jsonData;
+ return "alipay.ecapiprod.data.put";
+ * ALIPAY API: alipay.ecapiprod.drawndn.contract.get request
+ * @since 1.0, 2016-03-29 11:34:32
+class AlipayEcapiprodDrawndnContractGetRequest
+ * 支用编号
+ private $drawndnNo;
+ * 客户身份证号码,为18位,最后X必须为大写
+ * 客户姓名
+ * 融资平台分配给ISV的编码
+ public function setDrawndnNo($drawndnNo)
+ $this->drawndnNo = $drawndnNo;
+ $this->apiParas["drawndn_no"] = $drawndnNo;
+ public function getDrawndnNo()
+ return $this->drawndnNo;
+ return "alipay.ecapiprod.drawndn.contract.get";
+ * ALIPAY API: alipay.ecapiprod.drawndn.drawndnlist.query request
+ * @since 1.0, 2016-03-29 11:34:45
+class AlipayEcapiprodDrawndnDrawndnlistQueryRequest
+ return "alipay.ecapiprod.drawndn.drawndnlist.query";
@@ -0,0 +1,214 @@
+ * ALIPAY API: alipay.ecapiprod.drawndn.feerecord.query request
+ * @since 1.0, 2016-03-29 11:34:27
+class AlipayEcapiprodDrawndnFeerecordQueryRequest
+ * 费用还款记录的终止时间,终止时间与起始时间的范围不能超过31天
+ private $end;
+ * 费用还款记录的起始时间(距离当前时间不能大于183天,只能在【0-183】之间)
+ private $start;
+ public function setEnd($end)
+ $this->end = $end;
+ $this->apiParas["end"] = $end;
+ public function getEnd()
+ return $this->end;
+ public function setStart($start)
+ $this->start = $start;
+ $this->apiParas["start"] = $start;
+ public function getStart()
+ return $this->start;
+ return "alipay.ecapiprod.drawndn.feerecord.query";
+ * ALIPAY API: alipay.ecapiprod.drawndn.lendingrecord.query request
+ * @since 1.0, 2016-03-29 11:34:36
+class AlipayEcapiprodDrawndnLendingrecordQueryRequest
+ * 还款记录的终止时间,终止时间与起始时间的范围不能超过31天
+ * 还款记录的起始时间(距离当前时间不能大于183天,只能在【0-183】之间)
+ return "alipay.ecapiprod.drawndn.lendingrecord.query";
+ * ALIPAY API: alipay.ecapiprod.drawndn.paymentschedule.get request
+ * @since 1.0, 2016-03-29 11:34:20
+class AlipayEcapiprodDrawndnPaymentscheduleGetRequest
+ * 身份证
+ return "alipay.ecapiprod.drawndn.paymentschedule.get";
+ * ALIPAY API: alipay.ecapiprod.drawndn.repaymentrecord.query request
+ * @since 1.0, 2016-03-29 11:34:40
+class AlipayEcapiprodDrawndnRepaymentrecordQueryRequest
+ return "alipay.ecapiprod.drawndn.repaymentrecord.query";
@@ -0,0 +1,198 @@
+ * ALIPAY API: alipay.ecard.edu.public.bind request
+ * @since 1.0, 2014-06-12 17:16:41
+class AlipayEcardEduPublicBindRequest
+ * 机构编码
+ * 公众账号协议Id
+ * 支付宝userId
+ private $alipayUserId;
+ * 一卡通姓名
+ private $cardName;
+ * 一卡通卡号
+ private $cardNo;
+ * 公众账号id
+ private $publicId;
+ public function setAlipayUserId($alipayUserId)
+ $this->alipayUserId = $alipayUserId;
+ $this->apiParas["alipay_user_id"] = $alipayUserId;
+ public function getAlipayUserId()
+ return $this->alipayUserId;
+ public function setCardName($cardName)
+ $this->cardName = $cardName;
+ $this->apiParas["card_name"] = $cardName;
+ public function getCardName()
+ return $this->cardName;
+ public function setCardNo($cardNo)
+ $this->cardNo = $cardNo;
+ $this->apiParas["card_no"] = $cardNo;
+ public function getCardNo()
+ return $this->cardNo;
+ public function setPublicId($publicId)
+ $this->publicId = $publicId;
+ $this->apiParas["public_id"] = $publicId;
+ public function getPublicId()
+ return $this->publicId;
+ return "alipay.ecard.edu.public.bind";