添加网站文件

This commit is contained in:
2025-12-22 13:59:40 +08:00
commit 117aaf83d1
19468 changed files with 2111999 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AlipayEasySDK", "AlipayEasySDK\AlipayEasySDK.csproj", "{14B089B9-C61C-46E6-BD93-5DFBBB77E2B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.csproj", "{79DE080D-34C1-485E-996D-435A8515766D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{14B089B9-C61C-46E6-BD93-5DFBBB77E2B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14B089B9-C61C-46E6-BD93-5DFBBB77E2B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14B089B9-C61C-46E6-BD93-5DFBBB77E2B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14B089B9-C61C-46E6-BD93-5DFBBB77E2B2}.Release|Any CPU.Build.0 = Release|Any CPU
{79DE080D-34C1-485E-996D-435A8515766D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{79DE080D-34C1-485E-996D-435A8515766D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{79DE080D-34C1-485E-996D-435A8515766D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{79DE080D-34C1-485E-996D-435A8515766D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<PackOnBuild>true</PackOnBuild>
<PackageVersion>2.1.2</PackageVersion>
<Authors>antopen</Authors>
<NeutralLanguage>zh</NeutralLanguage>
<PackageLicenseUrl>https://github.com/alipay/alipay-easysdk/blob/master/LICENSE</PackageLicenseUrl>
<Description>Alipay Easy SDK for .NET allows you to enjoy a minimalist programming experience and quickly access the various high-frequency capabilities of the Alipay Open Platform.</Description>
<PackageId>AlipayEasySDK</PackageId>
<Owners>antopen</Owners>
<PackageProjectUrl>https://github.com/alipay/alipay-easysdk/tree/master/csharp</PackageProjectUrl>
<Summary>Alipay Easy SDK for .NET allows you to enjoy a minimalist programming experience and quickly access the various high-frequency capabilities of the Alipay Open Platform.</Summary>
<Title>Alipay Easy SDK</Title>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType></DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Class1.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Factory\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AlipayEasySDK.Kernel" Version="1.0.5" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,324 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Base.Image.Models;
namespace Alipay.EasySDK.Base.Image
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayOfflineMaterialImageUploadResponse Upload(string imageName, string imageFilePath)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 100000},
{"readTimeout", 100000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"image_type", "jpg"},
{"image_name", imageName},
};
Dictionary<string, string> fileParams = new Dictionary<string, string>
{
{"image_content", imageFilePath},
};
string boundary = this._kernel.GetRandomBoundary();
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", this._kernel.ConcatStr("multipart/form-data;charset=utf-8;boundary=", boundary)},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams
));
request_.Body = this._kernel.ToMultipartRequestBody(textParams, fileParams, boundary);
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayOfflineMaterialImageUploadResponse> UploadAsync(string imageName, string imageFilePath)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 100000},
{"readTimeout", 100000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"image_type", "jpg"},
{"image_name", imageName},
};
Dictionary<string, string> fileParams = new Dictionary<string, string>
{
{"image_content", imageFilePath},
};
string boundary = this._kernel.GetRandomBoundary();
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", this._kernel.ConcatStr("multipart/form-data;charset=utf-8;boundary=", boundary)},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams
));
request_.Body = this._kernel.ToMultipartRequestBody(textParams, fileParams, boundary);
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.offline.material.image.upload");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Base.Image.Models
{
public class AlipayOfflineMaterialImageUploadResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("image_id")]
[Validation(Required=true)]
public string ImageId { get; set; }
[NameInMap("image_url")]
[Validation(Required=true)]
public string ImageUrl { get; set; }
}
}

View File

@@ -0,0 +1,528 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Base.OAuth.Models;
namespace Alipay.EasySDK.Base.OAuth
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipaySystemOauthTokenResponse GetToken(string code)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"grant_type", "authorization_code"},
{"code", code},
};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipaySystemOauthTokenResponse> GetTokenAsync(string code)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"grant_type", "authorization_code"},
{"code", code},
};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.system.oauth.token");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipaySystemOauthTokenResponse RefreshToken(string refreshToken)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"grant_type", "refresh_token"},
{"refresh_token", refreshToken},
};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipaySystemOauthTokenResponse> RefreshTokenAsync(string refreshToken)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"grant_type", "refresh_token"},
{"refresh_token", refreshToken},
};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.system.oauth.token");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,57 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Base.OAuth.Models
{
public class AlipaySystemOauthTokenResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("user_id")]
[Validation(Required=true)]
public string UserId { get; set; }
[NameInMap("access_token")]
[Validation(Required=true)]
public string AccessToken { get; set; }
[NameInMap("expires_in")]
[Validation(Required=true)]
public long ExpiresIn { get; set; }
[NameInMap("refresh_token")]
[Validation(Required=true)]
public string RefreshToken { get; set; }
[NameInMap("re_expires_in")]
[Validation(Required=true)]
public long ReExpiresIn { get; set; }
}
}

View File

@@ -0,0 +1,318 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Base.Qrcode.Models;
namespace Alipay.EasySDK.Base.Qrcode
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayOpenAppQrcodeCreateResponse Create(string urlParam, string queryParam, string describe)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"url_param", urlParam},
{"query_param", queryParam},
{"describe", describe},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayOpenAppQrcodeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenAppQrcodeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayOpenAppQrcodeCreateResponse> CreateAsync(string urlParam, string queryParam, string describe)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"url_param", urlParam},
{"query_param", queryParam},
{"describe", describe},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.open.app.qrcode.create");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOpenAppQrcodeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenAppQrcodeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,41 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Base.Qrcode.Models
{
public class AlipayOpenAppQrcodeCreateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("qr_code_url")]
[Validation(Required=true)]
public string QrCodeUrl { get; set; }
}
}

View File

@@ -0,0 +1,324 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Base.Video.Models;
namespace Alipay.EasySDK.Base.Video
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayOfflineMaterialImageUploadResponse Upload(string videoName, string videoFilePath)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 100000},
{"readTimeout", 100000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"image_type", "mp4"},
{"image_name", videoName},
};
Dictionary<string, string> fileParams = new Dictionary<string, string>
{
{"image_content", videoFilePath},
};
string boundary = this._kernel.GetRandomBoundary();
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", this._kernel.ConcatStr("multipart/form-data;charset=utf-8;boundary=", boundary)},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams
));
request_.Body = this._kernel.ToMultipartRequestBody(textParams, fileParams, boundary);
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayOfflineMaterialImageUploadResponse> UploadAsync(string videoName, string videoFilePath)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 100000},
{"readTimeout", 100000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"image_type", "mp4"},
{"image_name", videoName},
};
Dictionary<string, string> fileParams = new Dictionary<string, string>
{
{"image_content", videoFilePath},
};
string boundary = this._kernel.GetRandomBoundary();
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", this._kernel.ConcatStr("multipart/form-data;charset=utf-8;boundary=", boundary)},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams
));
request_.Body = this._kernel.ToMultipartRequestBody(textParams, fileParams, boundary);
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.offline.material.image.upload");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Base.Video.Models
{
public class AlipayOfflineMaterialImageUploadResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("image_id")]
[Validation(Required=true)]
public string ImageId { get; set; }
[NameInMap("image_url")]
[Validation(Required=true)]
public string ImageUrl { get; set; }
}
}

View File

@@ -0,0 +1,244 @@
using System;
using Alipay.EasySDK.Kernel;
using System.Reflection;
namespace Alipay.EasySDK.Factory
{
/// <summary>
/// 客户端工厂用于快速配置和访问各种场景下的API Client
///
/// 注该Factory获取的Client不可储存重复使用请每次均通过Factory完成调用
/// </summary>
public static class Factory
{
public const string SDK_VERSION = "alipay-easysdk-net-2.1.0";
/// <summary>
/// 将一些初始化耗时较多的信息缓存在上下文中
/// </summary>
private static Context context;
/// <summary>
/// 设置客户端参数只需设置一次即可反复使用各种场景下的API Client
/// </summary>
/// <param name="options">客户端参数对象</param>
public static void SetOptions(Config options)
{
context = new Context(options, SDK_VERSION);
}
/// <summary>
/// 获取调用OpenAPI所需的客户端实例
/// 本方法用于调用SDK扩展包中的API Client下的方法
///
/// 注:返回的实例不可重复使用,只可用于单次调用
/// </summary>
/// <typeparam name="T">泛型参数</typeparam>
/// <param name="client">API Client的类型对象</param>
/// <returns>client实例用于发起单次调用</returns>
public static T GetClient<T>()
{
Type type = typeof(T);
ConstructorInfo constructor = type.GetConstructor(new Type[] { typeof(Client) });
context.SdkVersion = GetSdkVersion(type);
return (T)constructor.Invoke(new object[] { new Client(context) });
}
private static string GetSdkVersion(Type client)
{
return context.SdkVersion + "-" + client.FullName
.Replace("EasySDK.", "")
.Replace(".Client", "")
.Replace(".", "-");
}
/// <summary>
/// 基础能力相关
/// </summary>
public static class Base
{
/// <summary>
/// 获取图片相关API Client
/// </summary>
/// <returns>图片相关API Client</returns>
public static EasySDK.Base.Image.Client Image()
{
return new EasySDK.Base.Image.Client(new Client(context));
}
/// <summary>
/// 获取视频相关API Client
/// </summary>
/// <returns>视频相关API Client</returns>
public static EasySDK.Base.Video.Client Video()
{
return new EasySDK.Base.Video.Client(new Client(context));
}
/// <summary>
/// 获取OAuth认证相关API Client
/// </summary>
/// <returns>OAuth认证相关API Client</returns>
public static EasySDK.Base.OAuth.Client OAuth()
{
return new EasySDK.Base.OAuth.Client(new Client(context));
}
/// <summary>
/// 获取小程序二维码相关API Client
/// </summary>
/// <returns>小程序二维码相关API Client</returns>
public static EasySDK.Base.Qrcode.Client Qrcode()
{
return new EasySDK.Base.Qrcode.Client(new Client(context));
}
}
/// <summary>
/// 营销能力相关
/// </summary>
public static class Marketing
{
/// <summary>
/// 获取生活号相关API Client
/// </summary>
/// <returns>生活号相关API Client</returns>
public static EasySDK.Marketing.OpenLife.Client OpenLife()
{
return new EasySDK.Marketing.OpenLife.Client(new Client(context));
}
/// <summary>
/// 获取支付宝卡包相关API Client
/// </summary>
/// <returns>支付宝卡包相关API Client</returns>
public static EasySDK.Marketing.Pass.Client Pass()
{
return new EasySDK.Marketing.Pass.Client(new Client(context));
}
/// <summary>
/// 获取小程序模板消息相关API Client
/// </summary>
/// <returns>小程序模板消息相关API Client</returns>
public static EasySDK.Marketing.TemplateMessage.Client TemplateMessage()
{
return new EasySDK.Marketing.TemplateMessage.Client(new Client(context));
}
}
/// <summary>
/// 会员能力相关
/// </summary>
public static class Member
{
/// <summary>
/// 获取支付宝身份认证相关API Client
/// </summary>
/// <returns>支付宝身份认证相关API Client</returns>
public static EasySDK.Member.Identification.Client Identification()
{
return new EasySDK.Member.Identification.Client(new Client(context));
}
}
/// <summary>
/// 支付能力相关
/// </summary>
public static class Payment
{
/// <summary>
/// 获取支付通用API Client
/// </summary>
/// <returns>支付通用API Client</returns>
public static EasySDK.Payment.Common.Client Common()
{
return new EasySDK.Payment.Common.Client(new Client(context));
}
/// <summary>
/// 获取当面付API Client
/// </summary>
/// <returns>当面付API Client</returns>
public static EasySDK.Payment.FaceToFace.Client FaceToFace()
{
return new EasySDK.Payment.FaceToFace.Client(new Client(context));
}
/// <summary>
/// 获取花呗API Client
/// </summary>
/// <returns>花呗API Client</returns>
public static EasySDK.Payment.Huabei.Client Huabei()
{
return new EasySDK.Payment.Huabei.Client(new Client(context));
}
/// <summary>
/// 获取手机APP支付API Client
/// </summary>
/// <returns>手机APP支付API Client</returns>
public static EasySDK.Payment.App.Client App()
{
return new EasySDK.Payment.App.Client(new Client(context));
}
/// <summary>
/// 获取电脑网站支付API Client
/// </summary>
/// <returns>电脑网站支付API</returns>
public static EasySDK.Payment.Page.Client Page()
{
return new EasySDK.Payment.Page.Client(new Client(context));
}
/// <summary>
/// 获取手机网站支付API Client
/// </summary>
/// <returns>手机网站支付API</returns>
public static EasySDK.Payment.Wap.Client Wap()
{
return new EasySDK.Payment.Wap.Client(new Client(context));
}
}
/// <summary>
/// 安全能力相关
/// </summary>
public static class Security
{
/// <summary>
/// 获取文本风险识别相关API Client
/// </summary>
/// <returns>文本风险识别相关API Client</returns>
public static EasySDK.Security.TextRisk.Client TextRisk()
{
return new EasySDK.Security.TextRisk.Client(new Client(context));
}
}
/// <summary>
/// 辅助工具
/// </summary>
public static class Util
{
/// <summary>
/// 获取OpenAPI通用接口可通过自行拼装参数调用几乎所有OpenAPI
/// </summary>
/// <returns>OpenAPI通用接口</returns>
public static EasySDK.Util.Generic.Client Generic()
{
return new EasySDK.Util.Generic.Client(new Client(context));
}
/// <summary>
/// 获取AES128加解密相关API Client常用于会员手机号的解密
/// </summary>
/// <returns>AES128加解密相关API Client</returns>
public static EasySDK.Util.AES.Client AES()
{
return new EasySDK.Util.AES.Client(new Client(context));
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicLifeMsgRecallResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicMessageContentCreateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("content_id")]
[Validation(Required=true)]
public string ContentId { get; set; }
[NameInMap("content_url")]
[Validation(Required=true)]
public string ContentUrl { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicMessageContentModifyResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("content_id")]
[Validation(Required=true)]
public string ContentId { get; set; }
[NameInMap("content_url")]
[Validation(Required=true)]
public string ContentUrl { get; set; }
}
}

View File

@@ -0,0 +1,37 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicMessageSingleSendResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
}
}

