├── .gitignore ├── src ├── EchoBool │ └── AlipayLaravel │ │ ├── aop │ │ ├── SignData.php │ │ ├── EncryptResponseData.php │ │ ├── EncryptParseItem.php │ │ ├── AopEncrypt.php │ │ ├── request │ │ │ ├── AlipayTradeAppPayRequest.php │ │ │ ├── AlipayTradeCancelRequest.php │ │ │ ├── AlipayTradeWapPayRequest.php │ │ │ ├── AlipayTradeCreateRequest.php │ │ │ ├── AlipayTradePayRequest.php │ │ │ ├── AlipayTradeCustomsQueryRequest.php │ │ │ ├── AlipayTradeOrderSettleRequest.php │ │ │ ├── AlipayTradeCustomsDeclareRequest.php │ │ │ ├── AlipayTradeCloseRequest.php │ │ │ ├── AlipayTradeRefundRequest.php │ │ │ ├── AlipayTradePagePayRequest.php │ │ │ ├── AlipayTradeQueryRequest.php │ │ │ ├── AlipayTradePrecreateRequest.php │ │ │ ├── AlipayTradeVendorpayDevicedataUploadRequest.php │ │ │ ├── AlipayTradeFastpayRefundQueryRequest.php │ │ │ └── AlipayDataDataserviceBillDownloadurlQueryRequest.php │ │ ├── AlipayMobilePublicMultiMediaExecute.php │ │ ├── test │ │ │ └── TestImage.php │ │ ├── AlipayMobilePublicMultiMediaClient.php │ │ └── AopClient.php │ │ ├── Facades │ │ └── Alipay.php │ │ ├── AlipayServiceProvider.php │ │ ├── buildermodel │ │ ├── AlipayTradeQueryContentBuilder.php │ │ ├── AlipayTradeCloseContentBuilder.php │ │ ├── AlipayTradeFastpayRefundQueryContentBuilder.php │ │ ├── AlipayTradeRefundContentBuilder.php │ │ └── AlipayTradePagePayContentBuilder.php │ │ ├── AlipaySdk.php │ │ └── service │ │ └── AlipayTradeService.php └── config │ └── config.php ├── composer.json ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.phar 3 | composer.lock 4 | .DS_Store 5 | .settings 6 | .buildpath 7 | .project -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/SignData.php: -------------------------------------------------------------------------------- 1 | =5.4.0", 21 | "illuminate/support": "5.*", 22 | "illuminate/config": "5.*" 23 | }, 24 | "autoload": { 25 | "psr-4": { 26 | "EchoBool\\AlipayLaravel\\": "src/EchoBool/AlipayLaravel/" 27 | } 28 | }, 29 | "minimum-stability": "stable" 30 | } -------------------------------------------------------------------------------- /src/config/config.php: -------------------------------------------------------------------------------- 1 | "", 12 | 13 | //商户私钥 不能用pkcs8.pem中的密钥!!!!! 14 | 'merchant_private_key' => "", 15 | 16 | //异步通知地址 17 | 'notify_url' => "http://外网可访问网关地址/alipay.trade.page.pay-PHP-UTF-8/notify_url.php", 18 | 19 | //同步跳转 20 | 'return_url' => "http://外网可访问网关地址/alipay.trade.page.pay-PHP-UTF-8/return_url.php", 21 | 22 | //编码格式 23 | 'charset' => "UTF-8", 24 | 25 | //签名方式 26 | 'sign_type' => "RSA2", 27 | 28 | //支付宝网关 29 | 'gatewayUrl' => "https://openapi.alipay.com/gateway.do", 30 | 31 | //支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。 32 | 'alipay_public_key' => "", 33 | 34 | //支付时提交方式 true 为表单提交方式成功后跳转到return_url, 35 | //false 时为Curl方式 返回支付宝支付页面址址 自己跳转上去 支付成功不会跳转到return_url上, 我也不知道为什么,有人发现可以跳转请告诉 我一下 谢谢 36 | // email: 40281612@qq.com 37 | 'trade_pay_type' => false, 38 | ]; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 echobool 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/AlipayServiceProvider.php: -------------------------------------------------------------------------------- 1 | publishes([ 32 | __DIR__ . '/../../config/config.php' => config_path('alipay-web.php'), 33 | ]); 34 | } 35 | 36 | /** 37 | * Register the application services. 38 | * 39 | * @return void 40 | */ 41 | public function register() 42 | { 43 | $this->app->singleton('Alipay', function ($app) { 44 | return new AlipaySdk($app['config']['alipay-web']);//config 45 | }); 46 | } 47 | 48 | /** 49 | * Get the services provided by the provider. 50 | * 51 | * @return array 52 | */ 53 | public function provides() 54 | { 55 | return ['Alipay']; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/buildermodel/AlipayTradeQueryContentBuilder.php: -------------------------------------------------------------------------------- 1 | bizContentarr)){ 28 | $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); 29 | } 30 | return $this->bizContent; 31 | } 32 | 33 | public function getTradeNo() 34 | { 35 | return $this->tradeNo; 36 | } 37 | 38 | public function setTradeNo($tradeNo) 39 | { 40 | $this->tradeNo = $tradeNo; 41 | $this->bizContentarr['trade_no'] = $tradeNo; 42 | } 43 | 44 | public function getOutTradeNo() 45 | { 46 | return $this->outTradeNo; 47 | } 48 | 49 | public function setOutTradeNo($outTradeNo) 50 | { 51 | $this->outTradeNo = $outTradeNo; 52 | $this->bizContentarr['out_trade_no'] = $outTradeNo; 53 | } 54 | } 55 | 56 | ?> -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/buildermodel/AlipayTradeCloseContentBuilder.php: -------------------------------------------------------------------------------- 1 | bizContentarr)){ 30 | $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); 31 | } 32 | return $this->bizContent; 33 | } 34 | 35 | public function getTradeNo() 36 | { 37 | return $this->tradeNo; 38 | } 39 | 40 | public function setTradeNo($tradeNo) 41 | { 42 | $this->tradeNo = $tradeNo; 43 | $this->bizContentarr['trade_no'] = $tradeNo; 44 | } 45 | 46 | public function getOutTradeNo() 47 | { 48 | return $this->outTradeNo; 49 | } 50 | 51 | public function setOutTradeNo($outTradeNo) 52 | { 53 | $this->outTradeNo = $outTradeNo; 54 | $this->bizContentarr['out_trade_no'] = $outTradeNo; 55 | } 56 | public function getOperatorId() 57 | { 58 | return $this->operatorId; 59 | } 60 | 61 | public function setOperatorId($operatorId) 62 | { 63 | $this->operatorId = $operatorId; 64 | $this->bizContentarr['operator_id'] = $operatorId; 65 | } 66 | 67 | } 68 | 69 | ?> -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/buildermodel/AlipayTradeFastpayRefundQueryContentBuilder.php: -------------------------------------------------------------------------------- 1 | bizContentarr)){ 29 | $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); 30 | } 31 | return $this->bizContent; 32 | } 33 | 34 | public function getTradeNo() 35 | { 36 | return $this->tradeNo; 37 | } 38 | 39 | public function setTradeNo($tradeNo) 40 | { 41 | $this->tradeNo = $tradeNo; 42 | $this->bizContentarr['trade_no'] = $tradeNo; 43 | } 44 | 45 | public function getOutTradeNo() 46 | { 47 | return $this->outTradeNo; 48 | } 49 | 50 | public function setOutTradeNo($outTradeNo) 51 | { 52 | $this->outTradeNo = $outTradeNo; 53 | $this->bizContentarr['out_trade_no'] = $outTradeNo; 54 | } 55 | public function getOutRequestNo() 56 | { 57 | return $this->outRequestNo; 58 | } 59 | public function setOutRequestNo($outRequestNo) 60 | { 61 | $this->outRequestNo = $outRequestNo; 62 | $this->bizContentarr['out_request_no'] = $outRequestNo; 63 | } 64 | } 65 | 66 | ?> -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/AopEncrypt.php: -------------------------------------------------------------------------------- 1 | bizContentarr)){ 36 | $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); 37 | } 38 | return $this->bizContent; 39 | } 40 | 41 | public function getTradeNo() 42 | { 43 | return $this->tradeNo; 44 | } 45 | 46 | public function setTradeNo($tradeNo) 47 | { 48 | $this->tradeNo = $tradeNo; 49 | $this->bizContentarr['trade_no'] = $tradeNo; 50 | } 51 | 52 | public function getOutTradeNo() 53 | { 54 | return $this->outTradeNo; 55 | } 56 | 57 | public function setOutTradeNo($outTradeNo) 58 | { 59 | $this->outTradeNo = $outTradeNo; 60 | $this->bizContentarr['out_trade_no'] = $outTradeNo; 61 | } 62 | 63 | public function getRefundAmount() 64 | { 65 | return $this->refundAmount; 66 | } 67 | 68 | public function setRefundAmount($refundAmount) 69 | { 70 | $this->refundAmount = $refundAmount; 71 | $this->bizContentarr['refund_amount'] = $refundAmount; 72 | } 73 | 74 | public function getRefundReason() 75 | { 76 | return $this->refundReason; 77 | } 78 | 79 | public function setRefundReason($refundReason) 80 | { 81 | $this->refundReason = $refundReason; 82 | $this->bizContentarr['refund_reason'] = $refundReason; 83 | } 84 | 85 | public function getOutRequestNo() 86 | { 87 | return $this->outRequestNo; 88 | } 89 | 90 | public function setOutRequestNo($outRequestNo) 91 | { 92 | $this->outRequestNo = $outRequestNo; 93 | $this->bizContentarr['out_request_no'] = $outRequestNo; 94 | } 95 | } 96 | 97 | ?> -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeAppPayRequest.php: -------------------------------------------------------------------------------- 1 | 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.trade.app.pay"; 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 | } 119 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeCancelRequest.php: -------------------------------------------------------------------------------- 1 | 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.trade.cancel"; 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 | } 119 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeWapPayRequest.php: -------------------------------------------------------------------------------- 1 | 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.trade.wap.pay"; 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 | } 119 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeCreateRequest.php: -------------------------------------------------------------------------------- 1 | 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.trade.create"; 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 | } 119 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradePayRequest.php: -------------------------------------------------------------------------------- 1 | bizContent = $bizContent; 29 | $this->apiParas["biz_content"] = $bizContent; 30 | } 31 | 32 | public function getBizContent() 33 | { 34 | return $this->bizContent; 35 | } 36 | 37 | public function getApiMethodName() 38 | { 39 | return "alipay.trade.pay"; 40 | } 41 | 42 | public function setNotifyUrl($notifyUrl) 43 | { 44 | $this->notifyUrl=$notifyUrl; 45 | } 46 | 47 | public function getNotifyUrl() 48 | { 49 | return $this->notifyUrl; 50 | } 51 | 52 | public function setReturnUrl($returnUrl) 53 | { 54 | $this->returnUrl=$returnUrl; 55 | } 56 | 57 | public function getReturnUrl() 58 | { 59 | return $this->returnUrl; 60 | } 61 | 62 | public function getApiParas() 63 | { 64 | return $this->apiParas; 65 | } 66 | 67 | public function getTerminalType() 68 | { 69 | return $this->terminalType; 70 | } 71 | 72 | public function setTerminalType($terminalType) 73 | { 74 | $this->terminalType = $terminalType; 75 | } 76 | 77 | public function getTerminalInfo() 78 | { 79 | return $this->terminalInfo; 80 | } 81 | 82 | public function setTerminalInfo($terminalInfo) 83 | { 84 | $this->terminalInfo = $terminalInfo; 85 | } 86 | 87 | public function getProdCode() 88 | { 89 | return $this->prodCode; 90 | } 91 | 92 | public function setProdCode($prodCode) 93 | { 94 | $this->prodCode = $prodCode; 95 | } 96 | 97 | public function setApiVersion($apiVersion) 98 | { 99 | $this->apiVersion=$apiVersion; 100 | } 101 | 102 | public function getApiVersion() 103 | { 104 | return $this->apiVersion; 105 | } 106 | 107 | public function setNeedEncrypt($needEncrypt) 108 | { 109 | 110 | $this->needEncrypt=$needEncrypt; 111 | 112 | } 113 | 114 | public function getNeedEncrypt() 115 | { 116 | return $this->needEncrypt; 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/AlipayMobilePublicMultiMediaExecute.php: -------------------------------------------------------------------------------- 1 | '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 | } 109 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeCustomsQueryRequest.php: -------------------------------------------------------------------------------- 1 | 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.trade.customs.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 | } 119 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeOrderSettleRequest.php: -------------------------------------------------------------------------------- 1 | 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.trade.order.settle"; 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 | } 119 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeCustomsDeclareRequest.php: -------------------------------------------------------------------------------- 1 | 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.trade.customs.declare"; 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 | } 119 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeCloseRequest.php: -------------------------------------------------------------------------------- 1 | bizContent = $bizContent; 30 | $this->apiParas["biz_content"] = $bizContent; 31 | } 32 | 33 | public function getBizContent() 34 | { 35 | return $this->bizContent; 36 | } 37 | 38 | public function getApiMethodName() 39 | { 40 | return "alipay.trade.close"; 41 | } 42 | 43 | public function setNotifyUrl($notifyUrl) 44 | { 45 | $this->notifyUrl=$notifyUrl; 46 | } 47 | 48 | public function getNotifyUrl() 49 | { 50 | return $this->notifyUrl; 51 | } 52 | 53 | public function setReturnUrl($returnUrl) 54 | { 55 | $this->returnUrl=$returnUrl; 56 | } 57 | 58 | public function getReturnUrl() 59 | { 60 | return $this->returnUrl; 61 | } 62 | 63 | public function getApiParas() 64 | { 65 | return $this->apiParas; 66 | } 67 | 68 | public function getTerminalType() 69 | { 70 | return $this->terminalType; 71 | } 72 | 73 | public function setTerminalType($terminalType) 74 | { 75 | $this->terminalType = $terminalType; 76 | } 77 | 78 | public function getTerminalInfo() 79 | { 80 | return $this->terminalInfo; 81 | } 82 | 83 | public function setTerminalInfo($terminalInfo) 84 | { 85 | $this->terminalInfo = $terminalInfo; 86 | } 87 | 88 | public function getProdCode() 89 | { 90 | return $this->prodCode; 91 | } 92 | 93 | public function setProdCode($prodCode) 94 | { 95 | $this->prodCode = $prodCode; 96 | } 97 | 98 | public function setApiVersion($apiVersion) 99 | { 100 | $this->apiVersion=$apiVersion; 101 | } 102 | 103 | public function getApiVersion() 104 | { 105 | return $this->apiVersion; 106 | } 107 | 108 | public function setNeedEncrypt($needEncrypt) 109 | { 110 | 111 | $this->needEncrypt=$needEncrypt; 112 | 113 | } 114 | 115 | public function getNeedEncrypt() 116 | { 117 | return $this->needEncrypt; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeRefundRequest.php: -------------------------------------------------------------------------------- 1 | bizContent = $bizContent; 30 | $this->apiParas["biz_content"] = $bizContent; 31 | } 32 | 33 | public function getBizContent() 34 | { 35 | return $this->bizContent; 36 | } 37 | 38 | public function getApiMethodName() 39 | { 40 | return "alipay.trade.refund"; 41 | } 42 | 43 | public function setNotifyUrl($notifyUrl) 44 | { 45 | $this->notifyUrl=$notifyUrl; 46 | } 47 | 48 | public function getNotifyUrl() 49 | { 50 | return $this->notifyUrl; 51 | } 52 | 53 | public function setReturnUrl($returnUrl) 54 | { 55 | $this->returnUrl=$returnUrl; 56 | } 57 | 58 | public function getReturnUrl() 59 | { 60 | return $this->returnUrl; 61 | } 62 | 63 | public function getApiParas() 64 | { 65 | return $this->apiParas; 66 | } 67 | 68 | public function getTerminalType() 69 | { 70 | return $this->terminalType; 71 | } 72 | 73 | public function setTerminalType($terminalType) 74 | { 75 | $this->terminalType = $terminalType; 76 | } 77 | 78 | public function getTerminalInfo() 79 | { 80 | return $this->terminalInfo; 81 | } 82 | 83 | public function setTerminalInfo($terminalInfo) 84 | { 85 | $this->terminalInfo = $terminalInfo; 86 | } 87 | 88 | public function getProdCode() 89 | { 90 | return $this->prodCode; 91 | } 92 | 93 | public function setProdCode($prodCode) 94 | { 95 | $this->prodCode = $prodCode; 96 | } 97 | 98 | public function setApiVersion($apiVersion) 99 | { 100 | $this->apiVersion=$apiVersion; 101 | } 102 | 103 | public function getApiVersion() 104 | { 105 | return $this->apiVersion; 106 | } 107 | 108 | public function setNeedEncrypt($needEncrypt) 109 | { 110 | 111 | $this->needEncrypt=$needEncrypt; 112 | 113 | } 114 | 115 | public function getNeedEncrypt() 116 | { 117 | return $this->needEncrypt; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradePagePayRequest.php: -------------------------------------------------------------------------------- 1 | bizContent = $bizContent; 29 | $this->apiParas["biz_content"] = $bizContent; 30 | } 31 | 32 | public function getBizContent() 33 | { 34 | return $this->bizContent; 35 | } 36 | 37 | public function getApiMethodName() 38 | { 39 | return "alipay.trade.page.pay"; 40 | } 41 | 42 | public function setNotifyUrl($notifyUrl) 43 | { 44 | $this->notifyUrl=$notifyUrl; 45 | } 46 | 47 | public function getNotifyUrl() 48 | { 49 | return $this->notifyUrl; 50 | } 51 | 52 | public function setReturnUrl($returnUrl) 53 | { 54 | $this->returnUrl=$returnUrl; 55 | } 56 | 57 | public function getReturnUrl() 58 | { 59 | return $this->returnUrl; 60 | } 61 | 62 | public function getApiParas() 63 | { 64 | return $this->apiParas; 65 | } 66 | 67 | public function getTerminalType() 68 | { 69 | return $this->terminalType; 70 | } 71 | 72 | public function setTerminalType($terminalType) 73 | { 74 | $this->terminalType = $terminalType; 75 | } 76 | 77 | public function getTerminalInfo() 78 | { 79 | return $this->terminalInfo; 80 | } 81 | 82 | public function setTerminalInfo($terminalInfo) 83 | { 84 | $this->terminalInfo = $terminalInfo; 85 | } 86 | 87 | public function getProdCode() 88 | { 89 | return $this->prodCode; 90 | } 91 | 92 | public function setProdCode($prodCode) 93 | { 94 | $this->prodCode = $prodCode; 95 | } 96 | 97 | public function setApiVersion($apiVersion) 98 | { 99 | $this->apiVersion=$apiVersion; 100 | } 101 | 102 | public function getApiVersion() 103 | { 104 | return $this->apiVersion; 105 | } 106 | 107 | public function setNeedEncrypt($needEncrypt) 108 | { 109 | 110 | $this->needEncrypt=$needEncrypt; 111 | 112 | } 113 | 114 | public function getNeedEncrypt() 115 | { 116 | return $this->needEncrypt; 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeQueryRequest.php: -------------------------------------------------------------------------------- 1 | bizContent = $bizContent; 31 | $this->apiParas["biz_content"] = $bizContent; 32 | } 33 | 34 | public function getBizContent() 35 | { 36 | return $this->bizContent; 37 | } 38 | 39 | public function getApiMethodName() 40 | { 41 | return "alipay.trade.query"; 42 | } 43 | 44 | public function setNotifyUrl($notifyUrl) 45 | { 46 | $this->notifyUrl=$notifyUrl; 47 | } 48 | 49 | public function getNotifyUrl() 50 | { 51 | return $this->notifyUrl; 52 | } 53 | 54 | public function setReturnUrl($returnUrl) 55 | { 56 | $this->returnUrl=$returnUrl; 57 | } 58 | 59 | public function getReturnUrl() 60 | { 61 | return $this->returnUrl; 62 | } 63 | 64 | public function getApiParas() 65 | { 66 | return $this->apiParas; 67 | } 68 | 69 | public function getTerminalType() 70 | { 71 | return $this->terminalType; 72 | } 73 | 74 | public function setTerminalType($terminalType) 75 | { 76 | $this->terminalType = $terminalType; 77 | } 78 | 79 | public function getTerminalInfo() 80 | { 81 | return $this->terminalInfo; 82 | } 83 | 84 | public function setTerminalInfo($terminalInfo) 85 | { 86 | $this->terminalInfo = $terminalInfo; 87 | } 88 | 89 | public function getProdCode() 90 | { 91 | return $this->prodCode; 92 | } 93 | 94 | public function setProdCode($prodCode) 95 | { 96 | $this->prodCode = $prodCode; 97 | } 98 | 99 | public function setApiVersion($apiVersion) 100 | { 101 | $this->apiVersion=$apiVersion; 102 | } 103 | 104 | public function getApiVersion() 105 | { 106 | return $this->apiVersion; 107 | } 108 | 109 | public function setNeedEncrypt($needEncrypt) 110 | { 111 | 112 | $this->needEncrypt=$needEncrypt; 113 | 114 | } 115 | 116 | public function getNeedEncrypt() 117 | { 118 | return $this->needEncrypt; 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradePrecreateRequest.php: -------------------------------------------------------------------------------- 1 | bizContent = $bizContent; 29 | $this->apiParas["biz_content"] = $bizContent; 30 | } 31 | 32 | public function getBizContent() 33 | { 34 | return $this->bizContent; 35 | } 36 | 37 | public function getApiMethodName() 38 | { 39 | return "alipay.trade.precreate"; 40 | } 41 | 42 | public function setNotifyUrl($notifyUrl) 43 | { 44 | $this->notifyUrl=$notifyUrl; 45 | } 46 | 47 | public function getNotifyUrl() 48 | { 49 | return $this->notifyUrl; 50 | } 51 | 52 | public function setReturnUrl($returnUrl) 53 | { 54 | $this->returnUrl=$returnUrl; 55 | } 56 | 57 | public function getReturnUrl() 58 | { 59 | return $this->returnUrl; 60 | } 61 | 62 | public function getApiParas() 63 | { 64 | return $this->apiParas; 65 | } 66 | 67 | public function getTerminalType() 68 | { 69 | return $this->terminalType; 70 | } 71 | 72 | public function setTerminalType($terminalType) 73 | { 74 | $this->terminalType = $terminalType; 75 | } 76 | 77 | public function getTerminalInfo() 78 | { 79 | return $this->terminalInfo; 80 | } 81 | 82 | public function setTerminalInfo($terminalInfo) 83 | { 84 | $this->terminalInfo = $terminalInfo; 85 | } 86 | 87 | public function getProdCode() 88 | { 89 | return $this->prodCode; 90 | } 91 | 92 | public function setProdCode($prodCode) 93 | { 94 | $this->prodCode = $prodCode; 95 | } 96 | 97 | public function setApiVersion($apiVersion) 98 | { 99 | $this->apiVersion=$apiVersion; 100 | } 101 | 102 | public function getApiVersion() 103 | { 104 | return $this->apiVersion; 105 | } 106 | 107 | public function setNeedEncrypt($needEncrypt) 108 | { 109 | 110 | $this->needEncrypt=$needEncrypt; 111 | 112 | } 113 | 114 | public function getNeedEncrypt() 115 | { 116 | return $this->needEncrypt; 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeVendorpayDevicedataUploadRequest.php: -------------------------------------------------------------------------------- 1 | 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.trade.vendorpay.devicedata.upload"; 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 | } 119 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayTradeFastpayRefundQueryRequest.php: -------------------------------------------------------------------------------- 1 | bizContent = $bizContent; 29 | $this->apiParas["biz_content"] = $bizContent; 30 | } 31 | 32 | public function getBizContent() 33 | { 34 | return $this->bizContent; 35 | } 36 | 37 | public function getApiMethodName() 38 | { 39 | return "alipay.trade.fastpay.refund.query"; 40 | } 41 | 42 | public function setNotifyUrl($notifyUrl) 43 | { 44 | $this->notifyUrl=$notifyUrl; 45 | } 46 | 47 | public function getNotifyUrl() 48 | { 49 | return $this->notifyUrl; 50 | } 51 | 52 | public function setReturnUrl($returnUrl) 53 | { 54 | $this->returnUrl=$returnUrl; 55 | } 56 | 57 | public function getReturnUrl() 58 | { 59 | return $this->returnUrl; 60 | } 61 | 62 | public function getApiParas() 63 | { 64 | return $this->apiParas; 65 | } 66 | 67 | public function getTerminalType() 68 | { 69 | return $this->terminalType; 70 | } 71 | 72 | public function setTerminalType($terminalType) 73 | { 74 | $this->terminalType = $terminalType; 75 | } 76 | 77 | public function getTerminalInfo() 78 | { 79 | return $this->terminalInfo; 80 | } 81 | 82 | public function setTerminalInfo($terminalInfo) 83 | { 84 | $this->terminalInfo = $terminalInfo; 85 | } 86 | 87 | public function getProdCode() 88 | { 89 | return $this->prodCode; 90 | } 91 | 92 | public function setProdCode($prodCode) 93 | { 94 | $this->prodCode = $prodCode; 95 | } 96 | 97 | public function setApiVersion($apiVersion) 98 | { 99 | $this->apiVersion=$apiVersion; 100 | } 101 | 102 | public function getApiVersion() 103 | { 104 | return $this->apiVersion; 105 | } 106 | 107 | public function setNeedEncrypt($needEncrypt) 108 | { 109 | 110 | $this->needEncrypt=$needEncrypt; 111 | 112 | } 113 | 114 | public function getNeedEncrypt() 115 | { 116 | return $this->needEncrypt; 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/request/AlipayDataDataserviceBillDownloadurlQueryRequest.php: -------------------------------------------------------------------------------- 1 | bizContent = $bizContent; 30 | $this->apiParas["biz_content"] = $bizContent; 31 | } 32 | 33 | public function getBizContent() 34 | { 35 | return $this->bizContent; 36 | } 37 | 38 | public function getApiMethodName() 39 | { 40 | return "alipay.data.dataservice.bill.downloadurl.query"; 41 | } 42 | 43 | public function setNotifyUrl($notifyUrl) 44 | { 45 | $this->notifyUrl=$notifyUrl; 46 | } 47 | 48 | public function getNotifyUrl() 49 | { 50 | return $this->notifyUrl; 51 | } 52 | 53 | public function setReturnUrl($returnUrl) 54 | { 55 | $this->returnUrl=$returnUrl; 56 | } 57 | 58 | public function getReturnUrl() 59 | { 60 | return $this->returnUrl; 61 | } 62 | 63 | public function getApiParas() 64 | { 65 | return $this->apiParas; 66 | } 67 | 68 | public function getTerminalType() 69 | { 70 | return $this->terminalType; 71 | } 72 | 73 | public function setTerminalType($terminalType) 74 | { 75 | $this->terminalType = $terminalType; 76 | } 77 | 78 | public function getTerminalInfo() 79 | { 80 | return $this->terminalInfo; 81 | } 82 | 83 | public function setTerminalInfo($terminalInfo) 84 | { 85 | $this->terminalInfo = $terminalInfo; 86 | } 87 | 88 | public function getProdCode() 89 | { 90 | return $this->prodCode; 91 | } 92 | 93 | public function setProdCode($prodCode) 94 | { 95 | $this->prodCode = $prodCode; 96 | } 97 | 98 | public function setApiVersion($apiVersion) 99 | { 100 | $this->apiVersion=$apiVersion; 101 | } 102 | 103 | public function getApiVersion() 104 | { 105 | return $this->apiVersion; 106 | } 107 | 108 | public function setNeedEncrypt($needEncrypt) 109 | { 110 | 111 | $this->needEncrypt=$needEncrypt; 112 | 113 | } 114 | 115 | public function getNeedEncrypt() 116 | { 117 | return $this->needEncrypt; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/buildermodel/AlipayTradePagePayContentBuilder.php: -------------------------------------------------------------------------------- 1 | bizContentarr)){ 41 | $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); 42 | } 43 | return $this->bizContent; 44 | } 45 | 46 | public function __construct() 47 | { 48 | $this->bizContentarr['product_code'] = "FAST_INSTANT_TRADE_PAY"; 49 | } 50 | 51 | public function AlipayTradeWapPayContentBuilder() 52 | { 53 | $this->__construct(); 54 | } 55 | 56 | public function getBody() 57 | { 58 | return $this->body; 59 | } 60 | 61 | public function setBody($body) 62 | { 63 | $this->body = $body; 64 | $this->bizContentarr['body'] = $body; 65 | } 66 | 67 | public function setSubject($subject) 68 | { 69 | $this->subject = $subject; 70 | $this->bizContentarr['subject'] = $subject; 71 | } 72 | 73 | /** 74 | * @param mixed $passback_params 75 | */ 76 | public function setPassbackParams($passback_params) 77 | { 78 | $this->passback_params = $passback_params; 79 | $this->bizContentarr['passback_params'] = $passback_params; 80 | } 81 | 82 | /** 83 | * @return mixed 84 | */ 85 | public function getPassbackParams() 86 | { 87 | return $this->passback_params; 88 | } 89 | 90 | 91 | 92 | public function getSubject() 93 | { 94 | return $this->subject; 95 | } 96 | 97 | public function getOutTradeNo() 98 | { 99 | return $this->outTradeNo; 100 | } 101 | 102 | public function setOutTradeNo($outTradeNo) 103 | { 104 | $this->outTradeNo = $outTradeNo; 105 | $this->bizContentarr['out_trade_no'] = $outTradeNo; 106 | } 107 | 108 | public function setTimeExpress($timeExpress) 109 | { 110 | $this->timeExpress = $timeExpress; 111 | $this->bizContentarr['timeout_express'] = $timeExpress; 112 | } 113 | 114 | public function getTimeExpress() 115 | { 116 | return $this->timeExpress; 117 | } 118 | 119 | public function setTotalAmount($totalAmount) 120 | { 121 | $this->totalAmount = $totalAmount; 122 | $this->bizContentarr['total_amount'] = $totalAmount; 123 | } 124 | 125 | public function getTotalAmount() 126 | { 127 | return $this->totalAmount; 128 | } 129 | 130 | } 131 | 132 | ?> -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/test/TestImage.php: -------------------------------------------------------------------------------- 1 | serverUrl, 42 | $this -> appId, 43 | $this -> partner_private_key, 44 | $this -> format, 45 | $this -> charset 46 | ); 47 | $response = null; 48 | $outputStream = null; 49 | $request = $alipayClient -> getContents() ; 50 | 51 | //200 52 | //echo( '状态码:'. $request -> getCode() .', '); 53 | //echo '
'; 84 | 85 | //echo ($request -> getParams()); 86 | 87 | //echo '' ; 88 | } 89 | } 90 | 91 | 92 | 93 | 94 | 95 | // 测试 96 | $test1 = new TestImage(); 97 | $test1 -> load(); 98 | -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/AlipaySdk.php: -------------------------------------------------------------------------------- 1 | config = $config; 29 | $this->aop = new AlipayTradeService($config); 30 | } 31 | 32 | /** 33 | * 支付接口 支持自定义数据传输 34 | * @param $subject 35 | * @param $body 36 | * @param $out_trade_no 37 | * @param $total_amount 38 | * @param $customData 自定义数据 39 | * @return bool|提交表单HTML文本|mixed|\SimpleXMLElement|string 40 | */ 41 | public function tradePagePay($subject, $body, $out_trade_no, $total_amount, $customData) 42 | { 43 | $payRequestBuilder = new AlipayTradePagePayContentBuilder(); 44 | $payRequestBuilder->setBody($body); 45 | $payRequestBuilder->setSubject($subject); 46 | $payRequestBuilder->setTotalAmount($total_amount); 47 | $payRequestBuilder->setOutTradeNo($out_trade_no); 48 | $payRequestBuilder->setPassbackParams($customData); 49 | $response = $this->aop->pagePay($payRequestBuilder, $this->config['return_url'], $this->config['notify_url'], $this->config['trade_pay_type']); 50 | 51 | return $response; 52 | } 53 | 54 | /** 55 | * 退款接口 56 | * @param $out_trade_no//商户订单号,商户网站订单系统中唯一订单号 57 | * @param $refund_amount//需要退款的金额,该金额不能大于订单金额,必填 58 | * @param $refund_reason//退款的原因说明 59 | * @param string $out_request_no//标识一次退款请求,同一笔交易多次退款需要保证唯一,如需部分退款,则此参数必传 60 | * @return bool|提交表单HTML文本|mixed|\SimpleXMLElement|\SimpleXMLElement[]|string 61 | */ 62 | public function tradeRefund($out_trade_no, $refund_amount, $refund_reason, $out_request_no = '') 63 | { 64 | $RequestBuilder = new AlipayTradeRefundContentBuilder(); 65 | 66 | $RequestBuilder->setOutTradeNo($out_trade_no); 67 | //$RequestBuilder->setTradeNo($trade_no); 68 | $RequestBuilder->setRefundAmount($refund_amount); 69 | $RequestBuilder->setOutRequestNo($out_request_no); 70 | $RequestBuilder->setRefundReason($refund_reason); 71 | 72 | $response = $this->aop->Refund($RequestBuilder); 73 | return $response; 74 | } 75 | 76 | /** 77 | * 支付交易查询接口,用于查询交易是否交易成功 78 | * @param $out_trade_no 79 | * @return bool|提交表单HTML文本|mixed|\SimpleXMLElement|\SimpleXMLElement[]|string 80 | */ 81 | public function tradePayQuery($out_trade_no) 82 | { 83 | $RequestBuilder = new AlipayTradeQueryContentBuilder(); 84 | $RequestBuilder->setOutTradeNo($out_trade_no); 85 | //$RequestBuilder->setTradeNo($trade_no); 86 | 87 | $response = $this->aop->Query($RequestBuilder); 88 | return $response; 89 | } 90 | 91 | /** 92 | * 退款查询接口 93 | * @param $out_trade_no//商户订单号,商户网站订单系统中唯一订单号 94 | * @param $out_request_no//请求退款接口时,传入的退款请求号,如果在退款请求时未传入,则该值为创建交易时的外部交易号,必填 95 | * @return bool|提交表单HTML文本|mixed|\SimpleXMLElement|string 96 | */ 97 | public function refundQuery($out_trade_no, $out_request_no) 98 | { 99 | $RequestBuilder=new AlipayTradeFastpayRefundQueryContentBuilder(); 100 | $RequestBuilder->setOutTradeNo($out_trade_no); 101 | //$RequestBuilder->setTradeNo($trade_no); 102 | $RequestBuilder->setOutRequestNo($out_request_no); 103 | 104 | $response = $this->aop->refundQuery($RequestBuilder); 105 | return $response; 106 | } 107 | 108 | /** 109 | * 关闭订单接口 110 | * @param $out_trade_no 111 | * @return bool|提交表单HTML文本|mixed|\SimpleXMLElement|\SimpleXMLElement[]|string 112 | */ 113 | public function Close($out_trade_no) 114 | { 115 | $RequestBuilder=new AlipayTradeCloseContentBuilder(); 116 | $RequestBuilder->setOutTradeNo($out_trade_no); 117 | //$RequestBuilder->setTradeNo($trade_no); 118 | 119 | $response = $this->aop->Close($RequestBuilder); 120 | return $response; 121 | } 122 | 123 | /** 124 | * 异步通知验证 125 | * @param $requestData 126 | * @return bool 127 | */ 128 | public function notify($requestData) 129 | { 130 | $this->aop->writeLog(var_export($requestData,true)); 131 | return $this->aop->check($requestData); 132 | } 133 | } -------------------------------------------------------------------------------- /src/EchoBool/AlipayLaravel/aop/AlipayMobilePublicMultiMediaClient.php: -------------------------------------------------------------------------------- 1 | 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 | } 232 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # alipay-laravel5 支付宝电脑网站支付 2 | **根据支付宝最新版 电脑网站支付接口SDK 整合laravel5** 3 | 4 | 5 | ## 安装 6 | 7 | 首先安装 [Composer](http://getcomposer.org/). 已安装请忽略。 8 | 在 `composer.json` 文件中添加: 9 | 10 | "echobool/alipay-laravel5": "dev-master" 11 | 12 | 然后执行composer进行安装: 13 | 14 | $ composer update -vvv 15 | 或直接: 16 | 17 | $ composer require "echobool/alipay-laravel5:dev-master" 18 | 在app.php中加上 19 | 20 | EchoBool\AlipayLaravel\AlipayServiceProvider::class, 21 | 22 | 更新配置 23 | 24 | php artisan config:cache 25 | 26 | 发布配置文件 27 | 28 | $ php artisan vendor:publish --provider="EchoBool\AlipayLaravel\AlipayServiceProvider" 29 | 30 | 如果出现 EchoBool\AlipayLaravel\AlipayServiceProvider not found 则运行下面代码再发布 31 | 32 | $ composer dump-autoload --optimize 33 | 34 | ## 支持 35 | 支付支持表单提交和Curl后台提交方式 36 | 37 | 当配置文件中 trade_pay_type=>true 时为表单提交 默认CURL提交。 38 | 39 | 支持交易查询操作 40 | 41 | 支持退款操作 42 | 43 | 支持退款查询操作 44 | 45 | 支持交易关闭操作 46 | 47 | ## 用法 48 | 49 | 先将config/alipay-web.php 中各项配置好 50 | 51 | ```php 52 | //文件头use一下 53 | use EchoBool\AlipayLaravel\Facades\Alipay; 54 | 55 | /** 56 | * 支付 57 | * @param Request $request 58 | * @return mixed 59 | */ 60 | public function goPay(Request $request) 61 | { 62 | //商户订单号,商户网站订单系统中唯一订单号,必填 63 | $out_trade_no = date('YmdHis') . '00045623'; 64 | //订单名称,必填 65 | $subject = '锁贸通任务ID448'; 66 | //付款金额,必填 67 | $total_amount = 0.01; 68 | //商品描述,可空 69 | $body = 'macbook pro2'; 70 | 71 | $customData = json_encode(['model_name' => 'ewrwe', 'id' => 121]);//自定义参数 72 | $response = Alipay::tradePagePay($subject, $body, $out_trade_no, $total_amount, $customData); 73 | //输出表单 74 | return $response['redirect_url']; 75 | } 76 | 77 | 78 | /** 79 | * 退款 80 | * @param Request $request 81 | */ 82 | public function refund(Request $request) 83 | { 84 | //商户订单号 85 | $out_trade_no = $request->get('trade_no'); 86 | $refund_amount = 0.01; 87 | $refund_reason = '任务取消退款'; 88 | $out_request_no = '201'; 89 | $response = Alipay::tradeRefund($out_trade_no, $refund_amount, $refund_reason, $out_request_no); 90 | dd($response); 91 | } 92 | 93 | /** 94 | * 退款查询 95 | * @param Request $request 96 | */ 97 | public function refundQuery(Request $request) 98 | { 99 | //商户订单号 100 | $out_trade_no = $request->get('trade_no'); 101 | $out_request_no = $request->get('out_request_no'); 102 | 103 | $response = Alipay::refundQuery($out_trade_no,$out_request_no); 104 | dd($response); 105 | } 106 | 107 | /** 108 | * 交易是否成功查询 109 | * @param Request $request 110 | */ 111 | public function tradePayQuery(Request $request) 112 | { 113 | //商户订单号 114 | $out_trade_no = $request->get('trade_no'); 115 | $response = Alipay::tradePayQuery($out_trade_no); 116 | dd($response); 117 | } 118 | 119 | /** 120 | * 交易关闭 121 | * @param Request $request 122 | */ 123 | public function tradeClose(Request $request) 124 | { 125 | //商户订单号 126 | $out_trade_no = $request->get('trade_no'); 127 | $response = Alipay::Close($out_trade_no); 128 | dd($response); 129 | } 130 | 131 | /** 132 | * 异步通知 133 | * @param Request $request 134 | */ 135 | public function notify(Request $request) 136 | { 137 | $result = Alipay::notify($_POST); 138 | /* 实际验证过程建议商户添加以下校验。 139 | 1、商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号, 140 | 2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额), 141 | 3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email) 142 | 4、验证app_id是否为该商户本身。 143 | */ 144 | if ($result) {//验证成功 145 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 146 | //请在这里加上商户的业务逻辑程序代 147 | 148 | 149 | //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— 150 | 151 | //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 152 | 153 | //商户订单号 154 | 155 | $out_trade_no = $_POST['out_trade_no']; 156 | 157 | //支付宝交易号 158 | 159 | $trade_no = $_POST['trade_no']; 160 | 161 | //交易状态 162 | $trade_status = $_POST['trade_status']; 163 | 164 | 165 | if ($_POST['trade_status'] == 'TRADE_FINISHED') { 166 | 167 | //判断该笔订单是否在商户网站中已经做过处理 168 | //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 169 | //请务必判断请求时的total_amount与通知时获取的total_fee为一致的 170 | //如果有做过处理,不执行商户的业务程序 171 | 172 | //注意: 173 | //退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知 174 | } else if ($_POST['trade_status'] == 'TRADE_SUCCESS') { 175 | //判断该笔订单是否在商户网站中已经做过处理 176 | //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 177 | //请务必判断请求时的total_amount与通知时获取的total_fee为一致的 178 | //如果有做过处理,不执行商户的业务程序 179 | //注意: 180 | //付款完成后,支付宝系统发送该交易状态通知 181 | } 182 | //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— 183 | echo "success"; //请不要修改或删除 184 | } else { 185 | //验证失败 186 | echo "fail"; 187 | 188 | } 189 | } 190 | 191 | 192 | /** 193 | * 同步通知 即支付成功后跳转到return_url 上时进行验证 如果支付方式是CURL方式将不会跳转 请注意 194 | * @param Request $request 195 | */ 196 | public function returnUrl(Request $request) 197 | { 198 | $result = Alipay::notify($_GET); 199 | /* 实际验证过程建议商户添加以下校验。 200 | 1、商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号, 201 | 2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额), 202 | 3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email) 203 | 4、验证app_id是否为该商户本身。 204 | */ 205 | 206 | if ($result) {//验证成功 207 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 208 | //请在这里加上商户的业务逻辑程序代码 209 | 210 | //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— 211 | //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表 212 | 213 | //商户订单号 214 | $out_trade_no = htmlspecialchars($_GET['out_trade_no']); 215 | 216 | //支付宝交易号 217 | $trade_no = htmlspecialchars($_GET['trade_no']); 218 | 219 | echo "验证成功