新增
This commit is contained in:
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Base\Image;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Base\Image\Models\AlipayOfflineMaterialImageUploadResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $imageName
|
||||
* @param string $imageFilePath
|
||||
* @return AlipayOfflineMaterialImageUploadResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function upload($imageName, $imageFilePath){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 100000,
|
||||
"readTimeout" => 100000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.offline.material.image.upload",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [];
|
||||
$textParams = [
|
||||
"image_type" => "jpg",
|
||||
"image_name" => $imageName
|
||||
];
|
||||
$fileParams = [
|
||||
"image_content" => $imageFilePath
|
||||
];
|
||||
$boundary = $this->_kernel->getRandomBoundary();
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => $this->_kernel->concatStr("multipart/form-data;charset=utf-8;boundary=", $boundary)
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams));
|
||||
$_request->body = $this->_kernel->toMultipartRequestBody($textParams, $fileParams, $boundary);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.offline.material.image.upload");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOfflineMaterialImageUploadResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOfflineMaterialImageUploadResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Base\Image\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOfflineMaterialImageUploadResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'imageId' => 'image_id',
|
||||
'imageUrl' => 'image_url',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('imageId', $this->imageId, true);
|
||||
Model::validateRequired('imageUrl', $this->imageUrl, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->imageId) {
|
||||
$res['image_id'] = $this->imageId;
|
||||
}
|
||||
if (null !== $this->imageUrl) {
|
||||
$res['image_url'] = $this->imageUrl;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOfflineMaterialImageUploadResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['image_id'])){
|
||||
$model->imageId = $map['image_id'];
|
||||
}
|
||||
if(isset($map['image_url'])){
|
||||
$model->imageUrl = $map['image_url'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $imageId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $imageUrl;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Base\OAuth;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Base\OAuth\Models\AlipaySystemOauthTokenResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @return AlipaySystemOauthTokenResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function getToken($code){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.system.oauth.token",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [];
|
||||
$textParams = [
|
||||
"grant_type" => "authorization_code",
|
||||
"code" => $code
|
||||
];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.system.oauth.token");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipaySystemOauthTokenResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipaySystemOauthTokenResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $refreshToken
|
||||
* @return AlipaySystemOauthTokenResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function refreshToken($refreshToken){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.system.oauth.token",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [];
|
||||
$textParams = [
|
||||
"grant_type" => "refresh_token",
|
||||
"refresh_token" => $refreshToken
|
||||
];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.system.oauth.token");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipaySystemOauthTokenResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipaySystemOauthTokenResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+156
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Base\OAuth\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipaySystemOauthTokenResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'userId' => 'user_id',
|
||||
'accessToken' => 'access_token',
|
||||
'expiresIn' => 'expires_in',
|
||||
'refreshToken' => 'refresh_token',
|
||||
'reExpiresIn' => 're_expires_in',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('userId', $this->userId, true);
|
||||
Model::validateRequired('accessToken', $this->accessToken, true);
|
||||
Model::validateRequired('expiresIn', $this->expiresIn, true);
|
||||
Model::validateRequired('refreshToken', $this->refreshToken, true);
|
||||
Model::validateRequired('reExpiresIn', $this->reExpiresIn, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->userId) {
|
||||
$res['user_id'] = $this->userId;
|
||||
}
|
||||
if (null !== $this->accessToken) {
|
||||
$res['access_token'] = $this->accessToken;
|
||||
}
|
||||
if (null !== $this->expiresIn) {
|
||||
$res['expires_in'] = $this->expiresIn;
|
||||
}
|
||||
if (null !== $this->refreshToken) {
|
||||
$res['refresh_token'] = $this->refreshToken;
|
||||
}
|
||||
if (null !== $this->reExpiresIn) {
|
||||
$res['re_expires_in'] = $this->reExpiresIn;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipaySystemOauthTokenResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['user_id'])){
|
||||
$model->userId = $map['user_id'];
|
||||
}
|
||||
if(isset($map['access_token'])){
|
||||
$model->accessToken = $map['access_token'];
|
||||
}
|
||||
if(isset($map['expires_in'])){
|
||||
$model->expiresIn = $map['expires_in'];
|
||||
}
|
||||
if(isset($map['refresh_token'])){
|
||||
$model->refreshToken = $map['refresh_token'];
|
||||
}
|
||||
if(isset($map['re_expires_in'])){
|
||||
$model->reExpiresIn = $map['re_expires_in'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $userId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $accessToken;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $expiresIn;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $refreshToken;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $reExpiresIn;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Base\Qrcode;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Base\Qrcode\Models\AlipayOpenAppQrcodeCreateResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $urlParam
|
||||
* @param string $queryParam
|
||||
* @param string $describe
|
||||
* @return AlipayOpenAppQrcodeCreateResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function create($urlParam, $queryParam, $describe){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.open.app.qrcode.create",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"url_param" => $urlParam,
|
||||
"query_param" => $queryParam,
|
||||
"describe" => $describe
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.open.app.qrcode.create");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenAppQrcodeCreateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenAppQrcodeCreateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Base\Qrcode\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOpenAppQrcodeCreateResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'qrCodeUrl' => 'qr_code_url',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('qrCodeUrl', $this->qrCodeUrl, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->qrCodeUrl) {
|
||||
$res['qr_code_url'] = $this->qrCodeUrl;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOpenAppQrcodeCreateResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['qr_code_url'])){
|
||||
$model->qrCodeUrl = $map['qr_code_url'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $qrCodeUrl;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Base\Video;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Base\Video\Models\AlipayOfflineMaterialImageUploadResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $videoName
|
||||
* @param string $videoFilePath
|
||||
* @return AlipayOfflineMaterialImageUploadResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function upload($videoName, $videoFilePath){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 100000,
|
||||
"readTimeout" => 100000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.offline.material.image.upload",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [];
|
||||
$textParams = [
|
||||
"image_type" => "mp4",
|
||||
"image_name" => $videoName
|
||||
];
|
||||
$fileParams = [
|
||||
"image_content" => $videoFilePath
|
||||
];
|
||||
$boundary = $this->_kernel->getRandomBoundary();
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => $this->_kernel->concatStr("multipart/form-data;charset=utf-8;boundary=", $boundary)
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams));
|
||||
$_request->body = $this->_kernel->toMultipartRequestBody($textParams, $fileParams, $boundary);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.offline.material.image.upload");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOfflineMaterialImageUploadResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOfflineMaterialImageUploadResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Base\Video\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOfflineMaterialImageUploadResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'imageId' => 'image_id',
|
||||
'imageUrl' => 'image_url',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('imageId', $this->imageId, true);
|
||||
Model::validateRequired('imageUrl', $this->imageUrl, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->imageId) {
|
||||
$res['image_id'] = $this->imageId;
|
||||
}
|
||||
if (null !== $this->imageUrl) {
|
||||
$res['image_url'] = $this->imageUrl;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOfflineMaterialImageUploadResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['image_id'])){
|
||||
$model->imageId = $map['image_id'];
|
||||
}
|
||||
if(isset($map['image_url'])){
|
||||
$model->imageUrl = $map['image_url'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $imageId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $imageUrl;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Alipay\EasySDK\Kernel;
|
||||
|
||||
|
||||
class AlipayConstants
|
||||
{
|
||||
/**
|
||||
* Config配置参数Key值
|
||||
*/
|
||||
const PROTOCOL_CONFIG_KEY = "protocol";
|
||||
const HOST_CONFIG_KEY = "gatewayHost";
|
||||
const ALIPAY_CERT_PATH_CONFIG_KEY = "alipayCertPath";
|
||||
const MERCHANT_CERT_PATH_CONFIG_KEY = "merchantCertPath";
|
||||
const ALIPAY_ROOT_CERT_PATH_CONFIG_KEY = "alipayRootCertPath";
|
||||
const SIGN_TYPE_CONFIG_KEY = "signType";
|
||||
const NOTIFY_URL_CONFIG_KEY = "notifyUrl";
|
||||
|
||||
/**
|
||||
* 与网关HTTP交互中涉及到的字段值
|
||||
*/
|
||||
const BIZ_CONTENT_FIELD = "biz_content";
|
||||
const ALIPAY_CERT_SN_FIELD = "alipay_cert_sn";
|
||||
const SIGN_FIELD = "sign";
|
||||
const BODY_FIELD = "http_body";
|
||||
const NOTIFY_URL_FIELD = "notify_url";
|
||||
const METHOD_FIELD = "method";
|
||||
const RESPONSE_SUFFIX = "_response";
|
||||
const ERROR_RESPONSE = "error_response";
|
||||
const SDK_VERSION = "alipay-easysdk-php-2.2.3";
|
||||
|
||||
/**
|
||||
* 默认字符集编码,EasySDK统一固定使用UTF-8编码,无需用户感知编码,用户面对的总是String而不是bytes
|
||||
*/
|
||||
const DEFAULT_CHARSET = "UTF-8";
|
||||
|
||||
/**
|
||||
* 默认的签名算法,EasySDK统一固定使用RSA2签名算法(即SHA_256_WITH_RSA),但此参数依然需要用户指定以便用户感知,因为在开放平台接口签名配置界面中需要选择同样的算法
|
||||
*/
|
||||
const RSA2 = "RSA2";
|
||||
|
||||
/**
|
||||
* RSA2对应的真实签名算法名称
|
||||
*/
|
||||
const SHA_256_WITH_RSA = "SHA256WithRSA";
|
||||
|
||||
/**
|
||||
* RSA2对应的真实非对称加密算法名称
|
||||
*/
|
||||
const RSA = "RSA";
|
||||
|
||||
/**
|
||||
* 申请生成的重定向网页的请求类型,GET表示生成URL
|
||||
*/
|
||||
const GET = "GET";
|
||||
|
||||
/**
|
||||
* 申请生成的重定向网页的请求类型,POST表示生成form表单
|
||||
*/
|
||||
const POST = "POST";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Alipay\EasySDK\Kernel;
|
||||
|
||||
|
||||
use Alipay\EasySDK\Kernel\Util\AntCertificationUtil;
|
||||
use http\Exception\RuntimeException;
|
||||
|
||||
class CertEnvironment
|
||||
{
|
||||
private $rootCertSN;
|
||||
|
||||
private $merchantCertSN;
|
||||
|
||||
private $cachedAlipayPublicKey;
|
||||
|
||||
/**
|
||||
* 构造证书运行环境
|
||||
* @param $merchantCertPath string 商户公钥证书路径
|
||||
* @param $alipayCertPath string 支付宝公钥证书路径
|
||||
* @param $alipayRootCertPath string 支付宝根证书路径
|
||||
*/
|
||||
public function certEnvironment($merchantCertPath, $alipayCertPath, $alipayRootCertPath)
|
||||
{
|
||||
if (empty($merchantCertPath) || empty($alipayCertPath) || empty($alipayRootCertPath)) {
|
||||
throw new RuntimeException("证书参数merchantCertPath、alipayCertPath或alipayRootCertPath设置不完整。");
|
||||
}
|
||||
$antCertificationUtil = new AntCertificationUtil();
|
||||
$this->rootCertSN = $antCertificationUtil->getRootCertSN($alipayRootCertPath);
|
||||
$this->merchantCertSN = $antCertificationUtil->getCertSN($merchantCertPath);
|
||||
$this->cachedAlipayPublicKey = $antCertificationUtil->getPublicKey($alipayCertPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRootCertSN()
|
||||
{
|
||||
return $this->rootCertSN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMerchantCertSN()
|
||||
{
|
||||
return $this->merchantCertSN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCachedAlipayPublicKey()
|
||||
{
|
||||
return $this->cachedAlipayPublicKey;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Alipay\EasySDK\Kernel;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class Config extends Model
|
||||
{
|
||||
public $protocol;
|
||||
public $gatewayHost;
|
||||
public $appId;
|
||||
public $signType;
|
||||
public $alipayPublicKey;
|
||||
public $merchantPrivateKey;
|
||||
public $merchantCertPath;
|
||||
public $alipayCertPath;
|
||||
public $alipayRootCertPath;
|
||||
public $merchantCertSN;
|
||||
public $alipayCertSN;
|
||||
public $alipayRootCertSN;
|
||||
public $notifyUrl;
|
||||
public $encryptKey;
|
||||
public $httpProxy;
|
||||
public $ignoreSSL;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Alipay\EasySDK\Kernel;
|
||||
|
||||
use Alipay\EasySDK\Kernel\Util\AES;
|
||||
use Alipay\EasySDK\Kernel\Util\JsonUtil;
|
||||
use Alipay\EasySDK\Kernel\Util\PageUtil;
|
||||
use Alipay\EasySDK\Kernel\Util\SignContentExtractor;
|
||||
use Alipay\EasySDK\Kernel\Util\Signer;
|
||||
use AlibabaCloud\Tea\FileForm\FileForm;
|
||||
use AlibabaCloud\Tea\FileForm\FileForm\FileField;
|
||||
use GuzzleHttp\Psr7\Stream;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class EasySDKKernel
|
||||
{
|
||||
|
||||
private $config;
|
||||
|
||||
private $optionalTextParams;
|
||||
|
||||
private $optionalBizParams;
|
||||
|
||||
private $textParams;
|
||||
|
||||
private $bizParams;
|
||||
|
||||
|
||||
public function __construct($config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function injectTextParam($key, $value)
|
||||
{
|
||||
if ($key != null) {
|
||||
$this->optionalTextParams[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function injectBizParam($key, $value)
|
||||
{
|
||||
if ($key != null) {
|
||||
$this->optionalBizParams[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时间戳,格式yyyy-MM-dd HH:mm:ss
|
||||
* @return false|string 当前时间戳
|
||||
*/
|
||||
public function getTimestamp()
|
||||
{
|
||||
return date("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
public function getConfig($key)
|
||||
{
|
||||
return $this->config->$key;
|
||||
}
|
||||
|
||||
public function getSdkVersion()
|
||||
{
|
||||
return AlipayConstants::SDK_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将业务参数和其他额外文本参数按www-form-urlencoded格式转换成HTTP Body中的字节数组,注意要做URL Encode
|
||||
*
|
||||
* @param $bizParams array 业务参数
|
||||
* @return false|string|null
|
||||
*/
|
||||
public function toUrlEncodedRequestBody($bizParams)
|
||||
{
|
||||
$sortedMap = $this->getSortedMap(null, $bizParams, null);
|
||||
if (empty($sortedMap)) {
|
||||
return null;
|
||||
}
|
||||
return $this->buildQueryString($sortedMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析网关响应内容,同时将API的接口名称和响应原文插入到响应数组的method和body字段中
|
||||
*
|
||||
* @param $response ResponseInterface HTTP响应
|
||||
* @param $method string 调用的OpenAPI的接口名称
|
||||
* @return array 响应的结果
|
||||
*/
|
||||
public function readAsJson($response, $method)
|
||||
{
|
||||
$responseBody = (string)$response->getBody();
|
||||
$map = [];
|
||||
$map[AlipayConstants::BODY_FIELD] = $responseBody;
|
||||
$map[AlipayConstants::METHOD_FIELD] = $method;
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机分界符,用于multipart格式的HTTP请求Body的多个字段间的分隔
|
||||
*
|
||||
* @return string 随机分界符
|
||||
*/
|
||||
public function getRandomBoundary()
|
||||
{
|
||||
return date("Y-m-d H:i:s") . '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 将其他额外文本参数和文件参数按multipart/form-data格式转换成HTTP Body中
|
||||
* @param $textParams
|
||||
* @param $fileParams
|
||||
* @param $boundary
|
||||
* @return false|string
|
||||
*/
|
||||
public function toMultipartRequestBody($textParams, $fileParams, $boundary)
|
||||
{
|
||||
$this->textParams = $textParams;
|
||||
if ($textParams != null && $this->optionalTextParams != null) {
|
||||
$this->textParams = array_merge($textParams, $this->optionalTextParams);
|
||||
} else if ($textParams == null) {
|
||||
$this->textParams = $this->optionalTextParams;
|
||||
}
|
||||
if (count($fileParams) > 0) {
|
||||
|
||||
foreach ($fileParams as $key => $value) {
|
||||
$fileField = new FileField();
|
||||
$fileField->filename = $value;
|
||||
$fileField->contentType = 'multipart/form-data;charset=utf-8;boundary=' . $boundary;
|
||||
$fileField->content = new Stream(fopen($value, 'r'));
|
||||
$this->textParams[$key] = $fileField;
|
||||
}
|
||||
}
|
||||
$stream = FileForm::toFileForm($this->textParams, $boundary);
|
||||
|
||||
// do {
|
||||
// $readLength = $stream->read(1024);
|
||||
// } while (0 != $readLength);
|
||||
return $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成页面类请求所需URL或Form表单
|
||||
* @param $method
|
||||
* @param $systemParams
|
||||
* @param $bizParams
|
||||
* @param $textParams
|
||||
* @param $sign
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function generatePage($method, $systemParams, $bizParams, $textParams, $sign)
|
||||
{
|
||||
if ($method == AlipayConstants::GET) {
|
||||
//采集并排序所有参数
|
||||
$sortedMap = $this->getSortedMap($systemParams, $bizParams, $textParams);
|
||||
$sortedMap[AlipayConstants::SIGN_FIELD] = $sign;
|
||||
return $this->getGatewayServerUrl() . '?' . $this->buildQueryString($sortedMap);
|
||||
} elseif ($method == AlipayConstants::POST) {
|
||||
//采集并排序所有参数
|
||||
$sortedMap = $this->getSortedMap($systemParams, $this->bizParams, $this->textParams);
|
||||
$sortedMap[AlipayConstants::SIGN_FIELD] = $sign;
|
||||
$pageUtil = new PageUtil();
|
||||
return $pageUtil->buildForm($this->getGatewayServerUrl(), $sortedMap);
|
||||
} else {
|
||||
throw new \Exception("不支持" . $method);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商户应用公钥证书序列号,从证书模式运行时环境对象中直接读取
|
||||
*
|
||||
* @return mixed 商户应用公钥证书序列号
|
||||
*/
|
||||
public function getMerchantCertSN()
|
||||
{
|
||||
return $this->config->merchantCertSN;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从响应Map中提取支付宝公钥证书序列号
|
||||
*
|
||||
* @param array $respMap string 响应Map
|
||||
* @return mixed 支付宝公钥证书序列号
|
||||
*/
|
||||
public function getAlipayCertSN(array $respMap)
|
||||
{
|
||||
if (!empty($this->config->merchantCertSN)) {
|
||||
$body = json_decode($respMap[AlipayConstants::BODY_FIELD]);
|
||||
$alipayCertSN = $body->alipay_cert_sn;
|
||||
return $alipayCertSN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付宝根证书序列号,从证书模式运行时环境对象中直接读取
|
||||
*
|
||||
* @return mixed 支付宝根证书序列号
|
||||
*/
|
||||
public function getAlipayRootCertSN()
|
||||
{
|
||||
return $this->config->alipayRootCertSN;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是证书模式
|
||||
* @return mixed true:是;false:不是
|
||||
*/
|
||||
public function isCertMode()
|
||||
{
|
||||
return $this->config->merchantCertSN;
|
||||
}
|
||||
|
||||
public function extractAlipayPublicKey($alipayCertSN)
|
||||
{
|
||||
// PHP 版本只存储一个版本支付宝公钥
|
||||
return $this->config->alipayPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证签名
|
||||
*
|
||||
* @param $respMap string 响应内容,可以从中提取出sign和body
|
||||
* @param $alipayPublicKey string 支付宝公钥
|
||||
* @return bool true:验签通过;false:验签不通过
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function verify($respMap, $alipayPublicKey)
|
||||
{
|
||||
$resp = json_decode($respMap[AlipayConstants::BODY_FIELD], true);
|
||||
$sign = $resp[AlipayConstants::SIGN_FIELD];
|
||||
$signContentExtractor = new SignContentExtractor();
|
||||
$content = $signContentExtractor->getSignSourceData($respMap[AlipayConstants::BODY_FIELD],
|
||||
$respMap[AlipayConstants::METHOD_FIELD]);
|
||||
$signer = new Signer();
|
||||
return $signer->verify($content, $sign, $alipayPublicKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算签名,注意要去除key或value为null的键值对
|
||||
*
|
||||
* @param $systemParams array 系统参数集合
|
||||
* @param $bizParams array 业务参数集合
|
||||
* @param $textParams array 其他额外文本参数集合
|
||||
* @param $privateKey string 私钥
|
||||
* @return string 签名值的Base64串
|
||||
*/
|
||||
public function sign($systemParams, $bizParams, $textParams, $privateKey)
|
||||
{
|
||||
$sortedMap = $this->getSortedMap($systemParams, $bizParams, $textParams);
|
||||
$data = $this->getSignContent($sortedMap);
|
||||
$sign = new Signer();
|
||||
return $sign->sign($data, $privateKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* AES加密
|
||||
* @param $content
|
||||
* @param $encryptKey
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function aesEncrypt($content, $encryptKey)
|
||||
{
|
||||
$aes = new AES();
|
||||
return $aes->aesEncrypt($content, $encryptKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* AES解密
|
||||
* @param $content
|
||||
* @param $encryptKey
|
||||
* @return false|string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function aesDecrypt($content, $encryptKey)
|
||||
{
|
||||
$aes = new AES();
|
||||
return $aes->aesDecrypt($content, $encryptKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成sdkExecute类请求所需URL
|
||||
*
|
||||
* @param $systemParams
|
||||
* @param $bizParams
|
||||
* @param $textParams
|
||||
* @param $sign
|
||||
* @return string
|
||||
*/
|
||||
public function generateOrderString($systemParams, $bizParams, $textParams, $sign)
|
||||
{
|
||||
//采集并排序所有参数
|
||||
$sortedMap = $this->getSortedMap($systemParams, $bizParams, $textParams);
|
||||
$sortedMap[AlipayConstants::SIGN_FIELD] = $sign;
|
||||
return http_build_query($sortedMap);
|
||||
}
|
||||
|
||||
public function sortMap($randomMap)
|
||||
{
|
||||
return $randomMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从响应Map中提取返回值对象的Map,并将响应原文插入到body字段中
|
||||
*
|
||||
* @param $respMap string 响应内容
|
||||
* @return mixed
|
||||
*/
|
||||
public function toRespModel($respMap)
|
||||
{
|
||||
$body = $respMap[AlipayConstants::BODY_FIELD];
|
||||
$methodName = $respMap[AlipayConstants::METHOD_FIELD];
|
||||
$responseNodeName = str_replace(".", "_", $methodName) . AlipayConstants::RESPONSE_SUFFIX;
|
||||
|
||||
$model = json_decode($body, true);
|
||||
if (strpos($body, AlipayConstants::ERROR_RESPONSE)) {
|
||||
$result = $model[AlipayConstants::ERROR_RESPONSE];
|
||||
$result[AlipayConstants::BODY_FIELD] = $body;
|
||||
} else {
|
||||
$result = $model[$responseNodeName];
|
||||
$result[AlipayConstants::BODY_FIELD] = $body;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function verifyParams($parameters, $publicKey)
|
||||
{
|
||||
$sign = new Signer();
|
||||
return $sign->verifyParams($parameters, $publicKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串拼接
|
||||
*
|
||||
* @param $a
|
||||
* @param $b
|
||||
* @return string 字符串a和b拼接后的字符串
|
||||
*/
|
||||
public function concatStr($a, $b)
|
||||
{
|
||||
return $a . $b;
|
||||
}
|
||||
|
||||
|
||||
private function buildQueryString(array $sortedMap)
|
||||
{
|
||||
$requestUrl = null;
|
||||
foreach ($sortedMap as $sysParamKey => $sysParamValue) {
|
||||
$requestUrl .= "$sysParamKey=" . urlencode($this->characet($sysParamValue, AlipayConstants::DEFAULT_CHARSET)) . "&";
|
||||
}
|
||||
$requestUrl = substr($requestUrl, 0, -1);
|
||||
return $requestUrl;
|
||||
|
||||
}
|
||||
|
||||
private function getSortedMap($systemParams, $bizParams, $textParams)
|
||||
{
|
||||
$this->textParams = $textParams;
|
||||
$this->bizParams = $bizParams;
|
||||
if ($textParams != null && $this->optionalTextParams != null) {
|
||||
$this->textParams = array_merge($textParams, $this->optionalTextParams);
|
||||
} else if ($textParams == null) {
|
||||
$this->textParams = $this->optionalTextParams;
|
||||
}
|
||||
if ($bizParams != null && $this->optionalBizParams != null) {
|
||||
$this->bizParams = array_merge($bizParams, $this->optionalBizParams);
|
||||
} else if ($bizParams == null) {
|
||||
$this->bizParams = $this->optionalBizParams;
|
||||
}
|
||||
$json = new JsonUtil();
|
||||
if ($this->bizParams != null) {
|
||||
$bizParams = $json->toJsonString($this->bizParams);
|
||||
}
|
||||
$sortedMap = $systemParams;
|
||||
if (!empty($bizParams)) {
|
||||
$sortedMap[AlipayConstants::BIZ_CONTENT_FIELD] = json_encode($bizParams, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (!empty($this->textParams)) {
|
||||
if (!empty($sortedMap)) {
|
||||
$sortedMap = array_merge($sortedMap, $this->textParams);
|
||||
} else {
|
||||
$sortedMap = $this->textParams;
|
||||
}
|
||||
}
|
||||
if ($this->getConfig(AlipayConstants::NOTIFY_URL_CONFIG_KEY) != null) {
|
||||
$sortedMap[AlipayConstants::NOTIFY_URL_FIELD] = $this->getConfig(AlipayConstants::NOTIFY_URL_CONFIG_KEY);
|
||||
}
|
||||
return $sortedMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签名字符串
|
||||
*
|
||||
* @param $params
|
||||
* @return string
|
||||
*/
|
||||
private 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, AlipayConstants::DEFAULT_CHARSET);
|
||||
if ($i == 0) {
|
||||
$stringToBeSigned .= "$k" . "=" . "$v";
|
||||
} else {
|
||||
$stringToBeSigned .= "&" . "$k" . "=" . "$v";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
unset ($k, $v);
|
||||
return $stringToBeSigned;
|
||||
}
|
||||
|
||||
private function setNotifyUrl($params)
|
||||
{
|
||||
if ($this->config(AlipayConstants::NOTIFY_URL_CONFIG_KEY) != null && $params(AlipayConstants::NOTIFY_URL_CONFIG_KEY) == null) {
|
||||
$params[AlipayConstants::NOTIFY_URL_CONFIG_KEY] = $this->config(AlipayConstants::NOTIFY_URL_CONFIG_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
private function getGatewayServerUrl()
|
||||
{
|
||||
return $this->getConfig(AlipayConstants::PROTOCOL_CONFIG_KEY) . '://' . $this->getConfig(AlipayConstants::HOST_CONFIG_KEY) . '/gateway.do';
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验$value是否非空
|
||||
*
|
||||
* @param $value
|
||||
* @return bool if not set ,return true;if is null , return true;
|
||||
*/
|
||||
function checkEmpty($value)
|
||||
{
|
||||
if (!isset($value))
|
||||
return true;
|
||||
if ($value === null)
|
||||
return true;
|
||||
if (trim($value) === "")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换字符集编码
|
||||
* @param $data
|
||||
* @param $targetCharset
|
||||
* @return string
|
||||
*/
|
||||
function characet($data, $targetCharset)
|
||||
{
|
||||
if (!empty($data)) {
|
||||
$fileType = AlipayConstants::DEFAULT_CHARSET;
|
||||
if (strcasecmp($fileType, $targetCharset) != 0) {
|
||||
$data = mb_convert_encoding($data, $targetCharset, $fileType);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Alipay\EasySDK\Kernel\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class RuntimeException extends Exception
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
|
||||
namespace Alipay\EasySDK\Kernel;
|
||||
|
||||
use Alipay\EasySDK\Base\Image\Client as imageClient;
|
||||
use Alipay\EasySDK\Base\OAuth\Client as oauthClient;
|
||||
use Alipay\EasySDK\Base\Qrcode\Client as qrcodeClient;
|
||||
use Alipay\EasySDK\Base\Video\Client as videoClient;
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Client as openLifeClient;
|
||||
use Alipay\EasySDK\Marketing\Pass\Client as passClient;
|
||||
use Alipay\EasySDK\Marketing\TemplateMessage\Client as templateMessageClient;
|
||||
use Alipay\EasySDK\Member\Identification\Client as identificationClient;
|
||||
use Alipay\EasySDK\Payment\App\Client as appClient;
|
||||
use Alipay\EasySDK\Payment\Common\Client as commonClient;
|
||||
use Alipay\EasySDK\Payment\FaceToFace\Client as faceToFaceClient;
|
||||
use Alipay\EasySDK\Payment\Huabei\Client as huabeiClient;
|
||||
use Alipay\EasySDK\Payment\Page\Client as pageClient;
|
||||
use Alipay\EasySDK\Payment\Wap\Client as wapClient;
|
||||
use Alipay\EasySDK\Security\TextRisk\Client as textRiskClient;
|
||||
use Alipay\EasySDK\Util\Generic\Client as genericClient;
|
||||
use Alipay\EasySDK\Util\AES\Client as aesClient;
|
||||
|
||||
class Factory
|
||||
{
|
||||
public $config = null;
|
||||
public $kernel = null;
|
||||
private static $instance;
|
||||
protected static $base;
|
||||
protected static $marketing;
|
||||
protected static $member;
|
||||
protected static $payment;
|
||||
protected static $security;
|
||||
protected static $util;
|
||||
|
||||
private function __construct($config)
|
||||
{
|
||||
if (!empty($config->alipayCertPath)) {
|
||||
$certEnvironment = new CertEnvironment();
|
||||
$certEnvironment->certEnvironment(
|
||||
$config->merchantCertPath,
|
||||
$config->alipayCertPath,
|
||||
$config->alipayRootCertPath
|
||||
);
|
||||
$config->merchantCertSN = $certEnvironment->getMerchantCertSN();
|
||||
$config->alipayRootCertSN = $certEnvironment->getRootCertSN();
|
||||
$config->alipayPublicKey = $certEnvironment->getCachedAlipayPublicKey();
|
||||
}
|
||||
|
||||
$kernel = new EasySDKKernel($config);
|
||||
self::$base = new Base($kernel);
|
||||
self::$marketing = new Marketing($kernel);
|
||||
self::$member = new Member($kernel);
|
||||
self::$payment = new Payment($kernel);
|
||||
self::$security = new Security($kernel);
|
||||
self::$util = new Util($kernel);
|
||||
}
|
||||
|
||||
public static function setOptions($config)
|
||||
{
|
||||
if (!(self::$instance instanceof self)) {
|
||||
self::$instance = new self($config);
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
private function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
public static function base()
|
||||
{
|
||||
return self::$base;
|
||||
}
|
||||
|
||||
public static function marketing()
|
||||
{
|
||||
return self::$marketing;
|
||||
}
|
||||
|
||||
public static function member()
|
||||
{
|
||||
return self::$member;
|
||||
}
|
||||
|
||||
public static function payment()
|
||||
{
|
||||
return self::$payment;
|
||||
}
|
||||
|
||||
public static function security()
|
||||
{
|
||||
return self::$security;
|
||||
}
|
||||
|
||||
public static function util()
|
||||
{
|
||||
return self::$util;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Base
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function image()
|
||||
{
|
||||
return new imageClient($this->kernel);
|
||||
}
|
||||
|
||||
public function oauth()
|
||||
{
|
||||
return new oauthClient($this->kernel);
|
||||
}
|
||||
|
||||
public function qrcode()
|
||||
{
|
||||
return new qrcodeClient($this->kernel);
|
||||
}
|
||||
|
||||
public function video()
|
||||
{
|
||||
return new videoClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
class Marketing
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function openLife()
|
||||
{
|
||||
return new openLifeClient($this->kernel);
|
||||
}
|
||||
|
||||
public function pass()
|
||||
{
|
||||
return new passClient($this->kernel);
|
||||
}
|
||||
|
||||
public function templateMessage()
|
||||
{
|
||||
return new templateMessageClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
class Member
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function identification()
|
||||
{
|
||||
return new identificationClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
class Payment
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function app()
|
||||
{
|
||||
return new appClient($this->kernel);
|
||||
}
|
||||
|
||||
public function common()
|
||||
{
|
||||
return new commonClient($this->kernel);
|
||||
}
|
||||
|
||||
public function faceToFace()
|
||||
{
|
||||
return new faceToFaceClient($this->kernel);
|
||||
}
|
||||
|
||||
public function huabei()
|
||||
{
|
||||
return new huabeiClient($this->kernel);
|
||||
}
|
||||
|
||||
public function page()
|
||||
{
|
||||
return new pageClient($this->kernel);
|
||||
}
|
||||
|
||||
public function wap()
|
||||
{
|
||||
return new wapClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
class Security
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function textRisk()
|
||||
{
|
||||
return new textRiskClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
class Util
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function generic()
|
||||
{
|
||||
return new genericClient($this->kernel);
|
||||
}
|
||||
|
||||
public function aes(){
|
||||
return new aesClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
|
||||
namespace Alipay\EasySDK\Kernel;
|
||||
|
||||
use Alipay\EasySDK\Base\Image\Client as imageClient;
|
||||
use Alipay\EasySDK\Base\OAuth\Client as oauthClient;
|
||||
use Alipay\EasySDK\Base\Qrcode\Client as qrcodeClient;
|
||||
use Alipay\EasySDK\Base\Video\Client as videoClient;
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Client as openLifeClient;
|
||||
use Alipay\EasySDK\Marketing\Pass\Client as passClient;
|
||||
use Alipay\EasySDK\Marketing\TemplateMessage\Client as templateMessageClient;
|
||||
use Alipay\EasySDK\Member\Identification\Client as identificationClient;
|
||||
use Alipay\EasySDK\Payment\App\Client as appClient;
|
||||
use Alipay\EasySDK\Payment\Common\Client as commonClient;
|
||||
use Alipay\EasySDK\Payment\FaceToFace\Client as faceToFaceClient;
|
||||
use Alipay\EasySDK\Payment\Huabei\Client as huabeiClient;
|
||||
use Alipay\EasySDK\Payment\Page\Client as pageClient;
|
||||
use Alipay\EasySDK\Payment\Wap\Client as wapClient;
|
||||
use Alipay\EasySDK\Security\TextRisk\Client as textRiskClient;
|
||||
use Alipay\EasySDK\Util\Generic\Client as genericClient;
|
||||
use Alipay\EasySDK\Util\AES\Client as aesClient;
|
||||
|
||||
/**
|
||||
* 多账号实例使用
|
||||
* Class MultipleFactory
|
||||
* @package Alipay\EasySDK\Kernel
|
||||
*/
|
||||
class MultipleFactory
|
||||
{
|
||||
public $config = null;
|
||||
public $kernel = null;
|
||||
private static $instance;
|
||||
protected static $base;
|
||||
protected static $marketing;
|
||||
protected static $member;
|
||||
protected static $payment;
|
||||
protected static $security;
|
||||
protected static $util;
|
||||
|
||||
private function __construct($config)
|
||||
{
|
||||
if (!empty($config->alipayCertPath)) {
|
||||
$certEnvironment = new CertEnvironment();
|
||||
$certEnvironment->certEnvironment(
|
||||
$config->merchantCertPath,
|
||||
$config->alipayCertPath,
|
||||
$config->alipayRootCertPath
|
||||
);
|
||||
$config->merchantCertSN = $certEnvironment->getMerchantCertSN();
|
||||
$config->alipayRootCertSN = $certEnvironment->getRootCertSN();
|
||||
$config->alipayPublicKey = $certEnvironment->getCachedAlipayPublicKey();
|
||||
}
|
||||
|
||||
$kernel = new EasySDKKernel($config);
|
||||
self::$base = new Base($kernel);
|
||||
self::$marketing = new Marketing($kernel);
|
||||
self::$member = new Member($kernel);
|
||||
self::$payment = new Payment($kernel);
|
||||
self::$security = new Security($kernel);
|
||||
self::$util = new Util($kernel);
|
||||
}
|
||||
|
||||
public static function setOptions($config)
|
||||
{
|
||||
self::$instance = new self($config);
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
private function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
public static function base()
|
||||
{
|
||||
return self::$base;
|
||||
}
|
||||
|
||||
public static function marketing()
|
||||
{
|
||||
return self::$marketing;
|
||||
}
|
||||
|
||||
public static function member()
|
||||
{
|
||||
return self::$member;
|
||||
}
|
||||
|
||||
public static function payment()
|
||||
{
|
||||
return self::$payment;
|
||||
}
|
||||
|
||||
public static function security()
|
||||
{
|
||||
return self::$security;
|
||||
}
|
||||
|
||||
public static function util()
|
||||
{
|
||||
return self::$util;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Base
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function image()
|
||||
{
|
||||
return new imageClient($this->kernel);
|
||||
}
|
||||
|
||||
public function oauth()
|
||||
{
|
||||
return new oauthClient($this->kernel);
|
||||
}
|
||||
|
||||
public function qrcode()
|
||||
{
|
||||
return new qrcodeClient($this->kernel);
|
||||
}
|
||||
|
||||
public function video()
|
||||
{
|
||||
return new videoClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
class Marketing
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function openLife()
|
||||
{
|
||||
return new openLifeClient($this->kernel);
|
||||
}
|
||||
|
||||
public function pass()
|
||||
{
|
||||
return new passClient($this->kernel);
|
||||
}
|
||||
|
||||
public function templateMessage()
|
||||
{
|
||||
return new templateMessageClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
class Member
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function identification()
|
||||
{
|
||||
return new identificationClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
class Payment
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function app()
|
||||
{
|
||||
return new appClient($this->kernel);
|
||||
}
|
||||
|
||||
public function common()
|
||||
{
|
||||
return new commonClient($this->kernel);
|
||||
}
|
||||
|
||||
public function faceToFace()
|
||||
{
|
||||
return new faceToFaceClient($this->kernel);
|
||||
}
|
||||
|
||||
public function huabei()
|
||||
{
|
||||
return new huabeiClient($this->kernel);
|
||||
}
|
||||
|
||||
public function page()
|
||||
{
|
||||
return new pageClient($this->kernel);
|
||||
}
|
||||
|
||||
public function wap()
|
||||
{
|
||||
return new wapClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
class Security
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function textRisk()
|
||||
{
|
||||
return new textRiskClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
class Util
|
||||
{
|
||||
private $kernel;
|
||||
|
||||
public function __construct($kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function generic()
|
||||
{
|
||||
return new genericClient($this->kernel);
|
||||
}
|
||||
|
||||
public function aes()
|
||||
{
|
||||
return new aesClient($this->kernel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Alipay\EasySDK\Kernel\Util;
|
||||
|
||||
|
||||
class AES
|
||||
{
|
||||
/**
|
||||
* AES加密
|
||||
*
|
||||
* @param $plainText String 明文
|
||||
* @param $key String 对称密钥
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function aesEncrypt($plainText, $key)
|
||||
{
|
||||
try {
|
||||
if(strlen($key) == 0){
|
||||
throw new \Exception("AES加密失败,plainText=".$plainText.",AES密钥为空。");
|
||||
}
|
||||
//AES, 128 模式加密数据 CBC
|
||||
$screct_key = base64_decode($key);
|
||||
$str = trim($plainText);
|
||||
$str = $this->addPKCS7Padding($str);
|
||||
$iv = str_repeat("\0", 16);
|
||||
$encrypt_str = openssl_encrypt($str, 'aes-128-cbc', $screct_key, OPENSSL_NO_PADDING, $iv);
|
||||
return base64_encode($encrypt_str);
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception("AES加密失败,plainText=".$plainText.",keySize=".strlen($key)."。".$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AES解密
|
||||
*
|
||||
* @param $cipherText String 密文
|
||||
* @param $key String 对称密钥
|
||||
* @return false|string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function aesDecrypt($cipherText, $key)
|
||||
{
|
||||
try{
|
||||
if(strlen($key) == 0){
|
||||
throw new \Exception("AES加密失败,plainText=".$cipherText.",AES密钥为空。");
|
||||
}
|
||||
//AES, 128 模式加密数据 CBC
|
||||
$str = base64_decode($cipherText);
|
||||
$screct_key = base64_decode($key);
|
||||
$iv = str_repeat("\0", 16);
|
||||
$decrypt_str = openssl_decrypt($str, 'aes-128-cbc', $screct_key, OPENSSL_NO_PADDING, $iv);
|
||||
$decrypt_str = $this->stripPKSC7Padding($decrypt_str);
|
||||
return $decrypt_str;
|
||||
}catch (\Exception $e){
|
||||
throw new \Exception("AES解密失败,cipherText=".$cipherText.",keySize=".strlen($key)."。".$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充算法
|
||||
* @param string $source
|
||||
* @return string
|
||||
*/
|
||||
private 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
|
||||
*/
|
||||
private function stripPKSC7Padding($source)
|
||||
{
|
||||
$char = substr($source, -1);
|
||||
$num = ord($char);
|
||||
if ($num == 62) return $source;
|
||||
$source = substr($source, 0, -$num);
|
||||
return $source;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Alipay\EasySDK\Kernel\Util;
|
||||
|
||||
|
||||
class AlipayEncrypt
|
||||
{
|
||||
const AES_ALG = "AES";
|
||||
const AES_CBC_PCK_ALG = "AES/CBC/PKCS5Padding";
|
||||
|
||||
}
|
||||
+612
@@ -0,0 +1,612 @@
|
||||
<?php
|
||||
|
||||
namespace Alipay\EasySDK\Kernel\Util;
|
||||
|
||||
class AntCertificationUtil
|
||||
{
|
||||
private $rootCertContent;
|
||||
|
||||
/**
|
||||
* 从证书中提取序列号
|
||||
* @param $certPath
|
||||
* @return string
|
||||
*/
|
||||
public function getCertSN($certPath)
|
||||
{
|
||||
$cert = file_get_contents($certPath);
|
||||
$ssl = openssl_x509_parse($cert);
|
||||
$SN = md5($this->array2string(array_reverse($ssl['issuer'])) . $ssl['serialNumber']);
|
||||
return $SN;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从证书中提取公钥
|
||||
* @param $certPath
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPublicKey($certPath)
|
||||
{
|
||||
$cert = file_get_contents($certPath);
|
||||
$pkey = openssl_pkey_get_public($cert);
|
||||
$keyData = openssl_pkey_get_details($pkey);
|
||||
$public_key = str_replace('-----BEGIN PUBLIC KEY-----', '', $keyData['key']);
|
||||
$public_key = trim(str_replace('-----END PUBLIC KEY-----', '', $public_key));
|
||||
return $public_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取根证书序列号
|
||||
* @param $certPath string 根证书
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRootCertSN($certPath)
|
||||
{
|
||||
$cert = file_get_contents($certPath);
|
||||
$this->rootCertContent = $cert;
|
||||
$array = explode("-----END CERTIFICATE-----", $cert);
|
||||
$SN = null;
|
||||
for ($i = 0; $i < count($array) - 1; $i++) {
|
||||
$ssl[$i] = openssl_x509_parse($array[$i] . "-----END CERTIFICATE-----");
|
||||
if (strpos($ssl[$i]['serialNumber'], '0x') === 0) {
|
||||
$ssl[$i]['serialNumber'] = $this->hex2dec($ssl[$i]['serialNumberHex']);
|
||||
}
|
||||
if ($ssl[$i]['signatureTypeLN'] == "sha1WithRSAEncryption" || $ssl[$i]['signatureTypeLN'] == "sha256WithRSAEncryption") {
|
||||
if ($SN == null) {
|
||||
$SN = md5($this->array2string(array_reverse($ssl[$i]['issuer'])) . $ssl[$i]['serialNumber']);
|
||||
} else {
|
||||
|
||||
$SN = $SN . "_" . md5($this->array2string(array_reverse($ssl[$i]['issuer'])) . $ssl[$i]['serialNumber']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $SN;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 0x转高精度数字
|
||||
* @param $hex
|
||||
* @return int|string
|
||||
*/
|
||||
function hex2dec($hex)
|
||||
{
|
||||
$dec = 0;
|
||||
$len = strlen($hex);
|
||||
for ($i = 1; $i <= $len; $i++) {
|
||||
$dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len - $i))));
|
||||
}
|
||||
return $dec;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证支付宝公钥证书是否可信
|
||||
* @param $alipayCert 支付宝公钥证书
|
||||
* @param $rootCert 支付宝根证书
|
||||
* @return bool 验证证书是否可信
|
||||
*/
|
||||
function isTrusted($alipayCert, $rootCert)
|
||||
{
|
||||
$alipayCerts = $this->readPemCertChain($alipayCert);
|
||||
$rootCerts = $this->readPemCertChain($rootCert);
|
||||
if ($this->verifyCertChain($alipayCerts, $rootCerts)) {
|
||||
return $this->verifySignature($alipayCert, $rootCert);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function verifySignature($alipayCert, $rootCert)
|
||||
{
|
||||
$alipayCertArray = explode("-----END CERTIFICATE-----", $alipayCert);
|
||||
$rootCertArray = explode("-----END CERTIFICATE-----", $rootCert);
|
||||
$length = count($rootCertArray) - 1;
|
||||
$checkSign = $this->isCertSigner($alipayCertArray[0] . "-----END CERTIFICATE-----", $alipayCertArray[1] . "-----END CERTIFICATE-----");
|
||||
if (!$checkSign) {
|
||||
$checkSign = $this->isCertSigner($alipayCertArray[1] . "-----END CERTIFICATE-----", $alipayCertArray[0] . "-----END CERTIFICATE-----");
|
||||
if ($checkSign) {
|
||||
$issuer = openssl_x509_parse($alipayCertArray[0] . "-----END CERTIFICATE-----")['issuer'];
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$subject = openssl_x509_parse($rootCertArray[$i] . "-----END CERTIFICATE-----")['subject'];
|
||||
if ($issuer == $subject) {
|
||||
$this->isCertSigner($alipayCertArray[0] . "-----END CERTIFICATE-----", $rootCertArray[$i] . $rootCertArray);
|
||||
return $checkSign;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $checkSign;
|
||||
}
|
||||
} else {
|
||||
$issuer = openssl_x509_parse($alipayCertArray[1] . "-----END CERTIFICATE-----")['issuer'];
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$subject = openssl_x509_parse($rootCertArray[$i] . "-----END CERTIFICATE-----")['subject'];
|
||||
if ($issuer == $subject) {
|
||||
$checkSign = $this->isCertSigner($alipayCertArray[1] . "-----END CERTIFICATE-----", $rootCertArray[$i] . "-----END CERTIFICATE-----");
|
||||
return $checkSign;
|
||||
}
|
||||
}
|
||||
return $checkSign;
|
||||
}
|
||||
}
|
||||
|
||||
function readPemCertChain($cert)
|
||||
{
|
||||
$array = explode("-----END CERTIFICATE-----", $cert);
|
||||
$certs[] = null;
|
||||
for ($i = 0; $i < count($array) - 1; $i++) {
|
||||
$certs[$i] = openssl_x509_parse($array[$i] . "-----END CERTIFICATE-----");
|
||||
}
|
||||
return $certs;
|
||||
}
|
||||
|
||||
function verifyCert($prev, $rootCerts)
|
||||
{
|
||||
$nowTime = time();
|
||||
if ($nowTime < $prev['validFrom_time_t']) {
|
||||
echo "证书未激活";
|
||||
return false;
|
||||
}
|
||||
if ($nowTime > $prev['validTo_time_t']) {
|
||||
echo "证书已经过期";
|
||||
return false;
|
||||
}
|
||||
$subjectMap = null;
|
||||
for ($i = 0; $i < count($rootCerts); $i++) {
|
||||
$subjectDN = $this->array2string($rootCerts[$i]['subject']);
|
||||
$subjectMap[$subjectDN] = $rootCerts[$i];
|
||||
}
|
||||
$issuerDN = $this->array2string(($prev['issuer']));
|
||||
if (!array_key_exists($issuerDN, $subjectMap)) {
|
||||
echo "证书链验证失败";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证证书链是否是信任证书库中证书签发的
|
||||
* @param $alipayCerts array 目标验证证书列表
|
||||
* @param $rootCerts array 可信根证书列表
|
||||
* @return bool
|
||||
*/
|
||||
function verifyCertChain($alipayCerts, $rootCerts)
|
||||
{
|
||||
$sorted = $this->sortByDn($alipayCerts);
|
||||
if (!$sorted) {
|
||||
echo "证书链验证失败:不是完整的证书链";
|
||||
return false;
|
||||
}
|
||||
//先验证第一个证书是不是信任库中证书签发的
|
||||
$prev = $alipayCerts[0];
|
||||
$firstOK = $this->verifyCert($prev, $rootCerts);
|
||||
$length = count($alipayCerts);
|
||||
if (!$firstOK || $length == 1) {
|
||||
return $firstOK;
|
||||
}
|
||||
|
||||
$nowTime = time();
|
||||
//验证证书链
|
||||
for ($i = 1; $i < $length; $i++) {
|
||||
$cert = $alipayCerts[$i];
|
||||
if ($nowTime < $cert['validFrom_time_t']) {
|
||||
echo "证书未激活";
|
||||
return false;
|
||||
}
|
||||
if ($nowTime > $cert['validTo_time_t']) {
|
||||
echo "证书已经过期";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将证书链按照完整的签发顺序进行排序,排序后证书链为:[issuerA, subjectA]-[issuerA, subjectB]-[issuerB, subjectC]-[issuerC, subjectD]...
|
||||
* @param $certs array 证书链
|
||||
* @return bool
|
||||
*/
|
||||
function sortByDn(&$certs)
|
||||
{
|
||||
//是否包含自签名证书
|
||||
$hasSelfSignedCert = false;
|
||||
$subjectMap = null;
|
||||
$issuerMap = null;
|
||||
for ($i = 0; $i < count($certs); $i++) {
|
||||
if ($this->isSelfSigned($certs[$i])) {
|
||||
if ($hasSelfSignedCert) {
|
||||
return false;
|
||||
}
|
||||
$hasSelfSignedCert = true;
|
||||
}
|
||||
$subjectDN = $this->array2string($certs[$i]['subject']);
|
||||
$issuerDN = $this->array2string(($certs[$i]['issuer']));
|
||||
$subjectMap[$subjectDN] = $certs[$i];
|
||||
$issuerMap[$issuerDN] = $certs[$i];
|
||||
}
|
||||
$certChain = null;
|
||||
$this->addressingUp($subjectMap, $certChain, $certs[0]);
|
||||
$this->addressingDown($issuerMap, $certChain, $certs[0]);
|
||||
|
||||
//说明证书链不完整
|
||||
if (count($certs) != count($certChain)) {
|
||||
return false;
|
||||
}
|
||||
//将证书链复制到原先的数据
|
||||
for ($i = 0; $i < count($certs); $i++) {
|
||||
$certs[$i] = $certChain[count($certs) - $i - 1];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证证书是否是自签发的
|
||||
* @param $cert array 目标证书
|
||||
* @return bool
|
||||
*/
|
||||
function isSelfSigned($cert)
|
||||
{
|
||||
$subjectDN = $this->array2string($cert['subject']);
|
||||
$issuerDN = $this->array2string($cert['issuer']);
|
||||
return ($subjectDN == $issuerDN);
|
||||
}
|
||||
|
||||
|
||||
function array2string($array)
|
||||
{
|
||||
$string = [];
|
||||
if ($array && is_array($array)) {
|
||||
foreach ($array as $key => $value) {
|
||||
$string[] = $key . '=' . $value;
|
||||
}
|
||||
}
|
||||
return implode(',', $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向上构造证书链
|
||||
* @param $subjectMap array 主题和证书的映射
|
||||
* @param $certChain array 证书链
|
||||
* @param $current 当前需要插入证书链的证书,include
|
||||
*/
|
||||
function addressingUp($subjectMap, &$certChain, $current)
|
||||
{
|
||||
$certChain[] = $current;
|
||||
if ($this->isSelfSigned($current)) {
|
||||
return;
|
||||
}
|
||||
$issuerDN = $this->array2string($current['issuer']);
|
||||
|
||||
if (!array_key_exists($issuerDN, $subjectMap)) {
|
||||
return;
|
||||
}
|
||||
$this->addressingUp($subjectMap, $certChain, $subjectMap[$issuerDN]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向下构造证书链
|
||||
* @param $issuerMap 签发者和证书的映射
|
||||
* @param $certChain 证书链
|
||||
* @param $current 当前需要插入证书链的证书,exclude
|
||||
* @return mixed
|
||||
*/
|
||||
function addressingDown($issuerMap, &$certChain, $current)
|
||||
{
|
||||
$subjectDN = $this->array2string($current['subject']);
|
||||
if (!array_key_exists($subjectDN, $issuerMap)) {
|
||||
return $certChain;
|
||||
}
|
||||
$certChain[] = $issuerMap[$subjectDN];
|
||||
$this->addressingDown($issuerMap, $certChain, $issuerMap[$subjectDN]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract signature from der encoded cert.
|
||||
* Expects x509 der encoded certificate consisting of a section container
|
||||
* containing 2 sections and a bitstream. The bitstream contains the
|
||||
* original encrypted signature, encrypted by the public key of the issuing
|
||||
* signer.
|
||||
* @param string $der
|
||||
* @return string on success
|
||||
* @return bool false on failures
|
||||
*/
|
||||
function extractSignature($der = false)
|
||||
{
|
||||
if (strlen($der) < 5) {
|
||||
return false;
|
||||
}
|
||||
// skip container sequence
|
||||
$der = substr($der, 4);
|
||||
// now burn through two sequences and the return the final bitstream
|
||||
while (strlen($der) > 1) {
|
||||
$class = ord($der[0]);
|
||||
$classHex = dechex($class);
|
||||
switch ($class) {
|
||||
// BITSTREAM
|
||||
case 0x03:
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
return substr($der, 3 + $bytes, $len);
|
||||
break;
|
||||
// SEQUENCE
|
||||
case 0x30:
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
$contents = substr($der, 2 + $bytes, $len);
|
||||
$der = substr($der, 2 + $bytes + $len);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get signature algorithm oid from der encoded signature data.
|
||||
* Expects decrypted signature data from a certificate in der format.
|
||||
* This ASN1 data should contain the following structure:
|
||||
* SEQUENCE
|
||||
* SEQUENCE
|
||||
* OID (signature algorithm)
|
||||
* NULL
|
||||
* OCTET STRING (signature hash)
|
||||
* @return bool false on failures
|
||||
* @return string oid
|
||||
*/
|
||||
function getSignatureAlgorithmOid($der = null)
|
||||
{
|
||||
// Validate this is the der we need...
|
||||
if (!is_string($der) or strlen($der) < 5) {
|
||||
return false;
|
||||
}
|
||||
$bit_seq1 = 0;
|
||||
$bit_seq2 = 2;
|
||||
$bit_oid = 4;
|
||||
if (ord($der[$bit_seq1]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureAlgorithmOid()');
|
||||
}
|
||||
if (ord($der[$bit_seq2]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureAlgorithmOid()');
|
||||
}
|
||||
if (ord($der[$bit_oid]) !== 0x06) {
|
||||
die('Invalid DER passed to getSignatureAlgorithmOid');
|
||||
}
|
||||
// strip out what we don't need and get the oid
|
||||
$der = substr($der, $bit_oid);
|
||||
// Get the oid
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
$oid_data = substr($der, 2 + $bytes, $len);
|
||||
// Unpack the OID
|
||||
$oid = floor(ord($oid_data[0]) / 40);
|
||||
$oid .= '.' . ord($oid_data[0]) % 40;
|
||||
$value = 0;
|
||||
$i = 1;
|
||||
while ($i < strlen($oid_data)) {
|
||||
$value = $value << 7;
|
||||
$value = $value | (ord($oid_data[$i]) & 0x7f);
|
||||
if (!(ord($oid_data[$i]) & 0x80)) {
|
||||
$oid .= '.' . $value;
|
||||
$value = 0;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $oid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get signature hash from der encoded signature data.
|
||||
* Expects decrypted signature data from a certificate in der format.
|
||||
* This ASN1 data should contain the following structure:
|
||||
* SEQUENCE
|
||||
* SEQUENCE
|
||||
* OID (signature algorithm)
|
||||
* NULL
|
||||
* OCTET STRING (signature hash)
|
||||
* @return bool false on failures
|
||||
* @return string hash
|
||||
*/
|
||||
function getSignatureHash($der = null)
|
||||
{
|
||||
// Validate this is the der we need...
|
||||
if (!is_string($der) or strlen($der) < 5) {
|
||||
return false;
|
||||
}
|
||||
if (ord($der[0]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureHash()');
|
||||
}
|
||||
// strip out the container sequence
|
||||
$der = substr($der, 2);
|
||||
if (ord($der[0]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureHash()');
|
||||
}
|
||||
// Get the length of the first sequence so we can strip it out.
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
$der = substr($der, 2 + $bytes + $len);
|
||||
// Now we should have an octet string
|
||||
if (ord($der[0]) !== 0x04) {
|
||||
die('Invalid DER passed to getSignatureHash()');
|
||||
}
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
return bin2hex(substr($der, 2 + $bytes, $len));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if one cert was used to sign another
|
||||
* Note that more than one CA cert can give a positive result, some certs
|
||||
* re-issue signing certs after having only changed the expiration dates.
|
||||
* @param string $cert - PEM encoded cert
|
||||
* @param string $caCert - PEM encoded cert that possibly signed $cert
|
||||
* @return bool
|
||||
*/
|
||||
function isCertSigner($certPem = null, $caCertPem = null)
|
||||
{
|
||||
if (!function_exists('openssl_pkey_get_public')) {
|
||||
die('Need the openssl_pkey_get_public() function.');
|
||||
}
|
||||
if (!function_exists('openssl_public_decrypt')) {
|
||||
die('Need the openssl_public_decrypt() function.');
|
||||
}
|
||||
if (!function_exists('hash')) {
|
||||
die('Need the php hash() function.');
|
||||
}
|
||||
if (empty($certPem) or empty($caCertPem)) {
|
||||
return false;
|
||||
}
|
||||
// Convert the cert to der for feeding to extractSignature.
|
||||
$certDer = pemToDer($certPem);
|
||||
if (!is_string($certDer)) {
|
||||
die('invalid certPem');
|
||||
}
|
||||
// Grab the encrypted signature from the der encoded cert.
|
||||
$encryptedSig = extractSignature($certDer);
|
||||
if (!is_string($encryptedSig)) {
|
||||
die('Failed to extract encrypted signature from certPem.');
|
||||
}
|
||||
// Extract the public key from the ca cert, which is what has
|
||||
// been used to encrypt the signature in the cert.
|
||||
$pubKey = openssl_pkey_get_public($caCertPem);
|
||||
if ($pubKey === false) {
|
||||
die('Failed to extract the public key from the ca cert.');
|
||||
}
|
||||
// Attempt to decrypt the encrypted signature using the CA's public
|
||||
// key, returning the decrypted signature in $decryptedSig. If
|
||||
// it can't be decrypted, this ca was not used to sign it for sure...
|
||||
$rc = openssl_public_decrypt($encryptedSig, $decryptedSig, $pubKey);
|
||||
if ($rc === false) {
|
||||
return false;
|
||||
}
|
||||
// We now have the decrypted signature, which is der encoded
|
||||
// asn1 data containing the signature algorithm and signature hash.
|
||||
// Now we need what was originally hashed by the issuer, which is
|
||||
// the original DER encoded certificate without the issuer and
|
||||
// signature information.
|
||||
$origCert = stripSignerAsn($certDer);
|
||||
if ($origCert === false) {
|
||||
die('Failed to extract unsigned cert.');
|
||||
}
|
||||
// Get the oid of the signature hash algorithm, which is required
|
||||
// to generate our own hash of the original cert. This hash is
|
||||
// what will be compared to the issuers hash.
|
||||
$oid = getSignatureAlgorithmOid($decryptedSig);
|
||||
if ($oid === false) {
|
||||
die('Failed to determine the signature algorithm.');
|
||||
}
|
||||
switch ($oid) {
|
||||
case '1.2.840.113549.2.2':
|
||||
$algo = 'md2';
|
||||
break;
|
||||
case '1.2.840.113549.2.4':
|
||||
$algo = 'md4';
|
||||
break;
|
||||
case '1.2.840.113549.2.5':
|
||||
$algo = 'md5';
|
||||
break;
|
||||
case '1.3.14.3.2.18':
|
||||
$algo = 'sha';
|
||||
break;
|
||||
case '1.3.14.3.2.26':
|
||||
$algo = 'sha1';
|
||||
break;
|
||||
case '2.16.840.1.101.3.4.2.1':
|
||||
$algo = 'sha256';
|
||||
break;
|
||||
case '2.16.840.1.101.3.4.2.2':
|
||||
$algo = 'sha384';
|
||||
break;
|
||||
case '2.16.840.1.101.3.4.2.3':
|
||||
$algo = 'sha512';
|
||||
break;
|
||||
default:
|
||||
die('Unknown signature hash algorithm oid: ' . $oid);
|
||||
break;
|
||||
}
|
||||
// Get the issuer generated hash from the decrypted signature.
|
||||
$decryptedHash = getSignatureHash($decryptedSig);
|
||||
// Ok, hash the original unsigned cert with the same algorithm
|
||||
// and if it matches $decryptedHash we have a winner.
|
||||
$certHash = hash($algo, $origCert);
|
||||
return ($decryptedHash === $certHash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pem encoded certificate to DER encoding
|
||||
* @return string $derEncoded on success
|
||||
* @return bool false on failures
|
||||
*/
|
||||
function pemToDer($pem = null)
|
||||
{
|
||||
if (!is_string($pem)) {
|
||||
return false;
|
||||
}
|
||||
$cert_split = preg_split('/(-----((BEGIN)|(END)) CERTIFICATE-----)/', $pem);
|
||||
if (!isset($cert_split[1])) {
|
||||
return false;
|
||||
}
|
||||
return base64_decode($cert_split[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain der cert with issuer and signature sections stripped.
|
||||
* @param string $der - der encoded certificate
|
||||
* @return string $der on success
|
||||
* @return bool false on failures.
|
||||
*/
|
||||
function stripSignerAsn($der = null)
|
||||
{
|
||||
if (!is_string($der) or strlen($der) < 8) {
|
||||
return false;
|
||||
}
|
||||
$bit = 4;
|
||||
$len = ord($der[($bit + 1)]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$bit + $i + 2]);
|
||||
}
|
||||
}
|
||||
return substr($der, 4, $len + 4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Alipay\EasySDK\Kernel\Util;
|
||||
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class JsonUtil
|
||||
{
|
||||
public function toJsonString(array $input)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($input as $k => $v) {
|
||||
if ($v instanceof Model) {
|
||||
$result[$k] = $this->getTeaModelMap($v);
|
||||
} else {
|
||||
$result[$k] = $v;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getTeaModelMap(Model $teaModel)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($teaModel as $k => $v) {
|
||||
if ($v instanceof Model) {
|
||||
$k = $this->toUnderScore($k);
|
||||
$result[$k] = $this->getTeaModelMap($v);
|
||||
} else {
|
||||
if (empty($result)) {
|
||||
$k = $this->toUnderScore($k);
|
||||
$result[$k] = $v;
|
||||
} else {
|
||||
$k = $this->toUnderScore($k);
|
||||
$result[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 驼峰命名转下划线命名
|
||||
* @param $str
|
||||
* @return string
|
||||
*/
|
||||
private function toUnderScore($str)
|
||||
{
|
||||
$dstr = preg_replace_callback('/([A-Z]+)/', function ($matchs) {
|
||||
return '_' . strtolower($matchs[0]);
|
||||
}, $str);
|
||||
return trim(preg_replace('/_{2,}/', '_', $dstr), '_');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Alipay\EasySDK\Kernel\Util;
|
||||
|
||||
|
||||
use Alipay\EasySDK\Kernel\AlipayConstants;
|
||||
|
||||
class PageUtil
|
||||
{
|
||||
public function buildForm($actionUrl,$parameters){
|
||||
$sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='" . $actionUrl . "?charset=" . trim(AlipayConstants::DEFAULT_CHARSET) . "' method='POST'>";
|
||||
while (list ($key, $val) = $this->fun_adm_each($parameters)) {
|
||||
if (false === $this->checkEmpty($val)) {
|
||||
$val = str_replace("'", "'", $val);
|
||||
//$val = str_replace("\"",""",$val);
|
||||
$sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>";
|
||||
}
|
||||
}
|
||||
|
||||
//submit按钮控件请不要含有name属性
|
||||
$sHtml = $sHtml . "<input type='submit' value='ok' style='display:none;'></form>";
|
||||
|
||||
$sHtml = $sHtml . "<script>document.forms['alipaysubmit'].submit();</script>";
|
||||
|
||||
return $sHtml;
|
||||
}
|
||||
|
||||
protected function fun_adm_each(&$array)
|
||||
{
|
||||
$res = array();
|
||||
$key = key($array);
|
||||
if ($key !== null) {
|
||||
next($array);
|
||||
$res[1] = $res['value'] = $array[$key];
|
||||
$res[0] = $res['key'] = $key;
|
||||
} else {
|
||||
$res = false;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验$value是否非空
|
||||
* if not set ,return true;
|
||||
* if is null , return true;
|
||||
**/
|
||||
protected function checkEmpty($value)
|
||||
{
|
||||
if (!isset($value))
|
||||
return true;
|
||||
if ($value === null)
|
||||
return true;
|
||||
if (trim($value) === "")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Alipay\EasySDK\Kernel\Util;
|
||||
|
||||
|
||||
class ResponseChecker
|
||||
{
|
||||
public function success($response)
|
||||
{
|
||||
if (!empty($response->code) && $response->code == 10000) {
|
||||
return true;
|
||||
}
|
||||
if (empty($response->code) && empty($response->subCode)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Alipay\EasySDK\Kernel\Util;
|
||||
|
||||
use Alipay\EasySDK\Kernel\AlipayConstants;
|
||||
|
||||
class SignContentExtractor
|
||||
{
|
||||
private $RESPONSE_SUFFIX = "_response";
|
||||
private $ERROR_RESPONSE = "error_response";
|
||||
|
||||
/**
|
||||
* @param $body string 网关的整体响应字符串
|
||||
* @param $method string 本次调用的OpenAPI接口名称
|
||||
* @return false|string|null 待验签的原文
|
||||
*/
|
||||
public function getSignSourceData($body, $method)
|
||||
{
|
||||
$rootNodeName = str_replace(".", "_", $method) . $this->RESPONSE_SUFFIX;
|
||||
$rootIndex = strpos($body, $rootNodeName);
|
||||
if ($rootIndex !== strrpos($body, $rootNodeName)) {
|
||||
throw new \Exception('检测到响应报文中有重复的' . $rootNodeName . ',验签失败。');
|
||||
}
|
||||
$errorIndex = strpos($body, $this->ERROR_RESPONSE);
|
||||
if ($rootIndex > 0) {
|
||||
return $this->parserJSONSource($body, $rootNodeName, $rootIndex);
|
||||
} else if ($errorIndex > 0) {
|
||||
return $this->parserJSONSource($body, $this->ERROR_RESPONSE, $errorIndex);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $responseContent
|
||||
* @param $nodeName
|
||||
* @param $nodeIndex
|
||||
* @return false|string|null
|
||||
*/
|
||||
function parserJSONSource($responseContent, $nodeName, $nodeIndex)
|
||||
{
|
||||
$signDataStartIndex = $nodeIndex + strlen($nodeName) + 2;
|
||||
if (strrpos($responseContent, AlipayConstants::ALIPAY_CERT_SN_FIELD)) {
|
||||
$signIndex = strrpos($responseContent, "\"" . AlipayConstants::ALIPAY_CERT_SN_FIELD . "\"");
|
||||
} else {
|
||||
$signIndex = strrpos($responseContent, "\"" . AlipayConstants::SIGN_FIELD . "\"");
|
||||
}
|
||||
// 签名前-逗号
|
||||
$signDataEndIndex = $signIndex - 1;
|
||||
$indexLen = $signDataEndIndex - $signDataStartIndex;
|
||||
if ($indexLen < 0) {
|
||||
return null;
|
||||
}
|
||||
return substr($responseContent, $signDataStartIndex, $indexLen);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Alipay\EasySDK\Kernel\Util;
|
||||
|
||||
class Signer
|
||||
{
|
||||
/**
|
||||
* @param $content string 待签名的内容
|
||||
* @param $privateKeyPem string 私钥
|
||||
* @return string 签名值的Base64串
|
||||
*/
|
||||
public function sign($content, $privateKeyPem)
|
||||
{
|
||||
$priKey = $privateKeyPem;
|
||||
$res = "-----BEGIN RSA PRIVATE KEY-----\n" .
|
||||
wordwrap($priKey, 64, "\n", true) .
|
||||
"\n-----END RSA PRIVATE KEY-----";
|
||||
($res) or die('您使用的私钥格式错误,请检查RSA私钥配置');
|
||||
|
||||
openssl_sign($content, $sign, $res, OPENSSL_ALGO_SHA256);
|
||||
$sign = base64_encode($sign);
|
||||
return $sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $content string 待验签的内容
|
||||
* @param $sign string 签名值的Base64串
|
||||
* @param $publicKeyPem string 支付宝公钥
|
||||
* @return bool true:验证成功;false:验证失败
|
||||
*/
|
||||
public function verify($content, $sign, $publicKeyPem)
|
||||
{
|
||||
$pubKey = $publicKeyPem;
|
||||
$res = "-----BEGIN PUBLIC KEY-----\n" .
|
||||
wordwrap($pubKey, 64, "\n", true) .
|
||||
"\n-----END PUBLIC KEY-----";
|
||||
($res) or die('支付宝RSA公钥错误。请检查公钥文件格式是否正确');
|
||||
|
||||
//调用openssl内置方法验签,返回bool值
|
||||
$result = FALSE;
|
||||
$result = (openssl_verify($content, base64_decode($sign), $res, OPENSSL_ALGO_SHA256) === 1);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function verifyParams($parameters, $publicKey)
|
||||
{
|
||||
$sign = $parameters['sign'];
|
||||
$content = $this->getSignContent($parameters);
|
||||
return $this->verify($content, $sign, $publicKey);
|
||||
}
|
||||
|
||||
public function getSignContent($params)
|
||||
{
|
||||
ksort($params);
|
||||
unset($params['sign']);
|
||||
unset($params['sign_type']);
|
||||
$stringToBeSigned = "";
|
||||
$i = 0;
|
||||
foreach ($params as $k => $v) {
|
||||
if ("@" != substr($v, 0, 1)) {
|
||||
if ($i == 0) {
|
||||
$stringToBeSigned .= "$k" . "=" . "$v";
|
||||
} else {
|
||||
$stringToBeSigned .= "&" . "$k" . "=" . "$v";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
unset ($k, $v);
|
||||
return $stringToBeSigned;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,866 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\AlipayOpenPublicMessageContentCreateResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\AlipayOpenPublicMessageContentModifyResponse;
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\AlipayOpenPublicMessageTotalSendResponse;
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\Text;
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\Article;
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\Template;
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\AlipayOpenPublicMessageSingleSendResponse;
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\AlipayOpenPublicLifeMsgRecallResponse;
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\AlipayOpenPublicTemplateMessageIndustryModifyResponse;
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\AlipayOpenPublicSettingCategoryQueryResponse;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
* @param string $cover
|
||||
* @param string $content
|
||||
* @param string $contentComment
|
||||
* @param string $ctype
|
||||
* @param string $benefit
|
||||
* @param string $extTags
|
||||
* @param string $loginIds
|
||||
* @return AlipayOpenPublicMessageContentCreateResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function createImageTextContent($title, $cover, $content, $contentComment, $ctype, $benefit, $extTags, $loginIds){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.open.public.message.content.create",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"title" => $title,
|
||||
"cover" => $cover,
|
||||
"content" => $content,
|
||||
"could_comment" => $contentComment,
|
||||
"ctype" => $ctype,
|
||||
"benefit" => $benefit,
|
||||
"ext_tags" => $extTags,
|
||||
"login_ids" => $loginIds
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.open.public.message.content.create");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenPublicMessageContentCreateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenPublicMessageContentCreateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $contentId
|
||||
* @param string $title
|
||||
* @param string $cover
|
||||
* @param string $content
|
||||
* @param string $couldComment
|
||||
* @param string $ctype
|
||||
* @param string $benefit
|
||||
* @param string $extTags
|
||||
* @param string $loginIds
|
||||
* @return AlipayOpenPublicMessageContentModifyResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function modifyImageTextContent($contentId, $title, $cover, $content, $couldComment, $ctype, $benefit, $extTags, $loginIds){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.open.public.message.content.modify",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"content_id" => $contentId,
|
||||
"title" => $title,
|
||||
"cover" => $cover,
|
||||
"content" => $content,
|
||||
"could_comment" => $couldComment,
|
||||
"ctype" => $ctype,
|
||||
"benefit" => $benefit,
|
||||
"ext_tags" => $extTags,
|
||||
"login_ids" => $loginIds
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.open.public.message.content.modify");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenPublicMessageContentModifyResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenPublicMessageContentModifyResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text
|
||||
* @return AlipayOpenPublicMessageTotalSendResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function sendText($text){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.open.public.message.total.send",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$textObj = new Text([
|
||||
"title" => "",
|
||||
"content" => $text
|
||||
]);
|
||||
$bizParams = [
|
||||
"msg_type" => "text",
|
||||
"text" => $textObj
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.open.public.message.total.send");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenPublicMessageTotalSendResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenPublicMessageTotalSendResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Article[] $articles
|
||||
* @return AlipayOpenPublicMessageTotalSendResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function sendImageText($articles){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.open.public.message.total.send",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"msg_type" => "image-text",
|
||||
"articles" => $articles
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.open.public.message.total.send");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenPublicMessageTotalSendResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenPublicMessageTotalSendResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $toUserId
|
||||
* @param Template $template
|
||||
* @return AlipayOpenPublicMessageSingleSendResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function sendSingleMessage($toUserId, $template){
|
||||
$template->validate();
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.open.public.message.single.send",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"to_user_id" => $toUserId,
|
||||
"template" => $template
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.open.public.message.single.send");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenPublicMessageSingleSendResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenPublicMessageSingleSendResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $messageId
|
||||
* @return AlipayOpenPublicLifeMsgRecallResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function recallMessage($messageId){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.open.public.life.msg.recall",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"message_id" => $messageId
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.open.public.life.msg.recall");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenPublicLifeMsgRecallResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenPublicLifeMsgRecallResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $primaryIndustryCode
|
||||
* @param string $primaryIndustryName
|
||||
* @param string $secondaryIndustryCode
|
||||
* @param string $secondaryIndustryName
|
||||
* @return AlipayOpenPublicTemplateMessageIndustryModifyResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function setIndustry($primaryIndustryCode, $primaryIndustryName, $secondaryIndustryCode, $secondaryIndustryName){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.open.public.template.message.industry.modify",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"primary_industry_code" => $primaryIndustryCode,
|
||||
"primary_industry_name" => $primaryIndustryName,
|
||||
"secondary_industry_code" => $secondaryIndustryCode,
|
||||
"secondary_industry_name" => $secondaryIndustryName
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.open.public.template.message.industry.modify");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenPublicTemplateMessageIndustryModifyResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenPublicTemplateMessageIndustryModifyResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AlipayOpenPublicSettingCategoryQueryResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function getIndustry(){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.open.public.setting.category.query",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.open.public.setting.category.query");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenPublicSettingCategoryQueryResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenPublicSettingCategoryQueryResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOpenPublicLifeMsgRecallResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOpenPublicLifeMsgRecallResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOpenPublicMessageContentCreateResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'contentId' => 'content_id',
|
||||
'contentUrl' => 'content_url',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('contentId', $this->contentId, true);
|
||||
Model::validateRequired('contentUrl', $this->contentUrl, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->contentId) {
|
||||
$res['content_id'] = $this->contentId;
|
||||
}
|
||||
if (null !== $this->contentUrl) {
|
||||
$res['content_url'] = $this->contentUrl;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOpenPublicMessageContentCreateResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['content_id'])){
|
||||
$model->contentId = $map['content_id'];
|
||||
}
|
||||
if(isset($map['content_url'])){
|
||||
$model->contentUrl = $map['content_url'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $contentId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $contentUrl;
|
||||
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOpenPublicMessageContentModifyResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'contentId' => 'content_id',
|
||||
'contentUrl' => 'content_url',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('contentId', $this->contentId, true);
|
||||
Model::validateRequired('contentUrl', $this->contentUrl, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->contentId) {
|
||||
$res['content_id'] = $this->contentId;
|
||||
}
|
||||
if (null !== $this->contentUrl) {
|
||||
$res['content_url'] = $this->contentUrl;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOpenPublicMessageContentModifyResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['content_id'])){
|
||||
$model->contentId = $map['content_id'];
|
||||
}
|
||||
if(isset($map['content_url'])){
|
||||
$model->contentUrl = $map['content_url'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $contentId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $contentUrl;
|
||||
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOpenPublicMessageSingleSendResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOpenPublicMessageSingleSendResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOpenPublicMessageTotalSendResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'messageId' => 'message_id',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('messageId', $this->messageId, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->messageId) {
|
||||
$res['message_id'] = $this->messageId;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOpenPublicMessageTotalSendResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['message_id'])){
|
||||
$model->messageId = $map['message_id'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $messageId;
|
||||
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOpenPublicSettingCategoryQueryResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'primaryCategory' => 'primary_category',
|
||||
'secondaryCategory' => 'secondary_category',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('primaryCategory', $this->primaryCategory, true);
|
||||
Model::validateRequired('secondaryCategory', $this->secondaryCategory, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->primaryCategory) {
|
||||
$res['primary_category'] = $this->primaryCategory;
|
||||
}
|
||||
if (null !== $this->secondaryCategory) {
|
||||
$res['secondary_category'] = $this->secondaryCategory;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOpenPublicSettingCategoryQueryResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['primary_category'])){
|
||||
$model->primaryCategory = $map['primary_category'];
|
||||
}
|
||||
if(isset($map['secondary_category'])){
|
||||
$model->secondaryCategory = $map['secondary_category'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $primaryCategory;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $secondaryCategory;
|
||||
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOpenPublicTemplateMessageIndustryModifyResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOpenPublicTemplateMessageIndustryModifyResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class Article extends Model {
|
||||
protected $_name = [
|
||||
'title' => 'title',
|
||||
'desc' => 'desc',
|
||||
'imageUrl' => 'image_url',
|
||||
'url' => 'url',
|
||||
'actionName' => 'action_name',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('desc', $this->desc, true);
|
||||
Model::validateRequired('url', $this->url, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->title) {
|
||||
$res['title'] = $this->title;
|
||||
}
|
||||
if (null !== $this->desc) {
|
||||
$res['desc'] = $this->desc;
|
||||
}
|
||||
if (null !== $this->imageUrl) {
|
||||
$res['image_url'] = $this->imageUrl;
|
||||
}
|
||||
if (null !== $this->url) {
|
||||
$res['url'] = $this->url;
|
||||
}
|
||||
if (null !== $this->actionName) {
|
||||
$res['action_name'] = $this->actionName;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return Article
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['title'])){
|
||||
$model->title = $map['title'];
|
||||
}
|
||||
if(isset($map['desc'])){
|
||||
$model->desc = $map['desc'];
|
||||
}
|
||||
if(isset($map['image_url'])){
|
||||
$model->imageUrl = $map['image_url'];
|
||||
}
|
||||
if(isset($map['url'])){
|
||||
$model->url = $map['url'];
|
||||
}
|
||||
if(isset($map['action_name'])){
|
||||
$model->actionName = $map['action_name'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $desc;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $imageUrl;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $actionName;
|
||||
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\Keyword;
|
||||
|
||||
class Context extends Model {
|
||||
protected $_name = [
|
||||
'headColor' => 'head_color',
|
||||
'url' => 'url',
|
||||
'actionName' => 'action_name',
|
||||
'keyword1' => 'keyword1',
|
||||
'keyword2' => 'keyword2',
|
||||
'first' => 'first',
|
||||
'remark' => 'remark',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('headColor', $this->headColor, true);
|
||||
Model::validateRequired('url', $this->url, true);
|
||||
Model::validateRequired('actionName', $this->actionName, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->headColor) {
|
||||
$res['head_color'] = $this->headColor;
|
||||
}
|
||||
if (null !== $this->url) {
|
||||
$res['url'] = $this->url;
|
||||
}
|
||||
if (null !== $this->actionName) {
|
||||
$res['action_name'] = $this->actionName;
|
||||
}
|
||||
if (null !== $this->keyword1) {
|
||||
$res['keyword1'] = null !== $this->keyword1 ? $this->keyword1->toMap() : null;
|
||||
}
|
||||
if (null !== $this->keyword2) {
|
||||
$res['keyword2'] = null !== $this->keyword2 ? $this->keyword2->toMap() : null;
|
||||
}
|
||||
if (null !== $this->first) {
|
||||
$res['first'] = null !== $this->first ? $this->first->toMap() : null;
|
||||
}
|
||||
if (null !== $this->remark) {
|
||||
$res['remark'] = null !== $this->remark ? $this->remark->toMap() : null;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return Context
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['head_color'])){
|
||||
$model->headColor = $map['head_color'];
|
||||
}
|
||||
if(isset($map['url'])){
|
||||
$model->url = $map['url'];
|
||||
}
|
||||
if(isset($map['action_name'])){
|
||||
$model->actionName = $map['action_name'];
|
||||
}
|
||||
if(isset($map['keyword1'])){
|
||||
$model->keyword1 = Keyword::fromMap($map['keyword1']);
|
||||
}
|
||||
if(isset($map['keyword2'])){
|
||||
$model->keyword2 = Keyword::fromMap($map['keyword2']);
|
||||
}
|
||||
if(isset($map['first'])){
|
||||
$model->first = Keyword::fromMap($map['first']);
|
||||
}
|
||||
if(isset($map['remark'])){
|
||||
$model->remark = Keyword::fromMap($map['remark']);
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $headColor;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $actionName;
|
||||
|
||||
/**
|
||||
* @var Keyword
|
||||
*/
|
||||
public $keyword1;
|
||||
|
||||
/**
|
||||
* @var Keyword
|
||||
*/
|
||||
public $keyword2;
|
||||
|
||||
/**
|
||||
* @var Keyword
|
||||
*/
|
||||
public $first;
|
||||
|
||||
/**
|
||||
* @var Keyword
|
||||
*/
|
||||
public $remark;
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class Keyword extends Model {
|
||||
protected $_name = [
|
||||
'color' => 'color',
|
||||
'value' => 'value',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('color', $this->color, true);
|
||||
Model::validateRequired('value', $this->value, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->color) {
|
||||
$res['color'] = $this->color;
|
||||
}
|
||||
if (null !== $this->value) {
|
||||
$res['value'] = $this->value;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return Keyword
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['color'])){
|
||||
$model->color = $map['color'];
|
||||
}
|
||||
if(isset($map['value'])){
|
||||
$model->value = $map['value'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $color;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
use Alipay\EasySDK\Marketing\OpenLife\Models\Context;
|
||||
|
||||
class Template extends Model {
|
||||
protected $_name = [
|
||||
'templateId' => 'template_id',
|
||||
'context' => 'context',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('templateId', $this->templateId, true);
|
||||
Model::validateRequired('context', $this->context, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->templateId) {
|
||||
$res['template_id'] = $this->templateId;
|
||||
}
|
||||
if (null !== $this->context) {
|
||||
$res['context'] = null !== $this->context ? $this->context->toMap() : null;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return Template
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['template_id'])){
|
||||
$model->templateId = $map['template_id'];
|
||||
}
|
||||
if(isset($map['context'])){
|
||||
$model->context = Context::fromMap($map['context']);
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $templateId;
|
||||
|
||||
/**
|
||||
* @var Context
|
||||
*/
|
||||
public $context;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\OpenLife\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class Text extends Model {
|
||||
protected $_name = [
|
||||
'title' => 'title',
|
||||
'content' => 'content',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('title', $this->title, true);
|
||||
Model::validateRequired('content', $this->content, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->title) {
|
||||
$res['title'] = $this->title;
|
||||
}
|
||||
if (null !== $this->content) {
|
||||
$res['content'] = $this->content;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return Text
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['title'])){
|
||||
$model->title = $map['title'];
|
||||
}
|
||||
if(isset($map['content'])){
|
||||
$model->content = $map['content'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $content;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,482 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\Pass;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Marketing\Pass\Models\AlipayPassTemplateAddResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
use Alipay\EasySDK\Marketing\Pass\Models\AlipayPassTemplateUpdateResponse;
|
||||
use Alipay\EasySDK\Marketing\Pass\Models\AlipayPassInstanceAddResponse;
|
||||
use Alipay\EasySDK\Marketing\Pass\Models\AlipayPassInstanceUpdateResponse;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $uniqueId
|
||||
* @param string $tplContent
|
||||
* @return AlipayPassTemplateAddResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function createTemplate($uniqueId, $tplContent){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.pass.template.add",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"unique_id" => $uniqueId,
|
||||
"tpl_content" => $tplContent
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.pass.template.add");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayPassTemplateAddResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayPassTemplateAddResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tplId
|
||||
* @param string $tplContent
|
||||
* @return AlipayPassTemplateUpdateResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function updateTemplate($tplId, $tplContent){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.pass.template.update",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"tpl_id" => $tplId,
|
||||
"tpl_content" => $tplContent
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.pass.template.update");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayPassTemplateUpdateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayPassTemplateUpdateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tplId
|
||||
* @param string $tplParams
|
||||
* @param string $recognitionType
|
||||
* @param string $recognitionInfo
|
||||
* @return AlipayPassInstanceAddResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function addInstance($tplId, $tplParams, $recognitionType, $recognitionInfo){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.pass.instance.add",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"tpl_id" => $tplId,
|
||||
"tpl_params" => $tplParams,
|
||||
"recognition_type" => $recognitionType,
|
||||
"recognition_info" => $recognitionInfo
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.pass.instance.add");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayPassInstanceAddResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayPassInstanceAddResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $serialNumber
|
||||
* @param string $channelId
|
||||
* @param string $tplParams
|
||||
* @param string $status
|
||||
* @param string $verifyCode
|
||||
* @param string $verifyType
|
||||
* @return AlipayPassInstanceUpdateResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function updateInstance($serialNumber, $channelId, $tplParams, $status, $verifyCode, $verifyType){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.pass.instance.update",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"serial_number" => $serialNumber,
|
||||
"channel_id" => $channelId,
|
||||
"tpl_params" => $tplParams,
|
||||
"status" => $status,
|
||||
"verify_code" => $verifyCode,
|
||||
"verify_type" => $verifyType
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.pass.instance.update");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayPassInstanceUpdateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayPassInstanceUpdateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\Pass\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayPassInstanceAddResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'success' => 'success',
|
||||
'result' => 'result',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('success', $this->success, true);
|
||||
Model::validateRequired('result', $this->result, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->success) {
|
||||
$res['success'] = $this->success;
|
||||
}
|
||||
if (null !== $this->result) {
|
||||
$res['result'] = $this->result;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayPassInstanceAddResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['success'])){
|
||||
$model->success = $map['success'];
|
||||
}
|
||||
if(isset($map['result'])){
|
||||
$model->result = $map['result'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $success;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $result;
|
||||
|
||||
}
|
||||
Vendored
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\Pass\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayPassInstanceUpdateResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'success' => 'success',
|
||||
'result' => 'result',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('success', $this->success, true);
|
||||
Model::validateRequired('result', $this->result, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->success) {
|
||||
$res['success'] = $this->success;
|
||||
}
|
||||
if (null !== $this->result) {
|
||||
$res['result'] = $this->result;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayPassInstanceUpdateResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['success'])){
|
||||
$model->success = $map['success'];
|
||||
}
|
||||
if(isset($map['result'])){
|
||||
$model->result = $map['result'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $success;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $result;
|
||||
|
||||
}
|
||||
Vendored
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\Pass\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayPassTemplateAddResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'success' => 'success',
|
||||
'result' => 'result',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('success', $this->success, true);
|
||||
Model::validateRequired('result', $this->result, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->success) {
|
||||
$res['success'] = $this->success;
|
||||
}
|
||||
if (null !== $this->result) {
|
||||
$res['result'] = $this->result;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayPassTemplateAddResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['success'])){
|
||||
$model->success = $map['success'];
|
||||
}
|
||||
if(isset($map['result'])){
|
||||
$model->result = $map['result'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $success;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $result;
|
||||
|
||||
}
|
||||
Vendored
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\Pass\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayPassTemplateUpdateResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'success' => 'success',
|
||||
'result' => 'result',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('success', $this->success, true);
|
||||
Model::validateRequired('result', $this->result, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->success) {
|
||||
$res['success'] = $this->success;
|
||||
}
|
||||
if (null !== $this->result) {
|
||||
$res['result'] = $this->result;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayPassTemplateUpdateResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['success'])){
|
||||
$model->success = $map['success'];
|
||||
}
|
||||
if(isset($map['result'])){
|
||||
$model->result = $map['result'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $success;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $result;
|
||||
|
||||
}
|
||||
+200
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\TemplateMessage;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Marketing\TemplateMessage\Models\AlipayOpenAppMiniTemplatemessageSendResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $toUserId
|
||||
* @param string $formId
|
||||
* @param string $userTemplateId
|
||||
* @param string $page
|
||||
* @param string $data
|
||||
* @return AlipayOpenAppMiniTemplatemessageSendResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function send($toUserId, $formId, $userTemplateId, $page, $data){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.open.app.mini.templatemessage.send",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"to_user_id" => $toUserId,
|
||||
"form_id" => $formId,
|
||||
"user_template_id" => $userTemplateId,
|
||||
"page" => $page,
|
||||
"data" => $data
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.open.app.mini.templatemessage.send");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenAppMiniTemplatemessageSendResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenAppMiniTemplatemessageSendResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Marketing\TemplateMessage\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOpenAppMiniTemplatemessageSendResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOpenAppMiniTemplatemessageSendResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Member\Identification;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Member\Identification\Models\IdentityParam;
|
||||
use Alipay\EasySDK\Member\Identification\Models\MerchantConfig;
|
||||
use Alipay\EasySDK\Member\Identification\Models\AlipayUserCertifyOpenInitializeResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
use Alipay\EasySDK\Member\Identification\Models\AlipayUserCertifyOpenQueryResponse;
|
||||
use Alipay\EasySDK\Member\Identification\Models\AlipayUserCertifyOpenCertifyResponse;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $outerOrderNo
|
||||
* @param string $bizCode
|
||||
* @param IdentityParam $identityParam
|
||||
* @param MerchantConfig $merchantConfig
|
||||
* @return AlipayUserCertifyOpenInitializeResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function init($outerOrderNo, $bizCode, $identityParam, $merchantConfig){
|
||||
$identityParam->validate();
|
||||
$merchantConfig->validate();
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.user.certify.open.initialize",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"outer_order_no" => $outerOrderNo,
|
||||
"biz_code" => $bizCode,
|
||||
"identity_param" => $identityParam,
|
||||
"merchant_config" => $merchantConfig
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.user.certify.open.initialize");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayUserCertifyOpenInitializeResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayUserCertifyOpenInitializeResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $certifyId
|
||||
* @return AlipayUserCertifyOpenQueryResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function query($certifyId){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.user.certify.open.query",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"certify_id" => $certifyId
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.user.certify.open.query");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayUserCertifyOpenQueryResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayUserCertifyOpenQueryResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $certifyId
|
||||
* @return AlipayUserCertifyOpenCertifyResponse
|
||||
*/
|
||||
public function certify($certifyId){
|
||||
$systemParams = [
|
||||
"method" => "alipay.user.certify.open.certify",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"certify_id" => $certifyId
|
||||
];
|
||||
$textParams = [];
|
||||
$sign = $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"));
|
||||
$response = [
|
||||
"body" => $this->_kernel->generatePage("GET", $systemParams, $bizParams, $textParams, $sign)
|
||||
];
|
||||
return AlipayUserCertifyOpenCertifyResponse::fromMap($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Member\Identification\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayUserCertifyOpenCertifyResponse extends Model {
|
||||
protected $_name = [
|
||||
'body' => 'body',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('body', $this->body, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->body) {
|
||||
$res['body'] = $this->body;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayUserCertifyOpenCertifyResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['body'])){
|
||||
$model->body = $map['body'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 认证服务请求地址
|
||||
* @var string
|
||||
*/
|
||||
public $body;
|
||||
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Member\Identification\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayUserCertifyOpenInitializeResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'certifyId' => 'certify_id',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('certifyId', $this->certifyId, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->certifyId) {
|
||||
$res['certify_id'] = $this->certifyId;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayUserCertifyOpenInitializeResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['certify_id'])){
|
||||
$model->certifyId = $map['certify_id'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $certifyId;
|
||||
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Member\Identification\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayUserCertifyOpenQueryResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'passed' => 'passed',
|
||||
'identityInfo' => 'identity_info',
|
||||
'materialInfo' => 'material_info',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('passed', $this->passed, true);
|
||||
Model::validateRequired('identityInfo', $this->identityInfo, true);
|
||||
Model::validateRequired('materialInfo', $this->materialInfo, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->passed) {
|
||||
$res['passed'] = $this->passed;
|
||||
}
|
||||
if (null !== $this->identityInfo) {
|
||||
$res['identity_info'] = $this->identityInfo;
|
||||
}
|
||||
if (null !== $this->materialInfo) {
|
||||
$res['material_info'] = $this->materialInfo;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayUserCertifyOpenQueryResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['passed'])){
|
||||
$model->passed = $map['passed'];
|
||||
}
|
||||
if(isset($map['identity_info'])){
|
||||
$model->identityInfo = $map['identity_info'];
|
||||
}
|
||||
if(isset($map['material_info'])){
|
||||
$model->materialInfo = $map['material_info'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $passed;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $identityInfo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $materialInfo;
|
||||
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Member\Identification\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class IdentityParam extends Model {
|
||||
protected $_name = [
|
||||
'identityType' => 'identity_type',
|
||||
'certType' => 'cert_type',
|
||||
'certName' => 'cert_name',
|
||||
'certNo' => 'cert_no',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('identityType', $this->identityType, true);
|
||||
Model::validateRequired('certType', $this->certType, true);
|
||||
Model::validateRequired('certName', $this->certName, true);
|
||||
Model::validateRequired('certNo', $this->certNo, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->identityType) {
|
||||
$res['identity_type'] = $this->identityType;
|
||||
}
|
||||
if (null !== $this->certType) {
|
||||
$res['cert_type'] = $this->certType;
|
||||
}
|
||||
if (null !== $this->certName) {
|
||||
$res['cert_name'] = $this->certName;
|
||||
}
|
||||
if (null !== $this->certNo) {
|
||||
$res['cert_no'] = $this->certNo;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return IdentityParam
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['identity_type'])){
|
||||
$model->identityType = $map['identity_type'];
|
||||
}
|
||||
if(isset($map['cert_type'])){
|
||||
$model->certType = $map['cert_type'];
|
||||
}
|
||||
if(isset($map['cert_name'])){
|
||||
$model->certName = $map['cert_name'];
|
||||
}
|
||||
if(isset($map['cert_no'])){
|
||||
$model->certNo = $map['cert_no'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $identityType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $certType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $certName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $certNo;
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Member\Identification\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class MerchantConfig extends Model {
|
||||
protected $_name = [
|
||||
'returnUrl' => 'return_url',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('returnUrl', $this->returnUrl, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->returnUrl) {
|
||||
$res['return_url'] = $this->returnUrl;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return MerchantConfig
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['return_url'])){
|
||||
$model->returnUrl = $map['return_url'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $returnUrl;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\App;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
|
||||
use Alipay\EasySDK\Payment\App\Models\AlipayTradeAppPayResponse;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subject
|
||||
* @param string $outTradeNo
|
||||
* @param string $totalAmount
|
||||
* @return AlipayTradeAppPayResponse
|
||||
*/
|
||||
public function pay($subject, $outTradeNo, $totalAmount){
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.app.pay",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"subject" => $subject,
|
||||
"out_trade_no" => $outTradeNo,
|
||||
"total_amount" => $totalAmount
|
||||
];
|
||||
$textParams = [];
|
||||
$sign = $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"));
|
||||
$response = [
|
||||
"body" => $this->_kernel->generateOrderString($systemParams, $bizParams, $textParams, $sign)
|
||||
];
|
||||
return AlipayTradeAppPayResponse::fromMap($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\App\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayTradeAppPayResponse extends Model {
|
||||
protected $_name = [
|
||||
'body' => 'body',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('body', $this->body, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->body) {
|
||||
$res['body'] = $this->body;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradeAppPayResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['body'])){
|
||||
$model->body = $map['body'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 订单信息,字符串形式
|
||||
* @var string
|
||||
*/
|
||||
public $body;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,757 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Payment\Common\Models\AlipayTradeCreateResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
use Alipay\EasySDK\Payment\Common\Models\AlipayTradeQueryResponse;
|
||||
use Alipay\EasySDK\Payment\Common\Models\AlipayTradeRefundResponse;
|
||||
use Alipay\EasySDK\Payment\Common\Models\AlipayTradeCloseResponse;
|
||||
use Alipay\EasySDK\Payment\Common\Models\AlipayTradeCancelResponse;
|
||||
use Alipay\EasySDK\Payment\Common\Models\AlipayTradeFastpayRefundQueryResponse;
|
||||
use Alipay\EasySDK\Payment\Common\Models\AlipayDataDataserviceBillDownloadurlQueryResponse;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subject
|
||||
* @param string $outTradeNo
|
||||
* @param string $totalAmount
|
||||
* @param string $buyerId
|
||||
* @return AlipayTradeCreateResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function create($subject, $outTradeNo, $totalAmount, $buyerId){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.create",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"subject" => $subject,
|
||||
"out_trade_no" => $outTradeNo,
|
||||
"total_amount" => $totalAmount,
|
||||
"buyer_id" => $buyerId
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.trade.create");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayTradeCreateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayTradeCreateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $outTradeNo
|
||||
* @return AlipayTradeQueryResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function query($outTradeNo){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.query",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"out_trade_no" => $outTradeNo
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.trade.query");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayTradeQueryResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayTradeQueryResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $outTradeNo
|
||||
* @param string $refundAmount
|
||||
* @return AlipayTradeRefundResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function refund($outTradeNo, $refundAmount){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.refund",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"out_trade_no" => $outTradeNo,
|
||||
"refund_amount" => $refundAmount
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.trade.refund");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayTradeRefundResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayTradeRefundResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $outTradeNo
|
||||
* @return AlipayTradeCloseResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function close($outTradeNo){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.close",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"out_trade_no" => $outTradeNo
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.trade.close");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayTradeCloseResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayTradeCloseResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $outTradeNo
|
||||
* @return AlipayTradeCancelResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function cancel($outTradeNo){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.cancel",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"out_trade_no" => $outTradeNo
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.trade.cancel");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayTradeCancelResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayTradeCancelResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $outTradeNo
|
||||
* @param string $outRequestNo
|
||||
* @return AlipayTradeFastpayRefundQueryResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function queryRefund($outTradeNo, $outRequestNo){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.fastpay.refund.query",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"out_trade_no" => $outTradeNo,
|
||||
"out_request_no" => $outRequestNo
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.trade.fastpay.refund.query");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayTradeFastpayRefundQueryResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayTradeFastpayRefundQueryResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $billType
|
||||
* @param string $billDate
|
||||
* @return AlipayDataDataserviceBillDownloadurlQueryResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function downloadBill($billType, $billDate){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.data.dataservice.bill.downloadurl.query",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"bill_type" => $billType,
|
||||
"bill_date" => $billDate
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.data.dataservice.bill.downloadurl.query");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayDataDataserviceBillDownloadurlQueryResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayDataDataserviceBillDownloadurlQueryResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $parameters
|
||||
* @return bool
|
||||
*/
|
||||
public function verifyNotify($parameters){
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
return $this->_kernel->verifyParams($parameters, $this->_kernel->extractAlipayPublicKey(""));
|
||||
}
|
||||
else {
|
||||
return $this->_kernel->verifyParams($parameters, $this->_kernel->getConfig("alipayPublicKey"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayDataDataserviceBillDownloadurlQueryResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'billDownloadUrl' => 'bill_download_url',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('billDownloadUrl', $this->billDownloadUrl, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->billDownloadUrl) {
|
||||
$res['bill_download_url'] = $this->billDownloadUrl;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayDataDataserviceBillDownloadurlQueryResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['bill_download_url'])){
|
||||
$model->billDownloadUrl = $map['bill_download_url'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $billDownloadUrl;
|
||||
|
||||
}
|
||||
Vendored
+169
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayTradeCancelResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'tradeNo' => 'trade_no',
|
||||
'outTradeNo' => 'out_trade_no',
|
||||
'retryFlag' => 'retry_flag',
|
||||
'action' => 'action',
|
||||
'gmtRefundPay' => 'gmt_refund_pay',
|
||||
'refundSettlementId' => 'refund_settlement_id',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('tradeNo', $this->tradeNo, true);
|
||||
Model::validateRequired('outTradeNo', $this->outTradeNo, true);
|
||||
Model::validateRequired('retryFlag', $this->retryFlag, true);
|
||||
Model::validateRequired('action', $this->action, true);
|
||||
Model::validateRequired('gmtRefundPay', $this->gmtRefundPay, true);
|
||||
Model::validateRequired('refundSettlementId', $this->refundSettlementId, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->tradeNo) {
|
||||
$res['trade_no'] = $this->tradeNo;
|
||||
}
|
||||
if (null !== $this->outTradeNo) {
|
||||
$res['out_trade_no'] = $this->outTradeNo;
|
||||
}
|
||||
if (null !== $this->retryFlag) {
|
||||
$res['retry_flag'] = $this->retryFlag;
|
||||
}
|
||||
if (null !== $this->action) {
|
||||
$res['action'] = $this->action;
|
||||
}
|
||||
if (null !== $this->gmtRefundPay) {
|
||||
$res['gmt_refund_pay'] = $this->gmtRefundPay;
|
||||
}
|
||||
if (null !== $this->refundSettlementId) {
|
||||
$res['refund_settlement_id'] = $this->refundSettlementId;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradeCancelResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['trade_no'])){
|
||||
$model->tradeNo = $map['trade_no'];
|
||||
}
|
||||
if(isset($map['out_trade_no'])){
|
||||
$model->outTradeNo = $map['out_trade_no'];
|
||||
}
|
||||
if(isset($map['retry_flag'])){
|
||||
$model->retryFlag = $map['retry_flag'];
|
||||
}
|
||||
if(isset($map['action'])){
|
||||
$model->action = $map['action'];
|
||||
}
|
||||
if(isset($map['gmt_refund_pay'])){
|
||||
$model->gmtRefundPay = $map['gmt_refund_pay'];
|
||||
}
|
||||
if(isset($map['refund_settlement_id'])){
|
||||
$model->refundSettlementId = $map['refund_settlement_id'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $outTradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $retryFlag;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $action;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $gmtRefundPay;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $refundSettlementId;
|
||||
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayTradeCloseResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'tradeNo' => 'trade_no',
|
||||
'outTradeNo' => 'out_trade_no',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('tradeNo', $this->tradeNo, true);
|
||||
Model::validateRequired('outTradeNo', $this->outTradeNo, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->tradeNo) {
|
||||
$res['trade_no'] = $this->tradeNo;
|
||||
}
|
||||
if (null !== $this->outTradeNo) {
|
||||
$res['out_trade_no'] = $this->outTradeNo;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradeCloseResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['trade_no'])){
|
||||
$model->tradeNo = $map['trade_no'];
|
||||
}
|
||||
if(isset($map['out_trade_no'])){
|
||||
$model->outTradeNo = $map['out_trade_no'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $outTradeNo;
|
||||
|
||||
}
|
||||
Vendored
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayTradeCreateResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'outTradeNo' => 'out_trade_no',
|
||||
'tradeNo' => 'trade_no',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('outTradeNo', $this->outTradeNo, true);
|
||||
Model::validateRequired('tradeNo', $this->tradeNo, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->outTradeNo) {
|
||||
$res['out_trade_no'] = $this->outTradeNo;
|
||||
}
|
||||
if (null !== $this->tradeNo) {
|
||||
$res['trade_no'] = $this->tradeNo;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradeCreateResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['out_trade_no'])){
|
||||
$model->outTradeNo = $map['out_trade_no'];
|
||||
}
|
||||
if(isset($map['trade_no'])){
|
||||
$model->tradeNo = $map['trade_no'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $outTradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tradeNo;
|
||||
|
||||
}
|
||||
+352
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
use Alipay\EasySDK\Payment\Common\Models\TradeFundBill;
|
||||
use Alipay\EasySDK\Payment\Common\Models\RefundRoyaltyResult;
|
||||
|
||||
class AlipayTradeFastpayRefundQueryResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'errorCode' => 'error_code',
|
||||
'gmtRefundPay' => 'gmt_refund_pay',
|
||||
'industrySepcDetail' => 'industry_sepc_detail',
|
||||
'outRequestNo' => 'out_request_no',
|
||||
'outTradeNo' => 'out_trade_no',
|
||||
'presentRefundBuyerAmount' => 'present_refund_buyer_amount',
|
||||
'presentRefundDiscountAmount' => 'present_refund_discount_amount',
|
||||
'presentRefundMdiscountAmount' => 'present_refund_mdiscount_amount',
|
||||
'refundAmount' => 'refund_amount',
|
||||
'refundChargeAmount' => 'refund_charge_amount',
|
||||
'refundDetailItemList' => 'refund_detail_item_list',
|
||||
'refundReason' => 'refund_reason',
|
||||
'refundRoyaltys' => 'refund_royaltys',
|
||||
'refundSettlementId' => 'refund_settlement_id',
|
||||
'refundStatus' => 'refund_status',
|
||||
'sendBackFee' => 'send_back_fee',
|
||||
'totalAmount' => 'total_amount',
|
||||
'tradeNo' => 'trade_no',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('errorCode', $this->errorCode, true);
|
||||
Model::validateRequired('gmtRefundPay', $this->gmtRefundPay, true);
|
||||
Model::validateRequired('industrySepcDetail', $this->industrySepcDetail, true);
|
||||
Model::validateRequired('outRequestNo', $this->outRequestNo, true);
|
||||
Model::validateRequired('outTradeNo', $this->outTradeNo, true);
|
||||
Model::validateRequired('presentRefundBuyerAmount', $this->presentRefundBuyerAmount, true);
|
||||
Model::validateRequired('presentRefundDiscountAmount', $this->presentRefundDiscountAmount, true);
|
||||
Model::validateRequired('presentRefundMdiscountAmount', $this->presentRefundMdiscountAmount, true);
|
||||
Model::validateRequired('refundAmount', $this->refundAmount, true);
|
||||
Model::validateRequired('refundChargeAmount', $this->refundChargeAmount, true);
|
||||
Model::validateRequired('refundDetailItemList', $this->refundDetailItemList, true);
|
||||
Model::validateRequired('refundReason', $this->refundReason, true);
|
||||
Model::validateRequired('refundRoyaltys', $this->refundRoyaltys, true);
|
||||
Model::validateRequired('refundSettlementId', $this->refundSettlementId, true);
|
||||
Model::validateRequired('refundStatus', $this->refundStatus, true);
|
||||
Model::validateRequired('sendBackFee', $this->sendBackFee, true);
|
||||
Model::validateRequired('totalAmount', $this->totalAmount, true);
|
||||
Model::validateRequired('tradeNo', $this->tradeNo, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->errorCode) {
|
||||
$res['error_code'] = $this->errorCode;
|
||||
}
|
||||
if (null !== $this->gmtRefundPay) {
|
||||
$res['gmt_refund_pay'] = $this->gmtRefundPay;
|
||||
}
|
||||
if (null !== $this->industrySepcDetail) {
|
||||
$res['industry_sepc_detail'] = $this->industrySepcDetail;
|
||||
}
|
||||
if (null !== $this->outRequestNo) {
|
||||
$res['out_request_no'] = $this->outRequestNo;
|
||||
}
|
||||
if (null !== $this->outTradeNo) {
|
||||
$res['out_trade_no'] = $this->outTradeNo;
|
||||
}
|
||||
if (null !== $this->presentRefundBuyerAmount) {
|
||||
$res['present_refund_buyer_amount'] = $this->presentRefundBuyerAmount;
|
||||
}
|
||||
if (null !== $this->presentRefundDiscountAmount) {
|
||||
$res['present_refund_discount_amount'] = $this->presentRefundDiscountAmount;
|
||||
}
|
||||
if (null !== $this->presentRefundMdiscountAmount) {
|
||||
$res['present_refund_mdiscount_amount'] = $this->presentRefundMdiscountAmount;
|
||||
}
|
||||
if (null !== $this->refundAmount) {
|
||||
$res['refund_amount'] = $this->refundAmount;
|
||||
}
|
||||
if (null !== $this->refundChargeAmount) {
|
||||
$res['refund_charge_amount'] = $this->refundChargeAmount;
|
||||
}
|
||||
if (null !== $this->refundDetailItemList) {
|
||||
$res['refund_detail_item_list'] = [];
|
||||
if(null !== $this->refundDetailItemList && is_array($this->refundDetailItemList)){
|
||||
$n = 0;
|
||||
foreach($this->refundDetailItemList as $item){
|
||||
$res['refund_detail_item_list'][$n++] = null !== $item ? $item->toMap() : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null !== $this->refundReason) {
|
||||
$res['refund_reason'] = $this->refundReason;
|
||||
}
|
||||
if (null !== $this->refundRoyaltys) {
|
||||
$res['refund_royaltys'] = [];
|
||||
if(null !== $this->refundRoyaltys && is_array($this->refundRoyaltys)){
|
||||
$n = 0;
|
||||
foreach($this->refundRoyaltys as $item){
|
||||
$res['refund_royaltys'][$n++] = null !== $item ? $item->toMap() : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null !== $this->refundSettlementId) {
|
||||
$res['refund_settlement_id'] = $this->refundSettlementId;
|
||||
}
|
||||
if (null !== $this->refundStatus) {
|
||||
$res['refund_status'] = $this->refundStatus;
|
||||
}
|
||||
if (null !== $this->sendBackFee) {
|
||||
$res['send_back_fee'] = $this->sendBackFee;
|
||||
}
|
||||
if (null !== $this->totalAmount) {
|
||||
$res['total_amount'] = $this->totalAmount;
|
||||
}
|
||||
if (null !== $this->tradeNo) {
|
||||
$res['trade_no'] = $this->tradeNo;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradeFastpayRefundQueryResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['error_code'])){
|
||||
$model->errorCode = $map['error_code'];
|
||||
}
|
||||
if(isset($map['gmt_refund_pay'])){
|
||||
$model->gmtRefundPay = $map['gmt_refund_pay'];
|
||||
}
|
||||
if(isset($map['industry_sepc_detail'])){
|
||||
$model->industrySepcDetail = $map['industry_sepc_detail'];
|
||||
}
|
||||
if(isset($map['out_request_no'])){
|
||||
$model->outRequestNo = $map['out_request_no'];
|
||||
}
|
||||
if(isset($map['out_trade_no'])){
|
||||
$model->outTradeNo = $map['out_trade_no'];
|
||||
}
|
||||
if(isset($map['present_refund_buyer_amount'])){
|
||||
$model->presentRefundBuyerAmount = $map['present_refund_buyer_amount'];
|
||||
}
|
||||
if(isset($map['present_refund_discount_amount'])){
|
||||
$model->presentRefundDiscountAmount = $map['present_refund_discount_amount'];
|
||||
}
|
||||
if(isset($map['present_refund_mdiscount_amount'])){
|
||||
$model->presentRefundMdiscountAmount = $map['present_refund_mdiscount_amount'];
|
||||
}
|
||||
if(isset($map['refund_amount'])){
|
||||
$model->refundAmount = $map['refund_amount'];
|
||||
}
|
||||
if(isset($map['refund_charge_amount'])){
|
||||
$model->refundChargeAmount = $map['refund_charge_amount'];
|
||||
}
|
||||
if(isset($map['refund_detail_item_list'])){
|
||||
if(!empty($map['refund_detail_item_list'])){
|
||||
$model->refundDetailItemList = [];
|
||||
$n = 0;
|
||||
foreach($map['refund_detail_item_list'] as $item) {
|
||||
$model->refundDetailItemList[$n++] = null !== $item ? TradeFundBill::fromMap($item) : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($map['refund_reason'])){
|
||||
$model->refundReason = $map['refund_reason'];
|
||||
}
|
||||
if(isset($map['refund_royaltys'])){
|
||||
if(!empty($map['refund_royaltys'])){
|
||||
$model->refundRoyaltys = [];
|
||||
$n = 0;
|
||||
foreach($map['refund_royaltys'] as $item) {
|
||||
$model->refundRoyaltys[$n++] = null !== $item ? RefundRoyaltyResult::fromMap($item) : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($map['refund_settlement_id'])){
|
||||
$model->refundSettlementId = $map['refund_settlement_id'];
|
||||
}
|
||||
if(isset($map['refund_status'])){
|
||||
$model->refundStatus = $map['refund_status'];
|
||||
}
|
||||
if(isset($map['send_back_fee'])){
|
||||
$model->sendBackFee = $map['send_back_fee'];
|
||||
}
|
||||
if(isset($map['total_amount'])){
|
||||
$model->totalAmount = $map['total_amount'];
|
||||
}
|
||||
if(isset($map['trade_no'])){
|
||||
$model->tradeNo = $map['trade_no'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $errorCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $gmtRefundPay;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $industrySepcDetail;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $outRequestNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $outTradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $presentRefundBuyerAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $presentRefundDiscountAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $presentRefundMdiscountAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $refundAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $refundChargeAmount;
|
||||
|
||||
/**
|
||||
* @var TradeFundBill[]
|
||||
*/
|
||||
public $refundDetailItemList;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $refundReason;
|
||||
|
||||
/**
|
||||
* @var RefundRoyaltyResult[]
|
||||
*/
|
||||
public $refundRoyaltys;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $refundSettlementId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $refundStatus;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $sendBackFee;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $totalAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tradeNo;
|
||||
|
||||
}
|
||||
+573
@@ -0,0 +1,573 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
use Alipay\EasySDK\Payment\Common\Models\TradeFundBill;
|
||||
use Alipay\EasySDK\Payment\Common\Models\TradeSettleInfo;
|
||||
|
||||
class AlipayTradeQueryResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'tradeNo' => 'trade_no',
|
||||
'outTradeNo' => 'out_trade_no',
|
||||
'buyerLogonId' => 'buyer_logon_id',
|
||||
'tradeStatus' => 'trade_status',
|
||||
'totalAmount' => 'total_amount',
|
||||
'transCurrency' => 'trans_currency',
|
||||
'settleCurrency' => 'settle_currency',
|
||||
'settleAmount' => 'settle_amount',
|
||||
'payCurrency' => 'pay_currency',
|
||||
'payAmount' => 'pay_amount',
|
||||
'settleTransRate' => 'settle_trans_rate',
|
||||
'transPayRate' => 'trans_pay_rate',
|
||||
'buyerPayAmount' => 'buyer_pay_amount',
|
||||
'pointAmount' => 'point_amount',
|
||||
'invoiceAmount' => 'invoice_amount',
|
||||
'sendPayDate' => 'send_pay_date',
|
||||
'receiptAmount' => 'receipt_amount',
|
||||
'storeId' => 'store_id',
|
||||
'terminalId' => 'terminal_id',
|
||||
'fundBillList' => 'fund_bill_list',
|
||||
'storeName' => 'store_name',
|
||||
'buyerUserId' => 'buyer_user_id',
|
||||
'chargeAmount' => 'charge_amount',
|
||||
'chargeFlags' => 'charge_flags',
|
||||
'settlementId' => 'settlement_id',
|
||||
'tradeSettleInfo' => 'trade_settle_info',
|
||||
'authTradePayMode' => 'auth_trade_pay_mode',
|
||||
'buyerUserType' => 'buyer_user_type',
|
||||
'mdiscountAmount' => 'mdiscount_amount',
|
||||
'discountAmount' => 'discount_amount',
|
||||
'buyerUserName' => 'buyer_user_name',
|
||||
'subject' => 'subject',
|
||||
'body' => 'body',
|
||||
'alipaySubMerchantId' => 'alipay_sub_merchant_id',
|
||||
'extInfos' => 'ext_infos',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('tradeNo', $this->tradeNo, true);
|
||||
Model::validateRequired('outTradeNo', $this->outTradeNo, true);
|
||||
Model::validateRequired('buyerLogonId', $this->buyerLogonId, true);
|
||||
Model::validateRequired('tradeStatus', $this->tradeStatus, true);
|
||||
Model::validateRequired('totalAmount', $this->totalAmount, true);
|
||||
Model::validateRequired('transCurrency', $this->transCurrency, true);
|
||||
Model::validateRequired('settleCurrency', $this->settleCurrency, true);
|
||||
Model::validateRequired('settleAmount', $this->settleAmount, true);
|
||||
Model::validateRequired('payCurrency', $this->payCurrency, true);
|
||||
Model::validateRequired('payAmount', $this->payAmount, true);
|
||||
Model::validateRequired('settleTransRate', $this->settleTransRate, true);
|
||||
Model::validateRequired('transPayRate', $this->transPayRate, true);
|
||||
Model::validateRequired('buyerPayAmount', $this->buyerPayAmount, true);
|
||||
Model::validateRequired('pointAmount', $this->pointAmount, true);
|
||||
Model::validateRequired('invoiceAmount', $this->invoiceAmount, true);
|
||||
Model::validateRequired('sendPayDate', $this->sendPayDate, true);
|
||||
Model::validateRequired('receiptAmount', $this->receiptAmount, true);
|
||||
Model::validateRequired('storeId', $this->storeId, true);
|
||||
Model::validateRequired('terminalId', $this->terminalId, true);
|
||||
Model::validateRequired('fundBillList', $this->fundBillList, true);
|
||||
Model::validateRequired('storeName', $this->storeName, true);
|
||||
Model::validateRequired('buyerUserId', $this->buyerUserId, true);
|
||||
Model::validateRequired('chargeAmount', $this->chargeAmount, true);
|
||||
Model::validateRequired('chargeFlags', $this->chargeFlags, true);
|
||||
Model::validateRequired('settlementId', $this->settlementId, true);
|
||||
Model::validateRequired('tradeSettleInfo', $this->tradeSettleInfo, true);
|
||||
Model::validateRequired('authTradePayMode', $this->authTradePayMode, true);
|
||||
Model::validateRequired('buyerUserType', $this->buyerUserType, true);
|
||||
Model::validateRequired('mdiscountAmount', $this->mdiscountAmount, true);
|
||||
Model::validateRequired('discountAmount', $this->discountAmount, true);
|
||||
Model::validateRequired('buyerUserName', $this->buyerUserName, true);
|
||||
Model::validateRequired('subject', $this->subject, true);
|
||||
Model::validateRequired('body', $this->body, true);
|
||||
Model::validateRequired('alipaySubMerchantId', $this->alipaySubMerchantId, true);
|
||||
Model::validateRequired('extInfos', $this->extInfos, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->tradeNo) {
|
||||
$res['trade_no'] = $this->tradeNo;
|
||||
}
|
||||
if (null !== $this->outTradeNo) {
|
||||
$res['out_trade_no'] = $this->outTradeNo;
|
||||
}
|
||||
if (null !== $this->buyerLogonId) {
|
||||
$res['buyer_logon_id'] = $this->buyerLogonId;
|
||||
}
|
||||
if (null !== $this->tradeStatus) {
|
||||
$res['trade_status'] = $this->tradeStatus;
|
||||
}
|
||||
if (null !== $this->totalAmount) {
|
||||
$res['total_amount'] = $this->totalAmount;
|
||||
}
|
||||
if (null !== $this->transCurrency) {
|
||||
$res['trans_currency'] = $this->transCurrency;
|
||||
}
|
||||
if (null !== $this->settleCurrency) {
|
||||
$res['settle_currency'] = $this->settleCurrency;
|
||||
}
|
||||
if (null !== $this->settleAmount) {
|
||||
$res['settle_amount'] = $this->settleAmount;
|
||||
}
|
||||
if (null !== $this->payCurrency) {
|
||||
$res['pay_currency'] = $this->payCurrency;
|
||||
}
|
||||
if (null !== $this->payAmount) {
|
||||
$res['pay_amount'] = $this->payAmount;
|
||||
}
|
||||
if (null !== $this->settleTransRate) {
|
||||
$res['settle_trans_rate'] = $this->settleTransRate;
|
||||
}
|
||||
if (null !== $this->transPayRate) {
|
||||
$res['trans_pay_rate'] = $this->transPayRate;
|
||||
}
|
||||
if (null !== $this->buyerPayAmount) {
|
||||
$res['buyer_pay_amount'] = $this->buyerPayAmount;
|
||||
}
|
||||
if (null !== $this->pointAmount) {
|
||||
$res['point_amount'] = $this->pointAmount;
|
||||
}
|
||||
if (null !== $this->invoiceAmount) {
|
||||
$res['invoice_amount'] = $this->invoiceAmount;
|
||||
}
|
||||
if (null !== $this->sendPayDate) {
|
||||
$res['send_pay_date'] = $this->sendPayDate;
|
||||
}
|
||||
if (null !== $this->receiptAmount) {
|
||||
$res['receipt_amount'] = $this->receiptAmount;
|
||||
}
|
||||
if (null !== $this->storeId) {
|
||||
$res['store_id'] = $this->storeId;
|
||||
}
|
||||
if (null !== $this->terminalId) {
|
||||
$res['terminal_id'] = $this->terminalId;
|
||||
}
|
||||
if (null !== $this->fundBillList) {
|
||||
$res['fund_bill_list'] = [];
|
||||
if(null !== $this->fundBillList && is_array($this->fundBillList)){
|
||||
$n = 0;
|
||||
foreach($this->fundBillList as $item){
|
||||
$res['fund_bill_list'][$n++] = null !== $item ? $item->toMap() : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null !== $this->storeName) {
|
||||
$res['store_name'] = $this->storeName;
|
||||
}
|
||||
if (null !== $this->buyerUserId) {
|
||||
$res['buyer_user_id'] = $this->buyerUserId;
|
||||
}
|
||||
if (null !== $this->chargeAmount) {
|
||||
$res['charge_amount'] = $this->chargeAmount;
|
||||
}
|
||||
if (null !== $this->chargeFlags) {
|
||||
$res['charge_flags'] = $this->chargeFlags;
|
||||
}
|
||||
if (null !== $this->settlementId) {
|
||||
$res['settlement_id'] = $this->settlementId;
|
||||
}
|
||||
if (null !== $this->tradeSettleInfo) {
|
||||
$res['trade_settle_info'] = [];
|
||||
if(null !== $this->tradeSettleInfo && is_array($this->tradeSettleInfo)){
|
||||
$n = 0;
|
||||
foreach($this->tradeSettleInfo as $item){
|
||||
$res['trade_settle_info'][$n++] = null !== $item ? $item->toMap() : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null !== $this->authTradePayMode) {
|
||||
$res['auth_trade_pay_mode'] = $this->authTradePayMode;
|
||||
}
|
||||
if (null !== $this->buyerUserType) {
|
||||
$res['buyer_user_type'] = $this->buyerUserType;
|
||||
}
|
||||
if (null !== $this->mdiscountAmount) {
|
||||
$res['mdiscount_amount'] = $this->mdiscountAmount;
|
||||
}
|
||||
if (null !== $this->discountAmount) {
|
||||
$res['discount_amount'] = $this->discountAmount;
|
||||
}
|
||||
if (null !== $this->buyerUserName) {
|
||||
$res['buyer_user_name'] = $this->buyerUserName;
|
||||
}
|
||||
if (null !== $this->subject) {
|
||||
$res['subject'] = $this->subject;
|
||||
}
|
||||
if (null !== $this->body) {
|
||||
$res['body'] = $this->body;
|
||||
}
|
||||
if (null !== $this->alipaySubMerchantId) {
|
||||
$res['alipay_sub_merchant_id'] = $this->alipaySubMerchantId;
|
||||
}
|
||||
if (null !== $this->extInfos) {
|
||||
$res['ext_infos'] = $this->extInfos;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradeQueryResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['trade_no'])){
|
||||
$model->tradeNo = $map['trade_no'];
|
||||
}
|
||||
if(isset($map['out_trade_no'])){
|
||||
$model->outTradeNo = $map['out_trade_no'];
|
||||
}
|
||||
if(isset($map['buyer_logon_id'])){
|
||||
$model->buyerLogonId = $map['buyer_logon_id'];
|
||||
}
|
||||
if(isset($map['trade_status'])){
|
||||
$model->tradeStatus = $map['trade_status'];
|
||||
}
|
||||
if(isset($map['total_amount'])){
|
||||
$model->totalAmount = $map['total_amount'];
|
||||
}
|
||||
if(isset($map['trans_currency'])){
|
||||
$model->transCurrency = $map['trans_currency'];
|
||||
}
|
||||
if(isset($map['settle_currency'])){
|
||||
$model->settleCurrency = $map['settle_currency'];
|
||||
}
|
||||
if(isset($map['settle_amount'])){
|
||||
$model->settleAmount = $map['settle_amount'];
|
||||
}
|
||||
if(isset($map['pay_currency'])){
|
||||
$model->payCurrency = $map['pay_currency'];
|
||||
}
|
||||
if(isset($map['pay_amount'])){
|
||||
$model->payAmount = $map['pay_amount'];
|
||||
}
|
||||
if(isset($map['settle_trans_rate'])){
|
||||
$model->settleTransRate = $map['settle_trans_rate'];
|
||||
}
|
||||
if(isset($map['trans_pay_rate'])){
|
||||
$model->transPayRate = $map['trans_pay_rate'];
|
||||
}
|
||||
if(isset($map['buyer_pay_amount'])){
|
||||
$model->buyerPayAmount = $map['buyer_pay_amount'];
|
||||
}
|
||||
if(isset($map['point_amount'])){
|
||||
$model->pointAmount = $map['point_amount'];
|
||||
}
|
||||
if(isset($map['invoice_amount'])){
|
||||
$model->invoiceAmount = $map['invoice_amount'];
|
||||
}
|
||||
if(isset($map['send_pay_date'])){
|
||||
$model->sendPayDate = $map['send_pay_date'];
|
||||
}
|
||||
if(isset($map['receipt_amount'])){
|
||||
$model->receiptAmount = $map['receipt_amount'];
|
||||
}
|
||||
if(isset($map['store_id'])){
|
||||
$model->storeId = $map['store_id'];
|
||||
}
|
||||
if(isset($map['terminal_id'])){
|
||||
$model->terminalId = $map['terminal_id'];
|
||||
}
|
||||
if(isset($map['fund_bill_list'])){
|
||||
if(!empty($map['fund_bill_list'])){
|
||||
$model->fundBillList = [];
|
||||
$n = 0;
|
||||
foreach($map['fund_bill_list'] as $item) {
|
||||
$model->fundBillList[$n++] = null !== $item ? TradeFundBill::fromMap($item) : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($map['store_name'])){
|
||||
$model->storeName = $map['store_name'];
|
||||
}
|
||||
if(isset($map['buyer_user_id'])){
|
||||
$model->buyerUserId = $map['buyer_user_id'];
|
||||
}
|
||||
if(isset($map['charge_amount'])){
|
||||
$model->chargeAmount = $map['charge_amount'];
|
||||
}
|
||||
if(isset($map['charge_flags'])){
|
||||
$model->chargeFlags = $map['charge_flags'];
|
||||
}
|
||||
if(isset($map['settlement_id'])){
|
||||
$model->settlementId = $map['settlement_id'];
|
||||
}
|
||||
if(isset($map['trade_settle_info'])){
|
||||
if(!empty($map['trade_settle_info'])){
|
||||
$model->tradeSettleInfo = [];
|
||||
$n = 0;
|
||||
foreach($map['trade_settle_info'] as $item) {
|
||||
$model->tradeSettleInfo[$n++] = null !== $item ? TradeSettleInfo::fromMap($item) : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($map['auth_trade_pay_mode'])){
|
||||
$model->authTradePayMode = $map['auth_trade_pay_mode'];
|
||||
}
|
||||
if(isset($map['buyer_user_type'])){
|
||||
$model->buyerUserType = $map['buyer_user_type'];
|
||||
}
|
||||
if(isset($map['mdiscount_amount'])){
|
||||
$model->mdiscountAmount = $map['mdiscount_amount'];
|
||||
}
|
||||
if(isset($map['discount_amount'])){
|
||||
$model->discountAmount = $map['discount_amount'];
|
||||
}
|
||||
if(isset($map['buyer_user_name'])){
|
||||
$model->buyerUserName = $map['buyer_user_name'];
|
||||
}
|
||||
if(isset($map['subject'])){
|
||||
$model->subject = $map['subject'];
|
||||
}
|
||||
if(isset($map['body'])){
|
||||
$model->body = $map['body'];
|
||||
}
|
||||
if(isset($map['alipay_sub_merchant_id'])){
|
||||
$model->alipaySubMerchantId = $map['alipay_sub_merchant_id'];
|
||||
}
|
||||
if(isset($map['ext_infos'])){
|
||||
$model->extInfos = $map['ext_infos'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $outTradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerLogonId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tradeStatus;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $totalAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transCurrency;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $settleCurrency;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $settleAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $payCurrency;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $payAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $settleTransRate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transPayRate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerPayAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $pointAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $invoiceAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $sendPayDate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $receiptAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $storeId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $terminalId;
|
||||
|
||||
/**
|
||||
* @var TradeFundBill[]
|
||||
*/
|
||||
public $fundBillList;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $storeName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerUserId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $chargeAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $chargeFlags;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $settlementId;
|
||||
|
||||
/**
|
||||
* @var TradeSettleInfo[]
|
||||
*/
|
||||
public $tradeSettleInfo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $authTradePayMode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerUserType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $mdiscountAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $discountAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerUserName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subject;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $body;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $alipaySubMerchantId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $extInfos;
|
||||
|
||||
}
|
||||
Vendored
+313
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
use Alipay\EasySDK\Payment\Common\Models\TradeFundBill;
|
||||
use Alipay\EasySDK\Payment\Common\Models\PresetPayToolInfo;
|
||||
|
||||
class AlipayTradeRefundResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'tradeNo' => 'trade_no',
|
||||
'outTradeNo' => 'out_trade_no',
|
||||
'buyerLogonId' => 'buyer_logon_id',
|
||||
'fundChange' => 'fund_change',
|
||||
'refundFee' => 'refund_fee',
|
||||
'refundCurrency' => 'refund_currency',
|
||||
'gmtRefundPay' => 'gmt_refund_pay',
|
||||
'refundDetailItemList' => 'refund_detail_item_list',
|
||||
'storeName' => 'store_name',
|
||||
'buyerUserId' => 'buyer_user_id',
|
||||
'refundPresetPaytoolList' => 'refund_preset_paytool_list',
|
||||
'refundSettlementId' => 'refund_settlement_id',
|
||||
'presentRefundBuyerAmount' => 'present_refund_buyer_amount',
|
||||
'presentRefundDiscountAmount' => 'present_refund_discount_amount',
|
||||
'presentRefundMdiscountAmount' => 'present_refund_mdiscount_amount',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('tradeNo', $this->tradeNo, true);
|
||||
Model::validateRequired('outTradeNo', $this->outTradeNo, true);
|
||||
Model::validateRequired('buyerLogonId', $this->buyerLogonId, true);
|
||||
Model::validateRequired('fundChange', $this->fundChange, true);
|
||||
Model::validateRequired('refundFee', $this->refundFee, true);
|
||||
Model::validateRequired('refundCurrency', $this->refundCurrency, true);
|
||||
Model::validateRequired('gmtRefundPay', $this->gmtRefundPay, true);
|
||||
Model::validateRequired('refundDetailItemList', $this->refundDetailItemList, true);
|
||||
Model::validateRequired('storeName', $this->storeName, true);
|
||||
Model::validateRequired('buyerUserId', $this->buyerUserId, true);
|
||||
Model::validateRequired('refundPresetPaytoolList', $this->refundPresetPaytoolList, true);
|
||||
Model::validateRequired('refundSettlementId', $this->refundSettlementId, true);
|
||||
Model::validateRequired('presentRefundBuyerAmount', $this->presentRefundBuyerAmount, true);
|
||||
Model::validateRequired('presentRefundDiscountAmount', $this->presentRefundDiscountAmount, true);
|
||||
Model::validateRequired('presentRefundMdiscountAmount', $this->presentRefundMdiscountAmount, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->tradeNo) {
|
||||
$res['trade_no'] = $this->tradeNo;
|
||||
}
|
||||
if (null !== $this->outTradeNo) {
|
||||
$res['out_trade_no'] = $this->outTradeNo;
|
||||
}
|
||||
if (null !== $this->buyerLogonId) {
|
||||
$res['buyer_logon_id'] = $this->buyerLogonId;
|
||||
}
|
||||
if (null !== $this->fundChange) {
|
||||
$res['fund_change'] = $this->fundChange;
|
||||
}
|
||||
if (null !== $this->refundFee) {
|
||||
$res['refund_fee'] = $this->refundFee;
|
||||
}
|
||||
if (null !== $this->refundCurrency) {
|
||||
$res['refund_currency'] = $this->refundCurrency;
|
||||
}
|
||||
if (null !== $this->gmtRefundPay) {
|
||||
$res['gmt_refund_pay'] = $this->gmtRefundPay;
|
||||
}
|
||||
if (null !== $this->refundDetailItemList) {
|
||||
$res['refund_detail_item_list'] = [];
|
||||
if(null !== $this->refundDetailItemList && is_array($this->refundDetailItemList)){
|
||||
$n = 0;
|
||||
foreach($this->refundDetailItemList as $item){
|
||||
$res['refund_detail_item_list'][$n++] = null !== $item ? $item->toMap() : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null !== $this->storeName) {
|
||||
$res['store_name'] = $this->storeName;
|
||||
}
|
||||
if (null !== $this->buyerUserId) {
|
||||
$res['buyer_user_id'] = $this->buyerUserId;
|
||||
}
|
||||
if (null !== $this->refundPresetPaytoolList) {
|
||||
$res['refund_preset_paytool_list'] = [];
|
||||
if(null !== $this->refundPresetPaytoolList && is_array($this->refundPresetPaytoolList)){
|
||||
$n = 0;
|
||||
foreach($this->refundPresetPaytoolList as $item){
|
||||
$res['refund_preset_paytool_list'][$n++] = null !== $item ? $item->toMap() : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null !== $this->refundSettlementId) {
|
||||
$res['refund_settlement_id'] = $this->refundSettlementId;
|
||||
}
|
||||
if (null !== $this->presentRefundBuyerAmount) {
|
||||
$res['present_refund_buyer_amount'] = $this->presentRefundBuyerAmount;
|
||||
}
|
||||
if (null !== $this->presentRefundDiscountAmount) {
|
||||
$res['present_refund_discount_amount'] = $this->presentRefundDiscountAmount;
|
||||
}
|
||||
if (null !== $this->presentRefundMdiscountAmount) {
|
||||
$res['present_refund_mdiscount_amount'] = $this->presentRefundMdiscountAmount;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradeRefundResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['trade_no'])){
|
||||
$model->tradeNo = $map['trade_no'];
|
||||
}
|
||||
if(isset($map['out_trade_no'])){
|
||||
$model->outTradeNo = $map['out_trade_no'];
|
||||
}
|
||||
if(isset($map['buyer_logon_id'])){
|
||||
$model->buyerLogonId = $map['buyer_logon_id'];
|
||||
}
|
||||
if(isset($map['fund_change'])){
|
||||
$model->fundChange = $map['fund_change'];
|
||||
}
|
||||
if(isset($map['refund_fee'])){
|
||||
$model->refundFee = $map['refund_fee'];
|
||||
}
|
||||
if(isset($map['refund_currency'])){
|
||||
$model->refundCurrency = $map['refund_currency'];
|
||||
}
|
||||
if(isset($map['gmt_refund_pay'])){
|
||||
$model->gmtRefundPay = $map['gmt_refund_pay'];
|
||||
}
|
||||
if(isset($map['refund_detail_item_list'])){
|
||||
if(!empty($map['refund_detail_item_list'])){
|
||||
$model->refundDetailItemList = [];
|
||||
$n = 0;
|
||||
foreach($map['refund_detail_item_list'] as $item) {
|
||||
$model->refundDetailItemList[$n++] = null !== $item ? TradeFundBill::fromMap($item) : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($map['store_name'])){
|
||||
$model->storeName = $map['store_name'];
|
||||
}
|
||||
if(isset($map['buyer_user_id'])){
|
||||
$model->buyerUserId = $map['buyer_user_id'];
|
||||
}
|
||||
if(isset($map['refund_preset_paytool_list'])){
|
||||
if(!empty($map['refund_preset_paytool_list'])){
|
||||
$model->refundPresetPaytoolList = [];
|
||||
$n = 0;
|
||||
foreach($map['refund_preset_paytool_list'] as $item) {
|
||||
$model->refundPresetPaytoolList[$n++] = null !== $item ? PresetPayToolInfo::fromMap($item) : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($map['refund_settlement_id'])){
|
||||
$model->refundSettlementId = $map['refund_settlement_id'];
|
||||
}
|
||||
if(isset($map['present_refund_buyer_amount'])){
|
||||
$model->presentRefundBuyerAmount = $map['present_refund_buyer_amount'];
|
||||
}
|
||||
if(isset($map['present_refund_discount_amount'])){
|
||||
$model->presentRefundDiscountAmount = $map['present_refund_discount_amount'];
|
||||
}
|
||||
if(isset($map['present_refund_mdiscount_amount'])){
|
||||
$model->presentRefundMdiscountAmount = $map['present_refund_mdiscount_amount'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $outTradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerLogonId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $fundChange;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $refundFee;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $refundCurrency;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $gmtRefundPay;
|
||||
|
||||
/**
|
||||
* @var TradeFundBill[]
|
||||
*/
|
||||
public $refundDetailItemList;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $storeName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerUserId;
|
||||
|
||||
/**
|
||||
* @var PresetPayToolInfo[]
|
||||
*/
|
||||
public $refundPresetPaytoolList;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $refundSettlementId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $presentRefundBuyerAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $presentRefundDiscountAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $presentRefundMdiscountAmount;
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class PresetPayToolInfo extends Model {
|
||||
protected $_name = [
|
||||
'amount' => 'amount',
|
||||
'assertTypeCode' => 'assert_type_code',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('amount', $this->amount, true);
|
||||
Model::validateRequired('assertTypeCode', $this->assertTypeCode, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->amount) {
|
||||
$res['amount'] = $this->amount;
|
||||
}
|
||||
if (null !== $this->assertTypeCode) {
|
||||
$res['assert_type_code'] = $this->assertTypeCode;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return PresetPayToolInfo
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['amount'])){
|
||||
if(!empty($map['amount'])){
|
||||
$model->amount = $map['amount'];
|
||||
}
|
||||
}
|
||||
if(isset($map['assert_type_code'])){
|
||||
$model->assertTypeCode = $map['assert_type_code'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $amount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $assertTypeCode;
|
||||
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class RefundRoyaltyResult extends Model {
|
||||
protected $_name = [
|
||||
'refundAmount' => 'refund_amount',
|
||||
'royaltyType' => 'royalty_type',
|
||||
'resultCode' => 'result_code',
|
||||
'transOut' => 'trans_out',
|
||||
'transOutEmail' => 'trans_out_email',
|
||||
'transIn' => 'trans_in',
|
||||
'transInEmail' => 'trans_in_email',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('refundAmount', $this->refundAmount, true);
|
||||
Model::validateRequired('royaltyType', $this->royaltyType, true);
|
||||
Model::validateRequired('resultCode', $this->resultCode, true);
|
||||
Model::validateRequired('transOut', $this->transOut, true);
|
||||
Model::validateRequired('transOutEmail', $this->transOutEmail, true);
|
||||
Model::validateRequired('transIn', $this->transIn, true);
|
||||
Model::validateRequired('transInEmail', $this->transInEmail, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->refundAmount) {
|
||||
$res['refund_amount'] = $this->refundAmount;
|
||||
}
|
||||
if (null !== $this->royaltyType) {
|
||||
$res['royalty_type'] = $this->royaltyType;
|
||||
}
|
||||
if (null !== $this->resultCode) {
|
||||
$res['result_code'] = $this->resultCode;
|
||||
}
|
||||
if (null !== $this->transOut) {
|
||||
$res['trans_out'] = $this->transOut;
|
||||
}
|
||||
if (null !== $this->transOutEmail) {
|
||||
$res['trans_out_email'] = $this->transOutEmail;
|
||||
}
|
||||
if (null !== $this->transIn) {
|
||||
$res['trans_in'] = $this->transIn;
|
||||
}
|
||||
if (null !== $this->transInEmail) {
|
||||
$res['trans_in_email'] = $this->transInEmail;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return RefundRoyaltyResult
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['refund_amount'])){
|
||||
$model->refundAmount = $map['refund_amount'];
|
||||
}
|
||||
if(isset($map['royalty_type'])){
|
||||
$model->royaltyType = $map['royalty_type'];
|
||||
}
|
||||
if(isset($map['result_code'])){
|
||||
$model->resultCode = $map['result_code'];
|
||||
}
|
||||
if(isset($map['trans_out'])){
|
||||
$model->transOut = $map['trans_out'];
|
||||
}
|
||||
if(isset($map['trans_out_email'])){
|
||||
$model->transOutEmail = $map['trans_out_email'];
|
||||
}
|
||||
if(isset($map['trans_in'])){
|
||||
$model->transIn = $map['trans_in'];
|
||||
}
|
||||
if(isset($map['trans_in_email'])){
|
||||
$model->transInEmail = $map['trans_in_email'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $refundAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $royaltyType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $resultCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transOut;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transOutEmail;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transIn;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transInEmail;
|
||||
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class TradeFundBill extends Model {
|
||||
protected $_name = [
|
||||
'fundChannel' => 'fund_channel',
|
||||
'bankCode' => 'bank_code',
|
||||
'amount' => 'amount',
|
||||
'realAmount' => 'real_amount',
|
||||
'fundType' => 'fund_type',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('fundChannel', $this->fundChannel, true);
|
||||
Model::validateRequired('bankCode', $this->bankCode, true);
|
||||
Model::validateRequired('amount', $this->amount, true);
|
||||
Model::validateRequired('realAmount', $this->realAmount, true);
|
||||
Model::validateRequired('fundType', $this->fundType, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->fundChannel) {
|
||||
$res['fund_channel'] = $this->fundChannel;
|
||||
}
|
||||
if (null !== $this->bankCode) {
|
||||
$res['bank_code'] = $this->bankCode;
|
||||
}
|
||||
if (null !== $this->amount) {
|
||||
$res['amount'] = $this->amount;
|
||||
}
|
||||
if (null !== $this->realAmount) {
|
||||
$res['real_amount'] = $this->realAmount;
|
||||
}
|
||||
if (null !== $this->fundType) {
|
||||
$res['fund_type'] = $this->fundType;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return TradeFundBill
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['fund_channel'])){
|
||||
$model->fundChannel = $map['fund_channel'];
|
||||
}
|
||||
if(isset($map['bank_code'])){
|
||||
$model->bankCode = $map['bank_code'];
|
||||
}
|
||||
if(isset($map['amount'])){
|
||||
$model->amount = $map['amount'];
|
||||
}
|
||||
if(isset($map['real_amount'])){
|
||||
$model->realAmount = $map['real_amount'];
|
||||
}
|
||||
if(isset($map['fund_type'])){
|
||||
$model->fundType = $map['fund_type'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $fundChannel;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $bankCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $amount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $realAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $fundType;
|
||||
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class TradeSettleDetail extends Model {
|
||||
protected $_name = [
|
||||
'operationType' => 'operation_type',
|
||||
'operationSerial_no' => 'operation_serial_no',
|
||||
'operationDt' => 'operation_dt',
|
||||
'transOut' => 'trans_out',
|
||||
'transIn' => 'trans_in',
|
||||
'amount' => 'amount',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('operationType', $this->operationType, true);
|
||||
Model::validateRequired('operationSerial_no', $this->operationSerial_no, true);
|
||||
Model::validateRequired('operationDt', $this->operationDt, true);
|
||||
Model::validateRequired('transOut', $this->transOut, true);
|
||||
Model::validateRequired('transIn', $this->transIn, true);
|
||||
Model::validateRequired('amount', $this->amount, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->operationType) {
|
||||
$res['operation_type'] = $this->operationType;
|
||||
}
|
||||
if (null !== $this->operationSerial_no) {
|
||||
$res['operation_serial_no'] = $this->operationSerial_no;
|
||||
}
|
||||
if (null !== $this->operationDt) {
|
||||
$res['operation_dt'] = $this->operationDt;
|
||||
}
|
||||
if (null !== $this->transOut) {
|
||||
$res['trans_out'] = $this->transOut;
|
||||
}
|
||||
if (null !== $this->transIn) {
|
||||
$res['trans_in'] = $this->transIn;
|
||||
}
|
||||
if (null !== $this->amount) {
|
||||
$res['amount'] = $this->amount;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return TradeSettleDetail
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['operation_type'])){
|
||||
$model->operationType = $map['operation_type'];
|
||||
}
|
||||
if(isset($map['operation_serial_no'])){
|
||||
$model->operationSerial_no = $map['operation_serial_no'];
|
||||
}
|
||||
if(isset($map['operation_dt'])){
|
||||
$model->operationDt = $map['operation_dt'];
|
||||
}
|
||||
if(isset($map['trans_out'])){
|
||||
$model->transOut = $map['trans_out'];
|
||||
}
|
||||
if(isset($map['trans_in'])){
|
||||
$model->transIn = $map['trans_in'];
|
||||
}
|
||||
if(isset($map['amount'])){
|
||||
$model->amount = $map['amount'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $operationType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $operationSerial_no;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $operationDt;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transOut;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transIn;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $amount;
|
||||
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Common\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
use Alipay\EasySDK\Payment\Common\Models\TradeSettleDetail;
|
||||
|
||||
class TradeSettleInfo extends Model {
|
||||
protected $_name = [
|
||||
'tradeSettleDetailList' => 'trade_settle_detail_list',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('tradeSettleDetailList', $this->tradeSettleDetailList, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->tradeSettleDetailList) {
|
||||
$res['trade_settle_detail_list'] = [];
|
||||
if(null !== $this->tradeSettleDetailList && is_array($this->tradeSettleDetailList)){
|
||||
$n = 0;
|
||||
foreach($this->tradeSettleDetailList as $item){
|
||||
$res['trade_settle_detail_list'][$n++] = null !== $item ? $item->toMap() : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return TradeSettleInfo
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['trade_settle_detail_list'])){
|
||||
if(!empty($map['trade_settle_detail_list'])){
|
||||
$model->tradeSettleDetailList = [];
|
||||
$n = 0;
|
||||
foreach($map['trade_settle_detail_list'] as $item) {
|
||||
$model->tradeSettleDetailList[$n++] = null !== $item ? TradeSettleDetail::fromMap($item) : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var TradeSettleDetail[]
|
||||
*/
|
||||
public $tradeSettleDetailList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\FaceToFace;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Payment\FaceToFace\Models\AlipayTradePayResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
use Alipay\EasySDK\Payment\FaceToFace\Models\AlipayTradePrecreateResponse;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subject
|
||||
* @param string $outTradeNo
|
||||
* @param string $totalAmount
|
||||
* @param string $authCode
|
||||
* @return AlipayTradePayResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function pay($subject, $outTradeNo, $totalAmount, $authCode){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.pay",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"subject" => $subject,
|
||||
"out_trade_no" => $outTradeNo,
|
||||
"total_amount" => $totalAmount,
|
||||
"auth_code" => $authCode,
|
||||
"scene" => "bar_code"
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.trade.pay");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayTradePayResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayTradePayResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subject
|
||||
* @param string $outTradeNo
|
||||
* @param string $totalAmount
|
||||
* @return AlipayTradePrecreateResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function preCreate($subject, $outTradeNo, $totalAmount){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.precreate",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"subject" => $subject,
|
||||
"out_trade_no" => $outTradeNo,
|
||||
"total_amount" => $totalAmount
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.trade.precreate");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayTradePrecreateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayTradePrecreateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+534
@@ -0,0 +1,534 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\FaceToFace\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
use Alipay\EasySDK\Payment\FaceToFace\Models\TradeFundBill;
|
||||
use Alipay\EasySDK\Payment\FaceToFace\Models\VoucherDetail;
|
||||
|
||||
class AlipayTradePayResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'tradeNo' => 'trade_no',
|
||||
'outTradeNo' => 'out_trade_no',
|
||||
'buyerLogonId' => 'buyer_logon_id',
|
||||
'settleAmount' => 'settle_amount',
|
||||
'payCurrency' => 'pay_currency',
|
||||
'payAmount' => 'pay_amount',
|
||||
'settleTransRate' => 'settle_trans_rate',
|
||||
'transPayRate' => 'trans_pay_rate',
|
||||
'totalAmount' => 'total_amount',
|
||||
'transCurrency' => 'trans_currency',
|
||||
'settleCurrency' => 'settle_currency',
|
||||
'receiptAmount' => 'receipt_amount',
|
||||
'buyerPayAmount' => 'buyer_pay_amount',
|
||||
'pointAmount' => 'point_amount',
|
||||
'invoiceAmount' => 'invoice_amount',
|
||||
'gmtPayment' => 'gmt_payment',
|
||||
'fundBillList' => 'fund_bill_list',
|
||||
'cardBalance' => 'card_balance',
|
||||
'storeName' => 'store_name',
|
||||
'buyerUserId' => 'buyer_user_id',
|
||||
'discountGoodsDetail' => 'discount_goods_detail',
|
||||
'voucherDetailList' => 'voucher_detail_list',
|
||||
'advanceAmount' => 'advance_amount',
|
||||
'authTradePayMode' => 'auth_trade_pay_mode',
|
||||
'chargeAmount' => 'charge_amount',
|
||||
'chargeFlags' => 'charge_flags',
|
||||
'settlementId' => 'settlement_id',
|
||||
'businessParams' => 'business_params',
|
||||
'buyerUserType' => 'buyer_user_type',
|
||||
'mdiscountAmount' => 'mdiscount_amount',
|
||||
'discountAmount' => 'discount_amount',
|
||||
'buyerUserName' => 'buyer_user_name',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('tradeNo', $this->tradeNo, true);
|
||||
Model::validateRequired('outTradeNo', $this->outTradeNo, true);
|
||||
Model::validateRequired('buyerLogonId', $this->buyerLogonId, true);
|
||||
Model::validateRequired('settleAmount', $this->settleAmount, true);
|
||||
Model::validateRequired('payCurrency', $this->payCurrency, true);
|
||||
Model::validateRequired('payAmount', $this->payAmount, true);
|
||||
Model::validateRequired('settleTransRate', $this->settleTransRate, true);
|
||||
Model::validateRequired('transPayRate', $this->transPayRate, true);
|
||||
Model::validateRequired('totalAmount', $this->totalAmount, true);
|
||||
Model::validateRequired('transCurrency', $this->transCurrency, true);
|
||||
Model::validateRequired('settleCurrency', $this->settleCurrency, true);
|
||||
Model::validateRequired('receiptAmount', $this->receiptAmount, true);
|
||||
Model::validateRequired('buyerPayAmount', $this->buyerPayAmount, true);
|
||||
Model::validateRequired('pointAmount', $this->pointAmount, true);
|
||||
Model::validateRequired('invoiceAmount', $this->invoiceAmount, true);
|
||||
Model::validateRequired('gmtPayment', $this->gmtPayment, true);
|
||||
Model::validateRequired('fundBillList', $this->fundBillList, true);
|
||||
Model::validateRequired('cardBalance', $this->cardBalance, true);
|
||||
Model::validateRequired('storeName', $this->storeName, true);
|
||||
Model::validateRequired('buyerUserId', $this->buyerUserId, true);
|
||||
Model::validateRequired('discountGoodsDetail', $this->discountGoodsDetail, true);
|
||||
Model::validateRequired('voucherDetailList', $this->voucherDetailList, true);
|
||||
Model::validateRequired('advanceAmount', $this->advanceAmount, true);
|
||||
Model::validateRequired('authTradePayMode', $this->authTradePayMode, true);
|
||||
Model::validateRequired('chargeAmount', $this->chargeAmount, true);
|
||||
Model::validateRequired('chargeFlags', $this->chargeFlags, true);
|
||||
Model::validateRequired('settlementId', $this->settlementId, true);
|
||||
Model::validateRequired('businessParams', $this->businessParams, true);
|
||||
Model::validateRequired('buyerUserType', $this->buyerUserType, true);
|
||||
Model::validateRequired('mdiscountAmount', $this->mdiscountAmount, true);
|
||||
Model::validateRequired('discountAmount', $this->discountAmount, true);
|
||||
Model::validateRequired('buyerUserName', $this->buyerUserName, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->tradeNo) {
|
||||
$res['trade_no'] = $this->tradeNo;
|
||||
}
|
||||
if (null !== $this->outTradeNo) {
|
||||
$res['out_trade_no'] = $this->outTradeNo;
|
||||
}
|
||||
if (null !== $this->buyerLogonId) {
|
||||
$res['buyer_logon_id'] = $this->buyerLogonId;
|
||||
}
|
||||
if (null !== $this->settleAmount) {
|
||||
$res['settle_amount'] = $this->settleAmount;
|
||||
}
|
||||
if (null !== $this->payCurrency) {
|
||||
$res['pay_currency'] = $this->payCurrency;
|
||||
}
|
||||
if (null !== $this->payAmount) {
|
||||
$res['pay_amount'] = $this->payAmount;
|
||||
}
|
||||
if (null !== $this->settleTransRate) {
|
||||
$res['settle_trans_rate'] = $this->settleTransRate;
|
||||
}
|
||||
if (null !== $this->transPayRate) {
|
||||
$res['trans_pay_rate'] = $this->transPayRate;
|
||||
}
|
||||
if (null !== $this->totalAmount) {
|
||||
$res['total_amount'] = $this->totalAmount;
|
||||
}
|
||||
if (null !== $this->transCurrency) {
|
||||
$res['trans_currency'] = $this->transCurrency;
|
||||
}
|
||||
if (null !== $this->settleCurrency) {
|
||||
$res['settle_currency'] = $this->settleCurrency;
|
||||
}
|
||||
if (null !== $this->receiptAmount) {
|
||||
$res['receipt_amount'] = $this->receiptAmount;
|
||||
}
|
||||
if (null !== $this->buyerPayAmount) {
|
||||
$res['buyer_pay_amount'] = $this->buyerPayAmount;
|
||||
}
|
||||
if (null !== $this->pointAmount) {
|
||||
$res['point_amount'] = $this->pointAmount;
|
||||
}
|
||||
if (null !== $this->invoiceAmount) {
|
||||
$res['invoice_amount'] = $this->invoiceAmount;
|
||||
}
|
||||
if (null !== $this->gmtPayment) {
|
||||
$res['gmt_payment'] = $this->gmtPayment;
|
||||
}
|
||||
if (null !== $this->fundBillList) {
|
||||
$res['fund_bill_list'] = [];
|
||||
if(null !== $this->fundBillList && is_array($this->fundBillList)){
|
||||
$n = 0;
|
||||
foreach($this->fundBillList as $item){
|
||||
$res['fund_bill_list'][$n++] = null !== $item ? $item->toMap() : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null !== $this->cardBalance) {
|
||||
$res['card_balance'] = $this->cardBalance;
|
||||
}
|
||||
if (null !== $this->storeName) {
|
||||
$res['store_name'] = $this->storeName;
|
||||
}
|
||||
if (null !== $this->buyerUserId) {
|
||||
$res['buyer_user_id'] = $this->buyerUserId;
|
||||
}
|
||||
if (null !== $this->discountGoodsDetail) {
|
||||
$res['discount_goods_detail'] = $this->discountGoodsDetail;
|
||||
}
|
||||
if (null !== $this->voucherDetailList) {
|
||||
$res['voucher_detail_list'] = [];
|
||||
if(null !== $this->voucherDetailList && is_array($this->voucherDetailList)){
|
||||
$n = 0;
|
||||
foreach($this->voucherDetailList as $item){
|
||||
$res['voucher_detail_list'][$n++] = null !== $item ? $item->toMap() : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null !== $this->advanceAmount) {
|
||||
$res['advance_amount'] = $this->advanceAmount;
|
||||
}
|
||||
if (null !== $this->authTradePayMode) {
|
||||
$res['auth_trade_pay_mode'] = $this->authTradePayMode;
|
||||
}
|
||||
if (null !== $this->chargeAmount) {
|
||||
$res['charge_amount'] = $this->chargeAmount;
|
||||
}
|
||||
if (null !== $this->chargeFlags) {
|
||||
$res['charge_flags'] = $this->chargeFlags;
|
||||
}
|
||||
if (null !== $this->settlementId) {
|
||||
$res['settlement_id'] = $this->settlementId;
|
||||
}
|
||||
if (null !== $this->businessParams) {
|
||||
$res['business_params'] = $this->businessParams;
|
||||
}
|
||||
if (null !== $this->buyerUserType) {
|
||||
$res['buyer_user_type'] = $this->buyerUserType;
|
||||
}
|
||||
if (null !== $this->mdiscountAmount) {
|
||||
$res['mdiscount_amount'] = $this->mdiscountAmount;
|
||||
}
|
||||
if (null !== $this->discountAmount) {
|
||||
$res['discount_amount'] = $this->discountAmount;
|
||||
}
|
||||
if (null !== $this->buyerUserName) {
|
||||
$res['buyer_user_name'] = $this->buyerUserName;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradePayResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['trade_no'])){
|
||||
$model->tradeNo = $map['trade_no'];
|
||||
}
|
||||
if(isset($map['out_trade_no'])){
|
||||
$model->outTradeNo = $map['out_trade_no'];
|
||||
}
|
||||
if(isset($map['buyer_logon_id'])){
|
||||
$model->buyerLogonId = $map['buyer_logon_id'];
|
||||
}
|
||||
if(isset($map['settle_amount'])){
|
||||
$model->settleAmount = $map['settle_amount'];
|
||||
}
|
||||
if(isset($map['pay_currency'])){
|
||||
$model->payCurrency = $map['pay_currency'];
|
||||
}
|
||||
if(isset($map['pay_amount'])){
|
||||
$model->payAmount = $map['pay_amount'];
|
||||
}
|
||||
if(isset($map['settle_trans_rate'])){
|
||||
$model->settleTransRate = $map['settle_trans_rate'];
|
||||
}
|
||||
if(isset($map['trans_pay_rate'])){
|
||||
$model->transPayRate = $map['trans_pay_rate'];
|
||||
}
|
||||
if(isset($map['total_amount'])){
|
||||
$model->totalAmount = $map['total_amount'];
|
||||
}
|
||||
if(isset($map['trans_currency'])){
|
||||
$model->transCurrency = $map['trans_currency'];
|
||||
}
|
||||
if(isset($map['settle_currency'])){
|
||||
$model->settleCurrency = $map['settle_currency'];
|
||||
}
|
||||
if(isset($map['receipt_amount'])){
|
||||
$model->receiptAmount = $map['receipt_amount'];
|
||||
}
|
||||
if(isset($map['buyer_pay_amount'])){
|
||||
$model->buyerPayAmount = $map['buyer_pay_amount'];
|
||||
}
|
||||
if(isset($map['point_amount'])){
|
||||
$model->pointAmount = $map['point_amount'];
|
||||
}
|
||||
if(isset($map['invoice_amount'])){
|
||||
$model->invoiceAmount = $map['invoice_amount'];
|
||||
}
|
||||
if(isset($map['gmt_payment'])){
|
||||
$model->gmtPayment = $map['gmt_payment'];
|
||||
}
|
||||
if(isset($map['fund_bill_list'])){
|
||||
if(!empty($map['fund_bill_list'])){
|
||||
$model->fundBillList = [];
|
||||
$n = 0;
|
||||
foreach($map['fund_bill_list'] as $item) {
|
||||
$model->fundBillList[$n++] = null !== $item ? TradeFundBill::fromMap($item) : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($map['card_balance'])){
|
||||
$model->cardBalance = $map['card_balance'];
|
||||
}
|
||||
if(isset($map['store_name'])){
|
||||
$model->storeName = $map['store_name'];
|
||||
}
|
||||
if(isset($map['buyer_user_id'])){
|
||||
$model->buyerUserId = $map['buyer_user_id'];
|
||||
}
|
||||
if(isset($map['discount_goods_detail'])){
|
||||
$model->discountGoodsDetail = $map['discount_goods_detail'];
|
||||
}
|
||||
if(isset($map['voucher_detail_list'])){
|
||||
if(!empty($map['voucher_detail_list'])){
|
||||
$model->voucherDetailList = [];
|
||||
$n = 0;
|
||||
foreach($map['voucher_detail_list'] as $item) {
|
||||
$model->voucherDetailList[$n++] = null !== $item ? VoucherDetail::fromMap($item) : $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($map['advance_amount'])){
|
||||
$model->advanceAmount = $map['advance_amount'];
|
||||
}
|
||||
if(isset($map['auth_trade_pay_mode'])){
|
||||
$model->authTradePayMode = $map['auth_trade_pay_mode'];
|
||||
}
|
||||
if(isset($map['charge_amount'])){
|
||||
$model->chargeAmount = $map['charge_amount'];
|
||||
}
|
||||
if(isset($map['charge_flags'])){
|
||||
$model->chargeFlags = $map['charge_flags'];
|
||||
}
|
||||
if(isset($map['settlement_id'])){
|
||||
$model->settlementId = $map['settlement_id'];
|
||||
}
|
||||
if(isset($map['business_params'])){
|
||||
$model->businessParams = $map['business_params'];
|
||||
}
|
||||
if(isset($map['buyer_user_type'])){
|
||||
$model->buyerUserType = $map['buyer_user_type'];
|
||||
}
|
||||
if(isset($map['mdiscount_amount'])){
|
||||
$model->mdiscountAmount = $map['mdiscount_amount'];
|
||||
}
|
||||
if(isset($map['discount_amount'])){
|
||||
$model->discountAmount = $map['discount_amount'];
|
||||
}
|
||||
if(isset($map['buyer_user_name'])){
|
||||
$model->buyerUserName = $map['buyer_user_name'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $outTradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerLogonId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $settleAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $payCurrency;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $payAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $settleTransRate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transPayRate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $totalAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transCurrency;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $settleCurrency;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $receiptAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerPayAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $pointAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $invoiceAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $gmtPayment;
|
||||
|
||||
/**
|
||||
* @var TradeFundBill[]
|
||||
*/
|
||||
public $fundBillList;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $cardBalance;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $storeName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerUserId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $discountGoodsDetail;
|
||||
|
||||
/**
|
||||
* @var VoucherDetail[]
|
||||
*/
|
||||
public $voucherDetailList;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $advanceAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $authTradePayMode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $chargeAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $chargeFlags;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $settlementId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $businessParams;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerUserType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $mdiscountAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $discountAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $buyerUserName;
|
||||
|
||||
}
|
||||
Vendored
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\FaceToFace\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayTradePrecreateResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'outTradeNo' => 'out_trade_no',
|
||||
'qrCode' => 'qr_code',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('outTradeNo', $this->outTradeNo, true);
|
||||
Model::validateRequired('qrCode', $this->qrCode, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->outTradeNo) {
|
||||
$res['out_trade_no'] = $this->outTradeNo;
|
||||
}
|
||||
if (null !== $this->qrCode) {
|
||||
$res['qr_code'] = $this->qrCode;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradePrecreateResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['out_trade_no'])){
|
||||
$model->outTradeNo = $map['out_trade_no'];
|
||||
}
|
||||
if(isset($map['qr_code'])){
|
||||
$model->qrCode = $map['qr_code'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $outTradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $qrCode;
|
||||
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\FaceToFace\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class TradeFundBill extends Model {
|
||||
protected $_name = [
|
||||
'fundChannel' => 'fund_channel',
|
||||
'bankCode' => 'bank_code',
|
||||
'amount' => 'amount',
|
||||
'realAmount' => 'real_amount',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('fundChannel', $this->fundChannel, true);
|
||||
Model::validateRequired('bankCode', $this->bankCode, true);
|
||||
Model::validateRequired('amount', $this->amount, true);
|
||||
Model::validateRequired('realAmount', $this->realAmount, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->fundChannel) {
|
||||
$res['fund_channel'] = $this->fundChannel;
|
||||
}
|
||||
if (null !== $this->bankCode) {
|
||||
$res['bank_code'] = $this->bankCode;
|
||||
}
|
||||
if (null !== $this->amount) {
|
||||
$res['amount'] = $this->amount;
|
||||
}
|
||||
if (null !== $this->realAmount) {
|
||||
$res['real_amount'] = $this->realAmount;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return TradeFundBill
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['fund_channel'])){
|
||||
$model->fundChannel = $map['fund_channel'];
|
||||
}
|
||||
if(isset($map['bank_code'])){
|
||||
$model->bankCode = $map['bank_code'];
|
||||
}
|
||||
if(isset($map['amount'])){
|
||||
$model->amount = $map['amount'];
|
||||
}
|
||||
if(isset($map['real_amount'])){
|
||||
$model->realAmount = $map['real_amount'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $fundChannel;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $bankCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $amount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $realAmount;
|
||||
|
||||
}
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\FaceToFace\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class VoucherDetail extends Model {
|
||||
protected $_name = [
|
||||
'id' => 'id',
|
||||
'name' => 'name',
|
||||
'type' => 'type',
|
||||
'amount' => 'amount',
|
||||
'merchantContribute' => 'merchant_contribute',
|
||||
'otherContribute' => 'other_contribute',
|
||||
'memo' => 'memo',
|
||||
'templateId' => 'template_id',
|
||||
'purchaseBuyerContribute' => 'purchase_buyer_contribute',
|
||||
'purchaseMerchantContribute' => 'purchase_merchant_contribute',
|
||||
'purchaseAntContribute' => 'purchase_ant_contribute',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('id', $this->id, true);
|
||||
Model::validateRequired('name', $this->name, true);
|
||||
Model::validateRequired('type', $this->type, true);
|
||||
Model::validateRequired('amount', $this->amount, true);
|
||||
Model::validateRequired('merchantContribute', $this->merchantContribute, true);
|
||||
Model::validateRequired('otherContribute', $this->otherContribute, true);
|
||||
Model::validateRequired('memo', $this->memo, true);
|
||||
Model::validateRequired('templateId', $this->templateId, true);
|
||||
Model::validateRequired('purchaseBuyerContribute', $this->purchaseBuyerContribute, true);
|
||||
Model::validateRequired('purchaseMerchantContribute', $this->purchaseMerchantContribute, true);
|
||||
Model::validateRequired('purchaseAntContribute', $this->purchaseAntContribute, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->id) {
|
||||
$res['id'] = $this->id;
|
||||
}
|
||||
if (null !== $this->name) {
|
||||
$res['name'] = $this->name;
|
||||
}
|
||||
if (null !== $this->type) {
|
||||
$res['type'] = $this->type;
|
||||
}
|
||||
if (null !== $this->amount) {
|
||||
$res['amount'] = $this->amount;
|
||||
}
|
||||
if (null !== $this->merchantContribute) {
|
||||
$res['merchant_contribute'] = $this->merchantContribute;
|
||||
}
|
||||
if (null !== $this->otherContribute) {
|
||||
$res['other_contribute'] = $this->otherContribute;
|
||||
}
|
||||
if (null !== $this->memo) {
|
||||
$res['memo'] = $this->memo;
|
||||
}
|
||||
if (null !== $this->templateId) {
|
||||
$res['template_id'] = $this->templateId;
|
||||
}
|
||||
if (null !== $this->purchaseBuyerContribute) {
|
||||
$res['purchase_buyer_contribute'] = $this->purchaseBuyerContribute;
|
||||
}
|
||||
if (null !== $this->purchaseMerchantContribute) {
|
||||
$res['purchase_merchant_contribute'] = $this->purchaseMerchantContribute;
|
||||
}
|
||||
if (null !== $this->purchaseAntContribute) {
|
||||
$res['purchase_ant_contribute'] = $this->purchaseAntContribute;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return VoucherDetail
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['id'])){
|
||||
$model->id = $map['id'];
|
||||
}
|
||||
if(isset($map['name'])){
|
||||
$model->name = $map['name'];
|
||||
}
|
||||
if(isset($map['type'])){
|
||||
$model->type = $map['type'];
|
||||
}
|
||||
if(isset($map['amount'])){
|
||||
$model->amount = $map['amount'];
|
||||
}
|
||||
if(isset($map['merchant_contribute'])){
|
||||
$model->merchantContribute = $map['merchant_contribute'];
|
||||
}
|
||||
if(isset($map['other_contribute'])){
|
||||
$model->otherContribute = $map['other_contribute'];
|
||||
}
|
||||
if(isset($map['memo'])){
|
||||
$model->memo = $map['memo'];
|
||||
}
|
||||
if(isset($map['template_id'])){
|
||||
$model->templateId = $map['template_id'];
|
||||
}
|
||||
if(isset($map['purchase_buyer_contribute'])){
|
||||
$model->purchaseBuyerContribute = $map['purchase_buyer_contribute'];
|
||||
}
|
||||
if(isset($map['purchase_merchant_contribute'])){
|
||||
$model->purchaseMerchantContribute = $map['purchase_merchant_contribute'];
|
||||
}
|
||||
if(isset($map['purchase_ant_contribute'])){
|
||||
$model->purchaseAntContribute = $map['purchase_ant_contribute'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $amount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $merchantContribute;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $otherContribute;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $memo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $templateId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $purchaseBuyerContribute;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $purchaseMerchantContribute;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $purchaseAntContribute;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Huabei;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Payment\Huabei\Models\HuabeiConfig;
|
||||
use Alipay\EasySDK\Payment\Huabei\Models\AlipayTradeCreateResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subject
|
||||
* @param string $outTradeNo
|
||||
* @param string $totalAmount
|
||||
* @param string $buyerId
|
||||
* @param HuabeiConfig $extendParams
|
||||
* @return AlipayTradeCreateResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function create($subject, $outTradeNo, $totalAmount, $buyerId, $extendParams){
|
||||
$extendParams->validate();
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.create",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"subject" => $subject,
|
||||
"out_trade_no" => $outTradeNo,
|
||||
"total_amount" => $totalAmount,
|
||||
"buyer_id" => $buyerId,
|
||||
"extend_params" => $extendParams
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.trade.create");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayTradeCreateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayTradeCreateResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Huabei\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayTradeCreateResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'outTradeNo' => 'out_trade_no',
|
||||
'tradeNo' => 'trade_no',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('outTradeNo', $this->outTradeNo, true);
|
||||
Model::validateRequired('tradeNo', $this->tradeNo, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->outTradeNo) {
|
||||
$res['out_trade_no'] = $this->outTradeNo;
|
||||
}
|
||||
if (null !== $this->tradeNo) {
|
||||
$res['trade_no'] = $this->tradeNo;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradeCreateResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['out_trade_no'])){
|
||||
$model->outTradeNo = $map['out_trade_no'];
|
||||
}
|
||||
if(isset($map['trade_no'])){
|
||||
$model->tradeNo = $map['trade_no'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $outTradeNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tradeNo;
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Huabei\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class HuabeiConfig extends Model {
|
||||
protected $_name = [
|
||||
'hbFqNum' => 'hb_fq_num',
|
||||
'hbFqSellerPercent' => 'hb_fq_seller_percent',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('hbFqNum', $this->hbFqNum, true);
|
||||
Model::validateRequired('hbFqSellerPercent', $this->hbFqSellerPercent, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->hbFqNum) {
|
||||
$res['hb_fq_num'] = $this->hbFqNum;
|
||||
}
|
||||
if (null !== $this->hbFqSellerPercent) {
|
||||
$res['hb_fq_seller_percent'] = $this->hbFqSellerPercent;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return HuabeiConfig
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['hb_fq_num'])){
|
||||
$model->hbFqNum = $map['hb_fq_num'];
|
||||
}
|
||||
if(isset($map['hb_fq_seller_percent'])){
|
||||
$model->hbFqSellerPercent = $map['hb_fq_seller_percent'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $hbFqNum;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $hbFqSellerPercent;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Page;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
|
||||
use Alipay\EasySDK\Payment\Page\Models\AlipayTradePagePayResponse;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subject
|
||||
* @param string $outTradeNo
|
||||
* @param string $totalAmount
|
||||
* @param string $returnUrl
|
||||
* @return AlipayTradePagePayResponse
|
||||
*/
|
||||
public function pay($subject, $outTradeNo, $totalAmount, $returnUrl){
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.page.pay",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"subject" => $subject,
|
||||
"out_trade_no" => $outTradeNo,
|
||||
"total_amount" => $totalAmount,
|
||||
"product_code" => "FAST_INSTANT_TRADE_PAY"
|
||||
];
|
||||
$textParams = [
|
||||
"return_url" => $returnUrl
|
||||
];
|
||||
$sign = $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"));
|
||||
$response = [
|
||||
"body" => $this->_kernel->generatePage("POST", $systemParams, $bizParams, $textParams, $sign)
|
||||
];
|
||||
return AlipayTradePagePayResponse::fromMap($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Page\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayTradePagePayResponse extends Model {
|
||||
protected $_name = [
|
||||
'body' => 'body',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('body', $this->body, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->body) {
|
||||
$res['body'] = $this->body;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradePagePayResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['body'])){
|
||||
$model->body = $map['body'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 订单信息,Form表单形式
|
||||
* @var string
|
||||
*/
|
||||
public $body;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Wap;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
|
||||
use Alipay\EasySDK\Payment\Wap\Models\AlipayTradeWapPayResponse;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subject
|
||||
* @param string $outTradeNo
|
||||
* @param string $totalAmount
|
||||
* @param string $quitUrl
|
||||
* @param string $returnUrl
|
||||
* @return AlipayTradeWapPayResponse
|
||||
*/
|
||||
public function pay($subject, $outTradeNo, $totalAmount, $quitUrl, $returnUrl){
|
||||
$systemParams = [
|
||||
"method" => "alipay.trade.wap.pay",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"subject" => $subject,
|
||||
"out_trade_no" => $outTradeNo,
|
||||
"total_amount" => $totalAmount,
|
||||
"quit_url" => $quitUrl,
|
||||
"product_code" => "QUICK_WAP_WAY"
|
||||
];
|
||||
$textParams = [
|
||||
"return_url" => $returnUrl
|
||||
];
|
||||
$sign = $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"));
|
||||
$response = [
|
||||
"body" => $this->_kernel->generatePage("POST", $systemParams, $bizParams, $textParams, $sign)
|
||||
];
|
||||
return AlipayTradeWapPayResponse::fromMap($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Payment\Wap\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayTradeWapPayResponse extends Model {
|
||||
protected $_name = [
|
||||
'body' => 'body',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('body', $this->body, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->body) {
|
||||
$res['body'] = $this->body;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayTradeWapPayResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['body'])){
|
||||
$model->body = $map['body'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 订单信息,Form表单形式
|
||||
* @var string
|
||||
*/
|
||||
public $body;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Security\TextRisk;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Security\TextRisk\Models\AlipaySecurityRiskContentDetectResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
* @return AlipaySecurityRiskContentDetectResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function detect($content){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => "alipay.security.risk.content.detect",
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$bizParams = [
|
||||
"content" => $content
|
||||
];
|
||||
$textParams = [];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, "alipay.security.risk.content.detect");
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipaySecurityRiskContentDetectResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipaySecurityRiskContentDetectResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Security\TextRisk\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipaySecurityRiskContentDetectResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
'action' => 'action',
|
||||
'keywords' => 'keywords',
|
||||
'uniqueId' => 'unique_id',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
Model::validateRequired('action', $this->action, true);
|
||||
Model::validateRequired('keywords', $this->keywords, true);
|
||||
Model::validateRequired('uniqueId', $this->uniqueId, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
if (null !== $this->action) {
|
||||
$res['action'] = $this->action;
|
||||
}
|
||||
if (null !== $this->keywords) {
|
||||
$res['keywords'] = $this->keywords;
|
||||
}
|
||||
if (null !== $this->uniqueId) {
|
||||
$res['unique_id'] = $this->uniqueId;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipaySecurityRiskContentDetectResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
if(isset($map['action'])){
|
||||
$model->action = $map['action'];
|
||||
}
|
||||
if(isset($map['keywords'])){
|
||||
if(!empty($map['keywords'])){
|
||||
$model->keywords = $map['keywords'];
|
||||
}
|
||||
}
|
||||
if(isset($map['unique_id'])){
|
||||
$model->uniqueId = $map['unique_id'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $action;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $keywords;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $uniqueId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Util\AES;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cipherText
|
||||
* @return string
|
||||
*/
|
||||
public function decrypt($cipherText){
|
||||
return $this->_kernel->aesDecrypt($cipherText, $this->_kernel->getConfig("encryptKey"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $plainText
|
||||
* @return string
|
||||
*/
|
||||
public function encrypt($plainText){
|
||||
return $this->_kernel->aesEncrypt($plainText, $this->_kernel->getConfig("encryptKey"));
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Util\Generic;
|
||||
|
||||
use Alipay\EasySDK\Kernel\EasySDKKernel;
|
||||
use AlibabaCloud\Tea\Tea;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use \Exception;
|
||||
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
||||
|
||||
use Alipay\EasySDK\Util\Generic\Models\AlipayOpenApiGenericResponse;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
use Alipay\EasySDK\Util\Generic\Models\AlipayOpenApiGenericSDKResponse;
|
||||
|
||||
class Client {
|
||||
protected $_kernel;
|
||||
|
||||
public function __construct($kernel){
|
||||
$this->_kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param string[] $textParams
|
||||
* @param mixed[] $bizParams
|
||||
* @return AlipayOpenApiGenericResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function execute($method, $textParams, $bizParams){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 15000,
|
||||
"readTimeout" => 15000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => $method,
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => "application/x-www-form-urlencoded;charset=utf-8"
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toUrlEncodedRequestBody($bizParams);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, $method);
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenApiGenericResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenApiGenericResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param string[] $textParams
|
||||
* @param mixed[] $bizParams
|
||||
* @param string[] $fileParams
|
||||
* @return AlipayOpenApiGenericResponse
|
||||
* @throws TeaError
|
||||
* @throws Exception
|
||||
* @throws TeaUnableRetryError
|
||||
*/
|
||||
public function fileExecute($method, $textParams, $bizParams, $fileParams){
|
||||
$_runtime = [
|
||||
"ignoreSSL" => $this->_kernel->getConfig("ignoreSSL"),
|
||||
"httpProxy" => $this->_kernel->getConfig("httpProxy"),
|
||||
"connectTimeout" => 100000,
|
||||
"readTimeout" => 100000,
|
||||
"retry" => [
|
||||
"maxAttempts" => 0
|
||||
]
|
||||
];
|
||||
$_lastRequest = null;
|
||||
$_lastException = null;
|
||||
$_now = time();
|
||||
$_retryTimes = 0;
|
||||
while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) {
|
||||
if ($_retryTimes > 0) {
|
||||
$_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes);
|
||||
if ($_backoffTime > 0) {
|
||||
Tea::sleep($_backoffTime);
|
||||
}
|
||||
}
|
||||
$_retryTimes = $_retryTimes + 1;
|
||||
try {
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => $method,
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$boundary = $this->_kernel->getRandomBoundary();
|
||||
$_request->protocol = $this->_kernel->getConfig("protocol");
|
||||
$_request->method = "POST";
|
||||
$_request->pathname = "/gateway.do";
|
||||
$_request->headers = [
|
||||
"host" => $this->_kernel->getConfig("gatewayHost"),
|
||||
"content-type" => $this->_kernel->concatStr("multipart/form-data;charset=utf-8;boundary=", $boundary)
|
||||
];
|
||||
$_request->query = $this->_kernel->sortMap(Tea::merge([
|
||||
"sign" => $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"))
|
||||
], $systemParams, $textParams));
|
||||
$_request->body = $this->_kernel->toMultipartRequestBody($textParams, $fileParams, $boundary);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request, $_runtime);
|
||||
$respMap = $this->_kernel->readAsJson($_response, $method);
|
||||
if ($this->_kernel->isCertMode()) {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->extractAlipayPublicKey($this->_kernel->getAlipayCertSN($respMap)))) {
|
||||
return AlipayOpenApiGenericResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_kernel->verify($respMap, $this->_kernel->getConfig("alipayPublicKey"))) {
|
||||
return AlipayOpenApiGenericResponse::fromMap($this->_kernel->toRespModel($respMap));
|
||||
}
|
||||
}
|
||||
throw new TeaError([
|
||||
"message" => "验签失败,请检查支付宝公钥设置是否正确。"
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (!($e instanceof TeaError)) {
|
||||
$e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
if (Tea::isRetryable($e)) {
|
||||
$_lastException = $e;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
throw new TeaUnableRetryError($_lastRequest, $_lastException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param string[] $textParams
|
||||
* @param mixed[] $bizParams
|
||||
* @return AlipayOpenApiGenericSDKResponse
|
||||
*/
|
||||
public function sdkExecute($method, $textParams, $bizParams){
|
||||
$_request = new Request();
|
||||
$systemParams = [
|
||||
"method" => $method,
|
||||
"app_id" => $this->_kernel->getConfig("appId"),
|
||||
"timestamp" => $this->_kernel->getTimestamp(),
|
||||
"format" => "json",
|
||||
"version" => "1.0",
|
||||
"alipay_sdk" => $this->_kernel->getSdkVersion(),
|
||||
"charset" => "UTF-8",
|
||||
"sign_type" => $this->_kernel->getConfig("signType"),
|
||||
"app_cert_sn" => $this->_kernel->getMerchantCertSN(),
|
||||
"alipay_root_cert_sn" => $this->_kernel->getAlipayRootCertSN()
|
||||
];
|
||||
$sign = $this->_kernel->sign($systemParams, $bizParams, $textParams, $this->_kernel->getConfig("merchantPrivateKey"));
|
||||
$response = [
|
||||
"body" => $this->_kernel->generateOrderString($systemParams, $bizParams, $textParams, $sign)
|
||||
];
|
||||
return AlipayOpenApiGenericSDKResponse::fromMap($response);
|
||||
$_lastRequest = $_request;
|
||||
$_response= Tea::send($_request);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISV代商户代用,指定appAuthToken
|
||||
*
|
||||
* @param $appAuthToken String 代调用token
|
||||
* @return $this 本客户端,便于链式调用
|
||||
*/
|
||||
public function agent($appAuthToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("app_auth_token", $appAuthToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权调用,指定authToken
|
||||
*
|
||||
* @param $authToken String 用户授权token
|
||||
* @return $this
|
||||
*/
|
||||
public function auth($authToken)
|
||||
{
|
||||
$this->_kernel->injectTextParam("auth_token", $authToken);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
|
||||
*
|
||||
* @param $url String 异步通知回调地址,例如:https://www.test.com/callback
|
||||
* @return $this
|
||||
*/
|
||||
public function asyncNotify($url)
|
||||
{
|
||||
$this->_kernel->injectTextParam("notify_url", $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
|
||||
*
|
||||
* @param $testUrl String 后端系统测试地址
|
||||
* @return $this
|
||||
*/
|
||||
public function route($testUrl)
|
||||
{
|
||||
$this->_kernel->injectTextParam("ws_service_url", $testUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
*
|
||||
* @param $key String 业务请求参数名称(biz_content下的字段名,比如timeout_express)
|
||||
* @param $value object 业务请求参数的值,一个可以序列化成JSON的对象
|
||||
* 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用String储存
|
||||
* 如果该字段是一个数值型类型(比如:Number),请使用Long储存
|
||||
* 如果该字段是一个复杂类型,请使用嵌套的array指定各下级字段的值
|
||||
* 如果该字段是一个数组,请使用array储存各个值
|
||||
* @return $this
|
||||
*/
|
||||
public function optional($key, $value)
|
||||
{
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
|
||||
* optional方法的批量版本
|
||||
*
|
||||
* @param $optionalArgs array 可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释
|
||||
* @return $this
|
||||
*/
|
||||
public function batchOptional($optionalArgs)
|
||||
{
|
||||
foreach ($optionalArgs as $key => $value) {
|
||||
$this->_kernel->injectBizParam($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Util\Generic\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOpenApiGenericResponse extends Model {
|
||||
protected $_name = [
|
||||
'httpBody' => 'http_body',
|
||||
'code' => 'code',
|
||||
'msg' => 'msg',
|
||||
'subCode' => 'sub_code',
|
||||
'subMsg' => 'sub_msg',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('httpBody', $this->httpBody, true);
|
||||
Model::validateRequired('code', $this->code, true);
|
||||
Model::validateRequired('msg', $this->msg, true);
|
||||
Model::validateRequired('subCode', $this->subCode, true);
|
||||
Model::validateRequired('subMsg', $this->subMsg, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->httpBody) {
|
||||
$res['http_body'] = $this->httpBody;
|
||||
}
|
||||
if (null !== $this->code) {
|
||||
$res['code'] = $this->code;
|
||||
}
|
||||
if (null !== $this->msg) {
|
||||
$res['msg'] = $this->msg;
|
||||
}
|
||||
if (null !== $this->subCode) {
|
||||
$res['sub_code'] = $this->subCode;
|
||||
}
|
||||
if (null !== $this->subMsg) {
|
||||
$res['sub_msg'] = $this->subMsg;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOpenApiGenericResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['http_body'])){
|
||||
$model->httpBody = $map['http_body'];
|
||||
}
|
||||
if(isset($map['code'])){
|
||||
$model->code = $map['code'];
|
||||
}
|
||||
if(isset($map['msg'])){
|
||||
$model->msg = $map['msg'];
|
||||
}
|
||||
if(isset($map['sub_code'])){
|
||||
$model->subCode = $map['sub_code'];
|
||||
}
|
||||
if(isset($map['sub_msg'])){
|
||||
$model->subMsg = $map['sub_msg'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 响应原始字符串
|
||||
* @var string
|
||||
*/
|
||||
public $httpBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $subMsg;
|
||||
|
||||
}
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace Alipay\EasySDK\Util\Generic\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class AlipayOpenApiGenericSDKResponse extends Model {
|
||||
protected $_name = [
|
||||
'body' => 'body',
|
||||
];
|
||||
public function validate() {
|
||||
Model::validateRequired('body', $this->body, true);
|
||||
}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->body) {
|
||||
$res['body'] = $this->body;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return AlipayOpenApiGenericSDKResponse
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['body'])){
|
||||
$model->body = $map['body'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description 订单信息,字符串形式
|
||||
* @var string
|
||||
*/
|
||||
public $body;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user