View File

@@ -0,0 +1,41 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicMessageTotalSendResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("message_id")]
[Validation(Required=true)]
public string MessageId { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicSettingCategoryQueryResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("primary_category")]
[Validation(Required=true)]
public string PrimaryCategory { get; set; }
[NameInMap("secondary_category")]
[Validation(Required=true)]
public string SecondaryCategory { get; set; }
}
}

View File

@@ -0,0 +1,37 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicTemplateMessageIndustryModifyResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
}
}

View File

@@ -0,0 +1,34 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class Article : TeaModel {
[NameInMap("title")]
[Validation(Required=false)]
public string Title { get; set; }
[NameInMap("desc")]
[Validation(Required=true)]
public string Desc { get; set; }
[NameInMap("image_url")]
[Validation(Required=false)]
public string ImageUrl { get; set; }
[NameInMap("url")]
[Validation(Required=true)]
public string Url { get; set; }
[NameInMap("action_name")]
[Validation(Required=false)]
public string ActionName { get; set; }
}
}

View File

@@ -0,0 +1,42 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class Context : TeaModel {
[NameInMap("head_color")]
[Validation(Required=true)]
public string HeadColor { get; set; }
[NameInMap("url")]
[Validation(Required=true)]
public string Url { get; set; }
[NameInMap("action_name")]
[Validation(Required=true)]
public string ActionName { get; set; }
[NameInMap("keyword1")]
[Validation(Required=false)]
public Keyword Keyword1 { get; set; }
[NameInMap("keyword2")]
[Validation(Required=false)]
public Keyword Keyword2 { get; set; }
[NameInMap("first")]
[Validation(Required=false)]
public Keyword First { get; set; }
[NameInMap("remark")]
[Validation(Required=false)]
public Keyword Remark { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class Keyword : TeaModel {
[NameInMap("color")]
[Validation(Required=true)]
public string Color { get; set; }
[NameInMap("value")]
[Validation(Required=true)]
public string Value { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class Template : TeaModel {
[NameInMap("template_id")]
[Validation(Required=true)]
public string TemplateId { get; set; }
[NameInMap("context")]
[Validation(Required=true)]
public Context Context { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class Text : TeaModel {
[NameInMap("title")]
[Validation(Required=true)]
public string Title { get; set; }
[NameInMap("content")]
[Validation(Required=true)]
public string Content { get; set; }
}
}

View File

@@ -0,0 +1,964 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Marketing.Pass.Models;
namespace Alipay.EasySDK.Marketing.Pass
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayPassTemplateAddResponse CreateTemplate(string uniqueId, string tplContent)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"unique_id", uniqueId},
{"tpl_content", tplContent},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayPassTemplateAddResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassTemplateAddResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayPassTemplateAddResponse> CreateTemplateAsync(string uniqueId, string tplContent)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"unique_id", uniqueId},
{"tpl_content", tplContent},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.pass.template.add");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassTemplateAddResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassTemplateAddResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayPassTemplateUpdateResponse UpdateTemplate(string tplId, string tplContent)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"tpl_id", tplId},
{"tpl_content", tplContent},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayPassTemplateUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassTemplateUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayPassTemplateUpdateResponse> UpdateTemplateAsync(string tplId, string tplContent)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"tpl_id", tplId},
{"tpl_content", tplContent},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.pass.template.update");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassTemplateUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassTemplateUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayPassInstanceAddResponse AddInstance(string tplId, string tplParams, string recognitionType, string recognitionInfo)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"tpl_id", tplId},
{"tpl_params", tplParams},
{"recognition_type", recognitionType},
{"recognition_info", recognitionInfo},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayPassInstanceAddResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassInstanceAddResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayPassInstanceAddResponse> AddInstanceAsync(string tplId, string tplParams, string recognitionType, string recognitionInfo)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"tpl_id", tplId},
{"tpl_params", tplParams},
{"recognition_type", recognitionType},
{"recognition_info", recognitionInfo},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.pass.instance.add");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassInstanceAddResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassInstanceAddResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayPassInstanceUpdateResponse UpdateInstance(string serialNumber, string channelId, string tplParams, string status, string verifyCode, string verifyType)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"serial_number", serialNumber},
{"channel_id", channelId},
{"tpl_params", tplParams},
{"status", status},
{"verify_code", verifyCode},
{"verify_type", verifyType},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayPassInstanceUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassInstanceUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayPassInstanceUpdateResponse> UpdateInstanceAsync(string serialNumber, string channelId, string tplParams, string status, string verifyCode, string verifyType)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"serial_number", serialNumber},
{"channel_id", channelId},
{"tpl_params", tplParams},
{"status", status},
{"verify_code", verifyCode},
{"verify_type", verifyType},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.pass.instance.update");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassInstanceUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassInstanceUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.Pass.Models
{
public class AlipayPassInstanceAddResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("success")]
[Validation(Required=true)]
public bool? Success { get; set; }
[NameInMap("result")]
[Validation(Required=true)]
public string Result { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.Pass.Models
{
public class AlipayPassInstanceUpdateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("success")]
[Validation(Required=true)]
public bool? Success { get; set; }
[NameInMap("result")]
[Validation(Required=true)]
public string Result { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.Pass.Models
{
public class AlipayPassTemplateAddResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("success")]
[Validation(Required=true)]
public bool? Success { get; set; }
[NameInMap("result")]
[Validation(Required=true)]
public string Result { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.Pass.Models
{
public class AlipayPassTemplateUpdateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("success")]
[Validation(Required=true)]
public bool? Success { get; set; }
[NameInMap("result")]
[Validation(Required=true)]
public string Result { get; set; }
}
}

View File

@@ -0,0 +1,322 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Marketing.TemplateMessage.Models;
namespace Alipay.EasySDK.Marketing.TemplateMessage
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayOpenAppMiniTemplatemessageSendResponse Send(string toUserId, string formId, string userTemplateId, string page, string data)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"to_user_id", toUserId},
{"form_id", formId},
{"user_template_id", userTemplateId},
{"page", page},
{"data", data},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayOpenAppMiniTemplatemessageSendResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenAppMiniTemplatemessageSendResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayOpenAppMiniTemplatemessageSendResponse> SendAsync(string toUserId, string formId, string userTemplateId, string page, string data)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"to_user_id", toUserId},
{"form_id", formId},
{"user_template_id", userTemplateId},
{"page", page},
{"data", data},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.open.app.mini.templatemessage.send");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOpenAppMiniTemplatemessageSendResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenAppMiniTemplatemessageSendResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,37 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.TemplateMessage.Models
{
public class AlipayOpenAppMiniTemplatemessageSendResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
}
}

View File

@@ -0,0 +1,562 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Member.Identification.Models;
namespace Alipay.EasySDK.Member.Identification
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayUserCertifyOpenInitializeResponse Init(string outerOrderNo, string bizCode, IdentityParam identityParam, MerchantConfig merchantConfig)
{
identityParam.Validate();
merchantConfig.Validate();
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"outer_order_no", outerOrderNo},
{"biz_code", bizCode},
{"identity_param", identityParam},
{"merchant_config", merchantConfig},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayUserCertifyOpenInitializeResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayUserCertifyOpenInitializeResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayUserCertifyOpenInitializeResponse> InitAsync(string outerOrderNo, string bizCode, IdentityParam identityParam, MerchantConfig merchantConfig)
{
identityParam.Validate();
merchantConfig.Validate();
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"outer_order_no", outerOrderNo},
{"biz_code", bizCode},
{"identity_param", identityParam},
{"merchant_config", merchantConfig},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.user.certify.open.initialize");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayUserCertifyOpenInitializeResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayUserCertifyOpenInitializeResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayUserCertifyOpenQueryResponse Query(string certifyId)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"certify_id", certifyId},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayUserCertifyOpenQueryResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayUserCertifyOpenQueryResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayUserCertifyOpenQueryResponse> QueryAsync(string certifyId)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"certify_id", certifyId},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.user.certify.open.query");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayUserCertifyOpenQueryResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayUserCertifyOpenQueryResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayUserCertifyOpenCertifyResponse Certify(string certifyId)
{
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"certify_id", certifyId},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
string sign = this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"));
Dictionary<string, string> response = new Dictionary<string, string>
{
{"body", this._kernel.GeneratePage("GET", systemParams, bizParams, textParams, sign)},
};
return TeaModel.ToObject<AlipayUserCertifyOpenCertifyResponse>(response);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,21 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Member.Identification.Models
{
public class AlipayUserCertifyOpenCertifyResponse : TeaModel {
/// <summary>
/// 认证服务请求地址
/// </summary>
[NameInMap("body")]
[Validation(Required=true)]
public string Body { get; set; }
}
}

View File

@@ -0,0 +1,41 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Member.Identification.Models
{
public class AlipayUserCertifyOpenInitializeResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("certify_id")]
[Validation(Required=true)]
public string CertifyId { get; set; }
}
}

View File

@@ -0,0 +1,49 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Member.Identification.Models
{
public class AlipayUserCertifyOpenQueryResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("passed")]
[Validation(Required=true)]
public string Passed { get; set; }
[NameInMap("identity_info")]
[Validation(Required=true)]
public string IdentityInfo { get; set; }
[NameInMap("material_info")]
[Validation(Required=true)]
public string MaterialInfo { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Member.Identification.Models
{
public class IdentityParam : TeaModel {
[NameInMap("identity_type")]
[Validation(Required=true)]
public string IdentityType { get; set; }
[NameInMap("cert_type")]
[Validation(Required=true)]
public string CertType { get; set; }
[NameInMap("cert_name")]
[Validation(Required=true)]
public string CertName { get; set; }
[NameInMap("cert_no")]
[Validation(Required=true)]
public string CertNo { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Member.Identification.Models
{
public class MerchantConfig : TeaModel {
[NameInMap("return_url")]
[Validation(Required=true)]
public string ReturnUrl { get; set; }
}
}

View File

@@ -0,0 +1,135 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Payment.App.Models;
namespace Alipay.EasySDK.Payment.App
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayTradeAppPayResponse Pay(string subject, string outTradeNo, string totalAmount)
{
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
string sign = this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"));
Dictionary<string, string> response = new Dictionary<string, string>
{
{"body", this._kernel.GenerateOrderString(systemParams, bizParams, textParams, sign)},
};
return TeaModel.ToObject<AlipayTradeAppPayResponse>(response);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,21 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.App.Models
{
public class AlipayTradeAppPayResponse : TeaModel {
/// <summary>
/// 订单信息,字符串形式
/// </summary>
[NameInMap("body")]
[Validation(Required=true)]
public string Body { get; set; }
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,41 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayDataDataserviceBillDownloadurlQueryResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("bill_download_url")]
[Validation(Required=true)]
public string BillDownloadUrl { get; set; }
}
}

View File

@@ -0,0 +1,61 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeCancelResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("retry_flag")]
[Validation(Required=true)]
public string RetryFlag { get; set; }
[NameInMap("action")]
[Validation(Required=true)]
public string Action { get; set; }
[NameInMap("gmt_refund_pay")]
[Validation(Required=true)]
public string GmtRefundPay { get; set; }
[NameInMap("refund_settlement_id")]
[Validation(Required=true)]
public string RefundSettlementId { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeCloseResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeCreateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
}
}

View File

@@ -0,0 +1,109 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeFastpayRefundQueryResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("error_code")]
[Validation(Required=true)]
public string ErrorCode { get; set; }
[NameInMap("gmt_refund_pay")]
[Validation(Required=true)]
public string GmtRefundPay { get; set; }
[NameInMap("industry_sepc_detail")]
[Validation(Required=true)]
public string IndustrySepcDetail { get; set; }
[NameInMap("out_request_no")]
[Validation(Required=true)]
public string OutRequestNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("present_refund_buyer_amount")]
[Validation(Required=true)]
public string PresentRefundBuyerAmount { get; set; }
[NameInMap("present_refund_discount_amount")]
[Validation(Required=true)]
public string PresentRefundDiscountAmount { get; set; }
[NameInMap("present_refund_mdiscount_amount")]
[Validation(Required=true)]
public string PresentRefundMdiscountAmount { get; set; }
[NameInMap("refund_amount")]
[Validation(Required=true)]
public string RefundAmount { get; set; }
[NameInMap("refund_charge_amount")]
[Validation(Required=true)]
public string RefundChargeAmount { get; set; }
[NameInMap("refund_detail_item_list")]
[Validation(Required=true)]
public List<TradeFundBill> RefundDetailItemList { get; set; }
[NameInMap("refund_reason")]
[Validation(Required=true)]
public string RefundReason { get; set; }
[NameInMap("refund_royaltys")]
[Validation(Required=true)]
public List<RefundRoyaltyResult> RefundRoyaltys { get; set; }
[NameInMap("refund_settlement_id")]
[Validation(Required=true)]
public string RefundSettlementId { get; set; }
[NameInMap("refund_status")]
[Validation(Required=true)]
public string RefundStatus { get; set; }
[NameInMap("send_back_fee")]
[Validation(Required=true)]
public string SendBackFee { get; set; }
[NameInMap("total_amount")]
[Validation(Required=true)]
public string TotalAmount { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
}
}

