wuliangbo
5 years ago
23 changed files with 248 additions and 846 deletions
@ -1,21 +0,0 @@
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT) |
||||
|
||||
Copyright (c) wjunying |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is furnished |
||||
to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
THE SOFTWARE. |
@ -1,114 +0,0 @@
@@ -1,114 +0,0 @@
|
||||
# Alibaba Cloud SDK for PHP |
||||
|
||||
<https://www.alibabacloud.com/> |
||||
|
||||
Copyright 1999-2019 Alibaba Group. or its affiliates. All Rights Reserved. |
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"). |
||||
You may not use this file except in compliance with the License. |
||||
A copy of the License is located at |
||||
|
||||
<http://www.apache.org/licenses/LICENSE-2.0> |
||||
|
||||
or in the "license" file accompanying this file. This file is distributed |
||||
on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
||||
express or implied. See the License for the specific language governing |
||||
permissions and limitations under the License. |
||||
|
||||
# Guzzle |
||||
|
||||
<https://github.com/guzzle/guzzle> |
||||
|
||||
Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
THE SOFTWARE. |
||||
|
||||
# |
||||
|
||||
<https://github.com/silexphp/Pimple> |
||||
|
||||
Copyright (c) 2009-2018 Fabien Potencier |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is furnished |
||||
to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
THE SOFTWARE. |
||||
|
||||
# Symfony |
||||
|
||||
<https://github.com/symfony/symfony> |
||||
|
||||
Copyright (c) 2004-2019 Fabien Potencier |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is furnished |
||||
to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
THE SOFTWARE. |
||||
|
||||
# EasyWeChat |
||||
|
||||
<https://github.com/overtrue/wechat> |
||||
|
||||
The MIT License (MIT) |
||||
|
||||
Copyright (c) overtrue <i@overtrue.me> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
@ -1,83 +0,0 @@
@@ -1,83 +0,0 @@
|
||||
## EasyAlipay |
||||
|
||||
EasyAlipay 是基于支付宝OpenAPI开源的PHP语言版本SDK。使用本SDK前你需要具备基础的PHP相关能力,掌握自动加载,[Composer](https://getcomposer.org/)的使用等,并了解[支付宝的相关业务](https://docs.open.alipay.com/api)。 |
||||
|
||||
## 1.0.0 🎉🎉🎉 |
||||
EsayAlipay 1.0.0 首次发布,欢迎加入下方的钉钉群一起交流,我们致力于打造一个方便开发者快速接入支付宝业务的SDK。本SDK针对通用授权、支付、小程序、生活号、营销等场景做了业务模型封装,并在持续增加中。同时对API参数做了最简单处理,以最少可用原则精简了参数,方便开发者更快的使用,降低开发者门槛。 |
||||
|
||||
## 一、背景 |
||||
|
||||
开发者在接入支付宝的过程中经常遇到想开发一个功能但是不清楚应该使用哪个API,找到对应API后参数又过于复杂不清楚哪些参数是自己真正要使用的。针对这种情况EsayAlipay主要在方法层面对API进行模型化归类,在参数层面对复杂参数进行简化,用最少的参数覆盖最高频的调用,不求百分百覆盖所有场景。 |
||||
|
||||
## 二、功能简介 |
||||
|
||||
EasyAlipay 提供了以下的能力: |
||||
|
||||
### 2.1 纯PHP语言开发不采用任何框架 |
||||
|
||||
提供给开发者一个最干净的SDK,开发者在使用时候可以直接引入到任何PHP框架中。 |
||||
|
||||
### 2.2 Composer管理 |
||||
|
||||
本SDK相关依赖全部采用Composer管理。 |
||||
|
||||
### 2.3 业务场景封装 |
||||
|
||||
对通用授权、支付、小程序、生活号、营销等场景做了简单业务封装,并在持续增加中。 |
||||
|
||||
### 2.4 参数精简 |
||||
|
||||
基于最少可用原则对参数做了精简,每个方法对应对原生OpenAPI都在对应场景目录下Model目录中的每个文件中做了注释说明,如果精简后的参数不能满足您的使用需求,可直接在文件中添加对应参数。 |
||||
## 三、环境需求 |
||||
```php |
||||
PHP >= 7.0 |
||||
PHP cURL 扩展 |
||||
PHP OpenSSL 扩展 |
||||
PHP fileinfo 扩展 |
||||
``` |
||||
## 四、快速开始 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
'app_id' => '你的应用APPID', |
||||
'gateway_url' => "网关地址",//沙箱环境网关gateway_url:https://openapi.alipaydev.com/gateway.do,线上网关gateway_url:https://openapi.alipay.com/gateway.do |
||||
'sign_type' => "RSA2", |
||||
'charset' => "UTF-8", |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
//通用基础 |
||||
$app = Factory::base($options); |
||||
//营销 |
||||
$app = Factory::marketing($options); |
||||
//小程序 |
||||
$app = Factory::mini($options); |
||||
//生活号 |
||||
$app = Factory::openPublic($options); |
||||
//支付 |
||||
$app = Factory::payment($options); |
||||
|
||||
``` |
||||
支付宝公钥与应用私钥配置请参考:[三步搞定签名](https://docs.open.alipay.com/291/106103/) |
||||
|
||||
创建应用地址:[支付宝开放平台](https://openhome.alipay.com) |
||||
|
||||
支付宝小程序门户:[小程序开发平台](https://mini.open.alipay.com) |
||||
|
||||
## 五、文档与示例 |
||||
|
||||
请参考 docs目录下的相关文档,里面有具体每个方法每个参数的详细说明,文档目录与代码结构保持一致方便开发者理解。在工程的 tests 目录下 test.php文件中提供了一个沙箱环境交易查询的示例。 |
||||
|
||||
## 六、开源许可 |
||||
|
||||
EasyAlipay 参考依赖了一些三方组件,在NOTICE中引入了他们的开源协议。 |
||||
|
||||
|
||||
## 七、信息交流 |
||||
|
||||
欢迎加入EasyAlipay钉钉交流群:23311489 |
||||
|
||||
<img src="https://gw.alipayobjects.com/mdn/rms_1e5ba1/afts/img/A*7sA8Tpin7f0AAAAAAAAAAABkARQnAQ" width=256 height=256> |
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
## 换取授权访问令牌 |
||||
|
||||
##### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::base($options); |
||||
|
||||
$app['oauth']->getToken($grant_type, $code,$refresh_token); |
||||
|
||||
``` |
||||
|
||||
参数说明 |
||||
|
||||
grant_type:值为authorization_code时,代表用code换取;值为refresh_token时,代表用refresh_token换取 |
||||
|
||||
code:授权码,用户对应用授权后得到。 |
||||
|
||||
refresh_token:刷刷新令牌,上次换取访问令牌时得到。见出参的refresh_token字段,可传null。 |
@ -1,162 +0,0 @@
@@ -1,162 +0,0 @@
|
||||
## 支付宝卡包 |
||||
产品文档:https://docs.alipay.com/mini/introduce/voucher |
||||
|
||||
#### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::marketing($options); |
||||
``` |
||||
|
||||
#### 卡券模板创建 |
||||
```php |
||||
$app['pass']->createTemplate($tpl_id,$tpl_content); |
||||
``` |
||||
参数说明 |
||||
|
||||
tpl_id:商户用于控制模版的唯一性,长度不超过999。(可以使用时间戳保证唯一性),长度不超过30。例如:20140709150010 |
||||
|
||||
tpl_content:模板内容信息,遵循JSON规范,长度不超过99999。详情参见:[tpl_content参数说明](https://doc.open.alipay.com/doc2/detail.htm?treeId=193&articleId=105249&docType=1#tpl_content) |
||||
|
||||
#### 卡券模板更新 |
||||
```php |
||||
$app['pass']->updateTemplate($tpl_id,$tpl_content); |
||||
``` |
||||
tpl_id:商户用于控制模版的唯一性,长度不超过999。(可以使用时间戳保证唯一性),长度不超过30。例如:20140709150010 |
||||
|
||||
tpl_content:模板内容信息,遵循JSON规范,长度不超过99999。详情参见:[tpl_content参数说明](https://doc.open.alipay.com/doc2/detail.htm?treeId=193&articleId=105249&docType=1#tpl_content) |
||||
|
||||
|
||||
#### 卡券实例发放 |
||||
```php |
||||
$app['pass']->addInstance($tpl_id,$tpl_params,$recognition_type,$recognition_info); |
||||
``` |
||||
tpl_id:商户用于控制模版的唯一性,长度不超过999。例如:20140709150010 |
||||
|
||||
tpl_params:模版动态参数信息:对应模板中$变量名$的动态参数,见模板创建接口返回值中的tpl_params字段,长度不超过99999。 |
||||
|
||||
recognition_type:Alipass添加对象识别类型:1–订单信息。长度不超过999。 |
||||
|
||||
recognition_info:支付宝用户识别信息,长度不超过999。 包括partner_id(商户的签约账号)和out_trade_no(某笔订单号)。例如:{"partner_id":"2088102114633762","out_trade_no":"1234567"} |
||||
|
||||
#### 卡券实例更新 |
||||
```php |
||||
$app['pass']->updateInstance($serial_number,$channel_id,$tpl_params,$status,$verify_code,$verify_type); |
||||
``` |
||||
参数说明 |
||||
|
||||
serial_number:商户指定卡券唯一值,卡券JSON模板中fileInfo->serialNumber字段对应的值,长度不超过999。 |
||||
|
||||
channel_id:代理商代替商户发放卡券后,再代替商户更新卡券时,此值为商户的pid/appid,长度不超过999。 |
||||
|
||||
tpl_params:对应模板中$变量名$的动态参数,见模板创建接口返回值中的tpl_params字段,长度不超过99999。 |
||||
|
||||
status:券状态,支持更新为USED、CLOSED两种状态 |
||||
|
||||
verify_code:核销码串值【当状态变更为USED时,建议传】。该值正常为模板中核销区域(Operation)对应的message值。长度不超过999。 |
||||
|
||||
verify_type:核销方式,该值正常为模板中核销区域(Operation)对应的format值。verify_code和verify_type需同时传入,长度不超过99999。 |
||||
|
||||
#### tpl_content示例 |
||||
```php |
||||
{ |
||||
"logo": "https://alipass.alipay.com//temps/free/logo.png", |
||||
"strip": "https://alipass.alipay.com//temps/free/strip.png", |
||||
"icon": "http://alipassprod.test.alipay.net/temps/free/icon.png", |
||||
"content": { |
||||
"evoucherInfo": { |
||||
"title": "优惠券", |
||||
"type": "boardingPass", |
||||
"product": "free", |
||||
"startDate": "2019-07-25 15:05:22", |
||||
"endDate": "2029-12-31 23:59:59", |
||||
"operation": [{ |
||||
"message": "$ackCode$", |
||||
"messageEncoding": "UTF-8", |
||||
"format": "barcode", |
||||
"altText": "$ackCode$" |
||||
}], |
||||
"einfo": { |
||||
"logoText": "优惠券", |
||||
"headFields": [{ |
||||
"key": "status", |
||||
"label": "状态", |
||||
"value": "可使用", |
||||
"type": "text" |
||||
}], |
||||
"primaryFields": [{ |
||||
"key": "strip", |
||||
"label": "", |
||||
"value": "凭此券即可抵扣1元", |
||||
"type": "text" |
||||
}], |
||||
"secondaryFields": [{ |
||||
"key": "validDate", |
||||
"label": "有效期至:", |
||||
"value": "2029-12-31 23:59:59", |
||||
"type": "text" |
||||
}], |
||||
"auxiliaryFields": [{ |
||||
"key": "key_1", |
||||
"label": "", |
||||
"value": "卡券Demo演示", |
||||
"type": "text" |
||||
}], |
||||
"backFields": [{ |
||||
"key": "description", |
||||
"label": "详情描述", |
||||
"value": "1.该优惠有效期:截止至2029年12月31日;2.凭此券可以享受以下优惠:享门抵扣1元不与其他优惠同享。详询商家。", |
||||
"type": "text" |
||||
}] |
||||
}, |
||||
"locations": [], |
||||
"remindInfo": { |
||||
"offset": "2" |
||||
} |
||||
}, |
||||
"merchant": { |
||||
"mname": "君泓测试", |
||||
"mtel": "", |
||||
"minfo": "" |
||||
}, |
||||
"platform": { |
||||
"channelID": "2088201564809153", |
||||
"webServiceUrl": "https://alipass.alipay.com/builder/syncRecord.htm?tempId=2019030622051381011176571" |
||||
}, |
||||
"style": { |
||||
"backgroundColor": "RGB(255,126,0)" |
||||
}, |
||||
"fileInfo": { |
||||
"formatVersion": "2", |
||||
"canShare": true, |
||||
"canBuy": false, |
||||
"canPresent": false, |
||||
"serialNumber": "$serialNumber$", |
||||
"supportTaxi": "false", |
||||
"taxiSchemaUrl": "alipays://platformapi/startapp?appId=20000778&bizid=260&channel=71322" |
||||
}, |
||||
"appInfo": { |
||||
"app": { |
||||
"android_appid": "com.taobao.ecoupon", |
||||
"ios_appid": "taobaolife://", |
||||
"android_launch": "com.taobao.ecoupon", |
||||
"ios_launch": "taobaolife://", |
||||
"android_download": "http://download.taobaocdn.com/freedom/17988/andriod/Ecoupon_2.0.1_taobao_wap.apk", |
||||
"ios_download": "https://itunes.apple.com/cn/app/id583295537" |
||||
}, |
||||
"label": "券券APP", |
||||
"message": "点击调起APP" |
||||
}, |
||||
"source": "alipassprod", |
||||
"alipayVerify": ["qrcode", "barcode", "text", "wave"] |
||||
} |
||||
} |
||||
``` |
@ -1,43 +0,0 @@
@@ -1,43 +0,0 @@
|
||||
## 小程序人脸采集与刷脸认证 |
||||
|
||||
##### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::mini($options); |
||||
``` |
||||
|
||||
##### 人脸采集 |
||||
|
||||
产品文档地址:https://docs.alipay.com/mini/introduce/facecapture |
||||
```php |
||||
$app['identification']->queryUserWeb($biz_id,$zim_id,$extern_param); |
||||
``` |
||||
参数说明 |
||||
|
||||
biz_id:业务流水号,需要保证唯一性,长度不超过64。例如:5456897876546767654 |
||||
|
||||
zim_id:刷脸认证标识,长度不超过64。例如:731be7f204a962b0486a9b64ea3050ae |
||||
|
||||
extern_param:扩展参数,长度不超过1024。 |
||||
|
||||
|
||||
##### 刷脸认证 |
||||
|
||||
产品文档地址:https://docs.alipay.com/mini/introduce/alipay-face-verify |
||||
```php |
||||
$app['identification']->queryCertifyzhub($biz_id,$zim_id,$face_type,$need_img); |
||||
``` |
||||
参数说明 |
||||
|
||||
biz_id:业务流水号,需要保证唯一性,长度不超过64。 |
||||
|
||||
zim_id:刷脸认证标识,长度不超过64。 |
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
## 小程序二维码 |
||||
|
||||
产品文档地址:https://docs.alipay.com/mini/introduce/qrcode |
||||
|
||||
##### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::mini($options); |
||||
|
||||
$app['qrcode']->create($url_param,$query_param,$describe); |
||||
``` |
||||
参数说明 |
||||
|
||||
url_param:小程序中能访问到的页面路径,长度不超过256。例如:page/component/component-pages/view/view |
||||
|
||||
query_param:小程序的启动参数,打开小程序的query ,在小程序 onLaunch的方法中获取,长度不超过256。例如:x=1 |
||||
|
||||
describe:对应的二维码描述,长度不超过32。 |
@ -1,24 +0,0 @@
@@ -1,24 +0,0 @@
|
||||
## 小程序文本风险识别 |
||||
|
||||
产品文档地址:https://docs.alipay.com/mini/introduce/text-identification |
||||
基于alipay.security.risk.content.detect接口进行封装 |
||||
|
||||
##### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::mini($options); |
||||
|
||||
$app['risk']->detectContent($content); |
||||
``` |
||||
参数说明 |
||||
|
||||
content:需要识别的文本,不要包含特殊字符以及双引号等可能引起json格式化错误问题的字符,长度不超过2000。例如:代办毕业证,我们最专业 |
@ -1,33 +0,0 @@
@@ -1,33 +0,0 @@
|
||||
## 小程序模版消息 |
||||
|
||||
产品文档地址:https://docs.alipay.com/mini/introduce/message |
||||
|
||||
##### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::mini($options); |
||||
|
||||
$app['templateMessage']->send($to_user_id,$form_id,$user_template_id,$page,$data); |
||||
``` |
||||
参数说明 |
||||
|
||||
to_user_id:发送消息的用户userid,长度不超过20。例如:2088102122458832 |
||||
|
||||
form_id:用户发生的交易行为的交易号,或者用户在小程序产生表单提交的表单号,用于信息发送的校验,长度不超过64。例如:2017010100000000580012345678 |
||||
|
||||
user_template_id:用户申请的模板id号,固定的模板id会发送固定的消息,长度不超过64。例如:MDI4YzIxMDE2M2I5YTQzYjUxNWE4MjA4NmU1MTIyYmM= |
||||
|
||||
page:小程序的跳转页面,用于消息中心用户点击之后详细跳转的小程序页面,长度不超过128。例如:page/component/index |
||||
|
||||
data:开发者需要发送模板消息中的自定义部分来替换模板的占位符,长度不超过2048。例如:{"keyword1": {"value" : "12:00"},"keyword2": {"value" : "20180808"},"keyword3": {"value" : "支付宝"}} |
||||
|
||||
|
@ -1,107 +0,0 @@
@@ -1,107 +0,0 @@
|
||||
## 生活号消息 |
||||
|
||||
#### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::openPublic($options); |
||||
``` |
||||
#### 创建图文消息内容 |
||||
```php |
||||
$app['message']->createImageTextContent($title, $cover, $content, $could_comment, $ctype, $benefit, $ext_tags, $login_ids); |
||||
``` |
||||
参数说明 |
||||
|
||||
title:标题,长度不超过32。 |
||||
|
||||
cover:封面图url,长度不超过255,图片尺寸为996*450,最大不超过3M,支持格式:.jpg、.png ,请先调用图片上传接口获得图片url https://oalipay-dl-django.alicdn.com/rest/1.0/image?fileIds=xxx&zoom=xxx |
||||
|
||||
content:消息正文(支持富文本),长度不超过10000。 |
||||
|
||||
could_comment:是否允许评论 T:允许 F:不允许,默认不允许 T |
||||
|
||||
ctype:图文类型 activity: 活动图文,不填默认普通图文 |
||||
|
||||
benefit:活动利益点,图文类型ctype为activity类型时才需要传,长度不超过10。例如:满**减** |
||||
|
||||
ext_tags:关键词列表,英文逗号分隔,最多不超过5个,长度不超过50。例如:关键,热度 |
||||
|
||||
login_ids:可预览支付宝账号列表,需要预览时才填写, 英文逗号分隔,最多不超过10个,长度不超过10000。例如:13434343432,xxx@163.com |
||||
|
||||
|
||||
#### 更新图文消息内容 |
||||
```php |
||||
$app['message']->modifyImageTextContent($content_id, $title, $cover, $content, $could_comment, $ctype, $benefit, $ext_tags, $login_ids); |
||||
``` |
||||
参数说明 |
||||
|
||||
content_id:内容id,长度不超过100。 |
||||
|
||||
title:标题,长度不超过32。 |
||||
|
||||
cover:封面图url,长度不超过255,图片尺寸为996*450,最大不超过3M,支持格式:.jpg、.png ,请先调用图片上传接口获得图片url https://docs.open.alipay.com/api_3/alipay.offline.material.image.upload |
||||
|
||||
content:消息正文(支持富文本),长度不超过10000。 |
||||
|
||||
could_comment:是否允许评论 T:允许 F:不允许,默认不允许 T |
||||
|
||||
ctype:图文类型 activity: 活动图文,不填默认普通图文 |
||||
|
||||
benefit:活动利益点,图文类型ctype为activity类型时才需要传,长度不超过10。例如:满**减** |
||||
|
||||
ext_tags:关键词列表,英文逗号分隔,最多不超过5个,长度不超过50。例如:关键,热度 |
||||
|
||||
login_ids:可预览支付宝账号列表,需要预览时才填写, 英文逗号分隔,最多不超过10个,长度不超过10000。例如:13434343432,xxx@163.com |
||||
|
||||
|
||||
#### 群发文本消息 |
||||
```php |
||||
$app['message']->sendText($text); |
||||
``` |
||||
参数说明 |
||||
|
||||
text:文本消息内容 |
||||
|
||||
|
||||
#### 群发图文消息 |
||||
```php |
||||
$app['message']->sendImageText($articles); |
||||
``` |
||||
参数说明 |
||||
|
||||
articles示例如下 |
||||
```php |
||||
"articles":[{ |
||||
"title":"图文消息标题(长度不超过100)", |
||||
"desc":"图文消息内容(长度不超过512)", |
||||
"image_url":"图片链接,例如:http://example.com/abc.jpg(长度不超过100)", |
||||
"url":"点击图文消息跳转的链接,例如:https://www.example.com/b.php(长度不超过100)", |
||||
"action_name":"链接文字,例如:查看详情" |
||||
}] |
||||
``` |
||||
#### 查询已发送消息 |
||||
```php |
||||
$app['message']->query($message_ids); |
||||
``` |
||||
参数说明 |
||||
|
||||
message_ids:消息id集,长度不超过64,限制最多传入20个message_id。message_id在调用群发、组发消息接口时会返回,需调用方保存。例如:2017080301329810fa9f7ca2-4634-481b-bca2-54092fd4be72 |
||||
|
||||
|
||||
#### 消息撤回 |
||||
```php |
||||
$app['message']->recall($message_id); |
||||
``` |
||||
参数说明 |
||||
|
||||
message_id:消息id,长度不超过64。例如:2016000000000000 |
||||
|
||||
|
@ -1,44 +0,0 @@
@@ -1,44 +0,0 @@
|
||||
## 生活号消息模版 |
||||
|
||||
#### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::openPublic($options); |
||||
``` |
||||
#### 模板消息行业设置修改 |
||||
```php |
||||
$app['template']->setIndustry($primary_industry_name,$primary_industry_code,$secondary_industry_code,$secondary_industry_name); |
||||
``` |
||||
参数说明 |
||||
|
||||
primary_industry_name:服务窗消息模板所属主行业一/二级名称,长度不超过30。例如:IT科技/IT软件与服务。查看行业信息:https://alipay.open.taobao.com/doc2/detail?treeId=197&docType=1&articleId=105043 |
||||
|
||||
primary_industry_code:服务窗消息模板所属主行业一/二级编码,长度不超过20。例如:10001/20102 |
||||
|
||||
secondary_industry_code:服务窗消息模板所属副行业一/二级编码,长度不超过20。例如:10001/20102 |
||||
|
||||
secondary_industry_name:服务窗消息模板所属副行业一/二级名称,长度不超过30。例如:IT科技/IT软件与服务 |
||||
|
||||
|
||||
#### 查询行业设置 |
||||
```php |
||||
$app['template']->getIndustry(); |
||||
``` |
||||
|
||||
#### 消息模板领取 |
||||
```php |
||||
$app['template']->getTemplate($template_id); |
||||
``` |
||||
参数说明 |
||||
|
||||
template_id:消息母板id,长度不超过20。登陆生活号后台(fuwu.alipay.com),点击菜单“模板消息”,点击“模板库”,即可看到相应模板的消息母板id。 |
||||
|
@ -1,22 +0,0 @@
@@ -1,22 +0,0 @@
|
||||
## 交易取消 |
||||
|
||||
##### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::payment($options); |
||||
|
||||
$app['cancel']->cancel($out_trade_no); |
||||
``` |
||||
参数说明 |
||||
|
||||
out_trade_no:订单支付时传入的商户订单号,长度不超过64。 |
||||
|
@ -1,24 +0,0 @@
@@ -1,24 +0,0 @@
|
||||
## 交易关闭 |
||||
|
||||
用于交易创建后,用户在一定时间内未进行支付,可调用该接口直接将未付款的交易进行关闭。 |
||||
|
||||
##### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::payment($options); |
||||
|
||||
$app['close']->close($out_trade_no); |
||||
``` |
||||
参数说明 |
||||
|
||||
out_trade_no:订单支付时传入的商户订单号,长度不超过64。 |
||||
|
@ -1,29 +0,0 @@
@@ -1,29 +0,0 @@
|
||||
## 交易创建 |
||||
|
||||
#### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::payment($options); |
||||
|
||||
$app['create']-> create($subject,$out_trade_no,$total_amount,$buyer_id); |
||||
|
||||
``` |
||||
参数说明 |
||||
|
||||
subject:订单标题,长度不超过256。 |
||||
|
||||
out_trade_no:订单支付时传入的商户订单号,长度不超过64。 |
||||
|
||||
total_amount:订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000] |
||||
|
||||
buyer_id:买家的支付宝唯一用户号(2088开头的16位纯数字) |
||||
|
@ -1,29 +0,0 @@
@@ -1,29 +0,0 @@
|
||||
## 交易支付 |
||||
|
||||
#### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::payment($options); |
||||
|
||||
$app['pay']->pay($subject,$out_trade_no,$total_amount,$auth_code); |
||||
``` |
||||
|
||||
参数说明 |
||||
|
||||
subject:订单标题,长度不超过256。 |
||||
|
||||
out_trade_no:订单支付时传入的商户订单号,长度不超过64。 |
||||
|
||||
total_amount:订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000] |
||||
|
||||
auth_code:支付授权码,25~30开头的长度为16~24位的数字,实际字符串长度以开发者获取的付款码长度为准 |
||||
|
@ -1,23 +0,0 @@
@@ -1,23 +0,0 @@
|
||||
## 交易查询 |
||||
|
||||
#### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::payment($options); |
||||
|
||||
$app['query']->query($out_trade_no));` |
||||
``` |
||||
参数说明 |
||||
|
||||
out_trade_no:out_trade_no:订单支付时传入的商户订单号,长度不超过64。 |
||||
|
||||
|
@ -1,26 +0,0 @@
@@ -1,26 +0,0 @@
|
||||
## 交易退款 |
||||
|
||||
当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付款退还给买家,支付宝将在收到退款请求并且验证成功之后,按照退款规则将支付款按原路退到买家帐号上。 交易超过约定时间(签约时设置的可退款时间)的订单无法进行退款。一笔退款失败后重新提交,要采用原来的退款单号。总退款金额不能超过用户实际支付金额。 |
||||
|
||||
##### 配置 |
||||
```php |
||||
use EasyAlipay\Factory; |
||||
|
||||
$options = [ |
||||
|
||||
'app_id' => '2016051900098985', |
||||
'alipay_public_key' => '支付宝公钥', |
||||
'merchant_private_key' => '应用私钥', |
||||
// ... |
||||
]; |
||||
|
||||
$app = Factory::payment($options); |
||||
|
||||
$app['refund']->refund($out_trade_no, $refund_amount); |
||||
``` |
||||
参数说明 |
||||
|
||||
out_trade_no:订单支付时传入的商户订单号,长度不超过64。 |
||||
refund_amount:需要退款的金额,该金额不能大于订单金额,单位为元,支持两位小数 |
||||
|
||||
|
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
<?php |
||||
|
||||
namespace EasyAlipay\Payment\Fund; |
||||
|
||||
use EasyAlipay\Kernel\AppClient; |
||||
use EasyAlipay\Kernel\AppRequest; |
||||
use EasyAlipay\Payment\Model\AlipayTradeCloseContentBuilder; |
||||
|
||||
class Client extends AppClient |
||||
{ |
||||
/** |
||||
* 关闭订单 |
||||
* @param string $out_trade_no |
||||
* @return \EasyAlipay\Kernel\Support\Collection |
||||
* @throws \EasyAlipay\Kernel\Exceptions\BadRequestException |
||||
* @throws \EasyAlipay\Kernel\Exceptions\InvalidArgumentException |
||||
* @throws \EasyAlipay\Kernel\Exceptions\InvalidConfigException |
||||
* @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException |
||||
* @throws \GuzzleHttp\Exception\GuzzleException |
||||
*/ |
||||
public function close(string $out_trade_no) |
||||
{ |
||||
//构造查询业务请求参数对象 |
||||
$closeContentBuilder = new AlipayTradeCloseContentBuilder(); |
||||
$closeContentBuilder->setOutTradeNo($out_trade_no); |
||||
$request = new AppRequest (); |
||||
$request->setBizContent($closeContentBuilder->getBizContent()); |
||||
$request->setApiMethodName("alipay.trade.close"); |
||||
return($this->execute($request)) ; |
||||
} |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
namespace EasyAlipay\Payment\Fund; |
||||
|
||||
use Pimple\Container; |
||||
use Pimple\ServiceProviderInterface; |
||||
|
||||
class ServiceProvider implements ServiceProviderInterface |
||||
{ |
||||
public function register(Container $app) |
||||
{ |
||||
$app['fund'] = function ($app) { |
||||
return new Client($app); |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,164 @@
@@ -0,0 +1,164 @@
|
||||
<?php |
||||
/** |
||||
* Created by PhpStorm. |
||||
* User: wuliangbo |
||||
* Date: 2020/3/6 |
||||
* Time: 15:32 |
||||
*/ |
||||
|
||||
namespace EasyAlipay\Payment\Model; |
||||
class AlipayFundTransUniTransferContentBuilder extends BaseContentBuilder |
||||
{ |
||||
/** |
||||
* 唯一订单号 |
||||
* @var string |
||||
*/ |
||||
protected $outBizNo; |
||||
/** |
||||
* 转账金额 |
||||
* @var string |
||||
*/ |
||||
protected $transAmount; |
||||
/** |
||||
* 业务产品码 STD_RED_PACKET|TRANS_ACCOUNT_NO_PWD|TRANS_BANKCARD_NO_PWD |
||||
* @var string |
||||
*/ |
||||
protected $productCode = 'TRANS_ACCOUNT_NO_PWD'; |
||||
/** |
||||
* 特定场景描述 PERSONAL_COLLECTION|DIRECT_TRANSFER |
||||
* @var string |
||||
*/ |
||||
protected $bizScene; |
||||
/** |
||||
* 原支付宝业务单号 C2C现金红包-红包领取时,传红包支付时返回的支付宝单号 |
||||
* @var string |
||||
*/ |
||||
protected $originalOrderId; |
||||
/** |
||||
* 收款方信息 |
||||
* @var array |
||||
*/ |
||||
protected $payeeInfo = [ |
||||
'identity' => '', |
||||
'identity_type' => 'ALIPAY_USER_ID', |
||||
'name' => '' |
||||
]; |
||||
/** |
||||
* 业务备注 |
||||
* @var string |
||||
*/ |
||||
protected $remark; |
||||
/** |
||||
* 转账标题 |
||||
* @var string |
||||
*/ |
||||
protected $orderTitle; |
||||
/** |
||||
* 转账业务请求的扩展参数 |
||||
* @var string |
||||
*/ |
||||
protected $businessParams; |
||||
|
||||
/** |
||||
* 获取唯一订单号 |
||||
* @return string |
||||
*/ |
||||
public function getOutBizNo() |
||||
{ |
||||
return $this->outBizNo; |
||||
} |
||||
|
||||
/** |
||||
* 设置唯一订单号 |
||||
* @param $outBizNo |
||||
*/ |
||||
public function setOutBizNo($outBizNo) |
||||
{ |
||||
$this->outBizNo = $outBizNo; |
||||
$this->bizContentarr['out_biz_no'] = $outBizNo; |
||||
} |
||||
|
||||
public function getTransAmount() |
||||
{ |
||||
return $this->transAmount; |
||||
} |
||||
|
||||
public function setTransAmount($transAmount) |
||||
{ |
||||
$this->transAmount = $transAmount; |
||||
$this->bizContentarr['trans_amount'] = $transAmount; |
||||
} |
||||
|
||||
public function getBizScene() |
||||
{ |
||||
return $this->bizScene; |
||||
} |
||||
|
||||
public function setBizScene($bizScene) |
||||
{ |
||||
$this->bizScene = $bizScene; |
||||
$this->bizContentarr['biz_scene'] = $bizScene; |
||||
} |
||||
|
||||
public function getOrderTitle() |
||||
{ |
||||
return $this->orderTitle; |
||||
} |
||||
|
||||
public function setOrderTitle($orderTitle) |
||||
{ |
||||
$this->orderTitle = $orderTitle; |
||||
$this->bizContentarr['order_title'] = $orderTitle; |
||||
} |
||||
|
||||
public function getOriginalOrderId() |
||||
{ |
||||
return $this->originalOrderId; |
||||
} |
||||
|
||||
public function setOriginalOrderId($originalOrderId) |
||||
{ |
||||
$this->originalOrderId = $originalOrderId; |
||||
$this->bizContentarr['original_order_id'] = $originalOrderId; |
||||
} |
||||
|
||||
public function setIdentity($identity) |
||||
{ |
||||
$this->payeeInfo['identity'] = $identity; |
||||
$this->bizContentarr['payee_info'] = $this->payeeInfo; |
||||
} |
||||
|
||||
public function setIdentityType($identityType) |
||||
{ |
||||
$this->payeeInfo['identity_type'] = $identityType; |
||||
$this->bizContentarr['payee_info'] = $this->payeeInfo; |
||||
} |
||||
|
||||
public function setIdentityName($name) |
||||
{ |
||||
$this->payeeInfo['name'] = $name; |
||||
$this->bizContentarr['payee_info'] = $this->payeeInfo; |
||||
} |
||||
|
||||
public function getRemark() |
||||
{ |
||||
return $this->remark; |
||||
} |
||||
|
||||
public function setRemark($remark) |
||||
{ |
||||
$this->remark = $remark; |
||||
$this->bizContentarr['remark'] = $remark; |
||||
} |
||||
|
||||
public function getBusinessParams() |
||||
{ |
||||
return $this->remark; |
||||
} |
||||
|
||||
public function setBusinessParams($businessParams) |
||||
{ |
||||
$this->businessParams = $businessParams; |
||||
$this->bizContentarr['business_params'] = $businessParams; |
||||
} |
||||
} |
Loading…
Reference in new issue