public static FederationResponse Success(FederationRequest req, OutsideGatewayFederationInfo userInfo) { return new FederationResponse { Result = "success", UserAccount = userInfo, OriginRequest = req }; }
public static FederationResponse NoSupportedType(FederationRequest req, string type) { return new FederationResponse { Result = "error", Error = "noSupported", ErrorMessage = "not support request type:" + type, OriginRequest = req }; }
public static FederationResponse NoSuchDomain(FederationRequest req) { return new FederationResponse { Result = "error", Error = "noSuchDomain", ErrorMessage = "The supplied domain is not served here.", OriginRequest = req }; }
public static FederationResponse NoSuchUser(FederationRequest req) { return new FederationResponse { Result = "error", Error = "noSuchUser", ErrorMessage = "The supplied user was not found.", OriginRequest = req }; }
public System.Web.Http.Results.JsonResult<FederationResponse> RippleBridge(string type, string destination, string domain) { var result = default(FederationResponse); var req = new FederationRequest { Type = type, Destination = destination, Domain = domain }; type = type.NullSafe().Trim(); destination = destination.NullSafe().Trim(); domain = domain.NullSafe().Trim(); #region 错误处理 if (!type.ToLower().Equals("federation")) result = FederationErrorResult.NoSupportedType(req, type); else if (!CheckDomain(domain)) result = FederationErrorResult.NoSuchDomain(req); else if (string.IsNullOrEmpty(destination)) result = FederationErrorResult.NoSuchUser(req); #endregion else { var tppBridge = default(ThirdPartyPaymentBridgeDestination); if (ThirdPartyPaymentBridgeDestination.TryParse(destination + "@" + domain, out tppBridge)) { #region 如果是第三方支付直转 destination = tppBridge.Bridge; domain = tppBridge.Domain; var tagFlg = Utilities.GetDestinationTagFlgByBridgeName(tppBridge.Bridge); var payway = Utilities.GetPayWayByBridgeName(tppBridge.Bridge); if (payway != default(PayWay)) { try { //创建一个交易 var cmd = new CreateThirdPartyPaymentInboundTx(payway, tppBridge.Account); IoC.Resolve<ICommandBus>().Send(cmd); var userInfo = new OutsideGatewayFederationInfo { Type = "federation_record", Destination = tppBridge.Account + GATEWAY_SPLIT + tppBridge.Bridge, DestinationAddress = GATEWAY_ADDRESS, DestinationTag = int.Parse(tagFlg.ToString("D") + cmd.ResultDestinationTag.ToString()), Domain = domain, AcceptCurrencys = new List<RippleCurrency> { new RippleCurrency { Issuer = GATEWAY_ADDRESS, Symbol = GATEWAY_ACCEPT_CURRENCY } } }; result = FederationErrorResult.Success(req, userInfo); } catch (Exception ex) { Log.Error("在ripple federation protocol解析时出现异常" + destination + "@" + domain, ex); result = FederationErrorResult.NoSuchUser(req); } } else { result = FederationErrorResult.NoSuchUser(req); } #endregion } else { #region 如果是普通用户或者是第三方支付表单方式 var repos = IoC.Resolve<IUserQuery>(); var user = default(LoginUser); //如果用户要做扩展表单直转 to alipay if (destination.Equals("alipay", StringComparison.OrdinalIgnoreCase)) { var federationInfo = new OutsideGatewayFederationInfo { Type = "federation_record", Destination = destination, ExtraFields = new List<ExtraFiled> { new ExtraFiled{Type="text", Hint="支付宝账户" ,Label="Destination alipay account",Required=true, Name="alipay_account"}, new ExtraFiled{Type="text", Hint="支付宝账户实名(可选)" ,Label="Real name of the destination alipay account (optional)", Name="alipay_username"}, new ExtraFiled{Type="text", Hint="留言(可选),可填联系方式,收货地址等信息,您可在支付完成后在 "+QUERY_URL+"查询交易状态",Label="Comments(optional), for contacts, shipping address etc., you can check the transaction status at "+QUERY_URL+" after confirming the payment",Name="memo"} }, Domain = domain, QuoteUrl = QUOTE_URL, AcceptCurrencys = new List<RippleCurrency> { new RippleCurrency { Issuer = GATEWAY_ADDRESS, Symbol = GATEWAY_ACCEPT_CURRENCY } } }; result = FederationErrorResult.Success(req, federationInfo); } //如果用户要做扩展表单直转 to tenpay else if (destination.Equals("tenpay", StringComparison.OrdinalIgnoreCase)) { var federationInfo = new OutsideGatewayFederationInfo { Type = "federation_record", Destination = destination, ExtraFields = new List<ExtraFiled> { new ExtraFiled{Type="text", Hint="财付通账户" ,Label="Destination alipay account",Required=true, Name="alipay_account"}, new ExtraFiled{Type="text", Hint="财付通账户实名(可选)" ,Label="Real name of the destination alipay account (optional)", Name="tenpay_username"}, new ExtraFiled{Type="text", Hint="留言(可选),可填联系方式,收货地址等信息,您可在支付完成后在 "+QUERY_URL+"查询交易状态",Label="Comments(optional), for contacts, shipping address etc., you can check the transaction status at "+QUERY_URL+" after confirming the payment",Name="memo"} }, Domain = domain, QuoteUrl = QUOTE_URL, AcceptCurrencys = new List<RippleCurrency> { new RippleCurrency { Issuer = GATEWAY_ADDRESS, Symbol = GATEWAY_ACCEPT_CURRENCY } } }; result = FederationErrorResult.Success(req, federationInfo); } //如果用户要做扩展表单直转 to bank else if (destination.Equals("bank", StringComparison.OrdinalIgnoreCase)) { var bank = new List<ExtraSelectFiledOption>(); var federationInfo = new OutsideGatewayFederationInfo { Type = "federation_record", Destination = destination, ExtraFields = new List<ExtraFiled> { new ExtraFiled{ Type="select", Hint="开户行(如果列表没有所需银行名称,请选择其它银行,并在留言中填写银行名称)" , Label="Bank Name(if the bank is not listed, please select \"Other Bank\" and give the bank name in comments below.)", Required=true, Name="bank", Options=GetBankFiledsList() }, new ExtraFiled{Type="text", Hint="银行卡号",Label="Bank Account Number",Required=true,Name="bank_account"}, new ExtraFiled{Type="text", Hint="开户人姓名",Label="Account Name",Required=true,Name="bank_username"}, new ExtraFiled{Type="text", Hint="留言(可选),可填联系方式,收货地址等信息,您可在支付完成后在 "+QUERY_URL+"查询交易状态",Label="Comments(optional), for contacts, shipping address etc., you can check the transaction status at "+QUERY_URL+" after confirming the payment",Name="memo"} }, Domain = domain, QuoteUrl = QUOTE_URL, AcceptCurrencys = new List<RippleCurrency> { new RippleCurrency { Issuer = GATEWAY_ADDRESS, Symbol = GATEWAY_ACCEPT_CURRENCY } } }; result = FederationErrorResult.Success(req, federationInfo); } //如果用户要做扩展表单来支付324活动 else if (destination.Equals("huodong", StringComparison.OrdinalIgnoreCase)) { var bank = new List<ExtraSelectFiledOption>(); var federationInfo = new OutsideGatewayFederationInfo { Type = "federation_record", Destination = destination, ExtraFields = new List<ExtraFiled> { new ExtraFiled{Type="text", Hint="参与人姓名",Label="Full Name",Required=true,Name="alipay_username"}, new ExtraFiled{Type="text", Hint="手机号",Label="Mobile",Required=true,Name="alipay_account"}, new ExtraFiled{Type="text", Hint="留言(可选)",Label="Comments(optional)",Name="memo"} }, Domain = domain, QuoteUrl = QUOTE_URL, AcceptCurrencys = new List<RippleCurrency> { new RippleCurrency { Issuer = GATEWAY_ADDRESS, Symbol = GATEWAY_ACCEPT_CURRENCY } } }; result = FederationErrorResult.Success(req, federationInfo); } else { if (destination.IsEmail()) user = repos.GetUserByEmail(destination); else user = repos.GetUserByLoginName(destination); if (user == null) result = FederationErrorResult.NoSuchUser(req); else { var userInfo = new OutsideGatewayFederationInfo { Type = "federation_record", Destination = destination, DestinationAddress = GATEWAY_ADDRESS, DestinationTag = int.Parse(DestinationTagFlg.Dotpay.ToString("D") + user.UserID.ToString()), Domain = domain, AcceptCurrencys = new List<RippleCurrency> { new RippleCurrency { Issuer = GATEWAY_ADDRESS, Symbol = GATEWAY_ACCEPT_CURRENCY } } }; result = FederationErrorResult.Success(req, userInfo); } } #endregion } } return Json(result); }