View File

@@ -0,0 +1,177 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeQueryResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("buyer_logon_id")]
[Validation(Required=true)]
public string BuyerLogonId { get; set; }
[NameInMap("trade_status")]
[Validation(Required=true)]
public string TradeStatus { get; set; }
[NameInMap("total_amount")]
[Validation(Required=true)]
public string TotalAmount { get; set; }
[NameInMap("trans_currency")]
[Validation(Required=true)]
public string TransCurrency { get; set; }
[NameInMap("settle_currency")]
[Validation(Required=true)]
public string SettleCurrency { get; set; }
[NameInMap("settle_amount")]
[Validation(Required=true)]
public string SettleAmount { get; set; }
[NameInMap("pay_currency")]
[Validation(Required=true)]
public string PayCurrency { get; set; }
[NameInMap("pay_amount")]
[Validation(Required=true)]
public string PayAmount { get; set; }
[NameInMap("settle_trans_rate")]
[Validation(Required=true)]
public string SettleTransRate { get; set; }
[NameInMap("trans_pay_rate")]
[Validation(Required=true)]
public string TransPayRate { get; set; }
[NameInMap("buyer_pay_amount")]
[Validation(Required=true)]
public string BuyerPayAmount { get; set; }
[NameInMap("point_amount")]
[Validation(Required=true)]
public string PointAmount { get; set; }
[NameInMap("invoice_amount")]
[Validation(Required=true)]
public string InvoiceAmount { get; set; }
[NameInMap("send_pay_date")]
[Validation(Required=true)]
public string SendPayDate { get; set; }
[NameInMap("receipt_amount")]
[Validation(Required=true)]
public string ReceiptAmount { get; set; }
[NameInMap("store_id")]
[Validation(Required=true)]
public string StoreId { get; set; }
[NameInMap("terminal_id")]
[Validation(Required=true)]
public string TerminalId { get; set; }
[NameInMap("fund_bill_list")]
[Validation(Required=true)]
public List<TradeFundBill> FundBillList { get; set; }
[NameInMap("store_name")]
[Validation(Required=true)]
public string StoreName { get; set; }
[NameInMap("buyer_user_id")]
[Validation(Required=true)]
public string BuyerUserId { get; set; }
[NameInMap("charge_amount")]
[Validation(Required=true)]
public string ChargeAmount { get; set; }
[NameInMap("charge_flags")]
[Validation(Required=true)]
public string ChargeFlags { get; set; }
[NameInMap("settlement_id")]
[Validation(Required=true)]
public string SettlementId { get; set; }
[NameInMap("trade_settle_info")]
[Validation(Required=true)]
public List<TradeSettleInfo> TradeSettleInfo { get; set; }
[NameInMap("auth_trade_pay_mode")]
[Validation(Required=true)]
public string AuthTradePayMode { get; set; }
[NameInMap("buyer_user_type")]
[Validation(Required=true)]
public string BuyerUserType { get; set; }
[NameInMap("mdiscount_amount")]
[Validation(Required=true)]
public string MdiscountAmount { get; set; }
[NameInMap("discount_amount")]
[Validation(Required=true)]
public string DiscountAmount { get; set; }
[NameInMap("buyer_user_name")]
[Validation(Required=true)]
public string BuyerUserName { get; set; }
[NameInMap("subject")]
[Validation(Required=true)]
public string Subject { get; set; }
[NameInMap("body")]
[Validation(Required=true)]
public string Body { get; set; }
[NameInMap("alipay_sub_merchant_id")]
[Validation(Required=true)]
public string AlipaySubMerchantId { get; set; }
[NameInMap("ext_infos")]
[Validation(Required=true)]
public string ExtInfos { get; set; }
}
}

View File

@@ -0,0 +1,97 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeRefundResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("buyer_logon_id")]
[Validation(Required=true)]
public string BuyerLogonId { get; set; }
[NameInMap("fund_change")]
[Validation(Required=true)]
public string FundChange { get; set; }
[NameInMap("refund_fee")]
[Validation(Required=true)]
public string RefundFee { get; set; }
[NameInMap("refund_currency")]
[Validation(Required=true)]
public string RefundCurrency { get; set; }
[NameInMap("gmt_refund_pay")]
[Validation(Required=true)]
public string GmtRefundPay { get; set; }
[NameInMap("refund_detail_item_list")]
[Validation(Required=true)]
public List<TradeFundBill> RefundDetailItemList { get; set; }
[NameInMap("store_name")]
[Validation(Required=true)]
public string StoreName { get; set; }
[NameInMap("buyer_user_id")]
[Validation(Required=true)]
public string BuyerUserId { get; set; }
[NameInMap("refund_preset_paytool_list")]
[Validation(Required=true)]
public List<PresetPayToolInfo> RefundPresetPaytoolList { get; set; }
[NameInMap("refund_settlement_id")]
[Validation(Required=true)]
public string RefundSettlementId { get; set; }
[NameInMap("present_refund_buyer_amount")]
[Validation(Required=true)]
public string PresentRefundBuyerAmount { get; set; }
[NameInMap("present_refund_discount_amount")]
[Validation(Required=true)]
public string PresentRefundDiscountAmount { get; set; }
[NameInMap("present_refund_mdiscount_amount")]
[Validation(Required=true)]
public string PresentRefundMdiscountAmount { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class PresetPayToolInfo : TeaModel {
[NameInMap("amount")]
[Validation(Required=true)]
public List<string> Amount { get; set; }
[NameInMap("assert_type_code")]
[Validation(Required=true)]
public string AssertTypeCode { get; set; }
}
}

View File

@@ -0,0 +1,42 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class RefundRoyaltyResult : TeaModel {
[NameInMap("refund_amount")]
[Validation(Required=true)]
public string RefundAmount { get; set; }
[NameInMap("royalty_type")]
[Validation(Required=true)]
public string RoyaltyType { get; set; }
[NameInMap("result_code")]
[Validation(Required=true)]
public string ResultCode { get; set; }
[NameInMap("trans_out")]
[Validation(Required=true)]
public string TransOut { get; set; }
[NameInMap("trans_out_email")]
[Validation(Required=true)]
public string TransOutEmail { get; set; }
[NameInMap("trans_in")]
[Validation(Required=true)]
public string TransIn { get; set; }
[NameInMap("trans_in_email")]
[Validation(Required=true)]
public string TransInEmail { get; set; }
}
}

View File

@@ -0,0 +1,34 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class TradeFundBill : TeaModel {
[NameInMap("fund_channel")]
[Validation(Required=true)]
public string FundChannel { get; set; }
[NameInMap("bank_code")]
[Validation(Required=true)]
public string BankCode { get; set; }
[NameInMap("amount")]
[Validation(Required=true)]
public string Amount { get; set; }
[NameInMap("real_amount")]
[Validation(Required=true)]
public string RealAmount { get; set; }
[NameInMap("fund_type")]
[Validation(Required=true)]
public string FundType { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class TradeSettleDetail : TeaModel {
[NameInMap("operation_type")]
[Validation(Required=true)]
public string OperationType { get; set; }
[NameInMap("operation_serial_no")]
[Validation(Required=true)]
public string OperationSerial_no { get; set; }
[NameInMap("operation_dt")]
[Validation(Required=true)]
public string OperationDt { get; set; }
[NameInMap("trans_out")]
[Validation(Required=true)]
public string TransOut { get; set; }
[NameInMap("trans_in")]
[Validation(Required=true)]
public string TransIn { get; set; }
[NameInMap("amount")]
[Validation(Required=true)]
public string Amount { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class TradeSettleInfo : TeaModel {
[NameInMap("trade_settle_detail_list")]
[Validation(Required=true)]
public List<TradeSettleDetail> TradeSettleDetailList { get; set; }
}
}

View File

@@ -0,0 +1,536 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Payment.FaceToFace.Models;
namespace Alipay.EasySDK.Payment.FaceToFace
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayTradePayResponse Pay(string subject, string outTradeNo, string totalAmount, string authCode)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"auth_code", authCode},
{"scene", "bar_code"},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayTradePayResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradePayResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayTradePayResponse> PayAsync(string subject, string outTradeNo, string totalAmount, string authCode)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"auth_code", authCode},
{"scene", "bar_code"},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.trade.pay");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayTradePayResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradePayResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayTradePrecreateResponse PreCreate(string subject, string outTradeNo, string totalAmount)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayTradePrecreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradePrecreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayTradePrecreateResponse> PreCreateAsync(string subject, string outTradeNo, string totalAmount)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.trade.precreate");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayTradePrecreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradePrecreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,165 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.FaceToFace.Models
{
public class AlipayTradePayResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("buyer_logon_id")]
[Validation(Required=true)]
public string BuyerLogonId { get; set; }
[NameInMap("settle_amount")]
[Validation(Required=true)]
public string SettleAmount { get; set; }
[NameInMap("pay_currency")]
[Validation(Required=true)]
public string PayCurrency { get; set; }
[NameInMap("pay_amount")]
[Validation(Required=true)]
public string PayAmount { get; set; }
[NameInMap("settle_trans_rate")]
[Validation(Required=true)]
public string SettleTransRate { get; set; }
[NameInMap("trans_pay_rate")]
[Validation(Required=true)]
public string TransPayRate { get; set; }
[NameInMap("total_amount")]
[Validation(Required=true)]
public string TotalAmount { get; set; }
[NameInMap("trans_currency")]
[Validation(Required=true)]
public string TransCurrency { get; set; }
[NameInMap("settle_currency")]
[Validation(Required=true)]
public string SettleCurrency { get; set; }
[NameInMap("receipt_amount")]
[Validation(Required=true)]
public string ReceiptAmount { get; set; }
[NameInMap("buyer_pay_amount")]
[Validation(Required=true)]
public string BuyerPayAmount { get; set; }
[NameInMap("point_amount")]
[Validation(Required=true)]
public string PointAmount { get; set; }
[NameInMap("invoice_amount")]
[Validation(Required=true)]
public string InvoiceAmount { get; set; }
[NameInMap("gmt_payment")]
[Validation(Required=true)]
public string GmtPayment { get; set; }
[NameInMap("fund_bill_list")]
[Validation(Required=true)]
public List<TradeFundBill> FundBillList { get; set; }
[NameInMap("card_balance")]
[Validation(Required=true)]
public string CardBalance { get; set; }
[NameInMap("store_name")]
[Validation(Required=true)]
public string StoreName { get; set; }
[NameInMap("buyer_user_id")]
[Validation(Required=true)]
public string BuyerUserId { get; set; }
[NameInMap("discount_goods_detail")]
[Validation(Required=true)]
public string DiscountGoodsDetail { get; set; }
[NameInMap("voucher_detail_list")]
[Validation(Required=true)]
public List<VoucherDetail> VoucherDetailList { get; set; }
[NameInMap("advance_amount")]
[Validation(Required=true)]
public string AdvanceAmount { get; set; }
[NameInMap("auth_trade_pay_mode")]
[Validation(Required=true)]
public string AuthTradePayMode { get; set; }
[NameInMap("charge_amount")]
[Validation(Required=true)]
public string ChargeAmount { get; set; }
[NameInMap("charge_flags")]
[Validation(Required=true)]
public string ChargeFlags { get; set; }
[NameInMap("settlement_id")]
[Validation(Required=true)]
public string SettlementId { get; set; }
[NameInMap("business_params")]
[Validation(Required=true)]
public string BusinessParams { get; set; }
[NameInMap("buyer_user_type")]
[Validation(Required=true)]
public string BuyerUserType { get; set; }
[NameInMap("mdiscount_amount")]
[Validation(Required=true)]
public string MdiscountAmount { get; set; }
[NameInMap("discount_amount")]
[Validation(Required=true)]
public string DiscountAmount { get; set; }
[NameInMap("buyer_user_name")]
[Validation(Required=true)]
public string BuyerUserName { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.FaceToFace.Models
{
public class AlipayTradePrecreateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("qr_code")]
[Validation(Required=true)]
public string QrCode { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.FaceToFace.Models
{
public class TradeFundBill : TeaModel {
[NameInMap("fund_channel")]
[Validation(Required=true)]
public string FundChannel { get; set; }
[NameInMap("bank_code")]
[Validation(Required=true)]
public string BankCode { get; set; }
[NameInMap("amount")]
[Validation(Required=true)]
public string Amount { get; set; }
[NameInMap("real_amount")]
[Validation(Required=true)]
public string RealAmount { get; set; }
}
}

View File

@@ -0,0 +1,58 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.FaceToFace.Models
{
public class VoucherDetail : TeaModel {
[NameInMap("id")]
[Validation(Required=true)]
public string Id { get; set; }
[NameInMap("name")]
[Validation(Required=true)]
public string Name { get; set; }
[NameInMap("type")]
[Validation(Required=true)]
public string Type { get; set; }
[NameInMap("amount")]
[Validation(Required=true)]
public string Amount { get; set; }
[NameInMap("merchant_contribute")]
[Validation(Required=true)]
public string MerchantContribute { get; set; }
[NameInMap("other_contribute")]
[Validation(Required=true)]
public string OtherContribute { get; set; }
[NameInMap("memo")]
[Validation(Required=true)]
public string Memo { get; set; }
[NameInMap("template_id")]
[Validation(Required=true)]
public string TemplateId { get; set; }
[NameInMap("purchase_buyer_contribute")]
[Validation(Required=true)]
public string PurchaseBuyerContribute { get; set; }
[NameInMap("purchase_merchant_contribute")]
[Validation(Required=true)]
public string PurchaseMerchantContribute { get; set; }
[NameInMap("purchase_ant_contribute")]
[Validation(Required=true)]
public string PurchaseAntContribute { get; set; }
}
}

View File

@@ -0,0 +1,324 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Payment.Huabei.Models;
namespace Alipay.EasySDK.Payment.Huabei
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayTradeCreateResponse Create(string subject, string outTradeNo, string totalAmount, string buyerId, HuabeiConfig extendParams)
{
extendParams.Validate();
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"buyer_id", buyerId},
{"extend_params", extendParams},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipayTradeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayTradeCreateResponse> CreateAsync(string subject, string outTradeNo, string totalAmount, string buyerId, HuabeiConfig extendParams)
{
extendParams.Validate();
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"buyer_id", buyerId},
{"extend_params", extendParams},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.trade.create");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayTradeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Huabei.Models
{
public class AlipayTradeCreateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Huabei.Models
{
public class HuabeiConfig : TeaModel {
[NameInMap("hb_fq_num")]
[Validation(Required=true)]
public string HbFqNum { get; set; }
[NameInMap("hb_fq_seller_percent")]
[Validation(Required=true)]
public string HbFqSellerPercent { get; set; }
}
}

View File

@@ -0,0 +1,139 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Payment.Page.Models;
namespace Alipay.EasySDK.Payment.Page
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayTradePagePayResponse Pay(string subject, string outTradeNo, string totalAmount, string returnUrl)
{
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"product_code", "FAST_INSTANT_TRADE_PAY"},
};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"return_url", returnUrl},
};
string sign = this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"));
Dictionary<string, string> response = new Dictionary<string, string>
{
{"body", this._kernel.GeneratePage("POST", systemParams, bizParams, textParams, sign)},
};
return TeaModel.ToObject<AlipayTradePagePayResponse>(response);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,21 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Page.Models
{
public class AlipayTradePagePayResponse : TeaModel {
/// <summary>
/// 订单信息Form表单形式
/// </summary>
[NameInMap("body")]
[Validation(Required=true)]
public string Body { get; set; }
}
}

