Esempio n. 1
0
        /// <summary>
        /// 支付宝单笔转账查询结果(蚂蚁金服)
        /// </summary>
        /// <param name="fundTransOrderQueryInfo">查询信息</param>
        /// <param name="config">config</param>
        /// <returns>结果</returns>
        public static FundTransOrderQueryResult FundTransOrderQuery(FundTransOrderQueryInfo fundTransOrderQueryInfo, SdkPay.Config config)
        {
            const string url           = SdkPay.Config.ServerUrl;
            string       appId         = config.GetAppId();
            string       privateKeyPem = config.GetPrivateKeyPem();
            const string format        = SdkPay.Config.Format;
            const string version       = SdkPay.Config.Version;
            const string signType      = SdkPay.Config.SignType;
            string       publicKeyPem  = config.GetPublicKeyPemAliPay();
            const string charset       = SdkPay.Config.Charset;
            IAopClient   client        = new DefaultAopClient(url, appId, privateKeyPem, format, version, signType, publicKeyPem, charset, false);
            AlipayFundTransOrderQueryRequest request = new AlipayFundTransOrderQueryRequest();
            AlipayFundTransOrderQueryModel   model   = new AlipayFundTransOrderQueryModel
            {
                OrderId  = fundTransOrderQueryInfo.OrderId,
                OutBizNo = fundTransOrderQueryInfo.OutBizNo
            };

            request.SetBizModel(model);
            AlipayFundTransOrderQueryResponse response = client.Execute(request);
            FundTransOrderQueryResult         result   = new FundTransOrderQueryResult();

            if (response.Code == "10000")
            {
                if (response.Status.ToUpper() == "SUCCESS")
                {
                    result.IsSuccess = true;
                    result.Message   = response.Status.ToUpper();
                    result.OrderId   = response.OrderId;
                    result.PayDate   = Convert.ToDateTime(response.PayDate);
                    result.OutBizNo  = response.OutBizNo;
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = response.Status.ToUpper();
                }
            }
            else
            {
                result.IsSuccess = false;
                result.Message   = response.SubMsg ?? response.Msg;
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取openId(蚂蚁金服)
        /// </summary>
        /// <param name="request">请求参数</param>
        /// <param name="config">配置</param>
        /// <returns>结果</returns>
        public static string GetOpenidFromCode(OpenidFromCodeRequestInfo request, SdkPay.Config config)
        {
            const string url           = SdkPay.Config.ServerUrl;
            string       appId         = config.GetAppId();
            string       privateKeyPem = config.GetPrivateKeyPem();
            const string format        = SdkPay.Config.Format;
            const string signType      = SdkPay.Config.SignType;
            string       publicKeyPem  = config.GetPublicKeyPemAliPay();
            const string charset       = SdkPay.Config.Charset;
            IAopClient   client        = new DefaultAopClient(url, appId, privateKeyPem, format, charset, signType, publicKeyPem);
            AlipaySystemOauthTokenRequest alipaySystemOauthTokenRequest = new AlipaySystemOauthTokenRequest
            {
                GrantType = "authorization_code",
                Code      = request.Code
            };
            AlipaySystemOauthTokenResponse response = client.Execute(alipaySystemOauthTokenRequest);

            return(response?.UserId);
        }
Esempio n. 3
0
        /// <summary>
        /// 支付宝单笔转账(蚂蚁金服)
        /// </summary>
        /// <param name="fundTransToaccountTransferInfo">转账信息</param>
        /// <param name="config">config</param>
        /// <returns>转账结果</returns>
        public static FundTransToaccountTransferInfoResult FundTransToAccountTransfer(FundTransToaccountTransferInfo fundTransToaccountTransferInfo, SdkPay.Config config)
        {
            const string url           = SdkPay.Config.ServerUrl;
            string       appId         = config.GetAppId();
            string       privateKeyPem = config.GetPrivateKeyPem();
            const string format        = SdkPay.Config.Format;
            const string version       = SdkPay.Config.Version;
            const string signType      = SdkPay.Config.SignType;
            string       publicKeyPem  = config.GetPublicKeyPemAliPay();
            const string charset       = SdkPay.Config.Charset;
            IAopClient   client        = new DefaultAopClient(url, appId, privateKeyPem, format, version, signType, publicKeyPem, charset, false);
            var          request       = new AlipayFundTransToaccountTransferRequest();
            AlipayFundTransToaccountTransferModel model = new AlipayFundTransToaccountTransferModel
            {
                OutBizNo      = fundTransToaccountTransferInfo.OutBizNo,
                PayeeAccount  = fundTransToaccountTransferInfo.PayeeAccount,
                Amount        = fundTransToaccountTransferInfo.Amount,
                PayeeRealName = fundTransToaccountTransferInfo.PayeeRealName,
                Remark        = fundTransToaccountTransferInfo.Remark
            };

            request.SetBizModel(model);
            AlipayFundTransToaccountTransferResponse response = client.Execute(request);
            FundTransToaccountTransferInfoResult     result   = new FundTransToaccountTransferInfoResult();

            result.Body = response.Body;
            if (response.Code == "10000")
            {
                result.IsSuccess = true;
                result.Message   = response.Msg;
                result.OrderId   = response.OrderId;
                result.PayDate   = Convert.ToDateTime(response.PayDate);
            }
            else
            {
                result.IsSuccess = false;
                result.Message   = $"{response.Msg}-{response.SubMsg}";
            }
            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// 创建Sdk支付链接串(蚂蚁金服)
        /// </summary>
        /// <param name="directInfo">支付信息</param>
        /// <param name="config">config</param>
        /// <returns>请求连接</returns>
        public static string CreateDirectSdkPayByUser(DirectInfo directInfo, SdkPay.Config config)
        {
            const string             url           = SdkPay.Config.ServerUrl;
            string                   appId         = config.GetAppId();
            string                   privateKeyPem = config.GetPrivateKeyPem();
            const string             format        = SdkPay.Config.Format;
            const string             version       = SdkPay.Config.Version;
            const string             signType      = SdkPay.Config.SignType;
            string                   publicKeyPem  = config.GetPublicKeyPem();
            const string             charset       = SdkPay.Config.Charset;
            const string             productCode   = SdkPay.Config.ProductCode;
            string                   pid           = config.GetPid();
            IAopClient               client        = new DefaultAopClient(url, appId, privateKeyPem, format, version, signType, publicKeyPem, charset, false);
            AlipayTradeAppPayRequest request       = new AlipayTradeAppPayRequest();

            if (!string.IsNullOrWhiteSpace(directInfo.Notify))
            {
                request.SetNotifyUrl(directInfo.Notify);
            }
            if (!string.IsNullOrWhiteSpace(directInfo.Return))
            {
                request.SetReturnUrl(directInfo.Return);
            }
            AlipayTradeAppPayModel model = new AlipayTradeAppPayModel
            {
                Body           = directInfo.ExtraCommonParam,
                Subject        = directInfo.Subject,
                TotalAmount    = directInfo.TotalFee.ToString("0.00"),
                ProductCode    = productCode,
                OutTradeNo     = directInfo.OutTradeNo,
                TimeoutExpress = "30m",
                SellerId       = pid
            };

            request.SetBizModel(model);
            AlipayTradeAppPayResponse response = client.SdkExecute(request);
            var body = response.Body;

            return(body);
        }
Esempio n. 5
0
        /// <summary>
        /// 支付宝支付查询(蚂蚁金服)
        /// </summary>
        /// <param name="alipayTradeQueryInfo">查询信息</param>
        /// <param name="config">config</param>
        /// <returns>结果</returns>
        public static string QueryPayTrade(AlipayTradeQueryInfo alipayTradeQueryInfo, SdkPay.Config config)
        {
            const string                url          = SdkPay.Config.ServerUrl;
            string                      appId        = config.GetAppId();
            string                      rivateKeyPem = config.GetPrivateKeyPem();
            const string                format       = SdkPay.Config.Format;
            const string                version      = SdkPay.Config.Version;
            const string                signType     = SdkPay.Config.SignType;
            string                      publicKeyPem = config.GetPublicKeyPemAliPay();
            const string                charset      = SdkPay.Config.Charset;
            IAopClient                  client       = new DefaultAopClient(url, appId, rivateKeyPem, format, version, signType, publicKeyPem, charset, false);
            AlipayTradeQueryRequest     request      = new AlipayTradeQueryRequest();
            AlipayTradeAppPayQueryModel model        = new AlipayTradeAppPayQueryModel
            {
                out_trade_no = alipayTradeQueryInfo.OutTradeNo,
                trade_no     = alipayTradeQueryInfo.TradeNo
            };

            request.SetBizModel(model);
            AlipayTradeQueryResponse response = client.Execute(request);
            var body = response.Body;

            return(body);
        }
Esempio n. 6
0
        /// <summary>
        /// 创建请求code的URL(蚂蚁金服)
        /// </summary>
        /// <param name="request">请求参数</param>
        /// <param name="config">配置</param>
        /// <returns>结果</returns>
        public static string GetOpenidAndAccessTokenUrl(OpenidAndAccessTokenUrlInfo request, SdkPay.Config config)
        {
            string scope = "auth_base";

            return($"https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id={config.GetAppId()}&scope={scope}&redirect_uri={request.RedirectUri}&state={request.State}");
        }