<?php
require_once 'AopEncrypt.php';
class AopClient {
//应用ID
public $appId;
//私钥文件路径
public $rsaPrivateKeyFilePath;
//私钥值
public $rsaPrivateKey;
//网关
public $gatewayUrl = "https://openapi.alipay.com/gateway.do";
//返回数据格式
public $format = "json";
//api版本
public $apiVersion = "1.0";
// 表单提交字符集编码
public $postCharset = "UTF-8";
//使用文件读取文件格式,请只传递该值
public $alipayPublicKey = null;
//使用读取字符串格式,请只传递该值
public $alipayrsaPublicKey;
public $debugInfo = false;
private $fileCharset = "UTF-8";
private $RESPONSE_SUFFIX = "_response";
private $ERROR_RESPONSE = "error_response";
private $SIGN_NODE_NAME = "sign";
//加密XML节点名称
private $ENCRYPT_XML_NODE_NAME = "response_encrypted";
private $needEncrypt = false;
//签名类型
public $signType = "RSA";
//加密密钥和类型
public $encryptKey;
public $encryptType = "AES";
protected $alipaySdkVersion = "alipay-sdk-php-20180705";
public function generateSign($params, $signType = "RSA") {
return $this->sign($this->getSignContent($params), $signType);
}
public function rsaSign($params, $signType = "RSA") {
return $this->sign($this->getSignContent($params), $signType);
}
public function getSignContent($params) {
ksort($params);
$stringToBeSigned = "";
$i = 0;
foreach ($params as $k => $v) {
if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) {
// 转换成目标字符集
$v = $this->characet($v, $this->postCharset);
if ($i == 0) {
$stringToBeSigned .= "$k" . "=" . "$v";
} else {
$stringToBeSigned .= "&" . "$k" . "=" . "$v";
}
$i++;
}
}
unset ($k, $v);
return $stringToBeSigned;
}
//此方法对value做urlencode
public function getSignContentUrlencode($params) {
ksort($params);
$stringToBeSigned = "";
$i = 0;
foreach ($params as $k => $v) {
if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) {
// 转换成目标字符集
$v = $this->characet($v, $this->postCharset);
if ($i == 0) {
$stringToBeSigned .= "$k" . "=" . urlencode($v);
} else {
$stringToBeSigned .= "&" . "$k" . "=" . urlencode($v);
}
$i++;
}
}
unset ($k, $v);
return $stringToBeSigned;
}
protected function sign($data, $signType = "RSA") {
if($this->checkEmpty($this->rsaPrivateKeyFilePath)){
$priKey=$this->rsaPrivateKey;
$res = "-----BEGIN RSA PRIVATE KEY-----\n" .
wordwrap($priKey, 64, "\n", true) .
"\n-----END RSA PRIVATE KEY-----";
}else {
$priKey = file_get_contents($this->rsaPrivateKeyFilePath);
$res = openssl_get_privatekey($priKey);
}
($res) or die('您使用的私钥格式错误,请检查RSA私钥配置');
if ("RSA2" == $signType) {
openssl_sign($data, $sign, $res, OPENSSL_ALGO_SHA256);
} else {
openssl_sign($data, $sign, $res);
}
if(!$this->checkEmpty($this->rsaPrivateKeyFilePath)){
openssl_free_key($res);
}
$sign = base64_encode($sign);
return $sign;
}
/**
* RSA单独签名方法,未做字符串处理,字符串处理见getSignContent()
* @param $data 待签名字符串
* @param $privatekey 商户私钥,根据keyfromfile来判断是读取字符串还是读取文件,false:填写私钥字符串去回车和空格 true:填写私钥文件路径
* @param $signType 签名方式,RSA:SHA1 RSA2:SHA256
* @param $keyfromfile 私钥获取方式,读取字符串还是读文件
* @return string
* @author mengyu.wh
*/
public function alonersaSign($data,$privatekey,$signType = "RSA",$keyfromfile=false) {
if(!$keyfromfile){
$priKey=$privatekey;
$res = "-----BEGIN RSA PRIVATE KEY-----\n" .
wordwrap($priKey, 64, "\n", true) .
"\n-----END RSA PRIVATE KEY-----";
}
else{
$priKey = file_get_contents($privatekey);
$res = openssl_get_privatekey($priKey);
}
($res) or die('您使用的私钥格式错误,请检查RSA私钥配置');
if ("RSA2" == $signType) {
openssl_sign($data, $sign, $res, OPENSSL_ALGO_SHA256);
} else {
openssl_sign($data, $sign, $res);
}
if($keyfromfile){
openssl_free_key($res);
}
$sign = base64_encode($sign);
return $sign;
}
protected function curl($url, $postFields = null) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$postBodyString = "";
$encodeArray = Array();
$postMultipart = false;
if (is_array($postFields) && 0 < count($postFields)) {
foreach ($postFields as $k => $v) {
if ("@" != substr($v, 0, 1)) //判断是不是文件上传
{
$postBodyString .= "$k=" . urlencode($this->characet($v, $this->postCharset)) . "&";
$encodeArray[$k] = $this->characet($v, $this->postCharset);
} else //文件上传用multipart/form-data,否则用www-form-urlencoded
{
$postMultipart = true;
$encodeArray[$k] = new \CURLFile(substr($v, 1));
}
}
unset ($k, $v);
curl_setopt($ch, CURLOPT_POST, true);
if ($postMultipart) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $encodeArray);
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString, 0, -1));
}
}
if ($postMultipart) {
$headers = array('content-type: multipart/form-data;charset=' . $this->postCharset . ';boundary=' . $this->getMillisecond());
} else {
$headers = array('content-type: application/x-www-form-urlencoded;charset=' . $this->postCharset);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$reponse = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception(curl_error($ch), 0);
} else {
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (200 !== $httpStatusCode) {
throw new Exception($reponse, $httpStatusCode);
}
}
curl_close($ch);
return $reponse;
}
protected function getMillisecond() {
list($s1, $s2) = explode(' ', microtime());
return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
}
protected function logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt) {
$localIp = isset ($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : "CLI";
$logger = new LtLogger;
$logger->conf["log_file"] = rtrim(AOP_SDK_WORK_DIR, '\\/') . '/' . "logs/aop_comm_err_" . $this->appId . "_" . date("Y-m-d") . ".log";
$logger->conf["separator"] = "^_^";
$logData = array(
date("Y-m-d H:i:s"),
$apiName,
$this->appId,
$localIp,
PHP_OS,
$this->alipaySdkVersion,
$requestUrl,
$errorCode,
str_replace("\n", "", $responseTxt)
);
$logger->log($logData);
}
/**
* 生成用于调用收银台SDK的字符串
* @param $request SDK接口的请求参数对象
* @return string
* @author guofa.tgf
*/
public function sdkExecute($request) {
$this->setupCharsets($request);
$params['app_id'] = $this->appId;
$params['method'] = $request->getApiMethodName();
$params['format'] = $this->format;
$params['sign_type'] = $this->signType;
$params['timestamp'] = date("Y-m-d H:i:s");
$params['alipay_sdk'] = $this->alipaySdkVersion;
$params['charset'] = $this->postCharset;
$version = $request->getApiVersion();
$params['version'] = $this->checkEmpty($version) ? $this->apiVersion : $version;
if ($notify_url = $request->getNotifyUrl()) {
$params['notify_url'] = $notify_url;
}
$dict = $request->getApiParas();
$params['biz_content'] = $dict['biz_content'];
ksort($params);
$params['sign'] = $this->generateSign($params, $this->signType);
foreach ($params as &$value) {
$value = $this->characet($value, $params['charset']);
}
return http_build_query($params);
}
/*
页面提交执行方法
@param:跳转类接口的request; $httpmethod 提交方式。两个值可选:post、get
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
支付宝提现(转账)到个人账户接口 (853个子文件)
.DS_Store 8KB
.DS_Store 6KB
.DS_Store 6KB
AopClient.php 34KB
AlipaySecurityRiskDetectRequest.php 19KB
AlipayOpenMiniVersionAuditApplyRequest.php 12KB
TemplateView.php 12KB
AlipayAcquireCreateandpayRequest.php 11KB
AlipayOpenAgentZhimabriefSignRequest.php 9KB
AlipaySecurityInfoAnalysisRequest.php 9KB
DbTableDataGateway.php 8KB
Xml.php 8KB
AlipayAcquirePrecreateRequest.php 8KB
AlipayEbppPdeductSignAddRequest.php 8KB
AlipayOpenPublicLifeAgentCreateRequest.php 8KB
AlipayTradeService.php 8KB
refund.php 7KB
pay.php 7KB
refundquery.php 7KB
Pagination.php 7KB
Autoloader.php 7KB
CaptchaImageEngine.php 7KB
AlipayOpenPublicLifeMsgSendRequest.php 6KB
datadownioad.php 6KB
close.php 6KB
AlipayEbppBillAddRequest.php 6KB
query.php 6KB
AlipayOpenAgentFacetofaceSignRequest.php 6KB
AlipayOpenPublicLifeCreateRequest.php 5KB
index.php 5KB
AlipayOpenAgentMobilepaySignRequest.php 5KB
DbHandle.php 5KB
ZhimaMerchantCloseloopDataUploadRequest.php 5KB
AlipayTransferThirdpartyBillCreateRequest.php 5KB
AlipayMobilePublicMultiMediaClient.php 5KB
AlipayOpenPublicLifeAccountCreateRequest.php 5KB
AlipayOpenAgentMiniCreateRequest.php 5KB
AlipayEbppPdeductPayRequest.php 5KB
Action.php 5KB
AlipayOpenPublicLifeModifyRequest.php 5KB
AlipayUserTradeSearchRequest.php 5KB
AlipayMobilePublicInfoModifyRequest.php 4KB
Router.php 4KB
ZhimaDataBatchFeedbackRequest.php 4KB
AlipayAcquireRefundRequest.php 4KB
AlipayMobileCodeCreateRequest.php 4KB
alipay_notify.class.php 4KB
DbConfigBuilder.php 4KB
DbConnectionManager.php 4KB
AlipayOpenMiniBaseinfoModifyRequest.php 4KB
AlipayZdatafrontDatatransferedFileuploadRequest.php 4KB
AlipayPassSyncUpdateRequest.php 4KB
AlipayEcapiprodDataPutRequest.php 4KB
AlipayMemberCouponQuerylistRequest.php 4KB
Validator.php 4KB
Lotus.php 4KB
AlipayPointOrderAddRequest.php 4KB
AlipayEbppPdeductSignCancelRequest.php 4KB
TestImage.php 4KB
AlipayOperatorMobileBindRequest.php 4KB
AlipayZdatafrontCommonQueryRequest.php 4KB
AlipayEbppBillSearchRequest.php 4KB
AlipayEcapiprodDrawndnRepaymentrecordQueryRequest.php 4KB
AlipayPassTplContentUpdateRequest.php 4KB
AlipayEcapiprodDrawndnFeerecordQueryRequest.php 4KB
AlipayEcapiprodDrawndnLendingrecordQueryRequest.php 3KB
AlipayMicropayOrderFreezeRequest.php 3KB
notify_url.php 3KB
Url.php 3KB
SessionStoreSqlite.php 3KB
AlipayMobilePublicAccountResetRequest.php 3KB
AlipayMobilePublicAccountAddRequest.php 3KB
AlipayMicropayOrderConfirmpayurlGetRequest.php 3KB
AlipayPassTplContentAddRequest.php 3KB
AlipayMicropayOrderDirectPayRequest.php 3KB
AlipayEcardEduPublicBindRequest.php 3KB
AlipayPassCodeAddRequest.php 3KB
AlipayUserAccountSearchRequest.php 3KB
AlipayMobileRecommendGetRequest.php 3KB
AlipayEcapiprodDrawndnContractGetRequest.php 3KB
AlipayTradeWapPayContentBuilder.php 3KB
AlipayEcapiprodDrawndnPaymentscheduleGetRequest.php 3KB
AlipayEcapiprodDrawndnDrawndnlistQueryRequest.php 3KB
AlipayEcapiprodCreditGetRequest.php 3KB
zz.php 3KB
AlipayAcquireCancelRequest.php 3KB
AlipayPointOrderGetRequest.php 3KB
AlipayPassFileAddRequest.php 3KB
AlipayOfflineMaterialImageUploadRequest.php 3KB
AlipayPassCodeVerifyRequest.php 3KB
Component.php 3KB
Cookie.php 3KB
AlipayPassSyncAddRequest.php 3KB
AlipayZdatafrontDatatransferedSendRequest.php 3KB
AlipaySystemOauthTokenRequest.php 2KB
DbSqlAdapterSqlite.php 2KB
AlipayAcquireCloseRequest.php 2KB
AlipayOfflineMarketingVoucherCodeUploadRequest.php 2KB
AlipayDataBillDownloadurlGetRequest.php 2KB
AlipayOfflineMarketShopPublicUnbindRequest.php 2KB
共 853 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
- wind_Cill2023-06-11#毫无价值
- ManyToOne2020-03-02骗子 根本没有转帐到个人的接口 只有几个基本的
嘉实付
- 粉丝: 3
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功