View File

@@ -0,0 +1,140 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Payment.Wap.Models;
namespace Alipay.EasySDK.Payment.Wap
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayTradeWapPayResponse Pay(string subject, string outTradeNo, string totalAmount, string quitUrl, string returnUrl)
{
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"quit_url", quitUrl},
{"product_code", "QUICK_WAP_WAY"},
};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"return_url", returnUrl},
};
string sign = this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"));
Dictionary<string, string> response = new Dictionary<string, string>
{
{"body", this._kernel.GeneratePage("POST", systemParams, bizParams, textParams, sign)},
};
return TeaModel.ToObject<AlipayTradeWapPayResponse>(response);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,21 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Wap.Models
{
public class AlipayTradeWapPayResponse : TeaModel {
/// <summary>
/// 订单信息Form表单形式
/// </summary>
[NameInMap("body")]
[Validation(Required=true)]
public string Body { get; set; }
}
}

View File

@@ -0,0 +1,314 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Security.TextRisk.Models;
namespace Alipay.EasySDK.Security.TextRisk
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipaySecurityRiskContentDetectResponse Detect(string content)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"content", content},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> 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 TeaModel.ToObject<AlipaySecurityRiskContentDetectResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySecurityRiskContentDetectResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipaySecurityRiskContentDetectResponse> DetectAsync(string content)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"content", content},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.security.risk.content.detect");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipaySecurityRiskContentDetectResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySecurityRiskContentDetectResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,49 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Security.TextRisk.Models
{
public class AlipaySecurityRiskContentDetectResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("action")]
[Validation(Required=true)]
public string Action { get; set; }
[NameInMap("keywords")]
[Validation(Required=true)]
public List<string> Keywords { get; set; }
[NameInMap("unique_id")]
[Validation(Required=true)]
public string UniqueId { get; set; }
}
}

View File

@@ -0,0 +1,114 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
namespace Alipay.EasySDK.Util.AES
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public string Decrypt(string cipherText)
{
return this._kernel.AesDecrypt(cipherText, this._kernel.GetConfig("encryptKey"));
}
public string Encrypt(string plainText)
{
return this._kernel.AesEncrypt(plainText, this._kernel.GetConfig("encryptKey"));
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,304 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Util.Generic.Models;
namespace Alipay.EasySDK.Util.Generic
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayOpenApiGenericResponse Execute(string method, Dictionary<string, string> textParams, Dictionary<string, object> bizParams)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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 = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, method);
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOpenApiGenericResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenApiGenericResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayOpenApiGenericResponse> ExecuteAsync(string method, Dictionary<string, string> textParams, Dictionary<string, object> bizParams)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"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 = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, method);
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOpenApiGenericResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenApiGenericResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,37 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Util.Generic.Models
{
public class AlipayOpenApiGenericResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
}
}

View File

@@ -0,0 +1,248 @@
[![NuGet](https://badge.fury.io/nu/AlipayEasySDK.svg)](https://badge.fury.io/nu/AlipayEasySDK)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Falipay%2Falipay-easysdk.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Falipay%2Falipay-easysdk?ref=badge_shield)
欢迎使用 Alipay **Easy** SDK for .NET
Alipay Esay SDK for .NET让您不用复杂编程即可访支付宝开放平台开放的各项常用能力SDK可以自动帮您满足能力调用过程中所需的证书校验加签验签发送HTTP请求等非功能性要求
下面向您介绍Alipay Easy SDK for .NET 的基本设计理念和使用方法
## 设计理念
不同于原有的[Alipay SDK](https://github.com/alipay/alipay-sdk-net-all)通用而全面的设计理念Alipay Easy SDK对开放能力的API进行了更加贴近高频场景的精心设计与裁剪简化了服务端调用方式让调用API像使用语言内置的函数一样简便。
同时您也不必担心面向高频场景提炼的API可能无法完全契合自己的个性化场景Alipay Easy SDK支持灵活的动态扩展方式同样可以满足低频参数低频API的使用需求
Alipay Easy SDK提供了与[能力地图](https://opendocs.alipay.com/mini/00am3f)相对应的代码组织结构让开发者可以快速找到不同能力对应的API。
Alipay Easy SDK主要目标是提升开发者在**服务端**集成支付宝开放平台开放的各类核心能力的效率
## 环境要求
1. Alipay Easy SDK for .NET基于`.Net Standard 2.0`开发支持`.Net Framework 4.6.1`.`Net Core 2.0`及其以上版本
2. 使用 Alipay Easy SDK for .NET 之前 您需要先前往[支付宝开发平台-开发者中心](https://openhome.alipay.com/platform/developerIndex.htm)完成开发者接入的一些准备工作,包括创建应用、为应用添加功能包、设置应用的接口加签方式等。
3. 准备工作完成后注意保存如下信息后续将作为使用SDK的输入
* 加签模式为公钥证书模式时推荐
`AppId``应用的私钥``应用公钥证书文件``支付宝公钥证书文件``支付宝根证书文件`
* 加签模式为公钥模式时
`AppId``应用的私钥``支付宝公钥`
## 安装依赖
### 通过[NuGet](https://www.nuget.org/packages/AlipayEasySDK/)程序包管理器在线安装依赖(推荐)
* `解决方案资源管理器面板` 中右击您的项目选择 `管理 NuGet 程序包` 菜单在打开的 `NuGet 管理面板` 中点击 `浏览` 选项卡输入 `AlipayEasySDK`在下方列表中选择 `Authors` `antopen` 由官方发布的**最新稳定版**NuGet包点击 **安装** 即可
* 或者通过 .NET CLI 工具来安装
> dotnet add package AlipayEasySDK
### 离线安装NuGet包适用于自己修改源码后的本地重新打包安装
1. 使用`Visual Studio`打开本`README.md`所在文件夹下的`AlipayEasySDK.sln`解决方案`生成`菜单栏下执行`全部重新生成`
2. `AlipayEasySDK/bin/Debug``AlipayEasySDK/bin/Release`目录下找到`AlipayEasySDK.[version].nupkg`文件该文件即为本SDK的NuGet离线包
3. 参照[NuGet离线安装程序包使用指南](https://yq.aliyun.com/articles/689227),在您的.NET应用项目工程中引入本SDK的NuGet离线包即可完成SDK的依赖安装。
## 快速开始
### 普通调用
以下这段代码示例向您展示了使用Alipay Easy SDK for .NET调用一个API的3个主要步骤
1. 设置参数全局只需设置一次
2. 发起API调用
3. 处理响应或异常
```charp
using System;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Kernel;
using Alipay.EasySDK.Kernel.Util;
using Alipay.EasySDK.Payment.FaceToFace.Models;
namespace SDKDemo
{
class Program
{
static void Main(string[] args)
{
// 1. 设置参数(全局只需设置一次)
Factory.SetOptions(GetConfig());
try
{
// 2. 发起API调用以创建当面付收款二维码为例
AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace()
.PreCreate("Apple iPhone11 128G", "2234567234890", "5799.00");
// 3. 处理响应或异常
if (ResponseChecker.Success(response))
{
Console.WriteLine("调用成功");
}
else
{
Console.WriteLine("调用失败,原因:" + response.Msg + "" + response.SubMsg);
}
}
catch (Exception ex)
{
Console.WriteLine("调用遭遇异常,原因:" + ex.Message);
throw ex;
}
}
static private Config GetConfig()
{
return new Config()
{
Protocol = "https",
GatewayHost = "openapi.alipay.com",
SignType = "RSA2",
AppId = "<-- 请填写您的AppId例如2019091767145019 -->",
// 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
MerchantPrivateKey = "<-- 请填写您的应用私钥例如MIIEvQIBADANB ... ... -->",
MerchantCertPath = "<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->",
AlipayCertPath = "<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->",
AlipayRootCertPath = "<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt -->",
// 如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
// AlipayPublicKey = "<-- 请填写您的支付宝公钥例如MIIBIjANBg... -->"
//可设置异步通知接收服务地址(可选)
NotifyUrl = "<-- 请填写您的支付类接口异步通知接收服务地址例如https://www.test.com/callback -->",
//可设置AES密钥调用AES加解密相关接口时需要可选
EncryptKey = "<-- 请填写您的AES密钥例如aa4BtZ4tspm2wnXLb1ThQA== -->"
};
}
}
}
```
### 扩展调用
#### ISV代调用
```csharp
Factory.Payment.FaceToFace()
//调用Agent扩展方法设置app_auth_token完成ISV代调用
.Agent("ca34ea491e7146cc87d25fca24c4cD11")
.PreCreate("Apple iPhone11 128G", "2234567890", "5799.00");
```
#### 设置独立的异步通知地址
```csharp
Factory.Payment.FaceToFace()
// 调用AsyncNotify扩展方法可以为每此API调用设置独立的异步通知地址
// 此处设置的异步通知地址的优先级高于全局Config中配置的异步通知地址
.AsyncNotify("https://www.test.com/callback")
.PreCreate("Apple iPhone11 128G", "2234567890", "5799.00");
```
#### 设置可选业务参数
```csharp
List<object> goodsDetailList = new List<object>();
Dictionary<string, object> goodsDetail = new Dictionary<string, object>
{
{ "goods_id", "apple-01" },
{ "goods_name", "Apple iPhone11 128G" },
{ "quantity", 1 },
{ "price", "5799.00" }
};
goodsDetailList.Add(goodsDetail);
Factory.Payment.FaceToFace()
// 调用Optional扩展方法完成可选业务参数biz_content下的可选字段的设置
.Optional("seller_id", "2088102146225135")
.Optional("discountable_amount", "8.88")
.Optional("goods_detail", goodsDetailList)
.PreCreate("Apple iPhone11 128G", "2234567890", "5799.00");
Dictionary<string, object> optionalArgs = new Dictionary<string, object>
{
{ "seller_id", "2088102146225135" },
{ "discountable_amount", "8.88" },
{ "goods_detail", goodsDetailList }
};
Factory.Payment.FaceToFace()
// 也可以调用BatchOptional扩展方法批量设置可选业务参数biz_content下的可选字段
.BatchOptional(optionalArgs)
.PreCreate("Apple iPhone11 128G", "2234567890", "5799.00");
```
#### 多种扩展灵活组合
```csharp
// 多种扩展方式可灵活组装(对扩展方法的调用顺序没有要求)
Factory.Payment.FaceToFace()
.Agent("ca34ea491e7146cc87d25fca24c4cD11")
.AsyncNotify("https://www.test.com/callback")
.Optional("seller_id", "2088102146225135")
.PreCreate("Apple iPhone11 128G", "2234567890", "5799.00");
```
## API组织规范
在Alipay Easy SDK中API的引用路径与能力地图的组织层次一致遵循如下规则
> Factory.能力名称.场景名称().接口方法名称( ... )
比如如果您想要使用[能力地图](https://opendocs.alipay.com/mini/00am3f)中`营销能力`下的`模板消息`场景中的`小程序发送模板消息`,只需按如下形式编写调用代码即可(不同编程语言的连接符号可能不同)。
`Factory.Marketing.TemplateMessage().send( ... )`
其中接口方法名称通常是对其依赖的OpenAPI功能的一个最简概况接口方法的出入参与OpenAPI中同名参数含义一致可参照OpenAPI相关参数的使用说明
Alipay Easy SDK将致力于保持良好的API命名以符合开发者的编程直觉
## 已支持的API列表
| 能力类别 | 场景类别 | 接口方法名称 | 调用的OpenAPI名称 |
|-----------|-----------------|------------------------|-----------------------------------------------------------|
| Base | OAuth | getToken | alipay\.system\.oauth\.token |
| Base | OAuth | refreshToken | alipay\.system\.oauth\.token |
| Base | Qrcode | create | alipay\.open\.app\.qrcode\.create |
| Base | Image | upload | alipay\.offline\.material\.image\.upload |
| Base | Video | upload | alipay\.offline\.material\.image\.upload |
| Member | Identification | init | alipay\.user\.certify\.open\.initialize |
| Member | Identification | certify | alipay\.user\.certify\.open\.certify |
| Member | Identification | query | alipay\.user\.certify\.open\.query |
| Payment | Common | create | alipay\.trade\.create |
| Payment | Common | query | alipay\.trade\.query |
| Payment | Common | refund | alipay\.trade\.refund |
| Payment | Common | close | alipay\.trade\.close |
| Payment | Common | cancel | alipay\.trade\.cancel |
| Payment | Common | queryRefund | alipay\.trade\.fastpay\.refund\.query |
| Payment | Common | downloadBill | alipay\.data\.dataservice\.bill\.downloadurl\.query |
| Payment | Common | verifyNotify | - |
| Payment | Huabei | create | alipay\.trade\.create |
| Payment | FaceToFace | pay | alipay\.trade\.pay |
| Payment | FaceToFace | precreate | alipay\.trade\.precreate |
| Payment | App | pay | alipay\.trade\.app\.pay |
| Payment | Page | pay | alipay\.trade\.page\.pay |
| Payment | Wap | pay | alipay\.trade\.wap\.pay |
| Security | TextRisk | detect | alipay\.security\.risk\.content\.detect |
| Marketing | Pass | createTemplate | alipay\.pass\.template\.add |
| Marketing | Pass | updateTemplate | alipay\.pass\.template\.update |
| Marketing | Pass | addInstance | alipay\.pass\.instance\.add |
| Marketing | Pass | updateInstance | alipay\.pass\.instance\.update |
| Marketing | TemplateMessage | send | alipay\.open\.app\.mini\.templatemessage\.send |
| Marketing | OpenLife | createImageTextContent | alipay\.open\.public\.message\.content\.create |
| Marketing | OpenLife | modifyImageTextContent | alipay\.open\.public\.message\.content\.modify |
| Marketing | OpenLife | sendText | alipay\.open\.public\.message\.total\.send |
| Marketing | OpenLife | sendImageText | alipay\.open\.public\.message\.total\.send |
| Marketing | OpenLife | sendSingleMessage | alipay\.open\.public\.message\.single\.send |
| Marketing | OpenLife | recallMessage | alipay\.open\.public\.life\.msg\.recall |
| Marketing | OpenLife | setIndustry | alipay\.open\.public\.template\.message\.industry\.modify |
| Marketing | OpenLife | getIndustry | alipay\.open\.public\.setting\.category\.query |
| Util | AES | decrypt | - |
| Util | AES | encrypt | - |
| Util | Generic | execute | - |
> 更多高频场景的API持续更新中敬请期待
## 文档
[API Doc](./../APIDoc.md)
[Alipay Easy SDK](./../README.md)

View File

@@ -0,0 +1,32 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Base.Image.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Base.Image
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestUpload()
{
AlipayOfflineMaterialImageUploadResponse response = Factory.Base.Image().Upload(
"测试图片", TestAccount.GetSolutionBasePath() + "/UnitTest/Fixture/sample.png");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.ImageId);
Assert.IsTrue(response.ImageUrl.StartsWith("https://"));
}
}
}

View File

@@ -0,0 +1,42 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Base.OAuth.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Base.OAuth
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestGetToken()
{
AlipaySystemOauthTokenResponse response = Factory.Base.OAuth().GetToken("1234567890");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40002");
Assert.AreEqual(response.Msg, "Invalid Arguments");
Assert.AreEqual(response.SubCode, "isv.code-invalid");
Assert.AreEqual(response.SubMsg, "授权码code无效");
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestRefreshToken()
{
AlipaySystemOauthTokenResponse response = Factory.Base.OAuth().RefreshToken("1234567890");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40002");
Assert.AreEqual(response.Msg, "Invalid Arguments");
Assert.AreEqual(response.SubCode, "isv.refresh-token-invalid");
Assert.AreEqual(response.SubMsg, "刷新令牌refresh_token无效");
Assert.NotNull(response.HttpBody);
}
}
}

View File

@@ -0,0 +1,31 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Base.Qrcode.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Base.Qrcode
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestCreate()
{
AlipayOpenAppQrcodeCreateResponse response = Factory.Base.Qrcode().Create(
"https://opendocs.alipay.com", "ageIndex=1", "文档站点");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.QrCodeUrl);
}
}
}

