作者 lihan
1 个管道 的构建 通过 耗费 1 秒

支付宝

正在显示 32 个修改的文件 包含 0 行增加4829 行删除

要显示太多修改。

为保证性能只显示 32 of 32+ 个文件。

1 -# Auto detect text files and perform LF normalization  
2 -* text=auto  
1 -Apache License  
2 - Version 2.0, January 2004  
3 - http://www.apache.org/licenses/  
4 -  
5 - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION  
6 -  
7 - 1. Definitions.  
8 -  
9 - "License" shall mean the terms and conditions for use, reproduction,  
10 - and distribution as defined by Sections 1 through 9 of this document.  
11 -  
12 - "Licensor" shall mean the copyright owner or entity authorized by  
13 - the copyright owner that is granting the License.  
14 -  
15 - "Legal Entity" shall mean the union of the acting entity and all  
16 - other entities that control, are controlled by, or are under common  
17 - control with that entity. For the purposes of this definition,  
18 - "control" means (i) the power, direct or indirect, to cause the  
19 - direction or management of such entity, whether by contract or  
20 - otherwise, or (ii) ownership of fifty percent (50%) or more of the  
21 - outstanding shares, or (iii) beneficial ownership of such entity.  
22 -  
23 - "You" (or "Your") shall mean an individual or Legal Entity  
24 - exercising permissions granted by this License.  
25 -  
26 - "Source" form shall mean the preferred form for making modifications,  
27 - including but not limited to software source code, documentation  
28 - source, and configuration files.  
29 -  
30 - "Object" form shall mean any form resulting from mechanical  
31 - transformation or translation of a Source form, including but  
32 - not limited to compiled object code, generated documentation,  
33 - and conversions to other media types.  
34 -  
35 - "Work" shall mean the work of authorship, whether in Source or  
36 - Object form, made available under the License, as indicated by a  
37 - copyright notice that is included in or attached to the work  
38 - (an example is provided in the Appendix below).  
39 -  
40 - "Derivative Works" shall mean any work, whether in Source or Object  
41 - form, that is based on (or derived from) the Work and for which the  
42 - editorial revisions, annotations, elaborations, or other modifications  
43 - represent, as a whole, an original work of authorship. For the purposes  
44 - of this License, Derivative Works shall not include works that remain  
45 - separable from, or merely link (or bind by name) to the interfaces of,  
46 - the Work and Derivative Works thereof.  
47 -  
48 - "Contribution" shall mean any work of authorship, including  
49 - the original version of the Work and any modifications or additions  
50 - to that Work or Derivative Works thereof, that is intentionally  
51 - submitted to Licensor for inclusion in the Work by the copyright owner  
52 - or by an individual or Legal Entity authorized to submit on behalf of  
53 - the copyright owner. For the purposes of this definition, "submitted"  
54 - means any form of electronic, verbal, or written communication sent  
55 - to the Licensor or its representatives, including but not limited to  
56 - communication on electronic mailing lists, source code control systems,  
57 - and issue tracking systems that are managed by, or on behalf of, the  
58 - Licensor for the purpose of discussing and improving the Work, but  
59 - excluding communication that is conspicuously marked or otherwise  
60 - designated in writing by the copyright owner as "Not a Contribution."  
61 -  
62 - "Contributor" shall mean Licensor and any individual or Legal Entity  
63 - on behalf of whom a Contribution has been received by Licensor and  
64 - subsequently incorporated within the Work.  
65 -  
66 - 2. Grant of Copyright License. Subject to the terms and conditions of  
67 - this License, each Contributor hereby grants to You a perpetual,  
68 - worldwide, non-exclusive, no-charge, royalty-free, irrevocable  
69 - copyright license to reproduce, prepare Derivative Works of,  
70 - publicly display, publicly perform, sublicense, and distribute the  
71 - Work and such Derivative Works in Source or Object form.  
72 -  
73 - 3. Grant of Patent License. Subject to the terms and conditions of  
74 - this License, each Contributor hereby grants to You a perpetual,  
75 - worldwide, non-exclusive, no-charge, royalty-free, irrevocable  
76 - (except as stated in this section) patent license to make, have made,  
77 - use, offer to sell, sell, import, and otherwise transfer the Work,  
78 - where such license applies only to those patent claims licensable  
79 - by such Contributor that are necessarily infringed by their  
80 - Contribution(s) alone or by combination of their Contribution(s)  
81 - with the Work to which such Contribution(s) was submitted. If You  
82 - institute patent litigation against any entity (including a  
83 - cross-claim or counterclaim in a lawsuit) alleging that the Work  
84 - or a Contribution incorporated within the Work constitutes direct  
85 - or contributory patent infringement, then any patent licenses  
86 - granted to You under this License for that Work shall terminate  
87 - as of the date such litigation is filed.  
88 -  
89 - 4. Redistribution. You may reproduce and distribute copies of the  
90 - Work or Derivative Works thereof in any medium, with or without  
91 - modifications, and in Source or Object form, provided that You  
92 - meet the following conditions:  
93 -  
94 - (a) You must give any other recipients of the Work or  
95 - Derivative Works a copy of this License; and  
96 -  
97 - (b) You must cause any modified files to carry prominent notices  
98 - stating that You changed the files; and  
99 -  
100 - (c) You must retain, in the Source form of any Derivative Works  
101 - that You distribute, all copyright, patent, trademark, and  
102 - attribution notices from the Source form of the Work,  
103 - excluding those notices that do not pertain to any part of  
104 - the Derivative Works; and  
105 -  
106 - (d) If the Work includes a "NOTICE" text file as part of its  
107 - distribution, then any Derivative Works that You distribute must  
108 - include a readable copy of the attribution notices contained  
109 - within such NOTICE file, excluding those notices that do not  
110 - pertain to any part of the Derivative Works, in at least one  
111 - of the following places: within a NOTICE text file distributed  
112 - as part of the Derivative Works; within the Source form or  
113 - documentation, if provided along with the Derivative Works; or,  
114 - within a display generated by the Derivative Works, if and  
115 - wherever such third-party notices normally appear. The contents  
116 - of the NOTICE file are for informational purposes only and  
117 - do not modify the License. You may add Your own attribution  
118 - notices within Derivative Works that You distribute, alongside  
119 - or as an addendum to the NOTICE text from the Work, provided  
120 - that such additional attribution notices cannot be construed  
121 - as modifying the License.  
122 -  
123 - You may add Your own copyright statement to Your modifications and  
124 - may provide additional or different license terms and conditions  
125 - for use, reproduction, or distribution of Your modifications, or  
126 - for any such Derivative Works as a whole, provided Your use,  
127 - reproduction, and distribution of the Work otherwise complies with  
128 - the conditions stated in this License.  
129 -  
130 - 5. Submission of Contributions. Unless You explicitly state otherwise,  
131 - any Contribution intentionally submitted for inclusion in the Work  
132 - by You to the Licensor shall be under the terms and conditions of  
133 - this License, without any additional terms or conditions.  
134 - Notwithstanding the above, nothing herein shall supersede or modify  
135 - the terms of any separate license agreement you may have executed  
136 - with Licensor regarding such Contributions.  
137 -  
138 - 6. Trademarks. This License does not grant permission to use the trade  
139 - names, trademarks, service marks, or product names of the Licensor,  
140 - except as required for reasonable and customary use in describing the  
141 - origin of the Work and reproducing the content of the NOTICE file.  
142 -  
143 - 7. Disclaimer of Warranty. Unless required by applicable law or  
144 - agreed to in writing, Licensor provides the Work (and each  
145 - Contributor provides its Contributions) on an "AS IS" BASIS,  
146 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
147 - implied, including, without limitation, any warranties or conditions  
148 - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A  
149 - PARTICULAR PURPOSE. You are solely responsible for determining the  
150 - appropriateness of using or redistributing the Work and assume any  
151 - risks associated with Your exercise of permissions under this License.  
152 -  
153 - 8. Limitation of Liability. In no event and under no legal theory,  
154 - whether in tort (including negligence), contract, or otherwise,  
155 - unless required by applicable law (such as deliberate and grossly  
156 - negligent acts) or agreed to in writing, shall any Contributor be  
157 - liable to You for damages, including any direct, indirect, special,  
158 - incidental, or consequential damages of any character arising as a  
159 - result of this License or out of the use or inability to use the  
160 - Work (including but not limited to damages for loss of goodwill,  
161 - work stoppage, computer failure or malfunction, or any and all  
162 - other commercial damages or losses), even if such Contributor  
163 - has been advised of the possibility of such damages.  
164 -  
165 - 9. Accepting Warranty or Additional Liability. While redistributing  
166 - the Work or Derivative Works thereof, You may choose to offer,  
167 - and charge a fee for, acceptance of support, warranty, indemnity,  
168 - or other liability obligations and/or rights consistent with this  
169 - License. However, in accepting such obligations, You may act only  
170 - on Your own behalf and on Your sole responsibility, not on behalf  
171 - of any other Contributor, and only if You agree to indemnify,  
172 - defend, and hold each Contributor harmless for any liability  
173 - incurred by, or claims asserted against, such Contributor by reason  
174 - of your accepting any such warranty or additional liability.  
175 -  
176 - END OF TERMS AND CONDITIONS  
177 -  
178 - APPENDIX: How to apply the Apache License to your work.  
179 -  
180 - To apply the Apache License to your work, attach the following  
181 - boilerplate notice, with the fields enclosed by brackets "{}"  
182 - replaced with your own identifying information. (Don't include  
183 - the brackets!) The text should be enclosed in the appropriate  
184 - comment syntax for the file format. We also recommend that a  
185 - file or class name and description of purpose be included on the  
186 - same "printed page" as the copyright notice for easier  
187 - identification within third-party archives.  
188 -  
189 - Copyright {yyyy} {name of copyright owner}  
190 -  
191 - Licensed under the Apache License, Version 2.0 (the "License");  
192 - you may not use this file except in compliance with the License.  
193 - You may obtain a copy of the License at  
194 -  
195 - http://www.apache.org/licenses/LICENSE-2.0  
196 -  
197 - Unless required by applicable law or agreed to in writing, software  
198 - distributed under the License is distributed on an "AS IS" BASIS,  
199 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
200 - See the License for the specific language governing permissions and  
201 - limitations under the License.  
1 -# ThinkPHP5 电脑与手机支付扩展库(2017年9月18日)  
2 -  
3 -## 使用说明  
4 -- 在默认配置情况下,将文件夹拷贝到根目录即可, 其中<code>extend</code>目录为支付扩展目录, <code>application\extra\alipay.php</code>为配置文件  
5 -- 需要在配置文件<code>application\extra\alipay.php</code>中填写必要的参数  
6 -  
7 -## 注意  
8 -错误采用抛出异常的方式, 可根据自己的业务在统一接口进行修改  
9 -  
10 -## 用法  
11 -#### 电脑网站支付 Pagepay.php  
12 -调用 <code>\alipay\Pagepay::pay($params)</code> 即可  
13 -  
14 -#### 手机网站支付 Wappay.php  
15 -调用 <code>\alipay\Wappay::pay($params)</code> 即可  
16 -  
17 -#### 交易查询接口 Query.php  
18 -调用 <code>\alipay\Query::exec($query_no)</code> 即可  
19 -  
20 -#### 交易退款接口 Refund.php  
21 -调用 <code>\alipay\Refund::exec($params)</code> 即可  
22 -  
23 -#### 退款统一订单查询 RefundQuery.php  
24 -调用 <code>\alipay\RefundQuery::exec($params)</code> 即可  
25 -  
26 -#### 交易关闭接口 Close.php  
27 -调用 <code>\alipay\Close::exec($query_no)</code> 即可  
28 -  
29 -#### 查询账单下载地址接口 Datadownload.php  
30 -调用 <code>\alipay\Datadownload::exec($bill_type, $bill_date)</code> 即可  
31 -  
32 -#### 验签 Notify.php  
33 -调用 <code>\alipay\Notify::check($params)</code> 即可  
34 -  
35 -#### 通知处理步骤建议  
36 -1. 验签  
37 -2. 判断订单状态  
38 -3. 进行业务操作  
39 -  
40 -###### 一下两个类仅为建议, 帮助理解, 可根据具体业务进行变更, 详细理解可参考[官方文档和SDK](https://docs.open.alipay.com/270/105902/)  
41 -- <code>application\common\NotifyHandler.php</code> 通知操作的处理类  
42 -- <code>application\example\Notify.php</code> 具体实现  
1 -<?php  
2 -  
3 -namespace app\common\controller;  
4 -  
5 -  
6 -use think\Controller;  
7 -  
8 -/**  
9 -* 通知控制器  
10 -*/  
11 -abstract class NotifyHandler extends Controller  
12 -{  
13 - protected $params;  
14 -  
15 - public function init()  
16 - {  
17 - // 1.验签和参数校检  
18 - $result = $this->checkSignAndOrder();  
19 - if($result) {  
20 - // 2.订单处理  
21 - $this->orderHandle();  
22 - echo "success"; //请不要修改或删除  
23 - } else {  
24 - echo "fail"; //请不要修改或删除  
25 - }  
26 - }  
27 -  
28 - // 1.验签和校检参数  
29 - public function checkSignAndOrder()  
30 - {  
31 - $this->getOrder();  
32 -  
33 - if(empty($this->params)) {  
34 - $this->processError('订单不存在');  
35 - }  
36 - $result = \alipay\Notify::check($this->params);  
37 -  
38 - if(!$result) {  
39 - $this->processError('校检失败');  
40 - }  
41 - return $result;  
42 - }  
43 -  
44 - // 2.订单处理  
45 - public function orderHandle()  
46 - {$_POST['trade_status'] = 'TRADE_SUCCESS';  
47 - if($_POST['trade_status'] == 'TRADE_SUCCESS') {  
48 - $orderStatus = $this->checkOrderStatus();  
49 - if(!$orderStatus) {  
50 - // 判断订单状态, 如果订单未做过处理, 则处理自己核心业务  
51 - $handlerResult = $this->handle();  
52 - if(!$handlerResult) {  
53 - // 如果订单未处理成功  
54 - exit('fail');  
55 - }  
56 - }  
57 - }  
58 - }  
59 -  
60 - /**  
61 - * 获取订单信息, 用于校检  
62 - * @return array 订单数组, 必须包含订单号和订单金额  
63 - * @param string $params['out_trade_no'] 商户订单  
64 - * @param float $params['total_amount'] 订单金额  
65 - */  
66 - abstract protected function getOrder();  
67 -  
68 - /**  
69 - * 检测订单状态, 用于判断订单是否已经做过处理  
70 - * 原因: 本次业务处理较慢, 没来得及echo 'success', 同一订单的通知多次到达, 会造成多次修改数据库, 所以有必要进行订单状态确认  
71 - *  
72 - * @return Boolean true表示已经处理过 false表示未处理过  
73 - */  
74 - abstract protected function checkOrderStatus();  
75 -  
76 - /**  
77 - * 处理自己业务  
78 - * @return Boolean true表示业务处理 false表示处理失败  
79 - */  
80 - abstract protected function handle();  
81 -  
82 - /**  
83 - * 统一错误处理接口  
84 - * @param string $msg 错误描述  
85 - */  
86 - private static function processError($msg)  
87 - {  
88 - throw new \think\Exception($msg);  
89 - }  
90 -}  
1 -<?php  
2 -  
3 -namespace app\example\controller;  
4 -  
5 -use think\Db;  
6 -use app\common\controller\NotifyHandler;  
7 -  
8 -/**  
9 -* 通知处理控制器  
10 -*  
11 -* 完善getOrder, 获取订单信息, 注意必须数组必须包含out_trade_no与total_amount  
12 -* 完善checkOrderStatus, 返回订单状态, 按要求返回布尔值  
13 -* 完善handle, 进行业务处理, 按要求返回布尔值  
14 -*  
15 -* 请求地址为index, NotifyHandler会自动调用以上三个方法  
16 -*/  
17 -class Notify extends NotifyHandler  
18 -{  
19 - protected $params; // 订单信息  
20 -  
21 - public function index()  
22 - {  
23 - parent::init();  
24 - }  
25 -  
26 - /**  
27 - * 获取订单信息, 必须包含订单号和订单金额  
28 - *  
29 - * @return string $params['out_trade_no'] 商户订单  
30 - * @return float $params['total_amount'] 订单金额  
31 - */  
32 - public function getOrder()  
33 - {  
34 - // 以下仅示例  
35 - $out_trade_no = $_POST['out_trade_no'];  
36 - $order = Db::name('order')->where('out_trade_no', $out_trade_no)->find();  
37 - $params = [  
38 - 'out_trade_no' => $order['out_trade_no'],  
39 - 'total_amount' => $order['total_amount'],  
40 - 'status' => $order['status'],  
41 - 'id' => $order['id']  
42 - ];  
43 -  
44 - $this->params = $params;  
45 - }  
46 -  
47 - /**  
48 - * 检查订单状态  
49 - *  
50 - * @return Boolean true表示已经处理过 false表示未处理过  
51 - */  
52 - public function checkOrderStatus()  
53 - {  
54 - // 以下仅示例  
55 - if($this->params['status'] == 0) {  
56 - // 表示未处理  
57 - return false;  
58 - } else {  
59 - return true;  
60 - }  
61 - }  
62 -  
63 - /**  
64 - * 业务处理  
65 - * @return Boolean true表示业务处理成功 false表示处理失败  
66 - */  
67 - public function handle()  
68 - {  
69 - // 以下仅示例  
70 - $result = Db::name('order')->where('id', $this->params['id'])->update(['status'=>1]);  
71 - if($result) {  
72 - return true;  
73 - } else {  
74 - return false;  
75 - }  
76 - }  
77 -}  
1 -<?php  
2 -/**  
3 - * 支付宝支付  
4 - */  
5 -  
6 -return [  
7 - //应用ID,您的APPID。  
8 - 'app_id' => "",  
9 -  
10 - //商户私钥, 请把生成的私钥文件中字符串拷贝在此  
11 - 'merchant_private_key' => "",  
12 -  
13 - //异步通知地址  
14 - 'notify_url' => "",  
15 -  
16 - //同步跳转  
17 - 'return_url' => "",  
18 -  
19 - //编码格式  
20 - 'charset' => "UTF-8",  
21 -  
22 - //签名方式  
23 - 'sign_type'=>"RSA2",  
24 -  
25 - //支付宝网关  
26 - 'gatewayUrl' => "https://openapi.alipay.com/gateway.do",  
27 -  
28 - //支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。  
29 - 'alipay_public_key' => "",  
30 -];  
1 -<?php  
2 -  
3 -namespace alipay;  
4 -  
5 -use think\Loader;  
6 -  
7 -Loader::import('alipay.pay.service.AlipayTradeService');  
8 -loader::import('alipay.pay.buildermodel.AlipayTradeCloseContentBuilder');  
9 -  
10 -/**  
11 -* 统一收单交易关闭接口  
12 -*  
13 -* 用法:  
14 -* 调用 \alipay\Close::exec($query_no) 即可  
15 -*  
16 -* ----------------- 求职 ------------------  
17 -* 姓名: zhangchaojie 邮箱: zhangchaojie_php@qq.com 应届生  
18 -* 期望职位: PHP初级工程师 地点: 深圳(其他城市亦可)  
19 -* 能力:  
20 -* 1.熟悉小程序开发, 前后端皆可  
21 -* 2.后端, PHP基础知识扎实, 熟悉ThinkPHP5框架, 用TP5做过CMS, 商城, API接口  
22 -* 3.MySQL, Linux都在进行进一步学习  
23 -*  
24 -*/  
25 -class Close  
26 -{  
27 - // 商户订单号(out_trade_no) or 支付宝交易号(trade_no) 二选一  
28 - const QUERY_TYPE = 'trade_no';  
29 -  
30 - public static function exec($query_no)  
31 - {  
32 - // 1.构建请求参数  
33 - $RequestBuilder = new \AlipayTradeCloseContentBuilder();  
34 - if (self::QUERY_TYPE == 'trade_no') {  
35 - $RequestBuilder->setTradeNo(trim($query_no));  
36 - } else {  
37 - $RequestBuilder->setOutTradeNo(trim($query_no));  
38 - }  
39 -  
40 - // 2.获取配置  
41 - $config = config('alipay');  
42 - $aop = new \AlipayTradeService($config);  
43 -  
44 - // 3.发起请求  
45 - $response = $aop->Close($RequestBuilder);  
46 -  
47 - // 4.转为数组格式返回  
48 - $response = json_decode(json_encode($response), true);  
49 -  
50 - // 5.进行结果处理  
51 - if (!empty($response['code']) && $response['code'] != '10000') {  
52 - self::processError('交易关闭接口出错, 错误码: '.$response['code'].' 错误原因: '.$response['sub_msg']);  
53 - }  
54 -  
55 - return $response;  
56 - }  
57 -  
58 - /**  
59 - * 统一错误处理接口  
60 - * @param string $msg 错误描述  
61 - */  
62 - private static function processError($msg)  
63 - {  
64 - throw new \think\Exception($msg);  
65 - }  
66 -}  
1 -<?php  
2 -  
3 -namespace alipay;  
4 -  
5 -use think\Loader;  
6 -  
7 -Loader::import('alipay.pay.service.AlipayTradeService');  
8 -loader::import('alipay.pay.buildermodel.AlipayDataDataserviceBillDownloadurlQueryContentBuilder');  
9 -  
10 -/**  
11 -* 查询账单下载地址接口  
12 -*  
13 -* 用法:  
14 -* 调用 \alipay\Datadownload::exec($bill_type, $bill_date) 即可  
15 -*  
16 -* ----------------- 求职 ------------------  
17 -* 姓名: zhangchaojie 邮箱: zhangchaojie_php@qq.com 应届生  
18 -* 期望职位: PHP初级工程师 地点: 深圳(其他城市亦可)  
19 -* 能力:  
20 -* 1.熟悉小程序开发, 前后端皆可  
21 -* 2.后端, PHP基础知识扎实, 熟悉ThinkPHP5框架, 用TP5做过CMS, 商城, API接口  
22 -* 3.MySQL, Linux都在进行进一步学习  
23 -*  
24 -*/  
25 -class Datadownload  
26 -{  
27 - /**  
28 - * 主入口  
29 - * @param string $bill_type trade/signcustomer, trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;  
30 - * @param string $bill_date 日期, 单格式为yyyy-MM-dd,月账单格式为yyyy-MM  
31 - * 注意:  
32 - * 1.当日或者当月日期为无效日期,毕竟没有过当日或者当月  
33 - * 2.如果是2017年7月,请填写2017-07,不能为2017-7  
34 - */  
35 - public static function exec($bill_type, $bill_date)  
36 - {  
37 - // 1.校检参数  
38 - self::checkParams($bill_type, $bill_date);  
39 -  
40 - // 2.设置请求参数  
41 - $RequestBuilder = new \AlipayDataDataserviceBillDownloadurlQueryContentBuilder();  
42 - $RequestBuilder->setBillType($bill_type);  
43 - $RequestBuilder->setBillDate($bill_date);  
44 -  
45 - // 3.获取配置  
46 - $config = config('alipay');  
47 - $Response = new \AlipayTradeService($config);  
48 -  
49 - // 4.请求  
50 - $response = $Response->downloadurlQuery($RequestBuilder);  
51 -  
52 - // 5.转为数组格式返回  
53 - $response = json_decode(json_encode($response), true);  
54 -  
55 - // 6.进行结果处理  
56 - if (!empty($response['code']) && $response['code'] != '10000') {  
57 - self::processError('查询账单接口出错, 错误码: '.$response['code'].' 错误原因: '.$response['sub_msg']);  
58 - }  
59 -  
60 - return $response;  
61 - }  
62 -  
63 - /**  
64 - * 校检参数  
65 - */  
66 - private static function checkParams($bill_type, $bill_date)  
67 - {  
68 - if (!in_array($bill_type, ['trade', 'signcustomer'])) {  
69 - self::processError('账单类型不正确');  
70 - }  
71 -  
72 - if (!strtotime($bill_date)) {  
73 - self::processError('日期格式不正确');  
74 - }  
75 - }  
76 -  
77 - /**  
78 - * 统一错误处理接口  
79 - * @param string $msg 错误描述  
80 - */  
81 - private static function processError($msg)  
82 - {  
83 - throw new \think\Exception($msg);  
84 - }  
85 -}  
1 -<?php  
2 -  
3 -namespace alipay;  
4 -  
5 -use think\Loader;  
6 -  
7 -Loader::import('alipay.pay.service.AlipayTradeService');  
8 -  
9 -/**  
10 -* 支付回调处理类  
11 -*  
12 -* 用法:  
13 -* 调用 \alipay\Pagepay::pay($params) 即可  
14 -*  
15 -* ----------------- 求职 ------------------  
16 -* 姓名: zhangchaojie 邮箱: zhangchaojie_php@qq.com 应届生  
17 -* 期望职位: PHP初级工程师 地点: 深圳(其他城市亦可)  
18 -* 能力:  
19 -* 1.熟悉小程序开发, 前后端皆可  
20 -* 2.后端, PHP基础知识扎实, 熟悉ThinkPHP5框架, 用TP5做过CMS, 商城, API接口  
21 -* 3.MySQL, Linux都在进行进一步学习  
22 -*  
23 -*/  
24 -class Notify  
25 -{  
26 - /**  
27 - * 异步通知校检, 包括验签和数据库信息与通知信息对比  
28 - *  
29 - * @param array $params 数据库中查询到的订单信息  
30 - * @param string $params['out_trade_no'] 商户订单  
31 - * @param float $params['total_amount'] 订单金额  
32 - */  
33 - public static function check($params)  
34 - {  
35 - // 1.第一步校检签名  
36 - $config = config('alipay');  
37 - $alipaySevice = new \AlipayTradeService($config);  
38 - $signResult = $alipaySevice->check($_POST);  
39 -  
40 - // 2.和数据库信息做对比  
41 - $paramsResult = self::checkParams($params);  
42 -  
43 - // 3.返回结果  
44 - if($signResult && $paramsResult) {  
45 - return true;  
46 - } else {  
47 - return false;  
48 - }  
49 - }  
50 -  
51 - /**  
52 - * 判断两个数组是否一致, 两个数组的参数如下:  
53 - * $params['out_trade_no'] 商户单号  
54 - * $params['total_amount'] 订单金额  
55 - * $params['app_id'] app_id号  
56 - */  
57 - public static function checkParams($params)  
58 - {  
59 - $notifyArr = [  
60 - 'out_trade_no' => $_POST['out_trade_no'],  
61 - 'total_amount' => $_POST['total_amount'],  
62 - 'app_id' => $_POST['app_id'],  
63 - ];  
64 - $paramsArr = [  
65 - 'out_trade_no' => $params['out_trade_no'],  
66 - 'total_amount' => $params['total_amount'],  
67 - 'app_id' => config('alipay.app_id'),  
68 - ];  
69 - $result = array_diff_assoc($paramsArr, $notifyArr);  
70 - return empty($result) ? true : false;  
71 - }  
72 -}  
1 -<?php  
2 -  
3 -namespace alipay;  
4 -  
5 -use think\Loader;  
6 -  
7 -Loader::import('alipay.pay.service.AlipayTradeService');  
8 -loader::import('alipay.pay.buildermodel.AlipayTradePagePayContentBuilder');  
9 -  
10 -/**  
11 -* 电脑网站支付(扫码支付或账号支付)  
12 -*  
13 -* 用法:  
14 -* 调用 \alipay\Pagepay::pay($params) 即可  
15 -*  
16 -* ----------------- 求职 ------------------  
17 -* 姓名: zhangchaojie 邮箱: zhangchaojie_php@qq.com  
18 -* 期望职位: PHP初级工程师 地点: 深圳(其他城市亦可)  
19 -* 能力:  
20 -* 1.熟悉小程序开发, 前后端皆可  
21 -* 2.后端, PHP基础知识扎实, 熟悉ThinkPHP5框架, 用TP5做过CMS, 商城, API接口  
22 -* 3.MySQL, Linux都在进行进一步学习  
23 -*/  
24 -class Pagepay  
25 -{  
26 - /**  
27 - * 主入口  
28 - * @param array $params 支付参数, 具体如下  
29 - * @param string $params['subject'] 订单标题  
30 - * @param string $params['out_trade_no'] 订单商户号  
31 - * @param float $params['total_amount'] 订单金额  
32 - */  
33 - public static function pay($params)  
34 - {  
35 - // 1.校检参数  
36 - self::checkParams($params);  
37 -  
38 - // 2.构造参数  
39 - $payRequestBuilder = new \AlipayTradePagePayContentBuilder();  
40 - $payRequestBuilder->setSubject($params['subject']);  
41 - $payRequestBuilder->setTotalAmount($params['total_amount']);  
42 - $payRequestBuilder->setOutTradeNo($params['out_trade_no']);  
43 -  
44 - // 3.获取配置  
45 - $config = config('alipay');  
46 - $aop = new \AlipayTradeService($config);  
47 -  
48 - /**  
49 - * 4.电脑网站支付请求(会自动跳转到支付页面)  
50 - * @param $builder 业务参数,使用buildmodel中的对象生成。  
51 - * @param $return_url 同步跳转地址,公网可以访问  
52 - * @param $notify_url 异步通知地址,公网可以访问  
53 - * @return $response 支付宝返回的信息  
54 - */  
55 - $aop->pagePay($payRequestBuilder, $config['return_url'],$config['notify_url']);  
56 - }  
57 -  
58 -  
59 - /**  
60 - * 校检参数  
61 - */  
62 - private static function checkParams($params)  
63 - {  
64 - if (empty(trim($params['out_trade_no']))) {  
65 - self::processError('商户订单号(out_trade_no)必填');  
66 - }  
67 -  
68 - if (empty(trim($params['subject']))) {  
69 - self::processError('商品标题(subject)必填');  
70 - }  
71 -  
72 - if (floatval(trim($params['total_amount'])) <= 0) {  
73 - self::processError('退款金额(total_amount)为大于0的数');  
74 - }  
75 - }  
76 -  
77 - /**  
78 - * 统一错误处理接口  
79 - * @param string $msg 错误描述  
80 - */  
81 - private static function processError($msg)  
82 - {  
83 - throw new \think\Exception($msg);  
84 - }  
85 -}  
1 -<?php  
2 -  
3 -namespace alipay;  
4 -  
5 -use think\Loader;  
6 -  
7 -Loader::import('alipay.pay.service.AlipayTradeService');  
8 -loader::import('alipay.pay.buildermodel.AlipayTradeQueryContentBuilder');  
9 -  
10 -/**  
11 -* 统一收单线下交易查询接口  
12 -*  
13 -* 用法:  
14 -* 调用 \alipay\Query::exec($query_no) 即可  
15 -*  
16 -* ----------------- 求职 ------------------  
17 -* 姓名: zhangchaojie 邮箱: zhangchaojie_php@qq.com 应届生  
18 -* 期望职位: PHP初级工程师 地点: 深圳(其他城市亦可)  
19 -* 能力:  
20 -* 1.熟悉小程序开发, 前后端皆可  
21 -* 2.后端, PHP基础知识扎实, 熟悉ThinkPHP5框架, 用TP5做过CMS, 商城, API接口  
22 -* 3.MySQL, Linux都在进行进一步学习  
23 -*  
24 -*/  
25 -class Query  
26 -{  
27 - // 商户订单号(out_trade_no) or 支付宝交易号(trade_no) 二选一  
28 - const QUERY_TYPE = 'trade_no';  
29 -  
30 - public static function exec($query_no)  
31 - {  
32 - // 1.设置请求参数  
33 - $RequestBuilder = new \AlipayTradeQueryContentBuilder();  
34 - if (self::QUERY_TYPE == 'trade_no') {  
35 - $RequestBuilder->setTradeNo(trim($query_no));  
36 - } else {  
37 - $RequestBuilder->setOutTradeNo($query_no);  
38 - }  
39 -  
40 - // 2.获取配置  
41 - $config = config('alipay');  
42 - $aop = new \AlipayTradeService($config);  
43 -  
44 - // 3.发起请求  
45 - $response = $aop->Query($RequestBuilder);  
46 -  
47 - // 4.转为数组格式返回  
48 - $response = json_decode(json_encode($response), true);  
49 -  
50 - // 5.进行结果处理  
51 - if (!empty($response['code']) && $response['code'] != '10000') {  
52 - self::processError('交易查询接口出错, 错误码: '.$response['code'].' 错误原因: '.$response['sub_msg']);  
53 - }  
54 -  
55 - return $response;  
56 - }  
57 -  
58 - /**  
59 - * 统一错误处理接口  
60 - * @param string $msg 错误描述  
61 - */  
62 - private static function processError($msg)  
63 - {  
64 - throw new \think\Exception($msg);  
65 - }  
66 -}  
1 -<?php  
2 -  
3 -namespace alipay;  
4 -  
5 -use think\Loader;  
6 -  
7 -Loader::import('alipay.pay.service.AlipayTradeService');  
8 -loader::import('alipay.pay.buildermodel.AlipayTradeRefundContentBuilder');  
9 -  
10 -/**  
11 -* 统一收单交易退款接口  
12 -*  
13 -* 用法:  
14 -* 调用 \alipay\Refund::exec($params) 即可  
15 -*  
16 -* ----------------- 求职 ------------------  
17 -* 姓名: zhangchaojie 邮箱: zhangchaojie_php@qq.com 应届生  
18 -* 期望职位: PHP初级工程师 地点: 深圳(其他城市亦可)  
19 -* 能力:  
20 -* 1.熟悉小程序开发, 前后端皆可  
21 -* 2.后端, PHP基础知识扎实, 熟悉ThinkPHP5框架, 用TP5做过CMS, 商城, API接口  
22 -* 3.MySQL, Linux都在进行进一步学习  
23 -*  
24 -*/  
25 -class Refund  
26 -{  
27 - /**  
28 - * 主入口  
29 - * @param array $params 退款参数, 具体如下  
30 - * @param string $params['trade_no']/$params['out_trade_no'] 商户订单号或支付宝单号其中之一  
31 - * @param string $params['out_request_no'] 商户退款号(可选, 如同一笔交易多次退款, 则必填)  
32 - * @param float $params['refund_amount'] 退款金额  
33 - */  
34 - public static function exec($params)  
35 - {  
36 - // 1.校检参数  
37 - self::checkParams($params);  
38 -  
39 - // 2.构造请求参数  
40 - $RequestBuilder = self::builderParams($params);  
41 -  
42 - // 3.获取配置  
43 - $config = config('alipay');  
44 - $aop = new \AlipayTradeService($config);  
45 -  
46 - // 4.发送请求  
47 - $response = $aop->Refund($RequestBuilder);  
48 -  
49 - // 5.转为数组格式返回  
50 - $response = json_decode(json_encode($response), true);  
51 -  
52 - // 6.进行结果处理  
53 - if (!empty($response['code']) && $response['code'] != '10000') {  
54 - self::processError('交易退款接口出错, 错误码: '.$response['code'].' 错误原因: '.$response['sub_msg']);  
55 - }  
56 -  
57 - return $response;  
58 - }  
59 -  
60 - /**  
61 - * 校检参数  
62 - */  
63 - private static function checkParams($params)  
64 - {  
65 - if (empty($params['trade_no']) && empty($params['out_trade_no'])) {  
66 - self::processError('商户订单号(out_trade_no)和支付宝单号(trade_no)不得通知为空');  
67 - }  
68 -  
69 - if (floatval(trim($params['refund_amount'])) <= 0) {  
70 - self::processError('退款金额(refund_amount)为大于0的数');  
71 - }  
72 - }  
73 -  
74 - /**  
75 - * 构造请求参数  
76 - */  
77 - private static function builderParams($params)  
78 - {  
79 - $RequestBuilder = new \AlipayTradeRefundContentBuilder();  
80 -  
81 - // 1.判断单号类型  
82 - if (isset($params['trade_no'])) {  
83 - $RequestBuilder->setTradeNo($params['trade_no']);  
84 - } else {  
85 - $RequestBuilder->setOutTradeNo($params['trade_no']);  
86 - }  
87 -  
88 - // 2.判断是否部分退款  
89 - if (!empty($params['out_request_no'])) {  
90 - $RequestBuilder->setOutRequestNo($params['out_request_no']);  
91 - }  
92 -  
93 - $RequestBuilder->setRefundAmount($params['refund_amount']);  
94 - return $RequestBuilder;  
95 - }  
96 -  
97 - /**  
98 - * 统一错误处理接口  
99 - * @param string $msg 错误描述  
100 - */  
101 - private static function processError($msg)  
102 - {  
103 - throw new \think\Exception($msg);  
104 - }  
105 -}  
1 -<?php  
2 -  
3 -namespace alipay;  
4 -  
5 -use think\Loader;  
6 -  
7 -Loader::import('alipay.pay.service.AlipayTradeService');  
8 -loader::import('alipay.pay.buildermodel.AlipayTradeFastpayRefundQueryContentBuilder');  
9 -  
10 -/**  
11 -* 退款统一订单查询  
12 -*  
13 -* 用法:  
14 -* 调用 \alipay\RefundQuery::exec($params) 即可  
15 -*  
16 -* ----------------- 求职 ------------------  
17 -* 姓名: zhangchaojie 邮箱: zhangchaojie_php@qq.com 应届生  
18 -* 期望职位: PHP初级工程师 地点: 深圳(其他城市亦可)  
19 -* 能力:  
20 -* 1.熟悉小程序开发, 前后端皆可  
21 -* 2.后端, PHP基础知识扎实, 熟悉ThinkPHP5框架, 用TP5做过CMS, 商城, API接口  
22 -* 3.MySQL, Linux都在进行进一步学习  
23 -*  
24 -*/  
25 -class RefundQuery  
26 -{  
27 - /**  
28 - * 主入口  
29 - * @param array $params 退款查询参数, 具体如下:  
30 - * @param string $params['trade_no']/$params['out_trade_no'] 商户订单号或支付宝单号其中之一  
31 - * @param string $params['out_request_no'] 可空, 为空时, 退款号为订单号  
32 - */  
33 - public static function exec($params)  
34 - {  
35 - // 1.校检参数  
36 - if (empty($params['trade_no']) && empty($params['out_trade_no'])) {  
37 - throw new \think\Exception('商户订单号(out_trade_no)和支付宝单号(trade_no)不得通知为空');  
38 - }  
39 -  
40 - // 2.构造请求参数  
41 - $RequestBuilder = self::builderParams($params);  
42 -  
43 - // 3.获取配置  
44 - $config = config('alipay');  
45 - $aop = new \AlipayTradeService($config);  
46 -  
47 - // 4.发起请求  
48 - $response = $aop->refundQuery($RequestBuilder);  
49 -  
50 - // 5.转为数组格式返回  
51 - $response = json_decode(json_encode($response), true);  
52 -  
53 - // 6.进行结果处理  
54 - if (!empty($response['code']) && $response['code'] != '10000') {  
55 - self::processError('退款查询接口出错, 错误码为: '.$response['code'].', 错误原因为: '.$response['sub_msg']);  
56 - }  
57 -  
58 - return $response;  
59 - }  
60 -  
61 - /**  
62 - * 构造请求参数  
63 - */  
64 - private static function builderParams($params)  
65 - {  
66 - $RequestBuilder = new \AlipayTradeFastpayRefundQueryContentBuilder();  
67 - if (isset($params['trade_no'])) {  
68 - $RequestBuilder->setTradeNo($params['trade_no']);  
69 - } else {  
70 - $RequestBuilder->setOutTradeNo($params['out_trade_no']);  
71 - }  
72 -  
73 - // 如果未传退款号, 则以单号为退款号查询  
74 - if (isset($params['out_request_no'])) {  
75 - $RequestBuilder->setOutRequestNo($params['out_request_no']);  
76 - } else {  
77 - $out_request_no = isset($params['trade_no']) ? $params['trade_no'] : $params['out_trade_no'];  
78 - $RequestBuilder->setOutRequestNo($out_request_no);  
79 - }  
80 -  
81 - return $RequestBuilder;  
82 - }  
83 -  
84 - /**  
85 - * 统一错误处理接口  
86 - * @param string $msg 错误描述  
87 - */  
88 - private static function processError($msg)  
89 - {  
90 - throw new \think\Exception($msg);  
91 - }  
92 -}  
1 -<?php  
2 -  
3 -namespace alipay;  
4 -  
5 -use think\Loader;  
6 -  
7 -Loader::import('alipay.pay.service.AlipayWapPayTradeService');  
8 -loader::import('alipay.pay.buildermodel.AlipayTradeWapPayContentBuilder');  
9 -  
10 -/**  
11 -* 支付宝手机网站支付接口  
12 -*  
13 -* 用法:  
14 -* 调用 \alipay\Wappay::pay($params) 即可  
15 -*  
16 -* ----------------- 求职 ------------------  
17 -* 姓名: zhangchaojie 邮箱: zhangchaojie_php@qq.com 应届生  
18 -* 期望职位: PHP初级工程师 地点: 深圳(其他城市亦可)  
19 -* 能力:  
20 -* 1.熟悉小程序开发, 前后端皆可  
21 -* 2.后端, PHP基础知识扎实, 熟悉ThinkPHP5框架, 用TP5做过CMS, 商城, API接口  
22 -* 3.MySQL, Linux都在进行进一步学习  
23 -*  
24 -*/  
25 -class Wappay  
26 -{  
27 - /**  
28 - * 主入口  
29 - * @param array $params 支付参数, 具体如下  
30 - * @param string $params['subject'] 订单标题  
31 - * @param string $params['out_trade_no'] 订单商户号  
32 - * @param float $params['total_amount'] 订单金额  
33 - */  
34 - public static function pay($params)  
35 - {  
36 - // 1.校检参数  
37 - self::checkParams($params);  
38 -  
39 - // 2.构造参数  
40 - $payRequestBuilder = new \AlipayTradeWapPayContentBuilder();  
41 - $payRequestBuilder->setSubject($params['subject']);  
42 - $payRequestBuilder->setOutTradeNo($params['out_trade_no']);  
43 - $payRequestBuilder->setTotalAmount($params['total_amount']);  
44 - $payRequestBuilder->setTimeExpress('1m');  
45 -  
46 - // 3.获取配置  
47 - $config = config('alipay');  
48 - $payResponse = new \AlipayWapPayTradeService($config);  
49 -  
50 - // 4.进行请求  
51 - $result=$payResponse->wapPay($payRequestBuilder,$config['return_url'],$config['notify_url']);  
52 - }  
53 -  
54 -  
55 - /**  
56 - * 校检参数  
57 - */  
58 - private static function checkParams($params)  
59 - {  
60 - if (empty(trim($params['out_trade_no']))) {  
61 - self::processError('商户订单号(out_trade_no)必填');  
62 - }  
63 -  
64 - if (empty(trim($params['subject']))) {  
65 - self::processError('商品标题(subject)必填');  
66 - }  
67 -  
68 - if (floatval(trim($params['total_amount'])) <= 0) {  
69 - self::processError('退款金额(total_amount)为大于0的数');  
70 - }  
71 - }  
72 -  
73 - /**  
74 - * 统一错误处理接口  
75 - * @param string $msg 错误描述  
76 - */  
77 - private static function processError($msg)  
78 - {  
79 - throw new \think\Exception($msg);  
80 - }  
81 -}  
1 -<?php  
2 -/**  
3 - * AOP SDK 入口文件  
4 - * 请不要修改这个文件,除非你知道怎样修改以及怎样恢复  
5 - * @author wuxiao  
6 - */  
7 -  
8 -/**  
9 - * 定义常量开始  
10 - * 在include("AopSdk.php")之前定义这些常量,不要直接修改本文件,以利于升级覆盖  
11 - */  
12 -/**  
13 - * SDK工作目录  
14 - * 存放日志,AOP缓存数据  
15 - */  
16 -if (!defined("AOP_SDK_WORK_DIR"))  
17 -{  
18 - define("AOP_SDK_WORK_DIR", RUNTIME_PATH);  
19 -}  
20 -/**  
21 - * 是否处于开发模式  
22 - * 在你自己电脑上开发程序的时候千万不要设为false,以免缓存造成你的代码修改了不生效  
23 - * 部署到生产环境正式运营后,如果性能压力大,可以把此常量设定为false,能提高运行速度(对应的代价就是你下次升级程序时要清一下缓存)  
24 - */  
25 -if (!defined("AOP_SDK_DEV_MODE"))  
26 -{  
27 - define("AOP_SDK_DEV_MODE", true);  
28 -}  
29 -/**  
30 - * 定义常量结束  
31 - */  
32 -  
33 -/**  
34 - * 找到lotusphp入口文件,并初始化lotusphp  
35 - * lotusphp是一个第三方php框架,其主页在:lotusphp.googlecode.com  
36 - */  
37 -$lotusHome = dirname(__FILE__) . DIRECTORY_SEPARATOR . "lotusphp_runtime" . DIRECTORY_SEPARATOR;  
38 -include($lotusHome . "Lotus.php");  
39 -$lotus = new Lotus;  
40 -$lotus->option["autoload_dir"] = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'aop';  
41 -$lotus->devMode = AOP_SDK_DEV_MODE;  
42 -$lotus->defaultStoreDir = AOP_SDK_WORK_DIR;  
43 -$lotus->init();  
1 -<?php  
2 -  
3 -/**  
4 - * 多媒体文件客户端  
5 - * @author yikai.hu  
6 - * @version $Id: AlipayMobilePublicMultiMediaClient.php, v 0.1 Aug 15, 2014 10:19:01 AM yikai.hu Exp $  
7 - */  
8 -  
9 -//namespace alipay\api ;  
10 -  
11 -include("AlipayMobilePublicMultiMediaExecute.php");  
12 -  
13 -  
14 -class AlipayMobilePublicMultiMediaClient{  
15 -  
16 - private $DEFAULT_CHARSET = 'UTF-8';  
17 - private $METHOD_POST = "POST";  
18 - private $METHOD_GET = "GET";  
19 - private $SIGN = 'sign'; //get name  
20 -  
21 - private $timeout = 10 ;// 超时时间  
22 - private $serverUrl;  
23 - private $appId;  
24 - private $privateKey;  
25 - private $prodCode;  
26 - private $format = 'json'; //todo  
27 - private $sign_type = 'RSA'; //todo  
28 -  
29 - private $charset;  
30 - private $apiVersion = "1.0";  
31 - private $apiMethodName = "alipay.mobile.public.multimedia.download";  
32 - private $media_id = "L21pZnMvVDFQV3hYWGJKWFhYYUNucHJYP3Q9YW13ZiZ4c2lnPTU0MzRhYjg1ZTZjNWJmZTMxZGJiNjIzNDdjMzFkNzkw575";  
33 - //此处写死的,实际开发中,请传入  
34 -  
35 - private $connectTimeout = 3000;  
36 - private $readTimeout = 15000;  
37 -  
38 -  
39 -  
40 - function __construct($serverUrl = '', $appId = '', $partner_private_key = '', $format = '', $charset = 'GBK'){  
41 - $this -> serverUrl = $serverUrl;  
42 - $this -> appId = $appId;  
43 - $this -> privateKey = $partner_private_key;  
44 - $this -> format = $format;  
45 - $this -> charset = $charset;  
46 - }  
47 -  
48 - /**  
49 - * getContents 获取网址内容  
50 - * @param $request  
51 - * @return text | bin  
52 - */  
53 - public function getContents(){  
54 - //自己的服务器如果没有 curl,可用:fsockopen() 等  
55 -  
56 -  
57 - //1:  
58 - //2: 私钥格式  
59 - $datas = array(  
60 - "app_id" => $this -> appId,  
61 - "method" => $this -> METHOD_POST,  
62 - "sign_type" => $this -> sign_type,  
63 - "version" => $this -> apiVersion,  
64 - "timestamp" => date('Y-m-d H:i:s') ,//yyyy-MM-dd HH:mm:ss  
65 - "biz_content" => '{"mediaId":"'. $this -> media_id .'"}',  
66 - "charset" => $this -> charset  
67 - );  
68 -  
69 -  
70 -  
71 - //要提交的数据  
72 - $data_sign = $this -> buildGetUrl( $datas );  
73 -  
74 - $post_data = $data_sign;  
75 - //初始化 curl  
76 - $ch = curl_init();  
77 - //设置目标服务器  
78 - curl_setopt($ch, CURLOPT_URL, $this -> serverUrl );  
79 - curl_setopt($ch, CURLOPT_HEADER, TRUE);  
80 - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
81 - //超时时间  
82 - curl_setopt($ch, CURLOPT_TIMEOUT, $this-> timeout);  
83 -  
84 - if( $this-> METHOD_POST == 'POST'){  
85 - // post数据  
86 - curl_setopt($ch, CURLOPT_POST, 1);  
87 - // post的变量  
88 - curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);  
89 - }  
90 -  
91 -  
92 -  
93 -  
94 - $output = curl_exec($ch);  
95 - $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);  
96 - curl_close($ch);  
97 -  
98 - echo $output;  
99 -  
100 - //分离头部  
101 - //list($header, $body) = explode("\r\n\r\n", $output, 2);  
102 - $datas = explode("\r\n\r\n", $output, 2);  
103 - $header = $datas[0];  
104 -  
105 - if( $httpCode == '200'){  
106 - $body = $datas[1];  
107 - }else{  
108 - $body = '';  
109 -  
110 - }  
111 -  
112 -  
113 -  
114 -  
115 - return $this -> execute( $header, $body, $httpCode );  
116 - }  
117 -  
118 - /**  
119 - *  
120 - * @param $request  
121 - * @return text | bin  
122 - */  
123 - public function execute( $header = '', $body = '', $httpCode = '' ){  
124 - $exe = new AlipayMobilePublicMultiMediaExecute( $header, $body, $httpCode );  
125 - return $exe;  
126 - }  
127 -  
128 - public function buildGetUrl( $query = array() ){  
129 -  
130 - if( ! is_array( $query ) ){  
131 - //exit;  
132 - }  
133 -  
134 - //排序参数,  
135 - $data = $this -> buildQuery( $query );  
136 -  
137 -  
138 -  
139 - // 私钥密码  
140 - $passphrase = '';  
141 - $key_width = 64;  
142 -  
143 - //私钥  
144 - $privateKey = $this -> privateKey;  
145 - $p_key = array();  
146 - //如果私钥是 1行  
147 - if( ! stripos( $privateKey, "\n" ) ){  
148 - $i = 0;  
149 - while( $key_str = substr( $privateKey , $i * $key_width , $key_width) ){  
150 - $p_key[] = $key_str;  
151 - $i ++ ;  
152 - }  
153 - }else{  
154 - //echo '一行?';  
155 - }  
156 - $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" . implode("\n", $p_key) ;  
157 - $privateKey = $privateKey ."\n-----END RSA PRIVATE KEY-----";  
158 -  
159 -// echo "\n\n私钥:\n";  
160 -// echo( $privateKey );  
161 -// echo "\n\n\n";  
162 -  
163 - //私钥  
164 - $private_id = openssl_pkey_get_private( $privateKey , $passphrase);  
165 -  
166 -  
167 - // 签名  
168 - $signature = '';  
169 -  
170 - if("RSA2"==$this->sign_type){  
171 -  
172 - openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA256 );  
173 - }else{  
174 -  
175 - openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA1 );  
176 - }  
177 -  
178 - openssl_free_key( $private_id );  
179 -  
180 - //加密后的内容通常含有特殊字符,需要编码转换下  
181 - $signature = base64_encode($signature);  
182 -  
183 - $signature = urlencode( $signature );  
184 -  
185 - //$signature = 'XjUN6YM1Mc9HXebKMv7GTLy7gmyhktyOgKk2/Jf+cz4DtP6udkzTdpkjW2j/Z4ZSD7xD6CNYI1Spz4yS93HPT0a5X9LgFWYY8SaADqe+ArXg+FBSiTwUz49SE//Xd9+LEiIRsSFkbpkuiGoO6mqJmB7vXjlD5lx6qCM3nb41wb8=';  
186 -  
187 - $out = $data .'&'. $this -> SIGN .'='. $signature;  
188 -  
189 -// echo "\n\n 加密后:\n";  
190 -// echo( $out );  
191 -// echo "\n\n\n";  
192 -  
193 - return $out ;  
194 - }  
195 -  
196 - /*  
197 - * 查询参数排序 a-z  
198 - * */  
199 - public function buildQuery( $query ){  
200 - if ( !$query ) {  
201 - return null;  
202 - }  
203 -  
204 -//将要 参数 排序  
205 - ksort( $query );  
206 -  
207 - //重新组装参数  
208 - $params = array();  
209 - foreach($query as $key => $value){  
210 - $params[] = $key .'='. $value ;  
211 - }  
212 - $data = implode('&', $params);  
213 -  
214 - return $data;  
215 -  
216 - }  
217 -  
218 -  
219 -  
220 -  
221 -  
222 -  
223 -  
224 -  
225 -  
226 -  
227 -  
228 -  
229 -  
230 -  
231 -}  
1 -<?php  
2 -  
3 -/**  
4 - * 多媒体文件客户端  
5 - * @author yuanwai.wang  
6 - * @version $Id: AlipayMobilePublicMultiMediaExecute.php, v 0.1 Aug 15, 2014 10:19:01 AM yuanwai.wang Exp $  
7 - */  
8 -  
9 -//namespace alipay\api ;  
10 -  
11 -  
12 -  
13 -class AlipayMobilePublicMultiMediaExecute{  
14 -  
15 - private $code = 200 ;  
16 - private $msg = '';  
17 - private $body = '';  
18 - private $params = '';  
19 -  
20 - private $fileSuffix = array(  
21 - "image/jpeg" => 'jpg', //+  
22 - "text/plain" => 'text'  
23 - );  
24 -  
25 - /*  
26 - * @$header : 头部  
27 - * */  
28 - function __construct( $header, $body, $httpCode ){  
29 - $this -> code = $httpCode;  
30 - $this -> msg = '';  
31 - $this -> params = $header ;  
32 - $this -> body = $body;  
33 - }  
34 -  
35 - /**  
36 - *  
37 - * @return text | bin  
38 - */  
39 - public function getCode(){  
40 - return $this -> code ;  
41 - }  
42 -  
43 - /**  
44 - *  
45 - * @return text | bin  
46 - */  
47 - public function getMsg(){  
48 - return $this -> msg ;  
49 - }  
50 -  
51 - /**  
52 - *  
53 - * @return text | bin  
54 - */  
55 - public function getType(){  
56 - $subject = $this -> params ;  
57 - $pattern = '/Content\-Type:([^;]+)/';  
58 - preg_match($pattern, $subject, $matches);  
59 - if( $matches ){  
60 - $type = $matches[1];  
61 - }else{  
62 - $type = 'application/download';  
63 - }  
64 -  
65 - return str_replace( ' ', '', $type );  
66 - }  
67 -  
68 - /**  
69 - *  
70 - * @return text | bin  
71 - */  
72 - public function getContentLength(){  
73 - $subject = $this -> params ;  
74 - $pattern = '/Content-Length:\s*([^\n]+)/';  
75 - preg_match($pattern, $subject, $matches);  
76 - return (int)( isset($matches[1] ) ? $matches[1] : '' );  
77 - }  
78 -  
79 -  
80 - public function getFileSuffix( $fileType ){  
81 - $type = isset( $this -> fileSuffix[ $fileType ] ) ? $this -> fileSuffix[ $fileType ] : 'text/plain' ;  
82 - if( !$type ){  
83 - $type = 'json';  
84 - }  
85 - return $type;  
86 - }  
87 -  
88 -  
89 -  
90 - /**  
91 - *  
92 - * @return text | bin  
93 - */  
94 - public function getBody(){  
95 - //header('Content-type: image/jpeg');  
96 - return $this -> body ;  
97 - }  
98 -  
99 - /**  
100 - * 获取参数  
101 - * @return text | bin  
102 - */  
103 - public function getParams(){  
104 - return $this -> params ;  
105 - }  
106 -  
107 -  
108 -}  
1 -<?php  
2 -  
3 -require_once 'AopEncrypt.php';  
4 -  
5 -class AopClient {  
6 - //应用ID  
7 - public $appId;  
8 - //私钥文件路径  
9 - public $rsaPrivateKeyFilePath;  
10 -  
11 - //私钥值  
12 - public $rsaPrivateKey;  
13 - //网关  
14 - public $gatewayUrl = "https://openapi.alipay.com/gateway.do";  
15 - //返回数据格式  
16 - public $format = "json";  
17 - //api版本  
18 - public $apiVersion = "1.0";  
19 -  
20 - // 表单提交字符集编码  
21 - public $postCharset = "UTF-8";  
22 -  
23 -  
24 - public $alipayPublicKey = null;  
25 -  
26 - public $alipayrsaPublicKey;  
27 -  
28 -  
29 - public $debugInfo = false;  
30 -  
31 - private $fileCharset = "UTF-8";  
32 -  
33 - private $RESPONSE_SUFFIX = "_response";  
34 -  
35 - private $ERROR_RESPONSE = "error_response";  
36 -  
37 - private $SIGN_NODE_NAME = "sign";  
38 -  
39 -  
40 - //加密XML节点名称  
41 - private $ENCRYPT_XML_NODE_NAME = "response_encrypted";  
42 -  
43 - private $needEncrypt = false;  
44 -  
45 -  
46 - //签名类型  
47 - public $signType = "RSA";  
48 -  
49 -  
50 - //加密密钥和类型  
51 -  
52 - public $encryptKey;  
53 -  
54 - public $encryptType = "AES";  
55 -  
56 - protected $alipaySdkVersion = "alipay-sdk-php-20161101";  
57 -  
58 - public function generateSign($params, $signType = "RSA") {  
59 - return $this->sign($this->getSignContent($params), $signType);  
60 - }  
61 -  
62 - public function rsaSign($params, $signType = "RSA") {  
63 - return $this->sign($this->getSignContent($params), $signType);  
64 - }  
65 -  
66 - protected function getSignContent($params) {  
67 - ksort($params);  
68 -  
69 - $stringToBeSigned = "";  
70 - $i = 0;  
71 - foreach ($params as $k => $v) {  
72 - if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) {  
73 -  
74 - // 转换成目标字符集  
75 - $v = $this->characet($v, $this->postCharset);  
76 -  
77 - if ($i == 0) {  
78 - $stringToBeSigned .= "$k" . "=" . "$v";  
79 - } else {  
80 - $stringToBeSigned .= "&" . "$k" . "=" . "$v";  
81 - }  
82 - $i++;  
83 - }  
84 - }  
85 -  
86 - unset ($k, $v);  
87 - return $stringToBeSigned;  
88 - }  
89 -  
90 - protected function sign($data, $signType = "RSA") {  
91 - if($this->checkEmpty($this->rsaPrivateKeyFilePath)){  
92 - $priKey=$this->rsaPrivateKey;  
93 - $res = "-----BEGIN RSA PRIVATE KEY-----\n" .  
94 - wordwrap($priKey, 64, "\n", true) .  
95 - "\n-----END RSA PRIVATE KEY-----";  
96 - }else {  
97 - $priKey = file_get_contents($this->rsaPrivateKeyFilePath);  
98 - $res = openssl_get_privatekey($priKey);  
99 - }  
100 -  
101 - ($res) or die('您使用的私钥格式错误,请检查RSA私钥配置');  
102 -  
103 - if ("RSA2" == $signType) {  
104 - openssl_sign($data, $sign, $res, OPENSSL_ALGO_SHA256);  
105 - } else {  
106 - openssl_sign($data, $sign, $res);  
107 - }  
108 -  
109 - if(!$this->checkEmpty($this->rsaPrivateKeyFilePath)){  
110 - openssl_free_key($res);  
111 - }  
112 - $sign = base64_encode($sign);  
113 - return $sign;  
114 - }  
115 -  
116 -  
117 - protected function curl($url, $postFields = null) {  
118 - $ch = curl_init();  
119 - curl_setopt($ch, CURLOPT_URL, $url);  
120 - curl_setopt($ch, CURLOPT_FAILONERROR, false);  
121 - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
122 - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  
123 -  
124 - $postBodyString = "";  
125 - $encodeArray = Array();  
126 - $postMultipart = false;  
127 -  
128 -  
129 - if (is_array($postFields) && 0 < count($postFields)) {  
130 -  
131 - foreach ($postFields as $k => $v) {  
132 - if ("@" != substr($v, 0, 1)) //判断是不是文件上传  
133 - {  
134 -  
135 - $postBodyString .= "$k=" . urlencode($this->characet($v, $this->postCharset)) . "&";  
136 - $encodeArray[$k] = $this->characet($v, $this->postCharset);  
137 - } else //文件上传用multipart/form-data,否则用www-form-urlencoded  
138 - {  
139 - $postMultipart = true;  
140 - $encodeArray[$k] = new \CURLFile(substr($v, 1));  
141 - }  
142 -  
143 - }  
144 - unset ($k, $v);  
145 - curl_setopt($ch, CURLOPT_POST, true);  
146 - if ($postMultipart) {  
147 - curl_setopt($ch, CURLOPT_POSTFIELDS, $encodeArray);  
148 - } else {  
149 - curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString, 0, -1));  
150 - }  
151 - }  
152 -  
153 - if ($postMultipart) {  
154 -  
155 - $headers = array('content-type: multipart/form-data;charset=' . $this->postCharset . ';boundary=' . $this->getMillisecond());  
156 - } else {  
157 -  
158 - $headers = array('content-type: application/x-www-form-urlencoded;charset=' . $this->postCharset);  
159 - }  
160 - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);  
161 -  
162 -  
163 -  
164 -  
165 - $reponse = curl_exec($ch);  
166 -  
167 - if (curl_errno($ch)) {  
168 -  
169 - throw new Exception(curl_error($ch), 0);  
170 - } else {  
171 - $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);  
172 - if (200 !== $httpStatusCode) {  
173 - throw new Exception($reponse, $httpStatusCode);  
174 - }  
175 - }  
176 -  
177 - curl_close($ch);  
178 - return $reponse;  
179 - }  
180 -  
181 - protected function getMillisecond() {  
182 - list($s1, $s2) = explode(' ', microtime());  
183 - return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);  
184 - }  
185 -  
186 -  
187 - protected function logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt) {  
188 - $localIp = isset ($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : "CLI";  
189 - $logger = new LtLogger;  
190 - $logger->conf["log_file"] = rtrim(AOP_SDK_WORK_DIR, '\\/') . '/' . "logs/aop_comm_err_" . $this->appId . "_" . date("Y-m-d") . ".log";  
191 - $logger->conf["separator"] = "^_^";  
192 - $logData = array(  
193 - date("Y-m-d H:i:s"),  
194 - $apiName,  
195 - $this->appId,  
196 - $localIp,  
197 - PHP_OS,  
198 - $this->alipaySdkVersion,  
199 - $requestUrl,  
200 - $errorCode,  
201 - str_replace("\n", "", $responseTxt)  
202 - );  
203 - $logger->log($logData);  
204 - }  
205 -  
206 - /**  
207 - * 生成用于调用收银台SDK的字符串  
208 - * @param $request SDK接口的请求参数对象  
209 - * @return string  
210 - * @author guofa.tgf  
211 - */  
212 - public function sdkExecute($request) {  
213 -  
214 - $this->setupCharsets($request);  
215 -  
216 - $params['app_id'] = $this->appId;  
217 - $params['method'] = $request->getApiMethodName();  
218 - $params['format'] = $this->format;  
219 - $params['sign_type'] = $this->signType;  
220 - $params['timestamp'] = date("Y-m-d H:i:s");  
221 - $params['alipay_sdk'] = $this->alipaySdkVersion;  
222 - $params['charset'] = $this->postCharset;  
223 -  
224 - $version = $request->getApiVersion();  
225 - $params['version'] = $this->checkEmpty($version) ? $this->apiVersion : $version;  
226 -  
227 - if ($notify_url = $request->getNotifyUrl()) {  
228 - $params['notify_url'] = $notify_url;  
229 - }  
230 -  
231 - $dict = $request->getApiParas();  
232 - $params['biz_content'] = $dict['biz_content'];  
233 -  
234 - ksort($params);  
235 -  
236 - $params['sign'] = $this->generateSign($params, $this->signType);  
237 -  
238 - foreach ($params as &$value) {  
239 - $value = $this->characet($value, $params['charset']);  
240 - }  
241 -  
242 - return http_build_query($params);  
243 - }  
244 -  
245 - /*  
246 - 页面提交执行方法  
247 - @param:跳转类接口的request; $httpmethod 提交方式。两个值可选:post、get  
248 - @return:构建好的、签名后的最终跳转URL(GET)或String形式的form(POST)  
249 - auther:笙默  
250 - */  
251 - public function pageExecute($request,$httpmethod = "POST") {  
252 -  
253 - $this->setupCharsets($request);  
254 -  
255 - if (strcasecmp($this->fileCharset, $this->postCharset)) {  
256 -  
257 - // writeLog("本地文件字符集编码与表单提交编码不一致,请务必设置成一样,属性名分别为postCharset!");  
258 - throw new Exception("文件编码:[" . $this->fileCharset . "] 与表单提交编码:[" . $this->postCharset . "]两者不一致!");  
259 - }  
260 -  
261 - $iv=null;  
262 -  
263 - if(!$this->checkEmpty($request->getApiVersion())){  
264 - $iv=$request->getApiVersion();  
265 - }else{  
266 - $iv=$this->apiVersion;  
267 - }  
268 -  
269 - //组装系统参数  
270 - $sysParams["app_id"] = $this->appId;  
271 - $sysParams["version"] = $iv;  
272 - $sysParams["format"] = $this->format;  
273 - $sysParams["sign_type"] = $this->signType;  
274 - $sysParams["method"] = $request->getApiMethodName();  
275 - $sysParams["timestamp"] = date("Y-m-d H:i:s");  
276 - $sysParams["alipay_sdk"] = $this->alipaySdkVersion;  
277 - $sysParams["terminal_type"] = $request->getTerminalType();  
278 - $sysParams["terminal_info"] = $request->getTerminalInfo();  
279 - $sysParams["prod_code"] = $request->getProdCode();  
280 - $sysParams["notify_url"] = $request->getNotifyUrl();  
281 - $sysParams["return_url"] = $request->getReturnUrl();  
282 - $sysParams["charset"] = $this->postCharset;  
283 -  
284 - //获取业务参数  
285 - $apiParams = $request->getApiParas();  
286 -  
287 - if (method_exists($request,"getNeedEncrypt") &&$request->getNeedEncrypt()){  
288 -  
289 - $sysParams["encrypt_type"] = $this->encryptType;  
290 -  
291 - if ($this->checkEmpty($apiParams['biz_content'])) {  
292 -  
293 - throw new Exception(" api request Fail! The reason : encrypt request is not supperted!");  
294 - }  
295 -  
296 - if ($this->checkEmpty($this->encryptKey) || $this->checkEmpty($this->encryptType)) {  
297 -  
298 - throw new Exception(" encryptType and encryptKey must not null! ");  
299 - }  
300 -  
301 - if ("AES" != $this->encryptType) {  
302 -  
303 - throw new Exception("加密类型只支持AES");  
304 - }  
305 -  
306 - // 执行加密  
307 - $enCryptContent = encrypt($apiParams['biz_content'], $this->encryptKey);  
308 - $apiParams['biz_content'] = $enCryptContent;  
309 -  
310 - }  
311 -  
312 - //print_r($apiParams);  
313 - $totalParams = array_merge($apiParams, $sysParams);  
314 -  
315 - //待签名字符串  
316 - $preSignStr = $this->getSignContent($totalParams);  
317 -  
318 - //签名  
319 - $totalParams["sign"] = $this->generateSign($totalParams, $this->signType);  
320 -  
321 - if ("GET" == $httpmethod) {  
322 -  
323 - //拼接GET请求串  
324 - $requestUrl = $this->gatewayUrl."?".$preSignStr."&sign=".urlencode($totalParams["sign"]);  
325 -  
326 - return $requestUrl;  
327 - } else {  
328 - //拼接表单字符串  
329 - return $this->buildRequestForm($totalParams);  
330 - }  
331 -  
332 -  
333 - }  
334 -  
335 - /**  
336 - * 建立请求,以表单HTML形式构造(默认)  
337 - * @param $para_temp 请求参数数组  
338 - * @return 提交表单HTML文本  
339 - */  
340 - protected function buildRequestForm($para_temp) {  
341 -  
342 - $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='".$this->gatewayUrl."?charset=".trim($this->postCharset)."' method='POST'>";  
343 - while (list ($key, $val) = each ($para_temp)) {  
344 - if (false === $this->checkEmpty($val)) {  
345 - //$val = $this->characet($val, $this->postCharset);  
346 - $val = str_replace("'","&apos;",$val);  
347 - //$val = str_replace("\"","&quot;",$val);  
348 - $sHtml.= "<input type='hidden' name='".$key."' value='".$val."'/>";  
349 - }  
350 - }  
351 -  
352 - //submit按钮控件请不要含有name属性  
353 - $sHtml = $sHtml."<input type='submit' value='ok' style='display:none;''></form>";  
354 -  
355 - $sHtml = $sHtml."<script>document.forms['alipaysubmit'].submit();</script>";  
356 -  
357 - return $sHtml;  
358 - }  
359 -  
360 -  
361 - public function execute($request, $authToken = null, $appInfoAuthtoken = null) {  
362 -  
363 - $this->setupCharsets($request);  
364 -  
365 - // // 如果两者编码不一致,会出现签名验签或者乱码  
366 - if (strcasecmp($this->fileCharset, $this->postCharset)) {  
367 -  
368 - // writeLog("本地文件字符集编码与表单提交编码不一致,请务必设置成一样,属性名分别为postCharset!");  
369 - throw new Exception("文件编码:[" . $this->fileCharset . "] 与表单提交编码:[" . $this->postCharset . "]两者不一致!");  
370 - }  
371 -  
372 - $iv = null;  
373 -  
374 - if (!$this->checkEmpty($request->getApiVersion())) {  
375 - $iv = $request->getApiVersion();  
376 - } else {  
377 - $iv = $this->apiVersion;  
378 - }  
379 -  
380 -  
381 - //组装系统参数  
382 - $sysParams["app_id"] = $this->appId;  
383 - $sysParams["version"] = $iv;  
384 - $sysParams["format"] = $this->format;  
385 - $sysParams["sign_type"] = $this->signType;  
386 - $sysParams["method"] = $request->getApiMethodName();  
387 - $sysParams["timestamp"] = date("Y-m-d H:i:s");  
388 - $sysParams["auth_token"] = $authToken;  
389 - $sysParams["alipay_sdk"] = $this->alipaySdkVersion;  
390 - $sysParams["terminal_type"] = $request->getTerminalType();  
391 - $sysParams["terminal_info"] = $request->getTerminalInfo();  
392 - $sysParams["prod_code"] = $request->getProdCode();  
393 - $sysParams["notify_url"] = $request->getNotifyUrl();  
394 - $sysParams["charset"] = $this->postCharset;  
395 - $sysParams["app_auth_token"] = $appInfoAuthtoken;  
396 -  
397 -  
398 - //获取业务参数  
399 - $apiParams = $request->getApiParas();  
400 -  
401 - if (method_exists($request,"getNeedEncrypt") &&$request->getNeedEncrypt()){  
402 -  
403 - $sysParams["encrypt_type"] = $this->encryptType;  
404 -  
405 - if ($this->checkEmpty($apiParams['biz_content'])) {  
406 -  
407 - throw new Exception(" api request Fail! The reason : encrypt request is not supperted!");  
408 - }  
409 -  
410 - if ($this->checkEmpty($this->encryptKey) || $this->checkEmpty($this->encryptType)) {  
411 -  
412 - throw new Exception(" encryptType and encryptKey must not null! ");  
413 - }  
414 -  
415 - if ("AES" != $this->encryptType) {  
416 -  
417 - throw new Exception("加密类型只支持AES");  
418 - }  
419 -  
420 - // 执行加密  
421 - $enCryptContent = encrypt($apiParams['biz_content'], $this->encryptKey);  
422 - $apiParams['biz_content'] = $enCryptContent;  
423 -  
424 - }  
425 -  
426 -  
427 - //签名  
428 - $sysParams["sign"] = $this->generateSign(array_merge($apiParams, $sysParams), $this->signType);  
429 -  
430 -  
431 - //系统参数放入GET请求串  
432 - $requestUrl = $this->gatewayUrl . "?";  
433 - foreach ($sysParams as $sysParamKey => $sysParamValue) {  
434 - $requestUrl .= "$sysParamKey=" . urlencode($this->characet($sysParamValue, $this->postCharset)) . "&";  
435 - }  
436 - $requestUrl = substr($requestUrl, 0, -1);  
437 -  
438 -  
439 - //发起HTTP请求  
440 - try {  
441 - $resp = $this->curl($requestUrl, $apiParams);  
442 - } catch (Exception $e) {  
443 -  
444 - $this->logCommunicationError($sysParams["method"], $requestUrl, "HTTP_ERROR_" . $e->getCode(), $e->getMessage());  
445 - return false;  
446 - }  
447 -  
448 - //解析AOP返回结果  
449 - $respWellFormed = false;  
450 -  
451 -  
452 - // 将返回结果转换本地文件编码  
453 - $r = iconv($this->postCharset, $this->fileCharset . "//IGNORE", $resp);  
454 -  
455 -  
456 -  
457 - $signData = null;  
458 -  
459 - if ("json" == $this->format) {  
460 -  
461 - $respObject = json_decode($r);  
462 - if (null !== $respObject) {  
463 - $respWellFormed = true;  
464 - $signData = $this->parserJSONSignData($request, $resp, $respObject);  
465 - }  
466 - } else if ("xml" == $this->format) {  
467 -  
468 - $respObject = @ simplexml_load_string($resp);  
469 - if (false !== $respObject) {  
470 - $respWellFormed = true;  
471 -  
472 - $signData = $this->parserXMLSignData($request, $resp);  
473 - }  
474 - }  
475 -  
476 -  
477 - //返回的HTTP文本不是标准JSON或者XML,记下错误日志  
478 - if (false === $respWellFormed) {  
479 - $this->logCommunicationError($sysParams["method"], $requestUrl, "HTTP_RESPONSE_NOT_WELL_FORMED", $resp);  
480 - return false;  
481 - }  
482 -  
483 - // 验签  
484 - $this->checkResponseSign($request, $signData, $resp, $respObject);  
485 -  
486 - // 解密  
487 - if (method_exists($request,"getNeedEncrypt") &&$request->getNeedEncrypt()){  
488 -  
489 - if ("json" == $this->format) {  
490 -  
491 -  
492 - $resp = $this->encryptJSONSignSource($request, $resp);  
493 -  
494 - // 将返回结果转换本地文件编码  
495 - $r = iconv($this->postCharset, $this->fileCharset . "//IGNORE", $resp);  
496 - $respObject = json_decode($r);  
497 - }else{  
498 -  
499 - $resp = $this->encryptXMLSignSource($request, $resp);  
500 -  
501 - $r = iconv($this->postCharset, $this->fileCharset . "//IGNORE", $resp);  
502 - $respObject = @ simplexml_load_string($r);  
503 -  
504 - }  
505 - }  
506 -  
507 - return $respObject;  
508 - }  
509 -  
510 - /**  
511 - * 转换字符集编码  
512 - * @param $data  
513 - * @param $targetCharset  
514 - * @return string  
515 - */  
516 - function characet($data, $targetCharset) {  
517 -  
518 - if (!empty($data)) {  
519 - $fileType = $this->fileCharset;  
520 - if (strcasecmp($fileType, $targetCharset) != 0) {  
521 - $data = mb_convert_encoding($data, $targetCharset, $fileType);  
522 - // $data = iconv($fileType, $targetCharset.'//IGNORE', $data);  
523 - }  
524 - }  
525 -  
526 -  
527 - return $data;  
528 - }  
529 -  
530 - public function exec($paramsArray) {  
531 - if (!isset ($paramsArray["method"])) {  
532 - trigger_error("No api name passed");  
533 - }  
534 - $inflector = new LtInflector;  
535 - $inflector->conf["separator"] = ".";  
536 - $requestClassName = ucfirst($inflector->camelize(substr($paramsArray["method"], 7))) . "Request";  
537 - if (!class_exists($requestClassName)) {  
538 - trigger_error("No such api: " . $paramsArray["method"]);  
539 - }  
540 -  
541 - $session = isset ($paramsArray["session"]) ? $paramsArray["session"] : null;  
542 -  
543 - $req = new $requestClassName;  
544 - foreach ($paramsArray as $paraKey => $paraValue) {  
545 - $inflector->conf["separator"] = "_";  
546 - $setterMethodName = $inflector->camelize($paraKey);  
547 - $inflector->conf["separator"] = ".";  
548 - $setterMethodName = "set" . $inflector->camelize($setterMethodName);  
549 - if (method_exists($req, $setterMethodName)) {  
550 - $req->$setterMethodName ($paraValue);  
551 - }  
552 - }  
553 - return $this->execute($req, $session);  
554 - }  
555 -  
556 - /**  
557 - * 校验$value是否非空  
558 - * if not set ,return true;  
559 - * if is null , return true;  
560 - **/  
561 - protected function checkEmpty($value) {  
562 - if (!isset($value))  
563 - return true;  
564 - if ($value === null)  
565 - return true;  
566 - if (trim($value) === "")  
567 - return true;  
568 -  
569 - return false;  
570 - }  
571 -  
572 - /** rsaCheckV1 & rsaCheckV2  
573 - * 验证签名  
574 - * 在使用本方法前,必须初始化AopClient且传入公钥参数。  
575 - * 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。  
576 - **/  
577 - public function rsaCheckV1($params, $rsaPublicKeyFilePath,$signType='RSA') {  
578 - $sign = $params['sign'];  
579 - $params['sign_type'] = null;  
580 - $params['sign'] = null;  
581 - return $this->verify($this->getSignContent($params), $sign, $rsaPublicKeyFilePath,$signType);  
582 - }  
583 - public function rsaCheckV2($params, $rsaPublicKeyFilePath, $signType='RSA') {  
584 - $sign = $params['sign'];  
585 - $params['sign'] = null;  
586 - return $this->verify($this->getSignContent($params), $sign, $rsaPublicKeyFilePath, $signType);  
587 - }  
588 -  
589 - function verify($data, $sign, $rsaPublicKeyFilePath, $signType = 'RSA') {  
590 -  
591 - if($this->checkEmpty($this->alipayPublicKey)){  
592 -  
593 - $pubKey= $this->alipayrsaPublicKey;  
594 - $res = "-----BEGIN PUBLIC KEY-----\n" .  
595 - wordwrap($pubKey, 64, "\n", true) .  
596 - "\n-----END PUBLIC KEY-----";  
597 - }else {  
598 - //读取公钥文件  
599 - $pubKey = file_get_contents($rsaPublicKeyFilePath);  
600 - //转换为openssl格式密钥  
601 - $res = openssl_get_publickey($pubKey);  
602 - }  
603 -  
604 - ($res) or die('支付宝RSA公钥错误。请检查公钥文件格式是否正确');  
605 -  
606 - //调用openssl内置方法验签,返回bool值  
607 -  
608 - if ("RSA2" == $signType) {  
609 - $result = (bool)openssl_verify($data, base64_decode($sign), $res, OPENSSL_ALGO_SHA256);  
610 - } else {  
611 - $result = (bool)openssl_verify($data, base64_decode($sign), $res);  
612 - }  
613 -  
614 - if(!$this->checkEmpty($this->alipayPublicKey)) {  
615 - //释放资源  
616 - openssl_free_key($res);  
617 - }  
618 -  
619 - return $result;  
620 - }  
621 -  
622 - public function checkSignAndDecrypt($params, $rsaPublicKeyPem, $rsaPrivateKeyPem, $isCheckSign, $isDecrypt) {  
623 - $charset = $params['charset'];  
624 - $bizContent = $params['biz_content'];  
625 - if ($isCheckSign) {  
626 - if (!$this->rsaCheckV2($params, $rsaPublicKeyPem)) {  
627 - echo "<br/>checkSign failure<br/>";  
628 - exit;  
629 - }  
630 - }  
631 - if ($isDecrypt) {  
632 - return $this->rsaDecrypt($bizContent, $rsaPrivateKeyPem, $charset);  
633 - }  
634 -  
635 - return $bizContent;  
636 - }  
637 -  
638 - public function encryptAndSign($bizContent, $rsaPublicKeyPem, $rsaPrivateKeyPem, $charset, $isEncrypt, $isSign) {  
639 - // 加密,并签名  
640 - if ($isEncrypt && $isSign) {  
641 - $encrypted = $this->rsaEncrypt($bizContent, $rsaPublicKeyPem, $charset);  
642 - $sign = $this->sign($bizContent);  
643 - $response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$encrypted</response><encryption_type>RSA</encryption_type><sign>$sign</sign><sign_type>RSA</sign_type></alipay>";  
644 - return $response;  
645 - }  
646 - // 加密,不签名  
647 - if ($isEncrypt && (!$isSign)) {  
648 - $encrypted = $this->rsaEncrypt($bizContent, $rsaPublicKeyPem, $charset);  
649 - $response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$encrypted</response><encryption_type>RSA</encryption_type></alipay>";  
650 - return $response;  
651 - }  
652 - // 不加密,但签名  
653 - if ((!$isEncrypt) && $isSign) {  
654 - $sign = $this->sign($bizContent);  
655 - $response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$bizContent</response><sign>$sign</sign><sign_type>RSA</sign_type></alipay>";  
656 - return $response;  
657 - }  
658 - // 不加密,不签名  
659 - $response = "<?xml version=\"1.0\" encoding=\"$charset\"?>$bizContent";  
660 - return $response;  
661 - }  
662 -  
663 - public function rsaEncrypt($data, $rsaPublicKeyPem, $charset) {  
664 - //读取公钥文件  
665 - $pubKey = file_get_contents($rsaPublicKeyPem);  
666 - //转换为openssl格式密钥  
667 - $res = openssl_get_publickey($pubKey);  
668 - $blocks = $this->splitCN($data, 0, 30, $charset);  
669 - $chrtext  = null;  
670 - $encodes  = array();  
671 - foreach ($blocks as $n => $block) {  
672 - if (!openssl_public_encrypt($block, $chrtext , $res)) {  
673 - echo "<br/>" . openssl_error_string() . "<br/>";  
674 - }  
675 - $encodes[] = $chrtext ;  
676 - }  
677 - $chrtext = implode(",", $encodes);  
678 -  
679 - return $chrtext;  
680 - }  
681 -  
682 - public function rsaDecrypt($data, $rsaPrivateKeyPem, $charset) {  
683 - //读取私钥文件  
684 - $priKey = file_get_contents($rsaPrivateKeyPem);  
685 - //转换为openssl格式密钥  
686 - $res = openssl_get_privatekey($priKey);  
687 - $decodes = explode(',', $data);  
688 - $strnull = "";  
689 - $dcyCont = "";  
690 - foreach ($decodes as $n => $decode) {  
691 - if (!openssl_private_decrypt($decode, $dcyCont, $res)) {  
692 - echo "<br/>" . openssl_error_string() . "<br/>";  
693 - }  
694 - $strnull .= $dcyCont;  
695 - }  
696 - return $strnull;  
697 - }  
698 -  
699 - function splitCN($cont, $n = 0, $subnum, $charset) {  
700 - //$len = strlen($cont) / 3;  
701 - $arrr = array();  
702 - for ($i = $n; $i < strlen($cont); $i += $subnum) {  
703 - $res = $this->subCNchar($cont, $i, $subnum, $charset);  
704 - if (!empty ($res)) {  
705 - $arrr[] = $res;  
706 - }  
707 - }  
708 -  
709 - return $arrr;  
710 - }  
711 -  
712 - function subCNchar($str, $start = 0, $length, $charset = "gbk") {  
713 - if (strlen($str) <= $length) {  
714 - return $str;  
715 - }  
716 - $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";  
717 - $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/";  
718 - $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/";  
719 - $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/";  
720 - preg_match_all($re[$charset], $str, $match);  
721 - $slice = join("", array_slice($match[0], $start, $length));  
722 - return $slice;  
723 - }  
724 -  
725 - function parserResponseSubCode($request, $responseContent, $respObject, $format) {  
726 -  
727 - if ("json" == $format) {  
728 -  
729 - $apiName = $request->getApiMethodName();  
730 - $rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;  
731 - $errorNodeName = $this->ERROR_RESPONSE;  
732 -  
733 - $rootIndex = strpos($responseContent, $rootNodeName);  
734 - $errorIndex = strpos($responseContent, $errorNodeName);  
735 -  
736 - if ($rootIndex > 0) {  
737 - // 内部节点对象  
738 - $rInnerObject = $respObject->$rootNodeName;  
739 - } elseif ($errorIndex > 0) {  
740 -  
741 - $rInnerObject = $respObject->$errorNodeName;  
742 - } else {  
743 - return null;  
744 - }  
745 -  
746 - // 存在属性则返回对应值  
747 - if (isset($rInnerObject->sub_code)) {  
748 -  
749 - return $rInnerObject->sub_code;  
750 - } else {  
751 -  
752 - return null;  
753 - }  
754 -  
755 -  
756 - } elseif ("xml" == $format) {  
757 -  
758 - // xml格式sub_code在同一层级  
759 - return $respObject->sub_code;  
760 -  
761 - }  
762 -  
763 -  
764 - }  
765 -  
766 - function parserJSONSignData($request, $responseContent, $responseJSON) {  
767 -  
768 - $signData = new SignData();  
769 -  
770 - $signData->sign = $this->parserJSONSign($responseJSON);  
771 - $signData->signSourceData = $this->parserJSONSignSource($request, $responseContent);  
772 -  
773 -  
774 - return $signData;  
775 -  
776 - }  
777 -  
778 - function parserJSONSignSource($request, $responseContent) {  
779 -  
780 - $apiName = $request->getApiMethodName();  
781 - $rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;  
782 -  
783 - $rootIndex = strpos($responseContent, $rootNodeName);  
784 - $errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);  
785 -  
786 -  
787 - if ($rootIndex > 0) {  
788 -  
789 - return $this->parserJSONSource($responseContent, $rootNodeName, $rootIndex);  
790 - } else if ($errorIndex > 0) {  
791 -  
792 - return $this->parserJSONSource($responseContent, $this->ERROR_RESPONSE, $errorIndex);  
793 - } else {  
794 -  
795 - return null;  
796 - }  
797 -  
798 -  
799 - }  
800 -  
801 - function parserJSONSource($responseContent, $nodeName, $nodeIndex) {  
802 - $signDataStartIndex = $nodeIndex + strlen($nodeName) + 2;  
803 - $signIndex = strpos($responseContent, "\"" . $this->SIGN_NODE_NAME . "\"");  
804 - // 签名前-逗号  
805 - $signDataEndIndex = $signIndex - 1;  
806 - $indexLen = $signDataEndIndex - $signDataStartIndex;  
807 - if ($indexLen < 0) {  
808 -  
809 - return null;  
810 - }  
811 -  
812 - return substr($responseContent, $signDataStartIndex, $indexLen);  
813 -  
814 - }  
815 -  
816 - function parserJSONSign($responseJSon) {  
817 -  
818 - return $responseJSon->sign;  
819 - }  
820 -  
821 - function parserXMLSignData($request, $responseContent) {  
822 -  
823 -  
824 - $signData = new SignData();  
825 -  
826 - $signData->sign = $this->parserXMLSign($responseContent);  
827 - $signData->signSourceData = $this->parserXMLSignSource($request, $responseContent);  
828 -  
829 -  
830 - return $signData;  
831 -  
832 -  
833 - }  
834 -  
835 - function parserXMLSignSource($request, $responseContent) {  
836 -  
837 -  
838 - $apiName = $request->getApiMethodName();  
839 - $rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;  
840 -  
841 -  
842 - $rootIndex = strpos($responseContent, $rootNodeName);  
843 - $errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);  
844 - // $this->echoDebug("<br/>rootNodeName:" . $rootNodeName);  
845 - // $this->echoDebug("<br/> responseContent:<xmp>" . $responseContent . "</xmp>");  
846 -  
847 -  
848 - if ($rootIndex > 0) {  
849 -  
850 - return $this->parserXMLSource($responseContent, $rootNodeName, $rootIndex);  
851 - } else if ($errorIndex > 0) {  
852 -  
853 - return $this->parserXMLSource($responseContent, $this->ERROR_RESPONSE, $errorIndex);  
854 - } else {  
855 -  
856 - return null;  
857 - }  
858 -  
859 -  
860 - }  
861 -  
862 - function parserXMLSource($responseContent, $nodeName, $nodeIndex) {  
863 - $signDataStartIndex = $nodeIndex + strlen($nodeName) + 1;  
864 - $signIndex = strpos($responseContent, "<" . $this->SIGN_NODE_NAME . ">");  
865 - // 签名前-逗号  
866 - $signDataEndIndex = $signIndex - 1;  
867 - $indexLen = $signDataEndIndex - $signDataStartIndex + 1;  
868 -  
869 - if ($indexLen < 0) {  
870 - return null;  
871 - }  
872 -  
873 -  
874 - return substr($responseContent, $signDataStartIndex, $indexLen);  
875 -  
876 -  
877 - }  
878 -  
879 - function parserXMLSign($responseContent) {  
880 - $signNodeName = "<" . $this->SIGN_NODE_NAME . ">";  
881 - $signEndNodeName = "</" . $this->SIGN_NODE_NAME . ">";  
882 -  
883 - $indexOfSignNode = strpos($responseContent, $signNodeName);  
884 - $indexOfSignEndNode = strpos($responseContent, $signEndNodeName);  
885 -  
886 -  
887 - if ($indexOfSignNode < 0 || $indexOfSignEndNode < 0) {  
888 - return null;  
889 - }  
890 -  
891 - $nodeIndex = ($indexOfSignNode + strlen($signNodeName));  
892 -  
893 - $indexLen = $indexOfSignEndNode - $nodeIndex;  
894 -  
895 - if ($indexLen < 0) {  
896 - return null;  
897 - }  
898 -  
899 - // 签名  
900 - return substr($responseContent, $nodeIndex, $indexLen);  
901 -  
902 - }  
903 -  
904 - /**  
905 - * 验签  
906 - * @param $request  
907 - * @param $signData  
908 - * @param $resp  
909 - * @param $respObject  
910 - * @throws Exception  
911 - */  
912 - public function checkResponseSign($request, $signData, $resp, $respObject) {  
913 -  
914 - if (!$this->checkEmpty($this->alipayPublicKey) || !$this->checkEmpty($this->alipayrsaPublicKey)) {  
915 -  
916 -  
917 - if ($signData == null || $this->checkEmpty($signData->sign) || $this->checkEmpty($signData->signSourceData)) {  
918 -  
919 - throw new Exception(" check sign Fail! The reason : signData is Empty");  
920 - }  
921 -  
922 -  
923 - // 获取结果sub_code  
924 - $responseSubCode = $this->parserResponseSubCode($request, $resp, $respObject, $this->format);  
925 -  
926 -  
927 - if (!$this->checkEmpty($responseSubCode) || ($this->checkEmpty($responseSubCode) && !$this->checkEmpty($signData->sign))) {  
928 -  
929 - $checkResult = $this->verify($signData->signSourceData, $signData->sign, $this->alipayPublicKey, $this->signType);  
930 -  
931 -  
932 - if (!$checkResult) {  
933 -  
934 - if (strpos($signData->signSourceData, "\\/") > 0) {  
935 -  
936 - $signData->signSourceData = str_replace("\\/", "/", $signData->signSourceData);  
937 -  
938 - $checkResult = $this->verify($signData->signSourceData, $signData->sign, $this->alipayPublicKey, $this->signType);  
939 -  
940 - if (!$checkResult) {  
941 - throw new Exception("check sign Fail! [sign=" . $signData->sign . ", signSourceData=" . $signData->signSourceData . "]");  
942 - }  
943 -  
944 - } else {  
945 -  
946 - throw new Exception("check sign Fail! [sign=" . $signData->sign . ", signSourceData=" . $signData->signSourceData . "]");  
947 - }  
948 -  
949 - }  
950 - }  
951 -  
952 -  
953 - }  
954 - }  
955 -  
956 - private function setupCharsets($request) {  
957 - if ($this->checkEmpty($this->postCharset)) {  
958 - $this->postCharset = 'UTF-8';  
959 - }  
960 - $str = preg_match('/[\x80-\xff]/', $this->appId) ? $this->appId : print_r($request, true);  
961 - $this->fileCharset = mb_detect_encoding($str, "UTF-8, GBK") == 'UTF-8' ? 'UTF-8' : 'GBK';  
962 - }  
963 -  
964 - // 获取加密内容  
965 -  
966 - private function encryptJSONSignSource($request, $responseContent) {  
967 -  
968 - $parsetItem = $this->parserEncryptJSONSignSource($request, $responseContent);  
969 -  
970 - $bodyIndexContent = substr($responseContent, 0, $parsetItem->startIndex);  
971 - $bodyEndContent = substr($responseContent, $parsetItem->endIndex, strlen($responseContent) + 1 - $parsetItem->endIndex);  
972 -  
973 - $bizContent = decrypt($parsetItem->encryptContent, $this->encryptKey);  
974 - return $bodyIndexContent . $bizContent . $bodyEndContent;  
975 -  
976 - }  
977 -  
978 -  
979 - private function parserEncryptJSONSignSource($request, $responseContent) {  
980 -  
981 - $apiName = $request->getApiMethodName();  
982 - $rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;  
983 -  
984 - $rootIndex = strpos($responseContent, $rootNodeName);  
985 - $errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);  
986 -  
987 -  
988 - if ($rootIndex > 0) {  
989 -  
990 - return $this->parserEncryptJSONItem($responseContent, $rootNodeName, $rootIndex);  
991 - } else if ($errorIndex > 0) {  
992 -  
993 - return $this->parserEncryptJSONItem($responseContent, $this->ERROR_RESPONSE, $errorIndex);  
994 - } else {  
995 -  
996 - return null;  
997 - }  
998 -  
999 -  
1000 - }  
1001 -  
1002 -  
1003 - private function parserEncryptJSONItem($responseContent, $nodeName, $nodeIndex) {  
1004 - $signDataStartIndex = $nodeIndex + strlen($nodeName) + 2;  
1005 - $signIndex = strpos($responseContent, "\"" . $this->SIGN_NODE_NAME . "\"");  
1006 - // 签名前-逗号  
1007 - $signDataEndIndex = $signIndex - 1;  
1008 -  
1009 - if ($signDataEndIndex < 0) {  
1010 -  
1011 - $signDataEndIndex = strlen($responseContent)-1 ;  
1012 - }  
1013 -  
1014 - $indexLen = $signDataEndIndex - $signDataStartIndex;  
1015 -  
1016 - $encContent = substr($responseContent, $signDataStartIndex+1, $indexLen-2);  
1017 -  
1018 -  
1019 - $encryptParseItem = new EncryptParseItem();  
1020 -  
1021 - $encryptParseItem->encryptContent = $encContent;  
1022 - $encryptParseItem->startIndex = $signDataStartIndex;  
1023 - $encryptParseItem->endIndex = $signDataEndIndex;  
1024 -  
1025 - return $encryptParseItem;  
1026 -  
1027 - }  
1028 -  
1029 - // 获取加密内容  
1030 -  
1031 - private function encryptXMLSignSource($request, $responseContent) {  
1032 -  
1033 - $parsetItem = $this->parserEncryptXMLSignSource($request, $responseContent);  
1034 -  
1035 - $bodyIndexContent = substr($responseContent, 0, $parsetItem->startIndex);  
1036 - $bodyEndContent = substr($responseContent, $parsetItem->endIndex, strlen($responseContent) + 1 - $parsetItem->endIndex);  
1037 - $bizContent = decrypt($parsetItem->encryptContent, $this->encryptKey);  
1038 -  
1039 - return $bodyIndexContent . $bizContent . $bodyEndContent;  
1040 -  
1041 - }  
1042 -  
1043 - private function parserEncryptXMLSignSource($request, $responseContent) {  
1044 -  
1045 -  
1046 - $apiName = $request->getApiMethodName();  
1047 - $rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;  
1048 -  
1049 -  
1050 - $rootIndex = strpos($responseContent, $rootNodeName);  
1051 - $errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);  
1052 - // $this->echoDebug("<br/>rootNodeName:" . $rootNodeName);  
1053 - // $this->echoDebug("<br/> responseContent:<xmp>" . $responseContent . "</xmp>");  
1054 -  
1055 -  
1056 - if ($rootIndex > 0) {  
1057 -  
1058 - return $this->parserEncryptXMLItem($responseContent, $rootNodeName, $rootIndex);  
1059 - } else if ($errorIndex > 0) {  
1060 -  
1061 - return $this->parserEncryptXMLItem($responseContent, $this->ERROR_RESPONSE, $errorIndex);  
1062 - } else {  
1063 -  
1064 - return null;  
1065 - }  
1066 -  
1067 -  
1068 - }  
1069 -  
1070 - private function parserEncryptXMLItem($responseContent, $nodeName, $nodeIndex) {  
1071 -  
1072 - $signDataStartIndex = $nodeIndex + strlen($nodeName) + 1;  
1073 -  
1074 - $xmlStartNode="<".$this->ENCRYPT_XML_NODE_NAME.">";  
1075 - $xmlEndNode="</".$this->ENCRYPT_XML_NODE_NAME.">";  
1076 -  
1077 - $indexOfXmlNode=strpos($responseContent,$xmlEndNode);  
1078 - if($indexOfXmlNode<0){  
1079 -  
1080 - $item = new EncryptParseItem();  
1081 - $item->encryptContent = null;  
1082 - $item->startIndex = 0;  
1083 - $item->endIndex = 0;  
1084 - return $item;  
1085 - }  
1086 -  
1087 - $startIndex=$signDataStartIndex+strlen($xmlStartNode);  
1088 - $bizContentLen=$indexOfXmlNode-$startIndex;  
1089 - $bizContent=substr($responseContent,$startIndex,$bizContentLen);  
1090 -  
1091 - $encryptParseItem = new EncryptParseItem();  
1092 - $encryptParseItem->encryptContent = $bizContent;  
1093 - $encryptParseItem->startIndex = $signDataStartIndex;  
1094 - $encryptParseItem->endIndex = $indexOfXmlNode+strlen($xmlEndNode);  
1095 -  
1096 - return $encryptParseItem;  
1097 -  
1098 - }  
1099 -  
1100 -  
1101 - function echoDebug($content) {  
1102 -  
1103 - if ($this->debugInfo) {  
1104 - echo "<br/>" . $content;  
1105 - }  
1106 -  
1107 - }  
1108 -  
1109 -  
1110 -}  
1 -<?php  
2 -/**  
3 - * 加密工具类  
4 - *  
5 - * User: jiehua  
6 - * Date: 16/3/30  
7 - * Time: 下午3:25  
8 - */  
9 -  
10 -/**  
11 - * 加密方法  
12 - * @param string $str  
13 - * @return string  
14 - */  
15 - function encrypt($str,$screct_key){  
16 - //AES, 128 模式加密数据 CBC  
17 - $screct_key = base64_decode($screct_key);  
18 - $str = trim($str);  
19 - $str = addPKCS7Padding($str);  
20 - $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);  
21 - $encrypt_str = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);  
22 - return base64_encode($encrypt_str);  
23 -}  
24 -  
25 -/**  
26 - * 解密方法  
27 - * @param string $str  
28 - * @return string  
29 - */  
30 - function decrypt($str,$screct_key){  
31 - //AES, 128 模式加密数据 CBC  
32 - $str = base64_decode($str);  
33 - $screct_key = base64_decode($screct_key);  
34 - $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);  
35 - $encrypt_str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);  
36 - $encrypt_str = trim($encrypt_str);  
37 -  
38 - $encrypt_str = stripPKSC7Padding($encrypt_str);  
39 - return $encrypt_str;  
40 -  
41 -}  
42 -  
43 -/**  
44 - * 填充算法  
45 - * @param string $source  
46 - * @return string  
47 - */  
48 -function addPKCS7Padding($source){  
49 - $source = trim($source);  
50 - $block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);  
51 -  
52 - $pad = $block - (strlen($source) % $block);  
53 - if ($pad <= $block) {  
54 - $char = chr($pad);  
55 - $source .= str_repeat($char, $pad);  
56 - }  
57 - return $source;  
58 -}  
59 -/**  
60 - * 移去填充算法  
61 - * @param string $source  
62 - * @return string  
63 - */  
64 -function stripPKSC7Padding($source){  
65 - $source = trim($source);  
66 - $char = substr($source, -1);  
67 - $num = ord($char);  
68 - if($num==62)return $source;  
69 - $source = substr($source,0,-$num);  
70 - return $source;  
71 -}  
1 -<?php  
2 -/**  
3 - * TODO 补充说明  
4 - *  
5 - * User: jiehua  
6 - * Date: 16/3/30  
7 - * Time: 下午8:55  
8 - */  
9 -  
10 -class EncryptParseItem {  
11 -  
12 -  
13 - public $startIndex;  
14 -  
15 - public $endIndex;  
16 -  
17 - public $encryptContent;  
18 -  
19 -}  
1 -<?php  
2 -/**  
3 - * TODO 补充说明  
4 - *  
5 - * User: jiehua  
6 - * Date: 16/3/30  
7 - * Time: 下午8:51  
8 - */  
9 -  
10 -class EncryptResponseData {  
11 -  
12 -  
13 - public $realContent;  
14 -  
15 - public $returnContent;  
16 -  
17 -  
18 -}  
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: jiehua  
5 - * Date: 15/5/2  
6 - * Time: 下午6:21  
7 - */  
8 -  
9 -class SignData {  
10 -  
11 - public $signSourceData=null;  
12 -  
13 -  
14 - public $sign=null;  
15 -  
16 -}  
1 -<?php  
2 -/**  
3 - * ALIPAY API: alipay.account.exrate.advice.accept request  
4 - *  
5 - * @author auto create  
6 - * @since 1.0, 2016-05-23 14:55:42  
7 - */  
8 -class AlipayAccountExrateAdviceAcceptRequest  
9 -{  
10 - /**  
11 - * 标准的兑换交易受理接口  
12 - **/  
13 - private $bizContent;  
14 -  
15 - private $apiParas = array();  
16 - private $terminalType;  
17 - private $terminalInfo;  
18 - private $prodCode;  
19 - private $apiVersion="1.0";  
20 - private $notifyUrl;  
21 - private $returnUrl;  
22 - private $needEncrypt=false;  
23 -  
24 -  
25 - public function setBizContent($bizContent)  
26 - {  
27 - $this->bizContent = $bizContent;  
28 - $this->apiParas["biz_content"] = $bizContent;  
29 - }  
30 -  
31 - public function getBizContent()  
32 - {  
33 - return $this->bizContent;  
34 - }  
35 -  
36 - public function getApiMethodName()  
37 - {  
38 - return "alipay.account.exrate.advice.accept";  
39 - }  
40 -  
41 - public function setNotifyUrl($notifyUrl)  
42 - {  
43 - $this->notifyUrl=$notifyUrl;  
44 - }  
45 -  
46 - public function getNotifyUrl()  
47 - {  
48 - return $this->notifyUrl;  
49 - }  
50 -  
51 - public function setReturnUrl($returnUrl)  
52 - {  
53 - $this->returnUrl=$returnUrl;  
54 - }  
55 -  
56 - public function getReturnUrl()  
57 - {  
58 - return $this->returnUrl;  
59 - }  
60 -  
61 - public function getApiParas()  
62 - {  
63 - return $this->apiParas;  
64 - }  
65 -  
66 - public function getTerminalType()  
67 - {  
68 - return $this->terminalType;  
69 - }  
70 -  
71 - public function setTerminalType($terminalType)  
72 - {  
73 - $this->terminalType = $terminalType;  
74 - }  
75 -  
76 - public function getTerminalInfo()  
77 - {  
78 - return $this->terminalInfo;  
79 - }  
80 -  
81 - public function setTerminalInfo($terminalInfo)  
82 - {  
83 - $this->terminalInfo = $terminalInfo;  
84 - }  
85 -  
86 - public function getProdCode()  
87 - {  
88 - return $this->prodCode;  
89 - }  
90 -  
91 - public function setProdCode($prodCode)  
92 - {  
93 - $this->prodCode = $prodCode;  
94 - }  
95 -  
96 - public function setApiVersion($apiVersion)  
97 - {  
98 - $this->apiVersion=$apiVersion;  
99 - }  
100 -  
101 - public function getApiVersion()  
102 - {  
103 - return $this->apiVersion;  
104 - }  
105 -  
106 - public function setNeedEncrypt($needEncrypt)  
107 - {  
108 -  
109 - $this->needEncrypt=$needEncrypt;  
110 -  
111 - }  
112 -  
113 - public function getNeedEncrypt()  
114 - {  
115 - return $this->needEncrypt;  
116 - }  
117 -  
118 -}  
1 -<?php  
2 -/**  
3 - * ALIPAY API: alipay.account.exrate.allclientrate.query request  
4 - *  
5 - * @author auto create  
6 - * @since 1.0, 2016-05-23 14:55:48  
7 - */  
8 -class AlipayAccountExrateAllclientrateQueryRequest  
9 -{  
10 - /**  
11 - * 查询客户的所有币种对最新有效汇率  
12 - **/  
13 - private $bizContent;  
14 -  
15 - private $apiParas = array();  
16 - private $terminalType;  
17 - private $terminalInfo;  
18 - private $prodCode;  
19 - private $apiVersion="1.0";  
20 - private $notifyUrl;  
21 - private $returnUrl;  
22 - private $needEncrypt=false;  
23 -  
24 -  
25 - public function setBizContent($bizContent)  
26 - {  
27 - $this->bizContent = $bizContent;  
28 - $this->apiParas["biz_content"] = $bizContent;  
29 - }  
30 -  
31 - public function getBizContent()  
32 - {  
33 - return $this->bizContent;  
34 - }  
35 -  
36 - public function getApiMethodName()  
37 - {  
38 - return "alipay.account.exrate.allclientrate.query";  
39 - }  
40 -  
41 - public function setNotifyUrl($notifyUrl)  
42 - {  
43 - $this->notifyUrl=$notifyUrl;  
44 - }  
45 -  
46 - public function getNotifyUrl()  
47 - {  
48 - return $this->notifyUrl;  
49 - }  
50 -  
51 - public function setReturnUrl($returnUrl)  
52 - {  
53 - $this->returnUrl=$returnUrl;  
54 - }  
55 -  
56 - public function getReturnUrl()  
57 - {  
58 - return $this->returnUrl;  
59 - }  
60 -  
61 - public function getApiParas()  
62 - {  
63 - return $this->apiParas;  
64 - }  
65 -  
66 - public function getTerminalType()  
67 - {  
68 - return $this->terminalType;  
69 - }  
70 -  
71 - public function setTerminalType($terminalType)  
72 - {  
73 - $this->terminalType = $terminalType;  
74 - }  
75 -  
76 - public function getTerminalInfo()  
77 - {  
78 - return $this->terminalInfo;  
79 - }  
80 -  
81 - public function setTerminalInfo($terminalInfo)  
82 - {  
83 - $this->terminalInfo = $terminalInfo;  
84 - }  
85 -  
86 - public function getProdCode()  
87 - {  
88 - return $this->prodCode;  
89 - }  
90 -  
91 - public function setProdCode($prodCode)  
92 - {  
93 - $this->prodCode = $prodCode;  
94 - }  
95 -  
96 - public function setApiVersion($apiVersion)  
97 - {  
98 - $this->apiVersion=$apiVersion;  
99 - }  
100 -  
101 - public function getApiVersion()  
102 - {  
103 - return $this->apiVersion;  
104 - }  
105 -  
106 - public function setNeedEncrypt($needEncrypt)  
107 - {  
108 -  
109 - $this->needEncrypt=$needEncrypt;  
110 -  
111 - }  
112 -  
113 - public function getNeedEncrypt()  
114 - {  
115 - return $this->needEncrypt;  
116 - }  
117 -  
118 -}  
1 -<?php  
2 -/**  
3 - * ALIPAY API: alipay.account.exrate.ratequery request  
4 - *  
5 - * @author auto create  
6 - * @since 1.0, 2016-05-23 14:55:56  
7 - */  
8 -class AlipayAccountExrateRatequeryRequest  
9 -{  
10 - /**  
11 - * 对于部分签约境内当面付的商家,为了能够在境外进行推广,因此需要汇率进行币种之间的转换,本接口提供此业务场景下的汇率查询服务  
12 - **/  
13 - private $bizContent;  
14 -  
15 - private $apiParas = array();  
16 - private $terminalType;  
17 - private $terminalInfo;  
18 - private $prodCode;  
19 - private $apiVersion="1.0";  
20 - private $notifyUrl;  
21 - private $returnUrl;  
22 - private $needEncrypt=false;  
23 -  
24 -  
25 - public function setBizContent($bizContent)  
26 - {  
27 - $this->bizContent = $bizContent;  
28 - $this->apiParas["biz_content"] = $bizContent;  
29 - }  
30 -  
31 - public function getBizContent()  
32 - {  
33 - return $this->bizContent;  
34 - }  
35 -  
36 - public function getApiMethodName()  
37 - {  
38 - return "alipay.account.exrate.ratequery";  
39 - }  
40 -  
41 - public function setNotifyUrl($notifyUrl)  
42 - {  
43 - $this->notifyUrl=$notifyUrl;  
44 - }  
45 -  
46 - public function getNotifyUrl()  
47 - {  
48 - return $this->notifyUrl;  
49 - }  
50 -  
51 - public function setReturnUrl($returnUrl)  
52 - {  
53 - $this->returnUrl=$returnUrl;  
54 - }  
55 -  
56 - public function getReturnUrl()  
57 - {  
58 - return $this->returnUrl;  
59 - }  
60 -  
61 - public function getApiParas()  
62 - {  
63 - return $this->apiParas;  
64 - }  
65 -  
66 - public function getTerminalType()  
67 - {  
68 - return $this->terminalType;  
69 - }  
70 -  
71 - public function setTerminalType($terminalType)  
72 - {  
73 - $this->terminalType = $terminalType;  
74 - }  
75 -  
76 - public function getTerminalInfo()  
77 - {  
78 - return $this->terminalInfo;  
79 - }  
80 -  
81 - public function setTerminalInfo($terminalInfo)  
82 - {  
83 - $this->terminalInfo = $terminalInfo;  
84 - }  
85 -  
86 - public function getProdCode()  
87 - {  
88 - return $this->prodCode;  
89 - }  
90 -  
91 - public function setProdCode($prodCode)  
92 - {  
93 - $this->prodCode = $prodCode;  
94 - }  
95 -  
96 - public function setApiVersion($apiVersion)  
97 - {  
98 - $this->apiVersion=$apiVersion;  
99 - }  
100 -  
101 - public function getApiVersion()  
102 - {  
103 - return $this->apiVersion;  
104 - }  
105 -  
106 - public function setNeedEncrypt($needEncrypt)  
107 - {  
108 -  
109 - $this->needEncrypt=$needEncrypt;  
110 -  
111 - }  
112 -  
113 - public function getNeedEncrypt()  
114 - {  
115 - return $this->needEncrypt;  
116 - }  
117 -  
118 -}  
1 -<?php  
2 -/**  
3 - * ALIPAY API: alipay.acquire.cancel request  
4 - *  
5 - * @author auto create  
6 - * @since 1.0, 2014-06-12 17:17:06  
7 - */  
8 -class AlipayAcquireCancelRequest  
9 -{  
10 - /**  
11 - * 操作员ID。  
12 - **/  
13 - private $operatorId;  
14 -  
15 - /**  
16 - * 操作员的类型:  
17 -0:支付宝操作员  
18 -1:商户的操作员  
19 -如果传入其它值或者为空,则默认设置为1  
20 - **/  
21 - private $operatorType;  
22 -  
23 - /**  
24 - * 支付宝合作商户网站唯一订单号。  
25 - **/  
26 - private $outTradeNo;  
27 -  
28 - /**  
29 - * 该交易在支付宝系统中的交易流水号。  
30 -最短16位,最长64位。  
31 -如果同时传了out_trade_no和trade_no,则以trade_no为准。  
32 - **/  
33 - private $tradeNo;  
34 -  
35 - private $apiParas = array();  
36 - private $terminalType;  
37 - private $terminalInfo;  
38 - private $prodCode;  
39 - private $apiVersion="1.0";  
40 - private $notifyUrl;  
41 - private $returnUrl;  
42 - private $needEncrypt=false;  
43 -  
44 -  
45 - public function setOperatorId($operatorId)  
46 - {  
47 - $this->operatorId = $operatorId;  
48 - $this->apiParas["operator_id"] = $operatorId;  
49 - }  
50 -  
51 - public function getOperatorId()  
52 - {  
53 - return $this->operatorId;  
54 - }  
55 -  
56 - public function setOperatorType($operatorType)  
57 - {  
58 - $this->operatorType = $operatorType;  
59 - $this->apiParas["operator_type"] = $operatorType;  
60 - }  
61 -  
62 - public function getOperatorType()  
63 - {  
64 - return $this->operatorType;  
65 - }  
66 -  
67 - public function setOutTradeNo($outTradeNo)  
68 - {  
69 - $this->outTradeNo = $outTradeNo;  
70 - $this->apiParas["out_trade_no"] = $outTradeNo;  
71 - }  
72 -  
73 - public function getOutTradeNo()  
74 - {  
75 - return $this->outTradeNo;  
76 - }  
77 -  
78 - public function setTradeNo($tradeNo)  
79 - {  
80 - $this->tradeNo = $tradeNo;  
81 - $this->apiParas["trade_no"] = $tradeNo;  
82 - }  
83 -  
84 - public function getTradeNo()  
85 - {  
86 - return $this->tradeNo;  
87 - }  
88 -  
89 - public function getApiMethodName()  
90 - {  
91 - return "alipay.acquire.cancel";  
92 - }  
93 -  
94 - public function setNotifyUrl($notifyUrl)  
95 - {  
96 - $this->notifyUrl=$notifyUrl;  
97 - }  
98 -  
99 - public function getNotifyUrl()  
100 - {  
101 - return $this->notifyUrl;  
102 - }  
103 -  
104 - public function setReturnUrl($returnUrl)  
105 - {  
106 - $this->returnUrl=$returnUrl;  
107 - }  
108 -  
109 - public function getReturnUrl()  
110 - {  
111 - return $this->returnUrl;  
112 - }  
113 -  
114 - public function getApiParas()  
115 - {  
116 - return $this->apiParas;  
117 - }  
118 -  
119 - public function getTerminalType()  
120 - {  
121 - return $this->terminalType;  
122 - }  
123 -  
124 - public function setTerminalType($terminalType)  
125 - {  
126 - $this->terminalType = $terminalType;  
127 - }  
128 -  
129 - public function getTerminalInfo()  
130 - {  
131 - return $this->terminalInfo;  
132 - }  
133 -  
134 - public function setTerminalInfo($terminalInfo)  
135 - {  
136 - $this->terminalInfo = $terminalInfo;  
137 - }  
138 -  
139 - public function getProdCode()  
140 - {  
141 - return $this->prodCode;  
142 - }  
143 -  
144 - public function setProdCode($prodCode)  
145 - {  
146 - $this->prodCode = $prodCode;  
147 - }  
148 -  
149 - public function setApiVersion($apiVersion)  
150 - {  
151 - $this->apiVersion=$apiVersion;  
152 - }  
153 -  
154 - public function getApiVersion()  
155 - {  
156 - return $this->apiVersion;  
157 - }  
158 -  
159 - public function setNeedEncrypt($needEncrypt)  
160 - {  
161 -  
162 - $this->needEncrypt=$needEncrypt;  
163 -  
164 - }  
165 -  
166 - public function getNeedEncrypt()  
167 - {  
168 - return $this->needEncrypt;  
169 - }  
170 -  
171 -}  
1 -<?php  
2 -/**  
3 - * ALIPAY API: alipay.acquire.close request  
4 - *  
5 - * @author auto create  
6 - * @since 1.0, 2014-06-12 17:17:06  
7 - */  
8 -class AlipayAcquireCloseRequest  
9 -{  
10 - /**  
11 - * 卖家的操作员ID  
12 - **/  
13 - private $operatorId;  
14 -  
15 - /**  
16 - * 支付宝合作商户网站唯一订单号  
17 - **/  
18 - private $outTradeNo;  
19 -  
20 - /**  
21 - * 该交易在支付宝系统中的交易流水号。  
22 -最短16位,最长64位。  
23 -如果同时传了out_trade_no和trade_no,则以trade_no为准  
24 - **/  
25 - private $tradeNo;  
26 -  
27 - private $apiParas = array();  
28 - private $terminalType;  
29 - private $terminalInfo;  
30 - private $prodCode;  
31 - private $apiVersion="1.0";  
32 - private $notifyUrl;  
33 - private $returnUrl;  
34 - private $needEncrypt=false;  
35 -  
36 -  
37 - public function setOperatorId($operatorId)  
38 - {  
39 - $this->operatorId = $operatorId;  
40 - $this->apiParas["operator_id"] = $operatorId;  
41 - }  
42 -  
43 - public function getOperatorId()  
44 - {  
45 - return $this->operatorId;  
46 - }  
47 -  
48 - public function setOutTradeNo($outTradeNo)  
49 - {  
50 - $this->outTradeNo = $outTradeNo;  
51 - $this->apiParas["out_trade_no"] = $outTradeNo;  
52 - }  
53 -  
54 - public function getOutTradeNo()  
55 - {  
56 - return $this->outTradeNo;  
57 - }  
58 -  
59 - public function setTradeNo($tradeNo)  
60 - {  
61 - $this->tradeNo = $tradeNo;  
62 - $this->apiParas["trade_no"] = $tradeNo;  
63 - }  
64 -  
65 - public function getTradeNo()  
66 - {  
67 - return $this->tradeNo;  
68 - }  
69 -  
70 - public function getApiMethodName()  
71 - {  
72 - return "alipay.acquire.close";  
73 - }  
74 -  
75 - public function setNotifyUrl($notifyUrl)  
76 - {  
77 - $this->notifyUrl=$notifyUrl;  
78 - }  
79 -  
80 - public function getNotifyUrl()  
81 - {  
82 - return $this->notifyUrl;  
83 - }  
84 -  
85 - public function setReturnUrl($returnUrl)  
86 - {  
87 - $this->returnUrl=$returnUrl;  
88 - }  
89 -  
90 - public function getReturnUrl()  
91 - {  
92 - return $this->returnUrl;  
93 - }  
94 -  
95 - public function getApiParas()  
96 - {  
97 - return $this->apiParas;  
98 - }  
99 -  
100 - public function getTerminalType()  
101 - {  
102 - return $this->terminalType;  
103 - }  
104 -  
105 - public function setTerminalType($terminalType)  
106 - {  
107 - $this->terminalType = $terminalType;  
108 - }  
109 -  
110 - public function getTerminalInfo()  
111 - {  
112 - return $this->terminalInfo;  
113 - }  
114 -  
115 - public function setTerminalInfo($terminalInfo)  
116 - {  
117 - $this->terminalInfo = $terminalInfo;  
118 - }  
119 -  
120 - public function getProdCode()  
121 - {  
122 - return $this->prodCode;  
123 - }  
124 -  
125 - public function setProdCode($prodCode)  
126 - {  
127 - $this->prodCode = $prodCode;  
128 - }  
129 -  
130 - public function setApiVersion($apiVersion)  
131 - {  
132 - $this->apiVersion=$apiVersion;  
133 - }  
134 -  
135 - public function getApiVersion()  
136 - {  
137 - return $this->apiVersion;  
138 - }  
139 -  
140 - public function setNeedEncrypt($needEncrypt)  
141 - {  
142 -  
143 - $this->needEncrypt=$needEncrypt;  
144 -  
145 - }  
146 -  
147 - public function getNeedEncrypt()  
148 - {  
149 - return $this->needEncrypt;  
150 - }  
151 -  
152 -}  
1 -<?php  
2 -/**  
3 - * ALIPAY API: alipay.acquire.createandpay request  
4 - *  
5 - * @author auto create  
6 - * @since 1.0, 2016-11-22 19:31:24  
7 - */  
8 -class AlipayAcquireCreateandpayRequest  
9 -{  
10 - /**  
11 - * 证书签名  
12 - **/  
13 - private $alipayCaRequest;  
14 -  
15 - /**  
16 - * 对一笔交易的具体描述信息。如果是多种商品,请将商品描述字符串累加传给body。  
17 - **/  
18 - private $body;  
19 -  
20 - /**  
21 - * 买家支付宝账号,可以为email或者手机号。  
22 - **/  
23 - private $buyerEmail;  
24 -  
25 - /**  
26 - * 买家支付宝账号对应的支付宝唯一用户号。  
27 -以2088开头的纯16位数字。  
28 - **/  
29 - private $buyerId;  
30 -  
31 - /**  
32 - * 描述多渠道收单的渠道明细信息,json格式,具体请参见“4.5 渠道明细说明”。  
33 - **/  
34 - private $channelParameters;  
35 -  
36 - /**  
37 - * 订单金额币种。  
38 -目前只支持传入156(人民币)。  
39 -如果为空,则默认设置为156。  
40 - **/  
41 - private $currency;  
42 -  
43 - /**  
44 - * 动态ID。  
45 - **/  
46 - private $dynamicId;  
47 -  
48 - /**  
49 - * 动态ID类型:  
50 -&#1048698;  
51 -soundwave:声波  
52 -&#1048698;  
53 -qrcode:二维码  
54 -&#1048698;  
55 -barcode:条码  
56 -&#1048698;  
57 -wave_code:声波,等同soundwave  
58 -&#1048698;  
59 -qr_code:二维码,等同qrcode  
60 -&#1048698;  
61 -bar_code:条码,等同barcode  
62 -建议取值wave_code、qr_code、bar_code。  
63 - **/  
64 - private $dynamicIdType;  
65 -  
66 - /**  
67 - * 用于商户的特定业务信息的传递,只有商户与支付宝约定了传递此参数且约定了参数含义,此参数才有效。  
68 -比如可传递声波支付场景下的门店ID等信息,以json格式传输,具体请参见“4.7 业务扩展参数说明”。  
69 - **/  
70 - private $extendParams;  
71 -  
72 - /**  
73 - * xml或json  
74 - **/  
75 - private $formatType;  
76 -  
77 - /**  
78 - * 描述商品明细信息,json格式,具体请参见“4.3 商品明细说明”。  
79 - **/  
80 - private $goodsDetail;  
81 -  
82 - /**  
83 - * 设置未付款交易的超时时间,一旦超时,该笔交易就会自动被关闭。  
84 -取值范围:1m~15d。  
85 -m-分钟,h-小时,d-天,1c-当天(无论交易何时创建,都在0点关闭)。  
86 -该参数数值不接受小数点,如1.5h,可转换为90m。  
87 -该功能需要联系支付宝配置关闭时间。  
88 - **/  
89 - private $itBPay;  
90 -  
91 - /**  
92 - * 描述预付卡相关的明细信息,json格式,具体请参见“4.8 预付卡明细参数说明”。  
93 - **/  
94 - private $mcardParameters;  
95 -  
96 - /**  
97 - * 卖家的操作员ID。  
98 - **/  
99 - private $operatorId;  
100 -  
101 - /**  
102 - * 操作员的类型:  
103 -&#1048698;  
104 -0:支付宝操作员  
105 -&#1048698;  
106 -1:商户的操作员  
107 -如果传入其它值或者为空,则默认设置为1。  
108 - **/  
109 - private $operatorType;  
110 -  
111 - /**  
112 - * 支付宝合作商户网站唯一订单号。  
113 - **/  
114 - private $outTradeNo;  
115 -  
116 - /**  
117 - * 订单中商品的单价。  
118 -如果请求时传入本参数,则必须满足total_fee=price×quantity的条件。  
119 - **/  
120 - private $price;  
121 -  
122 - /**  
123 - * 订单中商品的数量。  
124 -如果请求时传入本参数,则必须满足total_fee=price×quantity的条件。  
125 - **/  
126 - private $quantity;  
127 -  
128 - /**  
129 - * 业务关联ID集合,用于放置商户的订单号、支付流水号等信息,json格式,具体请参见“4.6 业务关联ID集合说明”。  
130 - **/  
131 - private $refIds;  
132 -  
133 - /**  
134 - * 描述分账明细信息,json格式,具体请参见“4.4 分账明细说明”。  
135 - **/  
136 - private $royaltyParameters;  
137 -  
138 - /**  
139 - * 卖家的分账类型,目前只支持传入ROYALTY(普通分账类型)。  
140 - **/  
141 - private $royaltyType;  
142 -  
143 - /**  
144 - * 卖家支付宝账号,可以为email或者手机号。  
145 -如果seller_id不为空,则以seller_id的值作为卖家账号,忽略本参数。  
146 - **/  
147 - private $sellerEmail;  
148 -  
149 - /**  
150 - * 卖家支付宝账号对应的支付宝唯一用户号。  
151 -以2088开头的纯16位数字。  
152 -如果和seller_email同时为空,则本参数默认填充partner的值。  
153 - **/  
154 - private $sellerId;  
155 -  
156 - /**  
157 - * 收银台页面上,商品展示的超链接。  
158 - **/  
159 - private $showUrl;  
160 -  
161 - /**  
162 - * 商品的标题/交易标题/订单标题/订单关键字等。  
163 -该参数最长为128个汉字。  
164 - **/  
165 - private $subject;  
166 -  
167 - /**  
168 - * 该笔订单的资金总额,取值范围[0.01,100000000],精确到小数点后2位。  
169 - **/  
170 - private $totalFee;  
171 -  
172 - private $apiParas = array();  
173 - private $terminalType;  
174 - private $terminalInfo;  
175 - private $prodCode;  
176 - private $apiVersion="1.0";  
177 - private $notifyUrl;  
178 - private $returnUrl;  
179 - private $needEncrypt=false;  
180 -  
181 -  
182 - public function setAlipayCaRequest($alipayCaRequest)  
183 - {  
184 - $this->alipayCaRequest = $alipayCaRequest;  
185 - $this->apiParas["alipay_ca_request"] = $alipayCaRequest;  
186 - }  
187 -  
188 - public function getAlipayCaRequest()  
189 - {  
190 - return $this->alipayCaRequest;  
191 - }  
192 -  
193 - public function setBody($body)  
194 - {  
195 - $this->body = $body;  
196 - $this->apiParas["body"] = $body;  
197 - }  
198 -  
199 - public function getBody()  
200 - {  
201 - return $this->body;  
202 - }  
203 -  
204 - public function setBuyerEmail($buyerEmail)  
205 - {  
206 - $this->buyerEmail = $buyerEmail;  
207 - $this->apiParas["buyer_email"] = $buyerEmail;  
208 - }  
209 -  
210 - public function getBuyerEmail()  
211 - {  
212 - return $this->buyerEmail;  
213 - }  
214 -  
215 - public function setBuyerId($buyerId)  
216 - {  
217 - $this->buyerId = $buyerId;  
218 - $this->apiParas["buyer_id"] = $buyerId;  
219 - }  
220 -  
221 - public function getBuyerId()  
222 - {  
223 - return $this->buyerId;  
224 - }  
225 -  
226 - public function setChannelParameters($channelParameters)  
227 - {  
228 - $this->channelParameters = $channelParameters;  
229 - $this->apiParas["channel_parameters"] = $channelParameters;  
230 - }  
231 -  
232 - public function getChannelParameters()  
233 - {  
234 - return $this->channelParameters;  
235 - }  
236 -  
237 - public function setCurrency($currency)  
238 - {  
239 - $this->currency = $currency;  
240 - $this->apiParas["currency"] = $currency;  
241 - }  
242 -  
243 - public function getCurrency()  
244 - {  
245 - return $this->currency;  
246 - }  
247 -  
248 - public function setDynamicId($dynamicId)  
249 - {  
250 - $this->dynamicId = $dynamicId;  
251 - $this->apiParas["dynamic_id"] = $dynamicId;  
252 - }  
253 -  
254 - public function getDynamicId()  
255 - {  
256 - return $this->dynamicId;  
257 - }  
258 -  
259 - public function setDynamicIdType($dynamicIdType)  
260 - {  
261 - $this->dynamicIdType = $dynamicIdType;  
262 - $this->apiParas["dynamic_id_type"] = $dynamicIdType;  
263 - }  
264 -  
265 - public function getDynamicIdType()  
266 - {  
267 - return $this->dynamicIdType;  
268 - }  
269 -  
270 - public function setExtendParams($extendParams)  
271 - {  
272 - $this->extendParams = $extendParams;  
273 - $this->apiParas["extend_params"] = $extendParams;  
274 - }  
275 -  
276 - public function getExtendParams()  
277 - {  
278 - return $this->extendParams;  
279 - }  
280 -  
281 - public function setFormatType($formatType)  
282 - {  
283 - $this->formatType = $formatType;  
284 - $this->apiParas["format_type"] = $formatType;  
285 - }  
286 -  
287 - public function getFormatType()  
288 - {  
289 - return $this->formatType;  
290 - }  
291 -  
292 - public function setGoodsDetail($goodsDetail)  
293 - {  
294 - $this->goodsDetail = $goodsDetail;  
295 - $this->apiParas["goods_detail"] = $goodsDetail;  
296 - }  
297 -  
298 - public function getGoodsDetail()  
299 - {  
300 - return $this->goodsDetail;  
301 - }  
302 -  
303 - public function setItBPay($itBPay)  
304 - {  
305 - $this->itBPay = $itBPay;  
306 - $this->apiParas["it_b_pay"] = $itBPay;  
307 - }  
308 -  
309 - public function getItBPay()  
310 - {  
311 - return $this->itBPay;  
312 - }  
313 -  
314 - public function setMcardParameters($mcardParameters)  
315 - {  
316 - $this->mcardParameters = $mcardParameters;  
317 - $this->apiParas["mcard_parameters"] = $mcardParameters;  
318 - }  
319 -  
320 - public function getMcardParameters()  
321 - {  
322 - return $this->mcardParameters;  
323 - }  
324 -  
325 - public function setOperatorId($operatorId)  
326 - {  
327 - $this->operatorId = $operatorId;  
328 - $this->apiParas["operator_id"] = $operatorId;  
329 - }  
330 -  
331 - public function getOperatorId()  
332 - {  
333 - return $this->operatorId;  
334 - }  
335 -  
336 - public function setOperatorType($operatorType)  
337 - {  
338 - $this->operatorType = $operatorType;  
339 - $this->apiParas["operator_type"] = $operatorType;  
340 - }  
341 -  
342 - public function getOperatorType()  
343 - {  
344 - return $this->operatorType;  
345 - }  
346 -  
347 - public function setOutTradeNo($outTradeNo)  
348 - {  
349 - $this->outTradeNo = $outTradeNo;  
350 - $this->apiParas["out_trade_no"] = $outTradeNo;  
351 - }  
352 -  
353 - public function getOutTradeNo()  
354 - {  
355 - return $this->outTradeNo;  
356 - }  
357 -  
358 - public function setPrice($price)  
359 - {  
360 - $this->price = $price;  
361 - $this->apiParas["price"] = $price;  
362 - }  
363 -  
364 - public function getPrice()  
365 - {  
366 - return $this->price;  
367 - }  
368 -  
369 - public function setQuantity($quantity)  
370 - {  
371 - $this->quantity = $quantity;  
372 - $this->apiParas["quantity"] = $quantity;  
373 - }  
374 -  
375 - public function getQuantity()  
376 - {  
377 - return $this->quantity;  
378 - }  
379 -  
380 - public function setRefIds($refIds)  
381 - {  
382 - $this->refIds = $refIds;  
383 - $this->apiParas["ref_ids"] = $refIds;  
384 - }  
385 -  
386 - public function getRefIds()  
387 - {  
388 - return $this->refIds;  
389 - }  
390 -  
391 - public function setRoyaltyParameters($royaltyParameters)  
392 - {  
393 - $this->royaltyParameters = $royaltyParameters;  
394 - $this->apiParas["royalty_parameters"] = $royaltyParameters;  
395 - }  
396 -  
397 - public function getRoyaltyParameters()  
398 - {  
399 - return $this->royaltyParameters;  
400 - }  
401 -  
402 - public function setRoyaltyType($royaltyType)  
403 - {  
404 - $this->royaltyType = $royaltyType;  
405 - $this->apiParas["royalty_type"] = $royaltyType;  
406 - }  
407 -  
408 - public function getRoyaltyType()  
409 - {  
410 - return $this->royaltyType;  
411 - }  
412 -  
413 - public function setSellerEmail($sellerEmail)  
414 - {  
415 - $this->sellerEmail = $sellerEmail;  
416 - $this->apiParas["seller_email"] = $sellerEmail;  
417 - }  
418 -  
419 - public function getSellerEmail()  
420 - {  
421 - return $this->sellerEmail;  
422 - }  
423 -  
424 - public function setSellerId($sellerId)  
425 - {  
426 - $this->sellerId = $sellerId;  
427 - $this->apiParas["seller_id"] = $sellerId;  
428 - }  
429 -  
430 - public function getSellerId()  
431 - {  
432 - return $this->sellerId;  
433 - }  
434 -  
435 - public function setShowUrl($showUrl)  
436 - {  
437 - $this->showUrl = $showUrl;  
438 - $this->apiParas["show_url"] = $showUrl;  
439 - }  
440 -  
441 - public function getShowUrl()  
442 - {  
443 - return $this->showUrl;  
444 - }  
445 -  
446 - public function setSubject($subject)  
447 - {  
448 - $this->subject = $subject;  
449 - $this->apiParas["subject"] = $subject;  
450 - }  
451 -  
452 - public function getSubject()  
453 - {  
454 - return $this->subject;  
455 - }  
456 -  
457 - public function setTotalFee($totalFee)  
458 - {  
459 - $this->totalFee = $totalFee;  
460 - $this->apiParas["total_fee"] = $totalFee;  
461 - }  
462 -  
463 - public function getTotalFee()  
464 - {  
465 - return $this->totalFee;  
466 - }  
467 -  
468 - public function getApiMethodName()  
469 - {  
470 - return "alipay.acquire.createandpay";  
471 - }  
472 -  
473 - public function setNotifyUrl($notifyUrl)  
474 - {  
475 - $this->notifyUrl=$notifyUrl;  
476 - }  
477 -  
478 - public function getNotifyUrl()  
479 - {  
480 - return $this->notifyUrl;  
481 - }  
482 -  
483 - public function setReturnUrl($returnUrl)  
484 - {  
485 - $this->returnUrl=$returnUrl;  
486 - }  
487 -  
488 - public function getReturnUrl()  
489 - {  
490 - return $this->returnUrl;  
491 - }  
492 -  
493 - public function getApiParas()  
494 - {  
495 - return $this->apiParas;  
496 - }  
497 -  
498 - public function getTerminalType()  
499 - {  
500 - return $this->terminalType;  
501 - }  
502 -  
503 - public function setTerminalType($terminalType)  
504 - {  
505 - $this->terminalType = $terminalType;  
506 - }  
507 -  
508 - public function getTerminalInfo()  
509 - {  
510 - return $this->terminalInfo;  
511 - }  
512 -  
513 - public function setTerminalInfo($terminalInfo)  
514 - {  
515 - $this->terminalInfo = $terminalInfo;  
516 - }  
517 -  
518 - public function getProdCode()  
519 - {  
520 - return $this->prodCode;  
521 - }  
522 -  
523 - public function setProdCode($prodCode)  
524 - {  
525 - $this->prodCode = $prodCode;  
526 - }  
527 -  
528 - public function setApiVersion($apiVersion)  
529 - {  
530 - $this->apiVersion=$apiVersion;  
531 - }  
532 -  
533 - public function getApiVersion()  
534 - {  
535 - return $this->apiVersion;  
536 - }  
537 -  
538 - public function setNeedEncrypt($needEncrypt)  
539 - {  
540 -  
541 - $this->needEncrypt=$needEncrypt;  
542 -  
543 - }  
544 -  
545 - public function getNeedEncrypt()  
546 - {  
547 - return $this->needEncrypt;  
548 - }  
549 -  
550 -}  
1 -<?php  
2 -/**  
3 - * ALIPAY API: alipay.acquire.precreate request  
4 - *  
5 - * @author auto create  
6 - * @since 1.0, 2014-05-28 11:57:10  
7 - */  
8 -class AlipayAcquirePrecreateRequest  
9 -{  
10 - /**  
11 - * 对一笔交易的具体描述信息。如果是多种商品,请将商品描述字符串累加传给body  
12 - **/  
13 - private $body;  
14 -  
15 - /**  
16 - * 描述多渠道收单的渠道明细信息,json格式  
17 - **/  
18 - private $channelParameters;  
19 -  
20 - /**  
21 - * 订单金额币种。目前只支持传入156(人民币)。  
22 -如果为空,则默认设置为156  
23 - **/  
24 - private $currency;  
25 -  
26 - /**  
27 - * 公用业务扩展信息。用于商户的特定业务信息的传递,只有商户与支付宝约定了传递此参数且约定了参数含义,此参数才有效。  
28 -比如可传递二维码支付场景下的门店ID等信息,以json格式传输。  
29 - **/  
30 - private $extendParams;  
31 -  
32 - /**  
33 - * 描述商品明细信息,json格式。  
34 - **/  
35 - private $goodsDetail;  
36 -  
37 - /**  
38 - * 订单支付超时时间。设置未付款交易的超时时间,一旦超时,该笔交易就会自动被关闭。  
39 -取值范围:1m~15d。  
40 -m-分钟,h-小时,d-天,1c-当天(无论交易何时创建,都在0点关闭)。  
41 -该参数数值不接受小数点,如1.5h,可转换为90m。  
42 -该功能需要联系支付宝配置关闭时间。  
43 - **/  
44 - private $itBPay;  
45 -  
46 - /**  
47 - * 操作员的类型:  
48 -0:支付宝操作员  
49 -1:商户的操作员  
50 -如果传入其它值或者为空,则默认设置为1  
51 - **/  
52 - private $operatorCode;  
53 -  
54 - /**  
55 - * 卖家的操作员ID  
56 - **/  
57 - private $operatorId;  
58 -  
59 - /**  
60 - * 支付宝合作商户网站唯一订单号  
61 - **/  
62 - private $outTradeNo;  
63 -  
64 - /**  
65 - * 订单中商品的单价。  
66 -如果请求时传入本参数,则必须满足total_fee=price×quantity的条件  
67 - **/  
68 - private $price;  
69 -  
70 - /**  
71 - * 订单中商品的数量。  
72 -如果请求时传入本参数,则必须满足total_fee=price×quantity的条件  
73 - **/  
74 - private $quantity;  
75 -  
76 - /**  
77 - * 分账信息。  
78 -描述分账明细信息,json格式  
79 - **/  
80 - private $royaltyParameters;  
81 -  
82 - /**  
83 - * 分账类型。卖家的分账类型,目前只支持传入ROYALTY(普通分账类型)  
84 - **/  
85 - private $royaltyType;  
86 -  
87 - /**  
88 - * 卖家支付宝账号,可以为email或者手机号。如果seller_id不为空,则以seller_id的值作为卖家账号,忽略本参数  
89 - **/  
90 - private $sellerEmail;  
91 -  
92 - /**  
93 - * 卖家支付宝账号对应的支付宝唯一用户号,以2088开头的纯16位数字。如果和seller_email同时为空,则本参数默认填充partner的值  
94 - **/  
95 - private $sellerId;  
96 -  
97 - /**  
98 - * 收银台页面上,商品展示的超链接  
99 - **/  
100 - private $showUrl;  
101 -  
102 - /**  
103 - * 商品购买  
104 - **/  
105 - private $subject;  
106 -  
107 - /**  
108 - * 订单金额。该笔订单的资金总额,取值范围[0.01,100000000],精确到小数点后2位。  
109 - **/  
110 - private $totalFee;  
111 -  
112 - private $apiParas = array();  
113 - private $terminalType;  
114 - private $terminalInfo;  
115 - private $prodCode;  
116 - private $apiVersion="1.0";  
117 - private $notifyUrl;  
118 - private $returnUrl;  
119 - private $needEncrypt=false;  
120 -  
121 -  
122 - public function setBody($body)  
123 - {  
124 - $this->body = $body;  
125 - $this->apiParas["body"] = $body;  
126 - }  
127 -  
128 - public function getBody()  
129 - {  
130 - return $this->body;  
131 - }  
132 -  
133 - public function setChannelParameters($channelParameters)  
134 - {  
135 - $this->channelParameters = $channelParameters;  
136 - $this->apiParas["channel_parameters"] = $channelParameters;  
137 - }  
138 -  
139 - public function getChannelParameters()  
140 - {  
141 - return $this->channelParameters;  
142 - }  
143 -  
144 - public function setCurrency($currency)  
145 - {  
146 - $this->currency = $currency;  
147 - $this->apiParas["currency"] = $currency;  
148 - }  
149 -  
150 - public function getCurrency()  
151 - {  
152 - return $this->currency;  
153 - }  
154 -  
155 - public function setExtendParams($extendParams)  
156 - {  
157 - $this->extendParams = $extendParams;  
158 - $this->apiParas["extend_params"] = $extendParams;  
159 - }  
160 -  
161 - public function getExtendParams()  
162 - {  
163 - return $this->extendParams;  
164 - }  
165 -  
166 - public function setGoodsDetail($goodsDetail)  
167 - {  
168 - $this->goodsDetail = $goodsDetail;  
169 - $this->apiParas["goods_detail"] = $goodsDetail;  
170 - }  
171 -  
172 - public function getGoodsDetail()  
173 - {  
174 - return $this->goodsDetail;  
175 - }  
176 -  
177 - public function setItBPay($itBPay)  
178 - {  
179 - $this->itBPay = $itBPay;  
180 - $this->apiParas["it_b_pay"] = $itBPay;  
181 - }  
182 -  
183 - public function getItBPay()  
184 - {  
185 - return $this->itBPay;  
186 - }  
187 -  
188 - public function setOperatorCode($operatorCode)  
189 - {  
190 - $this->operatorCode = $operatorCode;  
191 - $this->apiParas["operator_code"] = $operatorCode;  
192 - }  
193 -  
194 - public function getOperatorCode()  
195 - {  
196 - return $this->operatorCode;  
197 - }  
198 -  
199 - public function setOperatorId($operatorId)  
200 - {  
201 - $this->operatorId = $operatorId;  
202 - $this->apiParas["operator_id"] = $operatorId;  
203 - }  
204 -  
205 - public function getOperatorId()  
206 - {  
207 - return $this->operatorId;  
208 - }  
209 -  
210 - public function setOutTradeNo($outTradeNo)  
211 - {  
212 - $this->outTradeNo = $outTradeNo;  
213 - $this->apiParas["out_trade_no"] = $outTradeNo;  
214 - }  
215 -  
216 - public function getOutTradeNo()  
217 - {  
218 - return $this->outTradeNo;  
219 - }  
220 -  
221 - public function setPrice($price)  
222 - {  
223 - $this->price = $price;  
224 - $this->apiParas["price"] = $price;  
225 - }  
226 -  
227 - public function getPrice()  
228 - {  
229 - return $this->price;  
230 - }  
231 -  
232 - public function setQuantity($quantity)  
233 - {  
234 - $this->quantity = $quantity;  
235 - $this->apiParas["quantity"] = $quantity;  
236 - }  
237 -  
238 - public function getQuantity()  
239 - {  
240 - return $this->quantity;  
241 - }  
242 -  
243 - public function setRoyaltyParameters($royaltyParameters)  
244 - {  
245 - $this->royaltyParameters = $royaltyParameters;  
246 - $this->apiParas["royalty_parameters"] = $royaltyParameters;  
247 - }  
248 -  
249 - public function getRoyaltyParameters()  
250 - {  
251 - return $this->royaltyParameters;  
252 - }  
253 -  
254 - public function setRoyaltyType($royaltyType)  
255 - {  
256 - $this->royaltyType = $royaltyType;  
257 - $this->apiParas["royalty_type"] = $royaltyType;  
258 - }  
259 -  
260 - public function getRoyaltyType()  
261 - {  
262 - return $this->royaltyType;  
263 - }  
264 -  
265 - public function setSellerEmail($sellerEmail)  
266 - {  
267 - $this->sellerEmail = $sellerEmail;  
268 - $this->apiParas["seller_email"] = $sellerEmail;  
269 - }  
270 -  
271 - public function getSellerEmail()  
272 - {  
273 - return $this->sellerEmail;  
274 - }  
275 -  
276 - public function setSellerId($sellerId)  
277 - {  
278 - $this->sellerId = $sellerId;  
279 - $this->apiParas["seller_id"] = $sellerId;  
280 - }  
281 -  
282 - public function getSellerId()  
283 - {  
284 - return $this->sellerId;  
285 - }  
286 -  
287 - public function setShowUrl($showUrl)  
288 - {  
289 - $this->showUrl = $showUrl;  
290 - $this->apiParas["show_url"] = $showUrl;  
291 - }  
292 -  
293 - public function getShowUrl()  
294 - {  
295 - return $this->showUrl;  
296 - }  
297 -  
298 - public function setSubject($subject)  
299 - {  
300 - $this->subject = $subject;  
301 - $this->apiParas["subject"] = $subject;  
302 - }  
303 -  
304 - public function getSubject()  
305 - {  
306 - return $this->subject;  
307 - }  
308 -  
309 - public function setTotalFee($totalFee)  
310 - {  
311 - $this->totalFee = $totalFee;  
312 - $this->apiParas["total_fee"] = $totalFee;  
313 - }  
314 -  
315 - public function getTotalFee()  
316 - {  
317 - return $this->totalFee;  
318 - }  
319 -  
320 - public function getApiMethodName()  
321 - {  
322 - return "alipay.acquire.precreate";  
323 - }  
324 -  
325 - public function setNotifyUrl($notifyUrl)  
326 - {  
327 - $this->notifyUrl=$notifyUrl;  
328 - }  
329 -  
330 - public function getNotifyUrl()  
331 - {  
332 - return $this->notifyUrl;  
333 - }  
334 -  
335 - public function setReturnUrl($returnUrl)  
336 - {  
337 - $this->returnUrl=$returnUrl;  
338 - }  
339 -  
340 - public function getReturnUrl()  
341 - {  
342 - return $this->returnUrl;  
343 - }  
344 -  
345 - public function getApiParas()  
346 - {  
347 - return $this->apiParas;  
348 - }  
349 -  
350 - public function getTerminalType()  
351 - {  
352 - return $this->terminalType;  
353 - }  
354 -  
355 - public function setTerminalType($terminalType)  
356 - {  
357 - $this->terminalType = $terminalType;  
358 - }  
359 -  
360 - public function getTerminalInfo()  
361 - {  
362 - return $this->terminalInfo;  
363 - }  
364 -  
365 - public function setTerminalInfo($terminalInfo)  
366 - {  
367 - $this->terminalInfo = $terminalInfo;  
368 - }  
369 -  
370 - public function getProdCode()  
371 - {  
372 - return $this->prodCode;  
373 - }  
374 -  
375 - public function setProdCode($prodCode)  
376 - {  
377 - $this->prodCode = $prodCode;  
378 - }  
379 -  
380 - public function setApiVersion($apiVersion)  
381 - {  
382 - $this->apiVersion=$apiVersion;  
383 - }  
384 -  
385 - public function getApiVersion()  
386 - {  
387 - return $this->apiVersion;  
388 - }  
389 -  
390 - public function setNeedEncrypt($needEncrypt)  
391 - {  
392 -  
393 - $this->needEncrypt=$needEncrypt;  
394 -  
395 - }  
396 -  
397 - public function getNeedEncrypt()  
398 - {  
399 - return $this->needEncrypt;  
400 - }  
401 -  
402 -}  
1 -<?php  
2 -/**  
3 - * ALIPAY API: alipay.acquire.query request  
4 - *  
5 - * @author auto create  
6 - * @since 1.0, 2014-05-28 11:58:01  
7 - */  
8 -class AlipayAcquireQueryRequest  
9 -{  
10 - /**  
11 - * 支付宝合作商户网站唯一订单号  
12 - **/  
13 - private $outTradeNo;  
14 -  
15 - /**  
16 - * 该交易在支付宝系统中的交易流水号。  
17 -最短16位,最长64位。  
18 -如果同时传了out_trade_no和trade_no,则以trade_no为准。  
19 - **/  
20 - private $tradeNo;  
21 -  
22 - private $apiParas = array();  
23 - private $terminalType;  
24 - private $terminalInfo;  
25 - private $prodCode;  
26 - private $apiVersion="1.0";  
27 - private $notifyUrl;  
28 - private $returnUrl;  
29 - private $needEncrypt=false;  
30 -  
31 -  
32 - public function setOutTradeNo($outTradeNo)  
33 - {  
34 - $this->outTradeNo = $outTradeNo;  
35 - $this->apiParas["out_trade_no"] = $outTradeNo;  
36 - }  
37 -  
38 - public function getOutTradeNo()  
39 - {  
40 - return $this->outTradeNo;  
41 - }  
42 -  
43 - public function setTradeNo($tradeNo)  
44 - {  
45 - $this->tradeNo = $tradeNo;  
46 - $this->apiParas["trade_no"] = $tradeNo;  
47 - }  
48 -  
49 - public function getTradeNo()  
50 - {  
51 - return $this->tradeNo;  
52 - }  
53 -  
54 - public function getApiMethodName()  
55 - {  
56 - return "alipay.acquire.query";  
57 - }  
58 -  
59 - public function setNotifyUrl($notifyUrl)  
60 - {  
61 - $this->notifyUrl=$notifyUrl;  
62 - }  
63 -  
64 - public function getNotifyUrl()  
65 - {  
66 - return $this->notifyUrl;  
67 - }  
68 -  
69 - public function setReturnUrl($returnUrl)  
70 - {  
71 - $this->returnUrl=$returnUrl;  
72 - }  
73 -  
74 - public function getReturnUrl()  
75 - {  
76 - return $this->returnUrl;  
77 - }  
78 -  
79 - public function getApiParas()  
80 - {  
81 - return $this->apiParas;  
82 - }  
83 -  
84 - public function getTerminalType()  
85 - {  
86 - return $this->terminalType;  
87 - }  
88 -  
89 - public function setTerminalType($terminalType)  
90 - {  
91 - $this->terminalType = $terminalType;  
92 - }  
93 -  
94 - public function getTerminalInfo()  
95 - {  
96 - return $this->terminalInfo;  
97 - }  
98 -  
99 - public function setTerminalInfo($terminalInfo)  
100 - {  
101 - $this->terminalInfo = $terminalInfo;  
102 - }  
103 -  
104 - public function getProdCode()  
105 - {  
106 - return $this->prodCode;  
107 - }  
108 -  
109 - public function setProdCode($prodCode)  
110 - {  
111 - $this->prodCode = $prodCode;  
112 - }  
113 -  
114 - public function setApiVersion($apiVersion)  
115 - {  
116 - $this->apiVersion=$apiVersion;  
117 - }  
118 -  
119 - public function getApiVersion()  
120 - {  
121 - return $this->apiVersion;  
122 - }  
123 -  
124 - public function setNeedEncrypt($needEncrypt)  
125 - {  
126 -  
127 - $this->needEncrypt=$needEncrypt;  
128 -  
129 - }  
130 -  
131 - public function getNeedEncrypt()  
132 - {  
133 - return $this->needEncrypt;  
134 - }  
135 -  
136 -}  
1 -<?php  
2 -/**  
3 - * ALIPAY API: alipay.acquire.refund request  
4 - *  
5 - * @author auto create  
6 - * @since 1.0, 2014-06-12 17:17:03  
7 - */  
8 -class AlipayAcquireRefundRequest  
9 -{  
10 - /**  
11 - * 卖家的操作员ID。  
12 - **/  
13 - private $operatorId;  
14 -  
15 - /**  
16 - * 操作员的类型:  
17 -0:支付宝操作员  
18 -1:商户的操作员  
19 -如果传入其它值或者为空,则默认设置为1。  
20 - **/  
21 - private $operatorType;  
22 -  
23 - /**  
24 - * 商户退款请求单号,用以标识本次交易的退款请求。  
25 -如果不传入本参数,则以out_trade_no填充本参数的值。同时,认为本次请求为全额退款,要求退款金额和交易支付金额一致。  
26 - **/  
27 - private $outRequestNo;  
28 -  
29 - /**  
30 - * 商户网站唯一订单号  
31 - **/  
32 - private $outTradeNo;  
33 -  
34 - /**  
35 - * 业务关联ID集合,用于放置商户的退款单号、退款流水号等信息,json格式  
36 - **/  
37 - private $refIds;  
38 -  
39 - /**  
40 - * 退款金额;退款金额不能大于订单金额,全额退款必须与订单金额一致。  
41 - **/  
42 - private $refundAmount;  
43 -  
44 - /**  
45 - * 退款原因说明。  
46 - **/  
47 - private $refundReason;  
48 -  
49 - /**  
50 - * 该交易在支付宝系统中的交易流水号。  
51 -最短16位,最长64位。  
52 -如果同时传了out_trade_no和trade_no,则以trade_no为准  
53 - **/  
54 - private $tradeNo;  
55 -  
56 - private $apiParas = array();  
57 - private $terminalType;  
58 - private $terminalInfo;  
59 - private $prodCode;  
60 - private $apiVersion="1.0";  
61 - private $notifyUrl;  
62 - private $returnUrl;  
63 - private $needEncrypt=false;  
64 -  
65 -  
66 - public function setOperatorId($operatorId)  
67 - {  
68 - $this->operatorId = $operatorId;  
69 - $this->apiParas["operator_id"] = $operatorId;  
70 - }  
71 -  
72 - public function getOperatorId()  
73 - {  
74 - return $this->operatorId;  
75 - }  
76 -  
77 - public function setOperatorType($operatorType)  
78 - {  
79 - $this->operatorType = $operatorType;  
80 - $this->apiParas["operator_type"] = $operatorType;  
81 - }  
82 -  
83 - public function getOperatorType()  
84 - {  
85 - return $this->operatorType;  
86 - }  
87 -  
88 - public function setOutRequestNo($outRequestNo)  
89 - {  
90 - $this->outRequestNo = $outRequestNo;  
91 - $this->apiParas["out_request_no"] = $outRequestNo;  
92 - }  
93 -  
94 - public function getOutRequestNo()  
95 - {  
96 - return $this->outRequestNo;  
97 - }  
98 -  
99 - public function setOutTradeNo($outTradeNo)  
100 - {  
101 - $this->outTradeNo = $outTradeNo;  
102 - $this->apiParas["out_trade_no"] = $outTradeNo;  
103 - }  
104 -  
105 - public function getOutTradeNo()  
106 - {  
107 - return $this->outTradeNo;  
108 - }  
109 -  
110 - public function setRefIds($refIds)  
111 - {  
112 - $this->refIds = $refIds;  
113 - $this->apiParas["ref_ids"] = $refIds;  
114 - }  
115 -  
116 - public function getRefIds()  
117 - {  
118 - return $this->refIds;  
119 - }  
120 -  
121 - public function setRefundAmount($refundAmount)  
122 - {  
123 - $this->refundAmount = $refundAmount;  
124 - $this->apiParas["refund_amount"] = $refundAmount;  
125 - }  
126 -  
127 - public function getRefundAmount()  
128 - {  
129 - return $this->refundAmount;  
130 - }  
131 -  
132 - public function setRefundReason($refundReason)  
133 - {  
134 - $this->refundReason = $refundReason;  
135 - $this->apiParas["refund_reason"] = $refundReason;  
136 - }  
137 -  
138 - public function getRefundReason()  
139 - {  
140 - return $this->refundReason;  
141 - }  
142 -  
143 - public function setTradeNo($tradeNo)  
144 - {  
145 - $this->tradeNo = $tradeNo;  
146 - $this->apiParas["trade_no"] = $tradeNo;  
147 - }  
148 -  
149 - public function getTradeNo()  
150 - {  
151 - return $this->tradeNo;  
152 - }  
153 -  
154 - public function getApiMethodName()  
155 - {  
156 - return "alipay.acquire.refund";  
157 - }  
158 -  
159 - public function setNotifyUrl($notifyUrl)  
160 - {  
161 - $this->notifyUrl=$notifyUrl;  
162 - }  
163 -  
164 - public function getNotifyUrl()  
165 - {  
166 - return $this->notifyUrl;  
167 - }  
168 -  
169 - public function setReturnUrl($returnUrl)  
170 - {  
171 - $this->returnUrl=$returnUrl;  
172 - }  
173 -  
174 - public function getReturnUrl()  
175 - {  
176 - return $this->returnUrl;  
177 - }  
178 -  
179 - public function getApiParas()  
180 - {  
181 - return $this->apiParas;  
182 - }  
183 -  
184 - public function getTerminalType()  
185 - {  
186 - return $this->terminalType;  
187 - }  
188 -  
189 - public function setTerminalType($terminalType)  
190 - {  
191 - $this->terminalType = $terminalType;  
192 - }  
193 -  
194 - public function getTerminalInfo()  
195 - {  
196 - return $this->terminalInfo;  
197 - }  
198 -  
199 - public function setTerminalInfo($terminalInfo)  
200 - {  
201 - $this->terminalInfo = $terminalInfo;  
202 - }  
203 -  
204 - public function getProdCode()  
205 - {  
206 - return $this->prodCode;  
207 - }  
208 -  
209 - public function setProdCode($prodCode)  
210 - {  
211 - $this->prodCode = $prodCode;  
212 - }  
213 -  
214 - public function setApiVersion($apiVersion)  
215 - {  
216 - $this->apiVersion=$apiVersion;  
217 - }  
218 -  
219 - public function getApiVersion()  
220 - {  
221 - return $this->apiVersion;  
222 - }  
223 -  
224 - public function setNeedEncrypt($needEncrypt)  
225 - {  
226 -  
227 - $this->needEncrypt=$needEncrypt;  
228 -  
229 - }  
230 -  
231 - public function getNeedEncrypt()  
232 - {  
233 - return $this->needEncrypt;  
234 - }  
235 -  
236 -}  
1 -<?php  
2 -/**  
3 - * ALIPAY API: alipay.app.token.get request  
4 - *  
5 - * @author auto create  
6 - * @since 1.0, 2016-07-29 19:56:12  
7 - */  
8 -class AlipayAppTokenGetRequest  
9 -{  
10 - /**  
11 - * 应用安全码  
12 - **/  
13 - private $secret;  
14 -  
15 - private $apiParas = array();  
16 - private $terminalType;  
17 - private $terminalInfo;  
18 - private $prodCode;  
19 - private $apiVersion="1.0";  
20 - private $notifyUrl;  
21 - private $returnUrl;  
22 - private $needEncrypt=false;  
23 -  
24 -  
25 - public function setSecret($secret)  
26 - {  
27 - $this->secret = $secret;  
28 - $this->apiParas["secret"] = $secret;  
29 - }  
30 -  
31 - public function getSecret()  
32 - {  
33 - return $this->secret;  
34 - }  
35 -  
36 - public function getApiMethodName()  
37 - {  
38 - return "alipay.app.token.get";  
39 - }  
40 -  
41 - public function setNotifyUrl($notifyUrl)  
42 - {  
43 - $this->notifyUrl=$notifyUrl;  
44 - }  
45 -  
46 - public function getNotifyUrl()  
47 - {  
48 - return $this->notifyUrl;  
49 - }  
50 -  
51 - public function setReturnUrl($returnUrl)  
52 - {  
53 - $this->returnUrl=$returnUrl;  
54 - }  
55 -  
56 - public function getReturnUrl()  
57 - {  
58 - return $this->returnUrl;  
59 - }  
60 -  
61 - public function getApiParas()  
62 - {  
63 - return $this->apiParas;  
64 - }  
65 -  
66 - public function getTerminalType()  
67 - {  
68 - return $this->terminalType;  
69 - }  
70 -  
71 - public function setTerminalType($terminalType)  
72 - {  
73 - $this->terminalType = $terminalType;  
74 - }  
75 -  
76 - public function getTerminalInfo()  
77 - {  
78 - return $this->terminalInfo;  
79 - }  
80 -  
81 - public function setTerminalInfo($terminalInfo)  
82 - {  
83 - $this->terminalInfo = $terminalInfo;  
84 - }  
85 -  
86 - public function getProdCode()  
87 - {  
88 - return $this->prodCode;  
89 - }  
90 -  
91 - public function setProdCode($prodCode)  
92 - {  
93 - $this->prodCode = $prodCode;  
94 - }  
95 -  
96 - public function setApiVersion($apiVersion)  
97 - {  
98 - $this->apiVersion=$apiVersion;  
99 - }  
100 -  
101 - public function getApiVersion()  
102 - {  
103 - return $this->apiVersion;  
104 - }  
105 -  
106 - public function setNeedEncrypt($needEncrypt)  
107 - {  
108 -  
109 - $this->needEncrypt=$needEncrypt;  
110 -  
111 - }  
112 -  
113 - public function getNeedEncrypt()  
114 - {  
115 - return $this->needEncrypt;  
116 - }  
117 -  
118 -}