예제 #1
0
        private XResult <CPIAgreePayPaymentRequest> BuildCPIAgreePayPaymentRequest(CommonPayRequest request)
        {
            if (request == null)
            {
                return(new XResult <CPIAgreePayPaymentRequest>(null, ErrorCode.INVALID_ARGUMENT, new ArgumentNullException(nameof(request))));
            }

            if (!request.IsValid)
            {
                return(new XResult <CPIAgreePayPaymentRequest>(null, ErrorCode.INVALID_ARGUMENT, new ArgumentException(request.ErrorMessage)));
            }

            var queryResult = _bindInfoService.GetBankCardBindDetails(request.PayerId, request.BankCardNo, GlobalConfig.X99BILL_PAYCHANNEL_CODE);

            if (!queryResult.Success || queryResult.Value == null || queryResult.Value.Count() == 0)
            {
                _logger.Error(TraceType.ROUTE.ToString(), CallResultStatus.ERROR.ToString(), $"{nameof(BuildCPIAgreePayPaymentRequest)}(...)", "构造协议支付请求参数", "未查询到该用户的绑卡信息", queryResult.FirstException, new
                {
                    request.PayerId,
                    request.BankCardNo,
                    PayChannelCode = GlobalConfig.X99BILL_PAYCHANNEL_CODE
                });
                return(new XResult <CPIAgreePayPaymentRequest>(null, ErrorCode.NO_BANKCARD_BOUND, new DbQueryException("未查询到该用户的绑卡信息")));
            }

            // 默认取第一条绑卡信息
            var boundInfo = queryResult.Value.FirstOrDefault();

            var result = new CPIAgreePayPaymentRequest()
            {
                PayerId     = request.PayerId,
                Amount      = request.Amount,
                OutTradeNo  = request.OutTradeNo,
                BankCardNo  = boundInfo.BankCardNo,
                PayToken    = boundInfo.PayToken,
                Mobile      = boundInfo.Mobile,
                SharingInfo = request.SharingInfo
            };

            return(new XResult <CPIAgreePayPaymentRequest>(result));
        }
예제 #2
0
        private XResult<CPIEntrustPayPaymentRequest> BuildCPIEntrustPayPaymentRequest(CommonPayRequest request)
        {
            if (request == null)
            {
                return new XResult<CPIEntrustPayPaymentRequest>(null, ErrorCode.INVALID_ARGUMENT, new ArgumentNullException(nameof(request)));
            }

            if (!request.IsValid)
            {
                return new XResult<CPIEntrustPayPaymentRequest>(null, ErrorCode.INVALID_ARGUMENT, new ArgumentException(request.ErrorMessage));
            }

            String service = $"{this.GetType().FullName}.{nameof(BuildCPIEntrustPayPaymentRequest)}(...)";

            var queryResult = _bindInfoService.GetBankCardBindDetails(request.PayerId, request.BankCardNo, GlobalConfig.X99BILL_PAYCHANNEL_CODE);
            if (!queryResult.Success || queryResult.Value == null || queryResult.Value.Count() == 0)
            {
                _logger.Error(TraceType.ROUTE.ToString(), CallResultStatus.ERROR.ToString(), service, $"{nameof(_bindInfoService)}.{nameof(_bindInfoService.GetBankCardBindDetails)}(...)", "未查询到该用户的绑卡信息", queryResult.FirstException, new
                {
                    request.PayerId,
                    request.BankCardNo,
                    PayChannelCode = GlobalConfig.X99BILL_PAYCHANNEL_CODE
                });
                return new XResult<CPIEntrustPayPaymentRequest>(null, ErrorCode.DB_QUERY_FAILED, new DbQueryException("未查询到该用户的绑卡信息"));
            }

            // 默认取第一条绑卡信息
            var boundInfo = queryResult.Value.FirstOrDefault();

            var result = new CPIEntrustPayPaymentRequest()
            {
                PayerId = request.PayerId,
                Amount = request.Amount,
                OutTradeNo = request.OutTradeNo,
                IDCardNo = boundInfo.IDCardNo,
                RealName = boundInfo.RealName,
                BankCardNo = boundInfo.BankCardNo,
                Mobile = boundInfo.Mobile
            };

            return new XResult<CPIEntrustPayPaymentRequest>(result);
        }