View File

@@ -0,0 +1,32 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Base.Video.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Base.Video
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestUpload()
{
AlipayOfflineMaterialImageUploadResponse response = Factory.Base.Video().Upload(
"测试视频", TestAccount.GetSolutionBasePath() + "/UnitTest/Fixture/sample.mp4");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.ImageId);
Assert.IsTrue(response.ImageUrl.StartsWith("https://"));
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using NUnit.Framework;
using Alipay.EasySDK.Payment.Common.Models;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.FactoryTest
{
public class FactoryTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestGetClient()
{
AlipayTradeFastpayRefundQueryResponse response = Factory.GetClient<Alipay.EasySDK.Payment.Common.Client>()
.QueryRefund("64628156-f784-4572-9540-485b7c91b850", "64628156-f784-4572-9540-485b7c91b850");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.RefundAmount, "0.01");
Assert.AreEqual(response.TotalAmount, "0.01");
}
}
}

View File

@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDkzCCAnugAwIBAgIQIBkJAnXy/rwX3BTZaKNEzjANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UE
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0
aG9yaXR5MTkwNwYDVQQDDDBBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IENs
YXNzIDIgUjEwHhcNMTkwOTAyMTI0NDIyWhcNMjEwOTAxMTI0NDIyWjB0MQswCQYDVQQGEwJDTjEP
MA0GA1UECgwG6ZKf6ZuoMQ8wDQYDVQQLDAZBbGlwYXkxQzBBBgNVBAMMOuaUr+S7mOWunSjkuK3l
m70p572R57uc5oqA5pyv5pyJ6ZmQ5YWs5Y+4LTIwODgwMDI2NTY3MTg5MjAwggEiMA0GCSqGSIb3
DQEBAQUAA4IBDwAwggEKAoIBAQDQxh7MsF7bsPyQlToJWOPlmGfqUerZI2o2725LUqrabGYOaAgx
a8OAm6sFXoq6TykRltIBEmAjYjMYudQelwxSv8NhQ1eLEFrY7o2Z3TQ+y8lvlLmvqWnEMzOqq4Fc
UN6gzd1nissGVtzUkmx9ErB+89g6WAKV1bFCZBQHIjzfMIqcZkddUZ4SiksMKB/ncKFOJPJf2CUI
i31URny3WlIoC44jG1SiX2sPKdbkbsSGQcDfGIpNRQBNJxlXX/8Y8D7RrFCWHtjh4ONSMT29+xjS
8HNM0gSR2y4QKXyRupXrNY9yTTtkPhQIEjfSjsQPnuM+3b7VFd3GSDcDbvskNRNLAgMBAAGjEjAQ
MA4GA1UdDwEB/wQEAwID+DANBgkqhkiG9w0BAQsFAAOCAQEAf8Qx2UsLFqPDTxKk9eT0np75NqJ8
MexTuPJ/gC+Lp20YzEUyYW2rPlDFhDmFztlqk9RdynLRqyjB5dOAdWlxhgDlEqB9E6DvkVKtpIaL
7h7zqJei9gb/STAyf5vTVWR/WTmOhp3vQhaj7+lt14JwK/ELYMdBLD2IdmFis7YdzhCsGo7Y4FPb
BuHCV8Ngfaf2PvDlKaFOVzDg8tGnMBbAOgpe+mhxKUdhNG3eXcO0Z813rNIC15YAvWm68tNAwuZJ
rIVgK+049WUojwUJxOwVyzewob/8Gx7o8ipIV5E/bMrduSvigsj7OmNzwQ5/iSm31dfcXi3fOXXz
BLMb888PlA==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIE4jCCAsqgAwIBAgIIYsSr5bKAMl8wDQYJKoZIhvcNAQELBQAwejELMAkGA1UEBhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFIxMB4XDTE4MDMyMjE0MzQxNVoXDTM3MTEyNjE0MzQxNVowgYIxCzAJBgNVBAYTAkNOMRYwFAYDVQQKDA1BbnQgRmluYW5jaWFsMSAwHgYDVQQLDBdDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTE5MDcGA1UEAwwwQW50IEZpbmFuY2lhbCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBDbGFzcyAyIFIxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsLMfYaoRoPRbmDcAfXPCmKf43pWRN5yTXa/KJWO0l+mrgQvs89bANEvbDUxlkGwycwtwi5DgBuBgVhLliXu+R9CYgr2dXs8D8Hx/gsggDcyGPLmVrDOnL+dyeauheARZfA3du60fwEwwbGcVIpIxPa/4n3IS/ElxQa6DNgqxh8J9Xwh7qMGl0JK9+bALuxf7B541Gr4p0WENG8fhgjBV4w4ut9eQLOoa1eddOUSZcy46Z7allwowwgt7b5VFfx/P1iKJ3LzBMgkCK7GZ2kiLrL7RiqV+h482J7hkJD+ardoc6LnrHO/hIZymDxok+VH9fVeUdQa29IZKrIDVj65THQIDAQABo2MwYTAfBgNVHSMEGDAWgBRfdLQEwE8HWurlsdsio4dBspzhATAdBgNVHQ4EFgQUSqHkYINtUSAtDPnS8XoyoP9p7qEwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggIBAIQ8TzFy4bVIVb8+WhHKCkKNPcJe2EZuIcqvRoi727lZTJOfYy/JzLtckyZYfEI8J0lasZ29wkTta1IjSo+a6XdhudU4ONVBrL70U8Kzntplw/6TBNbLFpp7taRALjUgbCOk4EoBMbeCL0GiYYsTS0mw7xdySzmGQku4GTyqutIGPQwKxSj9iSFw1FCZqr4VP4tyXzMUgc52SzagA6i7AyLedd3tbS6lnR5BL+W9Kx9hwT8L7WANAxQzv/jGldeuSLN8bsTxlOYlsdjmIGu/C9OWblPYGpjQQIRyvs4Cc/mNhrh+14EQgwuemIIFDLOgcD+iISoN8CqegelNcJndFw1PDN6LkVoiHz9p7jzsge8RKay/QW6C03KNDpWZEUCgCUdfHfo8xKeR+LL1cfn24HKJmZt8L/aeRZwZ1jwePXFRVtiXELvgJuM/tJDIFj2KD337iV64fWcKQ/ydDVGqfDZAdcU4hQdsrPWENwPTQPfVPq2NNLMyIH9+WKx9Ed6/WzeZmIy5ZWpX1TtTolo6OJXQFeItMAjHxW/ZSZTok5IS3FuRhExturaInnzjYpx50a6kS34c5+c8hYq7sAtZ/CNLZmBnBCFDaMQqT8xFZJ5uolUaSeXxg7JFY1QsYp5RKvj4SjFwCGKJ2+hPPe9UyyltxOidNtxjaknOCeBHytOr
-----END CERTIFICATE-----

View File

