Commit ae578b53 authored by wangtao's avatar wangtao

业务板块api接口

parent da14de52

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -41,6 +41,7 @@ class Index extends AdminBase
*/
public function main()
{
// Queue::push(Jobtask::class, '','coursetask'); // 推送到队列的任务类及其数据参数
if($this->request->isPost()){
return $this->returnMsg('登录成功!',1);
......
<?php
namespace app\api\controller;
use app\api\service\AlipayTradeService;
use app\BaseController;
use think\facade\Log;
class Wttest extends BaseController
{
//测试支付宝支付
public function paytest()
{
$pay = new AlipayTradeService();
$pay->ReturnUrl = url('Wttest/payhtml', [], true, true);
$pay->NotifyUrl = url('Wttest/notifyurl', [], true, true);
$biz_content['body'] = '测试测试';
$biz_content['subject'] = '苹果手机5G';
$biz_content['total_amount'] = '0.01';
$biz_content['product_code'] = 'FAST_INSTANT_TRADE_PAY';
$biz_content['out_trade_no'] = 'z' . time();
$pay->pcpaypage($biz_content);
}
//查询支付宝订单
public function checkpay()
{
// [code] => 10000
// [msg] => Success
// [buyer_logon_id] => 137******91
// [buyer_pay_amount] => 0.00
// [buyer_user_id] => 2088802284861832
// [invoice_amount] => 0.00
// [out_trade_no] => z1748403522
// [point_amount] => 0.00
// [receipt_amount] => 0.00
// [send_pay_date] => 2025-05-28 11:38:52
// [total_amount] => 0.01
// [trade_no] => 2025052822001461831415557350
// [trade_status] => TRADE_SUCCESS
$pay = new AlipayTradeService();
$biz_content['out_trade_no'] = 'z1748403522';
// $biz_content['out_trade_no'] = '2025052822001461831415557350';
$result = $pay->payquery($biz_content);
if ($result->code == 10000 && $result->trade_status == 'TRADE_SUCCESS') {
}
print_r($result);
}
public function payhtml()
{
$get = input();
Log::write('支付宝前台回调');
Log::write(json_encode($get));
Log::write($get);
print_r($get);
exit;
}
public function notifyurl()
{
$post = input();
$alipaySevice = new AlipayTradeService();
$result = $alipaySevice->check($post);
Log::write('支付宝后台回调');
Log::write($post);
if ($result) {//验证成功
Log::write('支付宝后台回调验签成功');
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//请在这里加上商户的业务逻辑程序代
//——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
//获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表
//商户订单号
$out_trade_no = $post['out_trade_no'];
//支付宝交易号
$trade_no = $post['trade_no'];
//交易状态
$trade_status = $post['trade_status'];
$total_amount = $post['total_amount'];
if ($post['trade_status'] == 'TRADE_FINISHED') {
//判断该笔订单是否在商户网站中已经做过处理
//如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
//请务必判断请求时的total_amount与通知时获取的total_fee为一致的
//如果有做过处理,不执行商户的业务程序
//注意:
//退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知
} elseif ($post['trade_status'] == 'TRADE_SUCCESS') {
$biz_content['out_trade_no'] = $out_trade_no;
$result = $alipaySevice->payquery($biz_content);
if ($result->code == 10000 && $result->trade_status == 'TRADE_SUCCESS') {
Log::write('支付宝后台回调支付查询');
Log::write($result);
}
}
//——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
echo "success"; //请不要修改或删除
} else {
//验证失败
Log::write('支付宝后台回调验签失败');
echo "fail";
}
}
//
//[2025-05-28T13:33:50+08:00][info] 支付宝后台回调
//[2025-05-28T13:33:50+08:00][info] array (
//'gmt_create' => '2025-05-28 13:33:44',
//'charset' => 'utf-8',
//'gmt_payment' => '2025-05-28 13:33:48',
//'notify_time' => '2025-05-28 13:33:49',
//'subject' => '苹果手机5G',
//'sign' => 'B5f83l47uzBW92Gav8qaA5UplRHFG+pXmt2jLornvYSXoPSalmg60uqU6Jd/MvLdAPwke4PeSPtB6dRNZJ1GF+zPFBy0QHi113P6SxTNbhqqWHmqTQT9x9olcYeNhqdI1NFfk/ALrqMwR/q+LGZhcsMPmX3Q4AqfiE1FXWxVck7STucnEUxpYpqsqjnVP6kyD+NQKB/MOkGaQM79ox9xIsfkvm2f/aqeSobG6+Yj9RuEEvXxP1CtPSPaCRuKH0wI7f0/KzFUY0f+TxbuBKYX2FydsAxRoRqjxFHFOMAsO6b6IO1pEZ0g0qklTHD52DtskL2lj/z8p2U6kyDB38sfVA==',
//'buyer_id' => '2088802284861832',
//'body' => '测试测试',
//'invoice_amount' => '0.01',
//'version' => '1.0',
//'notify_id' => '2025052801222133349061831412509666',
//'fund_bill_list' => '[{"amount":"0.01","fundChannel":"ALIPAYACCOUNT"}]',
//'notify_type' => 'trade_status_sync',
//'out_trade_no' => 'z1748410415',
//'total_amount' => '0.01',
//'trade_status' => 'TRADE_SUCCESS',
//'trade_no' => '2025052822001461831415577006',
//'auth_app_id' => '2021005147679343',
//'receipt_amount' => '0.01',
//'point_amount' => '0.00',
//'buyer_pay_amount' => '0.01',
//'app_id' => '2021005147679343',
//'sign_type' => 'RSA2',
//'seller_id' => '2088370543757256',
//)
//[2025-05-28T13:33:50+08:00][info] 支付宝后台回调验签成功
//[2025-05-28T13:33:50+08:00][info] 支付宝后台回调支付查询
//[2025-05-28T13:33:50+08:00][info] (object) array(
//'code' => '10000',
//'msg' => 'Success',
//'buyer_logon_id' => '137******91',
//'buyer_pay_amount' => '0.00',
//'buyer_user_id' => '2088802284861832',
//'invoice_amount' => '0.00',
//'out_trade_no' => 'z1748410415',
//'point_amount' => '0.00',
//'receipt_amount' => '0.00',
//'send_pay_date' => '2025-05-28 13:33:48',
//'total_amount' => '0.01',
//'trade_no' => '2025052822001461831415577006',
//'trade_status' => 'TRADE_SUCCESS',
}
\ No newline at end of file
<?php
/* *
* 功能:支付宝电脑网站支付
* 版本:2.0
* 修改日期:2017-05-01
* 说明:
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
*/
namespace app\api\service;
require_once ROOT_PATH . 'extend/aop/AopCertClient.php';
require_once ROOT_PATH . 'extend/aop/request/AlipayTradePagePayRequest.php';
require_once ROOT_PATH . 'extend/aop/request/AlipayTradeQueryRequest.php';
class AlipayTradeService
{
public $appId = '';
public $gatewayUrl = 'https://openapi.alipay.com/gateway.do';
public $rsaPrivateKey;
public $alipayCertPath; //支付宝公钥证书
public $appCertPath; //应用公钥证书
public $rootCertPath; //支付宝根证书
public $apiVersion = '1.0';
public $signType = 'RSA2';
public $postCharset = 'utf-8';
public $format = 'json';
public $NotifyUrl = ''; //后台回调
public $ReturnUrl = ''; //前台回调 支付成功页面
public function __construct()
{
$cofig = config('zfb');
$this->appCertPath = $this->appCertPath ?: $cofig['appCertPath'];
$this->rootCertPath = $this->rootCertPath ?: $cofig['rootCertPath'];
$this->alipayCertPath = $this->alipayCertPath ?: $cofig['alipayCertPath'];
$this->rsaPrivateKey = $this->rsaPrivateKey ?: $cofig['rsaPrivateKey'];
$this->appId = $this->appId ?: $cofig['appId'];
}
//pc网站支付
public function pcpaypage($biz_content)
{
//3、pageExecute 测试
$aop = new \AopCertClient ();
// $appCertPath = ROOT_PATH . 'cert/zfbcert/appCertPublicKey.crt';
// $alipayCertPath = ROOT_PATH . 'cert/zfbcert//alipayCertPublicKey_RSA2.crt';
// $rootCertPath = ROOT_PATH . 'cert/zfbcert//alipayRootCert.crt';
$aop->gatewayUrl = $this->gatewayUrl;
$aop->appId = $this->appId;
$aop->rsaPrivateKey = $this->rsaPrivateKey;
$aop->alipayrsaPublicKey = $aop->getPublicKey($this->alipayCertPath);
$aop->apiVersion = $this->apiVersion;
$aop->signType = $this->signType;
$aop->postCharset = $this->postCharset;
$aop->format = $this->format;
$aop->isCheckAlipayPublicCert = true;//是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内
$aop->appCertSN = $aop->getCertSN($this->appCertPath);//调用getCertSN获取证书序列号
$aop->alipayRootCertSN = $aop->getRootCertSN($this->rootCertPath);//调用getRootCertSN获取支付宝根证书序列号
$request = new \AlipayTradePagePayRequest ();
$request->setNotifyUrl($this->NotifyUrl);
$request->setReturnUrl($this->ReturnUrl);
$biz_content = json_encode($biz_content, JSON_UNESCAPED_UNICODE);
$request->setBizContent($biz_content);
$result = $aop->pageExecute($request);
echo $result;
}
//交易查询
public function payquery($biz_content)
{
$aop = new \AopCertClient();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = $this->appId;
$aop->rsaPrivateKey = $this->rsaPrivateKey;
$aop->alipayrsaPublicKey = $aop->getPublicKey($this->alipayCertPath);
$aop->apiVersion = $this->apiVersion;
$aop->signType = $this->signType;
$aop->postCharset = $this->postCharset;
$aop->format = $this->format;
$aop->isCheckAlipayPublicCert = true;//是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内
$aop->appCertSN = $aop->getCertSN($this->appCertPath);//调用getCertSN获取证书序列号
$aop->alipayRootCertSN = $aop->getRootCertSN($this->rootCertPath);//调用getRootCertSN获取支付宝根证书序列号
$request = new \AlipayTradeQueryRequest ();
$request->setNotifyUrl($this->NotifyUrl);
$request->setReturnUrl($this->ReturnUrl);
$biz_content = json_encode($biz_content, JSON_UNESCAPED_UNICODE);
$request->setBizContent($biz_content);
$result = $aop->execute($request);
return $result->alipay_trade_query_response;
}
/**
* 验签方法
* @param $arr 验签支付宝返回的信息,使用支付宝公钥。
* @return boolean
*/
public function check($arr)
{
$aop = new \AopCertClient();
$aop->alipayPublicKey = $this->alipayCertPath;
$result = $aop->rsaCheckV1($arr, $this->alipayCertPath, $this->signType);
return $result;
}
}
?>
\ No newline at end of file
This diff is collapsed.
-----BEGIN CERTIFICATE-----
MIIDrDCCApSgAwIBAgIQICUFJiOv0f8H8c2b5Me0bjANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UE
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0
aG9yaXR5MTkwNwYDVQQDDDBBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IENs
YXNzIDIgUjEwHhcNMjUwNTI2MDcxNjQyWhcNMzAwNTI1MDcxNjQyWjCBjDELMAk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J7aSKiLTwUqwlSTX/MpI4RUDdpzQ+LpuI3/ODrgBTiWttpTx9LCBuOC7Llp2/bjc2n++ghTEUdsyTvOyQJN1OPJLmnWM2vrFC6vIiIZha8/INFO2QtxYW4sKp1aSt+cFxyS38CgYEAqx/rFyXA9dnio4meNwx5tFJz5PSPOwOjtFt75VoTuOr8MWldNFhWXCPKeU0XIuRaOAF+hKMeZBexgwK2k3FFvMdNbQeGE2a3AbHQeQ9MbWtLRANeZjYTJ5clhbB2/Br2KaUkf6kn/rjCt+74gUoLtN7BL8pYHsS+bV7xoje/oJ0CgYBMlEHvliSd7se04A9DjtOXKGwJH+X3Pqmin2WHzmJMgsp69y/Q4svZjZ5uy7dhVnA0+mbWhUeuw48GNY3iT7kr5sHuvWZZ7qf9A9/GGCG6q34SUAAXOeIjpsE0URL0m0V06drOAaZU0SOl8maP0T5EMx4sKuu+MNmACBPnfiw2qQKBgFxPMuqkhSSUdJn/li6m2PDEQJb8VpWOw1IPvh6kPx34XLgZjI9obty1GNQ3dM8QHzuDZ3lhg255/NctLUJPDXA5seBsOhHFs4xkldCzQW0ImaA1M3Tm/i2Gxo+AYlZlQYa/8gZw5LkyKnb14muCvyMzV4cQnFfvunBpJcyDS+DY
\ No newline at end of file
<?php
// +----------------------------------------------------------------------
// | 应用设置
// +----------------------------------------------------------------------
return [
'appId' => '2021005147679343',
//应用私钥
'rsaPrivateKey' => 'MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCMfJB8oXmmAeTxhUfnDnoxQF1uUgIGC9akVuv6Y0OsKfzos0i1zvNB7TzEcFC73CdAUeRBSF34+CFuxJwtRxZcsjeginGUoCGUkal6I7Wos/CtkeqEN/9PSsD0VqZCklNBpmzZZKEyQxoLMyiYNP2mzjZnehTkyzrniKhdp+xrGF+FBS1SdM4pLEB+zkLQ+Mh17D5tLAHe9ceVI4H+F/1SEiGkjvYZJ1k00YNrLhenzatNfoKCcJjskrIkIy5P7Lyddau54mnl8m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q34SUAAXOeIjpsE0URL0m0V06drOAaZU0SOl8maP0T5EMx4sKuu+MNmACBPnfiw2qQKBgFxPMuqkhSSUdJn/li6m2PDEQJb8VpWOw1IPvh6kPx34XLgZjI9obty1GNQ3dM8QHzuDZ3lhg255/NctLUJPDXA5seBsOhHFs4xkldCzQW0ImaA1M3Tm/i2Gxo+AYlZlQYa/8gZw5LkyKnb14muCvyMzV4cQnFfvunBpJcyDS+DY',
'alipayCertPath' => ROOT_PATH . 'cert/zfbcert//alipayCertPublicKey_RSA2.crt', //支付宝公钥证书
'appCertPath' => ROOT_PATH . 'cert/zfbcert//appCertPublicKey.crt', //应用公钥证书
'rootCertPath' => ROOT_PATH . 'cert/zfbcert//alipayRootCert.crt', //支付宝根证书
];
\ No newline at end of file
<?php
class AlipayConfig {
/**
* 网关地址
* 线上:https://openapi.alipay.com/gateway.do
* 沙箱:https://openapi.alipaydev.com/gateway.do
*/
private $serverUrl;
/**
* 开放平台上创建的应用的ID
*/
private $appId;
/**
* 报文格式,推荐:json
*/
private $format = "json";
/**
* 字符串编码,推荐:utf-8
*/
private $charset = "utf-8";
/**
* 签名算法类型,推荐:RSA2
*/
private $signType = "RSA2";
/**
* 商户私钥
*/
private $privateKey;
/**
* 支付宝公钥字符串(公钥模式下设置,证书模式下无需设置)
*/
private $alipayPublicKey;
/**
* 商户应用公钥证书路径(证书模式下设置,公钥模式下无需设置)
*/
private $appCertPath;
/**
* 支付宝公钥证书路径(证书模式下设置,公钥模式下无需设置)
*/
private $alipayPublicCertPath;
/**
* 支付宝根证书路径(证书模式下设置,公钥模式下无需设置)
*/
private $rootCertPath;
/**
* 指定商户公钥应用证书内容字符串,该字段与appCertPath只需指定一个,优先以该字段的值为准(证书模式下设置,公钥模式下无需设置)
*/
private $appCertContent;
/**
* 指定支付宝公钥证书内容字符串,该字段与alipayPublicCertPath只需指定一个,优先以该字段的值为准(证书模式下设置,公钥模式下无需设置)
*/
private $alipayPublicCertContent;
/**
* 指定根证书内容字符串,该字段与rootCertPath只需指定一个,优先以该字段的值为准(证书模式下设置,公钥模式下无需设置)
*/
private $rootCertContent;
/**
* 敏感信息对称加密算法类型,推荐:AES
*/
private $encryptType = "AES";
/**
* 敏感信息对称加密算法密钥
*/
private $encryptKey;
/**
* 跳过加验签(小程序云免鉴权)
*/
private $skipSign = false;
public function getServerUrl() {
return $this->serverUrl;
}
public function setServerUrl($serverUrl) {
$this->serverUrl = $serverUrl;
}
public function getAppId(){
return $this->appId;
}
public function setAppId($appId){
$this->appId = $appId;
}
public function getFormat(){
return $this->format;
}
public function setFormat($format){
$this->format = $format;
}
public function getCharset() {
return $this->charset;
}
public function setCharset($charset) {
$this->charset = $charset;
}
public function getSignType() {
return $this->signType;
}
public function setSignType($signType) {
$this->signType = $signType;
}
public function getEncryptKey() {
return $this->encryptKey;
}
public function setEncryptKey($encryptKey) {
$this->encryptKey = $encryptKey;
}
public function getEncryptType() {
return $this->encryptType;
}
public function setEncryptType($encryptType) {
$this->encryptType = $encryptType;
}
public function getPrivateKey() {
return $this->privateKey;
}
public function setPrivateKey($privateKey) {
$this->privateKey = $privateKey;
}
public function getAlipayPublicKey() {
return $this->alipayPublicKey;
}
public function setAlipayPublicKey($alipayPublicKey) {
$this->alipayPublicKey = $alipayPublicKey;
}
public function getAppCertPath() {
return $this->appCertPath;
}
public function setAppCertPath($appCertPath) {
$this->appCertPath = $appCertPath;
}
public function getAlipayPublicCertPath() {
return $this->alipayPublicCertPath;
}
public function setAlipayPublicCertPath($alipayPublicCertPath) {
$this->alipayPublicCertPath = $alipayPublicCertPath;
}
public function getRootCertPath() {
return $this->rootCertPath;
}
public function setRootCertPath($rootCertPath) {
$this->rootCertPath = $rootCertPath;
}
public function getAppCertContent() {
return $this->appCertContent;
}
public function setAppCertContent($appCertContent) {
$this->appCertContent = $appCertContent;
}
public function getAlipayPublicCertContent() {
return $this->alipayPublicCertContent;
}
public function setAlipayPublicCertContent($alipayPublicCertContent) {
$this->alipayPublicCertContent = $alipayPublicCertContent;
}
public function getRootCertContent() {
return $this->rootCertContent;
}
public function setRootCertContent($rootCertContent) {
$this->rootCertContent = $rootCertContent;
}
public function isSkipSign()
{
return $this->skipSign;
}
public function setSkipSign(bool $skipSign)
{
$this->skipSign = $skipSign;
}
}
\ No newline at end of file
<?php
/**
* 多媒体文件客户端
* @author yikai.hu
* @version $Id: AlipayMobilePublicMultiMediaClient.php, v 0.1 Aug 15, 2014 10:19:01 AM yikai.hu Exp $
*/
include("AlipayMobilePublicMultiMediaExecute.php");
class AlipayMobilePublicMultiMediaClient
{
private $DEFAULT_CHARSET = 'UTF-8';
private $METHOD_POST = "POST";
private $METHOD_GET = "GET";
private $SIGN = 'sign'; //get name
private $timeout = 10;// 超时时间
private $serverUrl;
private $appId;
private $privateKey;
private $prodCode;
private $format = 'json'; //todo
private $sign_type = 'RSA'; //todo
private $charset;
private $apiVersion = "1.0";
private $apiMethodName = "alipay.mobile.public.multimedia.download";
private $media_id = "L21pZnMvVDFQV3hYWGJKWFhYYUNucHJYP3Q9YW13ZiZ4c2lnPTU0MzRhYjg1ZTZjNWJmZTMxZGJiNjIzNDdjMzFkNzkw575";
//此处写死的,实际开发中,请传入
private $connectTimeout = 3000;
private $readTimeout = 15000;
function __construct($serverUrl = '', $appId = '', $partner_private_key = '', $format = '', $charset = 'GBK')
{
$this->serverUrl = $serverUrl;
$this->appId = $appId;
$this->privateKey = $partner_private_key;
$this->format = $format;
$this->charset = $charset;
}
/**
* getContents 获取网址内容
* @param $request
* @return text | bin
*/
public function getContents()
{
$datas = array(
"app_id" => $this->appId,
"method" => $this->METHOD_POST,
"sign_type" => $this->sign_type,
"version" => $this->apiVersion,
"timestamp" => date('Y-m-d H:i:s'),//yyyy-MM-dd HH:mm:ss
"biz_content" => '{"mediaId":"' . $this->media_id . '"}',
"charset" => $this->charset
);
//要提交的数据
$data_sign = $this->buildGetUrl($datas);
$post_data = $data_sign;
//初始化 curl
$ch = curl_init();
//设置目标服务器
curl_setopt($ch, CURLOPT_URL, $this->serverUrl);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//超时时间
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
if ($this->METHOD_POST == 'POST') {
// post数据
curl_setopt($ch, CURLOPT_POST, 1);
// post的变量
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
$output = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $output;
$datas = explode("\r\n\r\n", $output, 2);
$header = $datas[0];
if ($httpCode == '200') {
$body = $datas[1];
} else {
$body = '';
}
return $this->execute($header, $body, $httpCode);
}
/**
*
* @param $request
* @return text | bin
*/
public function execute($header = '', $body = '', $httpCode = '')
{
$exe = new AlipayMobilePublicMultiMediaExecute($header, $body, $httpCode);
return $exe;
}
public function buildGetUrl($query = array())
{
if (!is_array($query)) {
//exit;
}
//排序参数,
$data = $this->buildQuery($query);
// 私钥密码
$passphrase = '';
$key_width = 64;
//私钥
$privateKey = $this->privateKey;
$p_key = array();
//如果私钥是 1行
if (!stripos($privateKey, "\n")) {
$i = 0;
while ($key_str = substr($privateKey, $i * $key_width, $key_width)) {
$p_key[] = $key_str;
$i++;
}
} else {
//echo '一行?';
}
$privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" . implode("\n", $p_key);
$privateKey = $privateKey . "\n-----END RSA PRIVATE KEY-----";
//私钥
$private_id = openssl_pkey_get_private($privateKey, $passphrase);
// 签名
$signature = '';
if ("RSA2" == $this->sign_type) {
openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA256);
} else {
openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA1);
}
openssl_free_key($private_id);
//加密后的内容通常含有特殊字符,需要编码转换下
$signature = base64_encode($signature);
$signature = urlencode($signature);
//$signature = 'XjUN6YM1Mc9HXebKMv7GTLy7gmyhktyOgKk2/Jf+cz4DtP6udkzTdpkjW2j/Z4ZSD7xD6CNYI1Spz4yS93HPT0a5X9LgFWYY8SaADqe+ArXg+FBSiTwUz49SE//Xd9+LEiIRsSFkbpkuiGoO6mqJmB7vXjlD5lx6qCM3nb41wb8=';
$out = $data . '&' . $this->SIGN . '=' . $signature;
return $out;
}
/*
* 查询参数排序 a-z
* */
public function buildQuery($query)
{
if (!$query) {
return null;
}
//将要 参数 排序
ksort($query);
//重新组装参数
$params = array();
foreach ($query as $key => $value) {
$params[] = $key . '=' . $value;
}
$data = implode('&', $params);
return $data;
}
}
<?php
/**
* 多媒体文件客户端
* @author yuanwai.wang
* @version $Id: AlipayMobilePublicMultiMediaExecute.php, v 0.1 Aug 15, 2014 10:19:01 AM yuanwai.wang Exp $
*/
//namespace alipay\api ;
class AlipayMobilePublicMultiMediaExecute
{
private $code = 200;
private $msg = '';
private $body = '';
private $params = '';
private $fileSuffix = array(
"image/jpeg" => 'jpg', //+
"text/plain" => 'text'
);
/*
* @$header : 头部
* */
function __construct($header, $body, $httpCode)
{
$this->code = $httpCode;
$this->msg = '';
$this->params = $header;
$this->body = $body;
}
/**
*
* @return text | bin
*/
public function getCode()
{
return $this->code;
}
/**
*
* @return text | bin
*/
public function getMsg()
{
return $this->msg;
}
/**
*
* @return text | bin
*/
public function getType()
{
$subject = $this->params;
$pattern = '/Content\-Type:([^;]+)/';
preg_match($pattern, $subject, $matches);
if ($matches) {
$type = $matches[1];
} else {
$type = 'application/download';
}
return str_replace(' ', '', $type);
}
/**
*
* @return text | bin
*/
public function getContentLength()
{
$subject = $this->params;
$pattern = '/Content-Length:\s*([^\n]+)/';
preg_match($pattern, $subject, $matches);
return (int)(isset($matches[1]) ? $matches[1] : '');
}
public function getFileSuffix($fileType)
{
$type = isset($this->fileSuffix[$fileType]) ? $this->fileSuffix[$fileType] : 'text/plain';
if (!$type) {
$type = 'json';
}
return $type;
}
/**
*
* @return text | bin
*/
public function getBody()
{
//header('Content-type: image/jpeg');
return $this->body;
}
/**
* 获取参数
* @return text | bin
*/
public function getParams()
{
return $this->params;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php
/**
* 加密工具类
*
* User: jiehua
* Date: 16/3/30
* Time: 下午3:25
*/
/**
* 加密方法
* @param string $str
* @return string
*/
function encrypt($str, $screct_key)
{
//AES, 128 模式加密数据 CBC
$screct_key = base64_decode($screct_key);
$str = trim($str);
$str = addPKCS7Padding($str);
//设置全0的IV
$iv = str_repeat("\0", 16);
$encrypt_str = openssl_encrypt($str, 'aes-128-cbc', $screct_key, OPENSSL_NO_PADDING, $iv);
return base64_encode($encrypt_str);
}
/**
* 解密方法
* @param string $str
* @return string
*/
function decrypt($str, $screct_key)
{
//AES, 128 模式加密数据 CBC
$str = base64_decode($str);
$screct_key = base64_decode($screct_key);
//设置全0的IV
$iv = str_repeat("\0", 16);
$decrypt_str = openssl_decrypt($str, 'aes-128-cbc', $screct_key, OPENSSL_NO_PADDING, $iv);
$decrypt_str = stripPKSC7Padding($decrypt_str);
return $decrypt_str;
}
/**
* 填充算法
* @param string $source
* @return string
*/
function addPKCS7Padding($source)
{
$source = trim($source);
$block = 16;
$pad = $block - (strlen($source) % $block);
if ($pad <= $block) {
$char = chr($pad);
$source .= str_repeat($char, $pad);
}
return $source;
}
/**
* 移去填充算法
* @param string $source
* @return string
*/
function stripPKSC7Padding($source)
{
$char = substr($source, -1);
$num = ord($char);
if ($num == 62) return $source;
$source = substr($source, 0, -$num);
return $source;
}
\ No newline at end of file
<?php
/**
* TODO 补充说明
*
* User: jiehua
* Date: 16/3/30
* Time: 下午8:55
*/
class EncryptParseItem
{
public $startIndex;
public $endIndex;
public $encryptContent;
}
\ No newline at end of file
<?php
/**
* TODO 补充说明
*
* User: jiehua
* Date: 16/3/30
* Time: 下午8:51
*/
class EncryptResponseData
{
public $realContent;
public $returnContent;
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: jiehua
* Date: 15/5/2
* Time: 下午6:21
*/
class SignData
{
public $signSourceData = null;
public $sign = null;
}
\ No newline at end of file
<?php
/**
* ALIPAY API: aft.aifin.fireeye.ocr.image.query request
*
* @author auto create
* @since 1.0, 2024-07-04 16:54:57
*/
class AftAifinFireeyeOcrImageQueryRequest
{
/**
* OCR火眼识别
**/
private $bizContent;
private $apiParas = array();
private $terminalType;
private $terminalInfo;
private $prodCode;
private $apiVersion="1.0";
private $notifyUrl;
private $returnUrl;
private $needEncrypt=false;
public function setBizContent($bizContent)
{
$this->bizContent = $bizContent;
$this->apiParas["biz_content"] = $bizContent;
}
public function getBizContent()
{
return $this->bizContent;
}
public function getApiMethodName()
{
return "aft.aifin.fireeye.ocr.image.query";
}
public function setNotifyUrl($notifyUrl)
{
$this->notifyUrl=$notifyUrl;
}
public function getNotifyUrl()
{
return $this->notifyUrl;
}
public function setReturnUrl($returnUrl)
{
$this->returnUrl=$returnUrl;
}
public function getReturnUrl()
{
return $this->returnUrl;
}
public function getApiParas()
{
return $this->apiParas;
}
public function getTerminalType()
{
return $this->terminalType;
}
public function setTerminalType($terminalType)
{
$this->terminalType = $terminalType;
}
public function getTerminalInfo()
{
return $this->terminalInfo;
}
public function setTerminalInfo($terminalInfo)
{
$this->terminalInfo = $terminalInfo;
}
public function getProdCode()
{
return $this->prodCode;
}
public function setProdCode($prodCode)
{
$this->prodCode = $prodCode;
}
public function setApiVersion($apiVersion)
{
$this->apiVersion=$apiVersion;
}
public function getApiVersion()
{
return $this->apiVersion;
}
public function setNeedEncrypt($needEncrypt)
{
$this->needEncrypt=$needEncrypt;
}
public function getNeedEncrypt()
{
return $this->needEncrypt;
}
}
<?php
/**
* ALIPAY API: aft.aifin.newtest.query request
*
* @author auto create
* @since 1.0, 2019-02-18 13:15:00
*/
class AftAifinNewtestQueryRequest
{
private $apiParas = array();
private $terminalType;
private $terminalInfo;
private $prodCode;
private $apiVersion="1.0";
private $notifyUrl;
private $returnUrl;
private $needEncrypt=false;
public function getApiMethodName()
{
return "aft.aifin.newtest.query";
}
public function setNotifyUrl($notifyUrl)
{
$this->notifyUrl=$notifyUrl;
}
public function getNotifyUrl()
{
return $this->notifyUrl;
}
public function setReturnUrl($returnUrl)
{
$this->returnUrl=$returnUrl;
}
public function getReturnUrl()
{
return $this->returnUrl;
}
public function getApiParas()
{
return $this->apiParas;
}
public function getTerminalType()
{
return $this->terminalType;
}
public function setTerminalType($terminalType)
{
$this->terminalType = $terminalType;
}
public function getTerminalInfo()
{
return $this->terminalInfo;
}
public function setTerminalInfo($terminalInfo)
{
$this->terminalInfo = $terminalInfo;
}
public function getProdCode()
{
return $this->prodCode;
}
public function setProdCode($prodCode)
{
$this->prodCode = $prodCode;
}
public function setApiVersion($apiVersion)
{
$this->apiVersion=$apiVersion;
}
public function getApiVersion()
{
return $this->apiVersion;
}
public function setNeedEncrypt($needEncrypt)
{
$this->needEncrypt=$needEncrypt;
}
public function getNeedEncrypt()
{
return $this->needEncrypt;
}
}
<?php
/**
* ALIPAY API: aft.finsecure.riskplus.security.policy.query request
*
* @author auto create
* @since 1.0, 2024-07-04 16:38:08
*/
class AftFinsecureRiskplusSecurityPolicyQueryRequest
{
/**
* 策略咨询服务输出
**/
private $bizContent;
private $apiParas = array();
private $terminalType;
private $terminalInfo;
private $prodCode;
private $apiVersion="1.0";
private $notifyUrl;
private $returnUrl;
private $needEncrypt=false;
public function setBizContent($bizContent)
{
$this->bizContent = $bizContent;
$this->apiParas["biz_content"] = $bizContent;
}
public function getBizContent()
{
return $this->bizContent;
}
public function getApiMethodName()
{
return "aft.finsecure.riskplus.security.policy.query";
}
public function setNotifyUrl($notifyUrl)
{
$this->notifyUrl=$notifyUrl;
}
public function getNotifyUrl()
{
return $this->notifyUrl;
}
public function setReturnUrl($returnUrl)
{
$this->returnUrl=$returnUrl;
}
public function getReturnUrl()
{
return $this->returnUrl;
}
public function getApiParas()
{
return $this->apiParas;
}
public function getTerminalType()
{
return $this->terminalType;
}
public function setTerminalType($terminalType)
{
$this->terminalType = $terminalType;
}
public function getTerminalInfo()
{
return $this->terminalInfo;
}
public function setTerminalInfo($terminalInfo)
{
$this->terminalInfo = $terminalInfo;
}
public function getProdCode()
{
return $this->prodCode;
}
public function setProdCode($prodCode)
{
$this->prodCode = $prodCode;
}
public function setApiVersion($apiVersion)
{
$this->apiVersion=$apiVersion;
}
public function getApiVersion()
{
return $this->apiVersion;
}
public function setNeedEncrypt($needEncrypt)
{
$this->needEncrypt=$needEncrypt;
}
public function getNeedEncrypt()
{
return $this->needEncrypt;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment