sunpengfei
2025-09-01 185eca1406926d46fa9f50d07a0c0ecc65ab6b96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
{
    /// <summary>
    /// 阿里支付工具
    /// </summary>
    public class AlipayUtils
    {
        private readonly IAopClient alipayClient;
 
        public AlipayUtils(IOptions<AlipayOptions> 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("调用失败");
            }
        }
    }
}