@@ -0,0 +1,88 @@
-----BEGIN CERTIFICATE-----
MIIBszCCAVegAwIBAgIIaeL+wBcKxnswDAYIKoEcz1UBg3UFADAuMQswCQYDVQQG
EwJDTjEOMAwGA1UECgwFTlJDQUMxDzANBgNVBAMMBlJPT1RDQTAeFw0xMjA3MTQw
MzExNTlaFw00MjA3MDcwMzExNTlaMC4xCzAJBgNVBAYTAkNOMQ4wDAYDVQQKDAVO
UkNBQzEPMA0GA1UEAwwGUk9PVENBMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE
MPCca6pmgcchsTf2UnBeL9rtp4nw+itk1Kzrmbnqo05lUwkwlWK+4OIrtFdAqnRT
V7Q9v1htkv42TsIutzd126NdMFswHwYDVR0jBBgwFoAUTDKxl9kzG8SmBcHG5Yti
W/CXdlgwDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFEwysZfZ
MxvEpgXBxuWLYlvwl3ZYMAwGCCqBHM9VAYN1BQADSAAwRQIgG1bSLeOXp3oB8H7b
53W+CKOPl2PknmWEq/lMhtn25HkCIQDaHDgWxWFtnCrBjH16/W3Ezn7/U/Vjo5xI
pDoiVhsLwg==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIF0zCCA7ugAwIBAgIIH8+hjWpIDREwDQYJKoZIhvcNAQELBQAwejELMAkGA1UE
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmlj
YXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5jaWFsIENlcnRpZmlj
YXRpb24gQXV0aG9yaXR5IFIxMB4XDTE4MDMyMTEzNDg0MFoXDTM4MDIyODEzNDg0
MFowejELMAkGA1UEBhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNV
BAsMF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5j
aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFIxMIICIjANBgkqhkiG9w0BAQEF
AAOCAg8AMIICCgKCAgEAtytTRcBNuur5h8xuxnlKJetT65cHGemGi8oD+beHFPTk
rUTlFt9Xn7fAVGo6QSsPb9uGLpUFGEdGmbsQ2q9cV4P89qkH04VzIPwT7AywJdt2
xAvMs+MgHFJzOYfL1QkdOOVO7NwKxH8IvlQgFabWomWk2Ei9WfUyxFjVO1LVh0Bp
dRBeWLMkdudx0tl3+21t1apnReFNQ5nfX29xeSxIhesaMHDZFViO/DXDNW2BcTs6
vSWKyJ4YIIIzStumD8K1xMsoaZBMDxg4itjWFaKRgNuPiIn4kjDY3kC66Sl/6yTl
YUz8AybbEsICZzssdZh7jcNb1VRfk79lgAprm/Ktl+mgrU1gaMGP1OE25JCbqli1
Pbw/BpPynyP9+XulE+2mxFwTYhKAwpDIDKuYsFUXuo8t261pCovI1CXFzAQM2w7H
DtA2nOXSW6q0jGDJ5+WauH+K8ZSvA6x4sFo4u0KNCx0ROTBpLif6GTngqo3sj+98
SZiMNLFMQoQkjkdN5Q5g9N6CFZPVZ6QpO0JcIc7S1le/g9z5iBKnifrKxy0TQjtG
PsDwc8ubPnRm/F82RReCoyNyx63indpgFfhN7+KxUIQ9cOwwTvemmor0A+ZQamRe
9LMuiEfEaWUDK+6O0Gl8lO571uI5onYdN1VIgOmwFbe+D8TcuzVjIZ/zvHrAGUcC
AwEAAaNdMFswCwYDVR0PBAQDAgEGMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFF90
tATATwda6uWx2yKjh0GynOEBMB8GA1UdIwQYMBaAFF90tATATwda6uWx2yKjh0Gy
nOEBMA0GCSqGSIb3DQEBCwUAA4ICAQCVYaOtqOLIpsrEikE5lb+UARNSFJg6tpkf
tJ2U8QF/DejemEHx5IClQu6ajxjtu0Aie4/3UnIXop8nH/Q57l+Wyt9T7N2WPiNq
JSlYKYbJpPF8LXbuKYG3BTFTdOVFIeRe2NUyYh/xs6bXGr4WKTXb3qBmzR02FSy3
IODQw5Q6zpXj8prYqFHYsOvGCEc1CwJaSaYwRhTkFedJUxiyhyB5GQwoFfExCVHW
05ZFCAVYFldCJvUzfzrWubN6wX0DD2dwultgmldOn/W/n8at52mpPNvIdbZb2F41
T0YZeoWnCJrYXjq/32oc1cmifIHqySnyMnavi75DxPCdZsCOpSAT4j4lAQRGsfgI
kkLPGQieMfNNkMCKh7qjwdXAVtdqhf0RVtFILH3OyEodlk1HYXqX5iE5wlaKzDop
PKwf2Q3BErq1xChYGGVS+dEvyXc/2nIBlt7uLWKp4XFjqekKbaGaLJdjYP5b2s7N
1dM0MXQ/f8XoXKBkJNzEiM3hfsU6DOREgMc1DIsFKxfuMwX3EkVQM1If8ghb6x5Y
jXayv+NLbidOSzk4vl5QwngO/JYFMkoc6i9LNwEaEtR9PhnrdubxmrtM+RjfBm02
77q3dSWFESFQ4QxYWew4pHE0DpWbWy/iMIKQ6UZ5RLvB8GEcgt8ON7BBJeMc+Dyi
kT9qhqn+lw==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIICiDCCAgygAwIBAgIIQX76UsB/30owDAYIKoZIzj0EAwMFADB6MQswCQYDVQQG
EwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UECwwXQ2VydGlmaWNh
dGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNpYWwgQ2VydGlmaWNh
dGlvbiBBdXRob3JpdHkgRTEwHhcNMTkwNDI4MTYyMDQ0WhcNNDkwNDIwMTYyMDQ0
WjB6MQswCQYDVQQGEwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UE
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNp
YWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgRTEwdjAQBgcqhkjOPQIBBgUrgQQA
IgNiAASCCRa94QI0vR5Up9Yr9HEupz6hSoyjySYqo7v837KnmjveUIUNiuC9pWAU
WP3jwLX3HkzeiNdeg22a0IZPoSUCpasufiLAnfXh6NInLiWBrjLJXDSGaY7vaokt
rpZvAdmjXTBbMAsGA1UdDwQEAwIBBjAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBRZ
4ZTgDpksHL2qcpkFkxD2zVd16TAfBgNVHSMEGDAWgBRZ4ZTgDpksHL2qcpkFkxD2
zVd16TAMBggqhkjOPQQDAwUAA2gAMGUCMQD4IoqT2hTUn0jt7oXLdMJ8q4vLp6sg
wHfPiOr9gxreb+e6Oidwd2LDnC4OUqCWiF8CMAzwKs4SnDJYcMLf2vpkbuVE4dTH
Rglz+HGcTLWsFs4KxLsq7MuU+vJTBUeDJeDjdA==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIDxTCCAq2gAwIBAgIUEMdk6dVgOEIS2cCP0Q43P90Ps5YwDQYJKoZIhvcNAQEF
BQAwajELMAkGA1UEBhMCQ04xEzARBgNVBAoMCmlUcnVzQ2hpbmExHDAaBgNVBAsM
E0NoaW5hIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMMH2lUcnVzQ2hpbmEgQ2xhc3Mg
MiBSb290IENBIC0gRzMwHhcNMTMwNDE4MDkzNjU2WhcNMzMwNDE4MDkzNjU2WjBq
MQswCQYDVQQGEwJDTjETMBEGA1UECgwKaVRydXNDaGluYTEcMBoGA1UECwwTQ2hp
bmEgVHJ1c3QgTmV0d29yazEoMCYGA1UEAwwfaVRydXNDaGluYSBDbGFzcyAyIFJv
b3QgQ0EgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOPPShpV
nJbMqqCw6Bz1kehnoPst9pkr0V9idOwU2oyS47/HjJXk9Rd5a9xfwkPO88trUpz5
4GmmwspDXjVFu9L0eFaRuH3KMha1Ak01citbF7cQLJlS7XI+tpkTGHEY5pt3EsQg
wykfZl/A1jrnSkspMS997r2Gim54cwz+mTMgDRhZsKK/lbOeBPpWtcFizjXYCqhw
WktvQfZBYi6o4sHCshnOswi4yV1p+LuFcQ2ciYdWvULh1eZhLxHbGXyznYHi0dGN
z+I9H8aXxqAQfHVhbdHNzi77hCxFjOy+hHrGsyzjrd2swVQ2iUWP8BfEQqGLqM1g
KgWKYfcTGdbPB1MCAwEAAaNjMGEwHQYDVR0OBBYEFG/oAMxTVe7y0+408CTAK8hA
uTyRMB8GA1UdIwQYMBaAFG/oAMxTVe7y0+408CTAK8hAuTyRMA8GA1UdEwEB/wQF
MAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBLnUTfW7hp
emMbuUGCk7RBswzOT83bDM6824EkUnf+X0iKS95SUNGeeSWK2o/3ALJo5hi7GZr3
U8eLaWAcYizfO99UXMRBPw5PRR+gXGEronGUugLpxsjuynoLQu8GQAeysSXKbN1I
UugDo9u8igJORYA+5ms0s5sCUySqbQ2R5z/GoceyI9LdxIVa1RjVX8pYOj8JFwtn
DJN3ftSFvNMYwRuILKuqUYSHc2GPYiHVflDh5nDymCMOQFcFG3WsEuB+EYQPFgIU
1DHmdZcz7Llx8UOZXX2JupWCYzK1XhJb+r4hK5ncf/w8qGtYlmyJpxk3hr1TfUJX
Yf4Zr0fJsGuv
-----END CERTIFICATE-----

View File

@@ -0,0 +1,23 @@
-----BEGIN CERTIFICATE-----
MIIEkzCCA3ugAwIBAgIQICABI1M0G1IN1Hv7M5NTmjANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UE
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0
aG9yaXR5MTkwNwYDVQQDDDBBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IENs
YXNzIDEgUjEwHhcNMjAwMTIzMDc0NTQ3WhcNMjIwMTIyMDc0NTQ3WjBbMQswCQYDVQQGEwJDTjEP
MA0GA1UECgwG6ZKf6ZuoMQ8wDQYDVQQLDAZBbGlwYXkxKjAoBgNVBAMMITIwODgwMDI2NTY3MTg5
MjAtMjAxOTA1MTA2NDUyMTAwMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIRaW3zN
ZGJY3oOUL41KMZqcoyI9JyDWG/fyb8qShWgH9NGinO6JeGWWX2pU2b5GKCd1CB6imnbD5U3zvErR
Z6h9Kc9pD4M22MNqnpuFontWuFXhq01MIbuolV5zTw94nrMR4aMPgTt7wX6svcQ8cKyg+v7Xz4DH
QCQOPhtFM3aL1UHsEZhLp+F2xNENTGpphmlV7D50ahnAo3A8Jdkt9ZBIzkWk4CoMdeoYk6BlOETG
XZ93Mc1TKR6cLNPj7LIUKb7xUh4ekaRoky2RP7k9NgBLsZLDjMkqZmzvHHhnstddmq5Er49Ger9b
VHnKsWNMWtN0Oi+ZyWTDcwvACdCgLbcCAwEAAaOCASkwggElMB8GA1UdIwQYMBaAFHEH4gRhFuTl
8mXrMQ/J4PQ8mtWRMB0GA1UdDgQWBBSNSXcCsxvjAa3v5QcTyVZ183CMjzBABgNVHSAEOTA3MDUG
B2CBHAFuAQEwKjAoBggrBgEFBQcCARYcaHR0cDovL2NhLmFsaXBheS5jb20vY3BzLnBkZjAOBgNV
HQ8BAf8EBAMCBsAwLwYDVR0fBCgwJjAkoCKgIIYeaHR0cDovL2NhLmFsaXBheS5jb20vY3JsMzcu
Y3JsMGAGCCsGAQUFBwEBBFQwUjAoBggrBgEFBQcwAoYcaHR0cDovL2NhLmFsaXBheS5jb20vY2E2
LmNlcjAmBggrBgEFBQcwAYYaaHR0cDovL2NhLmFsaXBheS5jb206ODM0MC8wDQYJKoZIhvcNAQEL
BQADggEBAA0l9rTtjEl4uqE4RP4Nd+A0KgM8NmWQHLxsubDRMSeYVFMzrpSm8V9zhlxLmKdFxWP/
OuY4SHRe8eOSA++5yJc3ihg9B7/ddK2kNTsnaB7Xtvex685kvDDR8DMZmQYeirDThGVPhUeBgPdk
wY0R5KU6mEh2FzT3QIxDzP6t4ssSyYHhFPssZ4PXHFQ5eHzmdpJ81/85crfques67JxAm4CCfldb
bX0DH1BUrPxcnvz4Kj5lKv1qIvBR71yUnrGFOKAVCx04VYK4dTNDI70W9lLgX1aTfLGUBTYiJe/J
Zq/XlYhQP/T7t8HOAaCQFf2hM9tRq62EaL1UbExV2hcAP/E=
-----END CERTIFICATE-----

View File

@@ -0,0 +1,4 @@
{
"2019022663440152": "<- 已脱敏如想要执行单元测试请开发者自行替换TestAccount中的相关账号并在此重新配置新的APPID与私钥的关联 ->",
"2019051064521003": "<- 已脱敏如想要执行单元测试请开发者自行替换TestAccount中的相关账号并在此重新配置新的APPID与私钥的关联 ->"
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

View File

@@ -0,0 +1,205 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Marketing.OpenLife.Models;
using System.Collections.Generic;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Marketing.OpenLife
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.OpenLife.CONFIG);
}
[Test]
public void TestCreateImageTextContent()
{
AlipayOpenPublicMessageContentCreateResponse response = Factory.Marketing.OpenLife().CreateImageTextContent("标题",
"http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
"示例", "T", "activity", "满100减10",
"关键,热度", "13434343432,xxx@163.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.ContentId);
Assert.NotNull(response.ContentUrl);
}
[Test]
public void TestModifyImageTextContent()
{
AlipayOpenPublicMessageContentModifyResponse response = Factory.Marketing.OpenLife().ModifyImageTextContent(
"20190510645210035577f788-d6cd-4020-9dba-1a195edb7342", "新标题",
"http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
"新示例", "T", "activity", "满100减20",
"关键,热度", "13434343432,xxx@163.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.ContentId, "20190510645210035577f788-d6cd-4020-9dba-1a195edb7342");
Assert.NotNull(response.ContentUrl);
}
[Test]
public void TestSendText()
{
AlipayOpenPublicMessageTotalSendResponse response = Factory.Marketing.OpenLife().SendText("测试");
if (response.Code.Equals("10000"))
{
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.MessageId);
}
else
{
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "PUB.MSG_BATCH_SD_OVER");
Assert.AreEqual(response.SubMsg, "批量发送消息频率超限");
Assert.NotNull(response.HttpBody);
Assert.Null(response.MessageId);
}
}
[Test]
public void TestSendImageText()
{
Article article = new Article
{
ActionName = "测试",
Desc = "测试",
Title = "测试",
ImageUrl = "http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
Url = "https://docs.open.alipay.com/api_6/alipay.open.public.message.total.send"
};
AlipayOpenPublicMessageTotalSendResponse response = Factory.Marketing.OpenLife().SendImageText(new List<Article> { article });
if (response.Code.Equals("10000"))
{
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.MessageId);
}
else
{
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "PUB.MSG_BATCH_SD_OVER");
Assert.AreEqual(response.SubMsg, "批量发送消息频率超限");
Assert.NotNull(response.HttpBody);
Assert.Null(response.MessageId);
}
}
[Test]
public void TestSendSingleMessage()
{
Keyword keyword = new Keyword
{
Color = "#85be53",
Value = "HU7142"
};
Context context = new Context
{
HeadColor = "#85be53",
Url = "https://docs.open.alipay.com/api_6/alipay.open.public.message.single.send",
ActionName = "查看详情",
Keyword1 = keyword,
Keyword2 = keyword,
First = keyword,
Remark = keyword
};
Alipay.EasySDK.Marketing.OpenLife.Models.Template template = new Alipay.EasySDK.Marketing.OpenLife.Models.Template
{
TemplateId = "e44cd3e52ffa46b1a50afc145f55d1ea",
Context = context
};
AlipayOpenPublicMessageSingleSendResponse response = Factory.Marketing.OpenLife().SendSingleMessage(
"2088002656718920", template);
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestRecallMessage()
{
AlipayOpenPublicLifeMsgRecallResponse response = Factory.Marketing.OpenLife().RecallMessage("201905106452100327f456f6-8dd2-4a06-8b0e-ec8a3a85c46a");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestSetIndustry()
{
AlipayOpenPublicTemplateMessageIndustryModifyResponse response = Factory.Marketing.OpenLife().SetIndustry(
"10001/20102", "IT科技/IT软件与服务",
"10001/20102", "IT科技/IT软件与服务");
if (response.Code.Equals("10000"))
{
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
}
else
{
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "3002");
Assert.AreEqual(response.SubMsg, ("模板消息行业一月只能修改一次"));
Assert.NotNull(response.HttpBody);
}
}
[Test]
public void TestGetIndustry()
{
AlipayOpenPublicSettingCategoryQueryResponse response = Factory.Marketing.OpenLife().GetIndustry();
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.PrimaryCategory, "IT科技/IT软件与服务");
Assert.AreEqual(response.SecondaryCategory, "IT科技/IT软件与服务");
}
}
}

