using Aliyun.OSS;
using Aop.Api;
using Aop.Api.Domain;
using Aop.Api.Request;
using Aop.Api.Response;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FlexJobApi.Core
{
///
/// 阿里支付工具
///
public class AlipayUtils
{
private readonly IAopClient alipayClient;
public AlipayUtils(IOptions options)
{
alipayClient = new DefaultAopClient(new AlipayConfig
{
ServerUrl = options.Value.ServerUrl,
AppId = options.Value.AppId,
PrivateKey = options.Value.PrivateKey,
Format = options.Value.Format,
Charset = options.Value.Charset,
SignType = options.Value.SignType,
AppCertPath = options.Value.AppCertPath,
AlipayPublicCertPath = options.Value.AlipayPublicCertPath,
RootCertContent = options.Value.RootCertContent,
AlipayPublicKey = options.Value.AlipayPublicKey,
EncryptKey = options.Value.EncryptKey,
});
}
public void UserAgreementPageSign(AlipayUserAgreementPageSignModel model)
{
// 初始化SDK
// 构造请求参数以调用接口
AlipayUserAgreementPageSignRequest request = new AlipayUserAgreementPageSignRequest();
model.PersonalProductCode = "FUND_SAFT_SIGN_WITHHOLDING_P";
model.SignScene = "INDUSTRY|SATF_ACC";
model.ThirdPartyType = "PARTNER";
model.AccessParams = new AccessParams
{
Channel = ""
};
// 设置签约有效时间限制
model.EffectTime = 300;
request.SetBizModel(model);
//request.SetNotifyUrl();
AlipayUserAgreementPageSignResponse response = alipayClient.pageExecute(request, null, "GET");
string pageRedirectionData = response.Body;
Console.WriteLine(pageRedirectionData);
if (!response.IsError)
{
Console.WriteLine("调用成功");
}
else
{
Console.WriteLine("调用失败");
}
}
}
}