View File

@@ -0,0 +1,100 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Marketing.Pass.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Marketing.Pass
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestCreateTemplate()
{
AlipayPassTemplateAddResponse response = Factory.Marketing.Pass().CreateTemplate("123456789", GetTplContent());
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.True(response.Success);
Assert.True(response.Result.Contains("tpl_id"));
}
[Test]
public void TestUpdateTemplate()
{
AlipayPassTemplateUpdateResponse response = Factory.Marketing.Pass().UpdateTemplate("2020012014534017917956080", GetTplContent());
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.True(response.Success);
Assert.True(response.Result.Contains("tpl_id"));
}
[Test]
public void TestAddInstance()
{
AlipayPassInstanceAddResponse response = Factory.Marketing.Pass().AddInstance("2020012014534017917956080", "{}",
"1", "{\"partner_id\":\"2088102114633762\",\"out_trade_no\":\"1234567\"}");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "KP.AE_ALIPASS_APPID_NOSUPPORT");
Assert.AreEqual(response.SubMsg, "该AppId不支持");
Assert.NotNull(response.HttpBody);
Assert.False(response.Success);
Assert.True(response.Result.Contains("该AppId不支持"));
}
[Test]
public void TestUpdateInstance()
{
AlipayPassInstanceUpdateResponse response = Factory.Marketing.Pass().UpdateInstance("209919213",
"2088918273", "{}", "USED", "8612231273", "wave");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "KP.AE_ALIPASS_NOTEXIST");
Assert.AreEqual(response.SubMsg, "卡券不存在");
Assert.NotNull(response.HttpBody);
Assert.False(response.Success);
Assert.True(response.Result.Contains("{\"operate\":\"UPDATE\"}"));
}
private string GetTplContent()
{
return "{\"logo\":\"http://img01.taobaocdn.com/top/i1/LB1NDJuQpXXXXbYXFXXXXXXXXXX\",\"strip\":null,\"icon\":null,"
+ "\"content\":{\"evoucherInfo\":{\"goodsId\":\"\",\"title\":\"test\",\"type\":\"boardingPass\","
+ "\"product\":\"air\",\"startDate\":\"2020-01-20 13:45:56\",\"endDate\":\"2020-01-25 13:45:56\","
+ "\"operation\":[{\"message\":{\"img\":\"http://img01.taobaocdn.com/top/i1/LB1NDJuQpXXXXbYXFXXXXXXXXXX\","
+ "\"target\":\"\"},\"format\":\"img\",\"messageEncoding\":\"utf-8\",\"altText\":\"\"}],"
+ "\"einfo\":{\"logoText\":\"test\",\"headFields\":[{\"key\":\"test\",\"label\":\"测试\",\"value\":\"\","
+ "\"type\":\"text\"}],\"primaryFields\":[{\"key\":\"from\",\"label\":\"测试\",\"value\":\"\",\"type\":\"text\"},"
+ "{\"key\":\"to\",\"label\":\"测试\",\"value\":\"\",\"type\":\"text\"}],\"secondaryFields\":[{\"key\":\"fltNo\","
+ "\"label\":\"航班号\",\"value\":\"CA123\",\"type\":\"text\"}],\"auxiliaryFields\":[{\"key\":\"test\","
+ "\"label\":\"测试\",\"value\":\"\",\"type\":\"text\"}],\"backFields\":[]},\"locations\":[]},"
+ "\"merchant\":{\"mname\":\"钟雨\",\"mtel\":\"\",\"minfo\":\"\"},\"platform\":{\"channelID\":\"2088201564809153\","
+ "\"webServiceUrl\":\"https://alipass.alipay.com/builder/syncRecord.htm?tempId=2020012013442621326446216\"},"
+ "\"style\":{\"backgroundColor\":\"RGB(26,150,219)\"},\"fileInfo\":{\"formatVersion\":\"2\",\"canShare\":true,"
+ "\"canBuy\":false,\"canPresent\":true,\"serialNumber\":\"2020012013520759738677158\",\"supportTaxi\":\"true\","
+ "\"taxiSchemaUrl\":\"alipays://platformapi/startapp?appId=20000778&bizid=260&channel=71322\"},"
+ "\"appInfo\":{\"app\":{\"android_appid\":\"\",\"ios_appid\":\"\",\"android_launch\":\"\",\"ios_launch\":\"\","
+ "\"android_download\":\"\",\"ios_download\":\"\"},\"label\":\"测试\",\"message\":\"\"},"
+ "\"source\":\"alipassprod\",\"alipayVerify\":[\"qrcode\"]}}";
}
}
}

View File

@@ -0,0 +1,34 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Marketing.TemplateMessage.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Marketing.TemplateMessage
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestSend()
{
AlipayOpenAppMiniTemplatemessageSendResponse response = Factory.Marketing.TemplateMessage().Send(
"2088102122458832",
"2017010100000000580012345678",
"MDI4YzIxMDE2M2I5YTQzYjUxNWE4MjA4NmU1MTIyYmM=",
"page/component/index",
"{\"keyword1\": {\"value\" : \"12:00\"},\"keyword2\": {\"value\" : \"20180808\"},\"keyword3\": {\"value\" : \"支付宝\"}}");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "USER_TEMPLATE_ILLEGAL");
Assert.AreEqual(response.SubMsg, "模板非法");
Assert.NotNull(response.HttpBody);
}
}
}

View File

@@ -0,0 +1,72 @@
using System;
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Member.Identification.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Member.Identification
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestInit()
{
IdentityParam identityParam = new IdentityParam()
{
IdentityType = "CERT_INFO",
CertType = "IDENTITY_CARD",
CertName = "张三",
CertNo = "513901198008089876"
};
MerchantConfig merchantConfig = new MerchantConfig()
{
ReturnUrl = "www.taobao.com"
};
AlipayUserCertifyOpenInitializeResponse response = Factory.Member.Identification().Init(
Guid.NewGuid().ToString(), "FACE", identityParam, merchantConfig);
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.CertifyId);
}
[Test]
public void TestCertify()
{
AlipayUserCertifyOpenCertifyResponse response = Factory.Member.Identification().Certify("bbdb57e87211279e2c22de5846d85161");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("https://openapi.alipay.com/gateway.do?alipay_sdk=alipay-easysdk-net"));
Assert.IsTrue(response.Body.Contains("sign"));
}
[Test]
public void TestQuery()
{
AlipayUserCertifyOpenQueryResponse response = Factory.Member.Identification().Query("89ad1f1b8171d9741c3e5620fd77f9de");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "CERTIFY_ID_EXPIRED");
Assert.AreEqual(response.SubMsg, "认证已失效");
Assert.NotNull(response.HttpBody);
Assert.IsNull(response.Passed);
Assert.IsNull(response.IdentityInfo);
Assert.IsNull(response.MaterialInfo);
}
}
}

View File

@@ -0,0 +1,54 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.App.Models;
using System.Collections.Generic;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Payment.App
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestPay()
{
AlipayTradeAppPayResponse response = Factory.Payment.App().Pay("iPhone6 16G",
"f4833085-0c46-4bb0-8e5f-622a02a4cffc", "0.10");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("app_id=2019022663440152&biz_content=%7b%22subject%22%3a%22iPhone6+16G%22%2c%22" +
"out_trade_no%22%3a%22f4833085-0c46-4bb0-8e5f-622a02a4cffc%22%2c%22total_amount%22%3a%220.10%22%7d&charset=UTF-8&" +
"format=json&method=alipay.trade.app.pay&notify_url=https%3a%2f%2fwww.test.com%2fcallback&sign="));
}
[Test]
public void TestPayWithOptional()
{
AlipayTradeAppPayResponse response = Factory.Payment.App()
.Agent("ca34ea491e7146cc87d25fca24c4cD11")
.Optional("extend_params", GetHuabeiConfig())
.Pay("iPhone6 16G", "f4833085-0c46-4bb0-8e5f-622a02a4cffc", "0.10");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("app_auth_token=ca34ea491e7146cc87d25fca24c4cD11&app_id=2019022663440152&biz_content=%7b%22subject%22%3a%22iPhone6+16G%22%2c"
+ "%22out_trade_no%22%3a%22f4833085-0c46-4bb0-8e5f-622a02a4cffc%22%2c%22total_amount%22%3a%220"
+ ".10%22%2c%22extend_params%22%3a%7b%22hb_fq_num%22%3a%223%22%2c%22hb_fq_seller_percent%22%3a%22100%22%7d%7d&charset=UTF"
+ "-8&format=json&method=alipay.trade.app.pay&notify_url=https%3a%2f%2fwww.test.com%2fcallback&sign="));
}
private Dictionary<string, string> GetHuabeiConfig()
{
Dictionary<string, string> extendParams = new Dictionary<string, string>
{
{ "hb_fq_num", "3" },
{ "hb_fq_seller_percent", "100" }
};
return extendParams;
}
}
}

View File

@@ -0,0 +1,154 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.Common.Models;
using System;
using System.Collections.Generic;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Payment.Common
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestCreate()
{
string outTradeNo = Guid.NewGuid().ToString();
AlipayTradeCreateResponse response = Factory.Payment.Common().Create("iPhone6 16G",
outTradeNo, "88.88", "2088002656718920");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.OutTradeNo, outTradeNo);
Assert.True(response.TradeNo.StartsWith("202"));
}
[Test]
public void TestCreateWithOptional()
{
string outTradeNo = Guid.NewGuid().ToString();
AlipayTradeCreateResponse response = Factory.Payment.Common().Optional("goods_detail", GetGoodsDetail())
.Create("iPhone6 16G", outTradeNo, "0.01", "2088002656718920");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.OutTradeNo, outTradeNo);
Assert.True(response.TradeNo.StartsWith("202"));
}
private List<object> GetGoodsDetail()
{
List<object> goodsDetail = new List<object>();
Dictionary<string, object> goodDetail = new Dictionary<string, object>();
goodDetail.Add("goods_id", "apple-01");
goodDetail.Add("goods_name", "iPhone6 16G");
goodDetail.Add("quantity", 1);
goodDetail.Add("price", "0.01");
goodsDetail.Add(goodDetail);
return goodsDetail;
}
[Test]
public void TestQuery()
{
AlipayTradeQueryResponse response = Factory.Payment.Common().Query("6f149ddb-ab8c-4546-81fb-5880b4aaa318");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.OutTradeNo, "6f149ddb-ab8c-4546-81fb-5880b4aaa318");
}
[Test]
public void TestCancel()
{
AlipayTradeCancelResponse response = Factory.Payment.Common().Cancel(CreateNewAndReturnOutTradeNo());
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.Action, "close");
}
[Test]
public void TestClose()
{
AlipayTradeCloseResponse response = Factory.Payment.Common().Close(CreateNewAndReturnOutTradeNo());
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestRefund()
{
AlipayTradeRefundResponse response = Factory.Payment.Common().Refund(CreateNewAndReturnOutTradeNo(), "0.01");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "ACQ.TRADE_STATUS_ERROR");
Assert.AreEqual(response.SubMsg, "交易状态不合法");
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestQueryRefund()
{
AlipayTradeFastpayRefundQueryResponse response = Factory.Payment.Common().QueryRefund(
"64628156-f784-4572-9540-485b7c91b850", "64628156-f784-4572-9540-485b7c91b850");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.RefundAmount, "0.01");
Assert.AreEqual(response.TotalAmount, "0.01");
}
[Test]
public void TestDownloadBill()
{
AlipayDataDataserviceBillDownloadurlQueryResponse response = Factory.Payment.Common().DownloadBill("trade", "2020-01");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.IsTrue(response.BillDownloadUrl.StartsWith("http://dwbillcenter.alipay.com/"));
}
private string CreateNewAndReturnOutTradeNo()
{
return Factory.Payment.Common().Create("iPhone6 16G", Guid.NewGuid().ToString(),
"88.88", "2088002656718920").OutTradeNo;
}
}
}

View File

@@ -0,0 +1,51 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.FaceToFace.Models;
using System;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Payment.FaceToFace
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestPay()
{
AlipayTradePayResponse response = Factory.Payment.FaceToFace().Pay("Iphone6 16G", CreateNewAndReturnOutTradeNo(), "0.01", "1234567890");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "ACQ.PAYMENT_AUTH_CODE_INVALID");
Assert.AreEqual(response.SubMsg, "支付失败,获取顾客账户信息失败,请顾客刷新付款码后重新收款,如再次收款失败,请联系管理员处理。[SOUNDWAVE_PARSER_FAIL]");
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestPreCreate()
{
AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace().PreCreate("iPhone6 16G",
CreateNewAndReturnOutTradeNo(), "0.10");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.IsTrue(response.QrCode.StartsWith("https://qr.alipay.com/"));
}
private string CreateNewAndReturnOutTradeNo()
{
return Factory.Payment.Common().Create("Iphone6 16G", Guid.NewGuid().ToString(),
"88.88", "2088002656718920").OutTradeNo;
}
}
}

View File

@@ -0,0 +1,39 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.Huabei.Models;
using System;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Payment.HuaBei
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestCrate()
{
string outTradeNo = Guid.NewGuid().ToString();
HuabeiConfig config = new HuabeiConfig()
{
HbFqNum = "3",
HbFqSellerPercent = "0"
};
AlipayTradeCreateResponse response = Factory.Payment.Huabei().Create("Iphone6 16G",
outTradeNo, "88.88", "2088002656718920", config);
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.OutTradeNo, outTradeNo);
Assert.True(response.TradeNo.StartsWith("202"));
}
}
}

View File

@@ -0,0 +1,50 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.Page.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Payment.Page
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestPay()
{
AlipayTradePagePayResponse response = Factory.Payment.Page().Pay("iPhone6 16G",
"e5b5bd79-8310-447d-b63b-0fe3a393324d", "0.10", "https://www.taobao.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipay.com/gateway.do?"));
Assert.IsTrue(response.Body.Contains("notify_url"));
Assert.IsTrue(response.Body.Contains("return_url"));
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{&quot;subject&quot;:&quot;iPhone6 16G&quot;,&quot;"
+ "out_trade_no&quot;:&quot;e5b5bd79-8310-447d-b63b-0fe3a393324d&quot;,&quot;total_amount&quot;:&quot;0.10&quot;,&quot;"
+ "product_code&quot;:&quot;FAST_INSTANT_TRADE_PAY&quot;}\">"));
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
}
[Test]
public void TestPayWithOptionalNotify()
{
AlipayTradePagePayResponse response = Factory.Payment.Page().AsyncNotify("https://www.test2.com/newCallback")
.Pay("iPhone6 16G", "e5b5bd79-8310-447d-b63b-0fe3a393324d", "0.10", "https://www.taobao.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipay.com/gateway.do?"));
Assert.IsTrue(response.Body.Contains("notify_url=https%3a%2f%2fwww.test2.com%2fnewCallback"));
Assert.IsTrue(response.Body.Contains("return_url"));
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{&quot;subject&quot;:&quot;iPhone6 16G&quot;,&quot;out_trade_no&quot;:&quot;"
+ "e5b5bd79-8310-447d-b63b-0fe3a393324d&quot;,&quot;total_amount&quot;:&quot;0.10&quot;,&quot;product_code&quot;:&quot;"
+ "FAST_INSTANT_TRADE_PAY&quot;}\">"));
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
}
}
}

View File

@@ -0,0 +1,65 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.Wap.Models;
using Alipay.EasySDK.Kernel.Util;
using System.Collections.Generic;
namespace UnitTest.Payment.Wap
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestPay()
{
AlipayTradeWapPayResponse response = Factory.Payment.Wap().Pay("iPhone6 16G",
"b7f4bc7d-ea4b-4efd-9072-d8ea913c8946", "0.10",
"https://www.taobao.com", "https://www.taobao.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipay.com/gateway.do?"));
Assert.IsTrue(response.Body.Contains("notify_url"));
Assert.IsTrue(response.Body.Contains("return_url"));
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{&quot;subject&quot;:&quot;iPhone6 16G&quot;,&quot;"
+ "out_trade_no&quot;:&quot;b7f4bc7d-ea4b-4efd-9072-d8ea913c8946&quot;,&quot;"
+ "total_amount&quot;:&quot;0.10&quot;,&quot;quit_url&quot;:&quot;https://www.taobao.com&quot;,&quot;"
+ "product_code&quot;:&quot;QUICK_WAP_WAY&quot;}\">"));
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
}
[Test]
public void TestPayWithOptional()
{
Dictionary<string, object> optionalArgs = new Dictionary<string, object>
{
{ "timeout_express", "10m" },
{ "body", "iPhone6 16G"}
};
AlipayTradeWapPayResponse response = Factory.Payment.Wap()
.Agent("ca34ea491e7146cc87d25fca24c4cD11").BatchOptional(optionalArgs)
.Pay("iPhone6 16G", "b7f4bc7d-ea4b-4efd-9072-d8ea913c8946", "0.10",
"https://www.taobao.com", "https://www.taobao.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" "
+ "action=\"https://openapi.alipay.com/gateway.do?"));
Assert.IsTrue(response.Body.Contains("notify_url"));
Assert.IsTrue(response.Body.Contains("return_url"));
Assert.IsTrue(response.Body.Contains("app_auth_token"));
Assert.IsTrue(response.Body.Contains("timeout_express"));
Assert.IsTrue(response.Body.Contains("body"));
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{&quot;subject&quot;:&quot;iPhone6 16G&quot;,&quot;out_trade_no&quot;:&quot;"
+ "b7f4bc7d-ea4b-4efd-9072-d8ea913c8946&quot;,&quot;total_amount&quot;:&quot;0.10&quot;,&quot;quit_url&quot;:&quot;"
+ "https://www.taobao.com&quot;,&quot;product_code&quot;:&quot;QUICK_WAP_WAY&quot;,&quot;timeout_express&quot;:&quot;"
+ "10m&quot;,&quot;body&quot;:&quot;iPhone6 16G&quot;}\">"));
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
}
}
}

View File

@@ -0,0 +1,31 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Security.TextRisk.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Security.TextRisk
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestDetect()
{
AlipaySecurityRiskContentDetectResponse response = Factory.Security.TextRisk().Detect("test");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.Action, "PASSED");
Assert.NotNull(response.UniqueId);
}
}
}

View File

@@ -0,0 +1,87 @@
using System.Collections.Generic;
using System.IO;
using System;
using Alipay.EasySDK.Kernel;
using Newtonsoft.Json;
namespace UnitTest
{
public static class TestAccount
{
/// <summary>
/// 从文件中读取私钥
///
/// 注意:实际开发过程中,请务必注意不要将私钥信息配置在源码中(比如配置为常量或储存在配置文件的某个字段中等),因为私钥的保密等级往往比源码高得多,将会增加私钥泄露的风险。
/// 推荐将私钥信息储存在专用的私钥文件中,将私钥文件通过安全的流程分发到服务器的安全储存区域上,仅供自己的应用运行时读取。
/// </summary>
/// <param name="appId">私钥对应的APP_ID</param>
/// <returns>私钥字符串</returns>
private static string GetPrivateKey(string appId)
{
IDictionary<string, string> json = JsonConvert.DeserializeObject<IDictionary<string, string>>(
File.ReadAllText(GetSolutionBasePath() + "/UnitTest/Fixture/privateKey.json"));
return json[appId];
}
/// <summary>
/// 获取解决方案所在路径
/// </summary>
/// <returns>解决方案所在绝对路径</returns>
public static string GetSolutionBasePath()
{
string current = Directory.GetCurrentDirectory();
do
{
current = Directory.GetParent(current).ToString();
}
while (!current.EndsWith("bin", StringComparison.Ordinal));
return current + "/../..";
}
/// <summary>
/// 线上小程序测试账号
/// </summary>
public static class Mini
{
public static Config CONFIG = GetConfig();
public static Config GetConfig()
{
return new Config
{
Protocol = "https",
GatewayHost = "openapi.alipay.com",
AppId = "<-- 请填写您的AppId例如2019022663440152 -->",
SignType = "RSA2",
AlipayPublicKey = "<-- 请填写您的支付宝公钥例如MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAumX1EaLM4ddn1Pia4SxTRb62aVYxU8I2mHMqrc"
+ "pQU6F01mIO/DjY7R4xUWcLi0I2oH/BK/WhckEDCFsGrT7mO+JX8K4sfaWZx1aDGs0m25wOCNjp+DCVBXotXSCurqgGI/9UrY+"
+ "QydYDnsl4jB65M3p8VilF93MfS01omEDjUW+1MM4o3FP0khmcKsoHnYGs21btEeh0LK1gnnTDlou6Jwv3Ew36CbCNY2cYkuyP"
+ "AW0j47XqzhWJ7awAx60fwgNBq6ZOEPJnODqH20TAdTLNxPSl4qGxamjBO+RuInBy+Bc2hFHq3pNv6hTAfktggRKkKzDlDEUwg"
+ "SLE7d2eL7P6rwIDAQAB -->",
MerchantPrivateKey = GetPrivateKey("<-- 请填写您的AppId例如2019022663440152 -->"),
NotifyUrl = "<-- 请填写您的异步通知接收服务器地址例如https://www.test.com/callback"
};
}
}
/// <summary>
/// 线上生活号测试账号
/// </summary>
public static class OpenLife
{
public static Config CONFIG = new Config
{
Protocol = "https",
GatewayHost = "openapi.alipay.com",
AppId = "<-- 请填写您的AppId例如2019051064521003 -->",
SignType = "RSA2",
AlipayCertPath = "<-- 请填写您的支付宝公钥证书文件路径例如GetSolutionBasePath() + \"/UnitTest/Fixture/alipayCertPublicKey_RSA2.crt\" -->",
AlipayRootCertPath = "<-- 请填写您的支付宝根证书文件路径例如GetSolutionBasePath() + \"/UnitTest/Fixture/alipayRootCert.crt\" -->",
MerchantCertPath = "<-- 请填写您的应用公钥证书文件路径例如GetSolutionBasePath() + \"/UnitTest/Fixture/appCertPublicKey_2019051064521003.crt\" -->",
MerchantPrivateKey = GetPrivateKey("<-- 请填写您的AppId例如2019051064521003 -->")
};
}
}
}

View File

@@ -0,0 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Fixture\" />
<Folder Include="Base\" />
<Folder Include="Base\OAuth\" />
<Folder Include="Marketing\" />
<Folder Include="Marketing\Pass\" />
<Folder Include="Payment\" />
<Folder Include="Base\Qrcode\" />
<Folder Include="Marketing\OpenLife\" />
<Folder Include="Marketing\TemplateMessage\" />
<Folder Include="Member\" />
<Folder Include="Security\" />
<Folder Include="Security\TextRisk\" />
<Folder Include="Base\Image\" />
<Folder Include="Base\Video\" />
<Folder Include="Member\Identification\" />
<Folder Include="Payment\Common\" />
<Folder Include="Payment\FaceToFace\" />
<Folder Include="Util\" />
<Folder Include="Util\Generic\" />
<Folder Include="Payment\Wap\" />
<Folder Include="Payment\Page\" />
<Folder Include="Payment\App\" />
<Folder Include="Util\AES\" />
<Folder Include="Factory\" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Payment\FaceToFace\ClientTest %28副本%29.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AlipayEasySDK\AlipayEasySDK.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,31 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Kernel;
namespace UnitTest.Util.AES
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Config config = TestAccount.Mini.GetConfig();
config.EncryptKey = "aa4BtZ4tspm2wnXLb1ThQA==";
Factory.SetOptions(config);
}
[Test]
public void TestDecrypt()
{
string plainText = Factory.Util.AES().Decrypt("ILpoMowjIQjfYMR847rnFQ==");
Assert.AreEqual(plainText, "test1234567");
}
[Test]
public void TestEncrypt()
{
string cipherText = Factory.Util.AES().Encrypt("test1234567");
Assert.AreEqual(cipherText, "ILpoMowjIQjfYMR847rnFQ==");
}
}
}

View File

@@ -0,0 +1,79 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Util.Generic.Models;
using System;
using System.Collections.Generic;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Util.Generic
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestExecuteWithoutAppAuthToken()
{
string outTradeNo = Guid.NewGuid().ToString();
AlipayOpenApiGenericResponse response = Factory.Util.Generic().Execute(
"alipay.trade.create", null, GetBizParams(outTradeNo));
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestExecuteWithAppAuthToken()
{
string outTradeNo = Guid.NewGuid().ToString();
AlipayOpenApiGenericResponse response = Factory.Util.Generic().Execute(
"alipay.trade.create", GetTextParams(), GetBizParams(outTradeNo));
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "20001");
Assert.AreEqual(response.Msg, "Insufficient Token Permissions");
Assert.AreEqual(response.SubCode, "aop.invalid-app-auth-token");
Assert.AreEqual(response.SubMsg, "无效的应用授权令牌");
Assert.NotNull(response.HttpBody);
}
private Dictionary<string, string> GetTextParams()
{
return new Dictionary<string, string>
{
{ "app_auth_token", "201712BB_D0804adb2e743078d1822d536956X34" }
};
}
private Dictionary<string, object> GetBizParams(string outTradeNo)
{
return new Dictionary<string, object>
{
{ "subject", "Iphone6 16G" },
{ "out_trade_no", outTradeNo },
{ "total_amount", "0.10" },
{ "buyer_id", "2088002656718920" },
{ "extend_params", GetHuabeiParams() }
};
}
private Dictionary<string, string> GetHuabeiParams()
{
return new Dictionary<string, string>
{
{ "hb_fq_num", "3"},
{ "hb_fq_seller_percent", "3"}
};
}
}
}