public string PayF2F(EAliPayApplication app, EUserInfo AgentUi, EStoreInfo storeInfo, float TotalAmount, out ResultEnum status) { string result = ""; string NotifyUrl = ConfigurationManager.AppSettings["Main_SiteUrl"] + "AliPay/PayNotify"; /* * IAlipayTradeService serviceClient = F2FBiz.CreateClientInstance(AliPayConfig.serverUrl, AliPayConfig.appId, AliPayConfig.merchant_private_key, AliPayConfig.version, * AliPayConfig.sign_type, AliPayConfig.alipay_public_key, AliPayConfig.charset); */ IAlipayTradeService serviceClient = F2FBiz.CreateClientInstance(app.ServerUrl, app.AppId, app.Merchant_Private_Key, app.Version, app.SignType, app.Merchant_Public_key, app.Charset); _handler = new F2FPayHandler(); AlipayTradePrecreateContentBuilder builder = _handler.BuildPrecreateContent(app, AgentUi, storeInfo.AliPayAccount, TotalAmount.ToString()); AlipayF2FPrecreateResult precreateResult = serviceClient.tradePrecreate(builder, NotifyUrl); status = precreateResult.Status; switch (precreateResult.Status) { case ResultEnum.SUCCESS: result = _handler.CreateQR(precreateResult); result = _handler.DeQR(result); break; case ResultEnum.FAILED: result = precreateResult.response.Body; break; case ResultEnum.UNKNOWN: if (precreateResult.response == null) { result = "配置或网络异常,请检查后重试"; } else { result = "系统异常,请更新外部订单后重新发起请求"; } break; } return(result); }
public string PayF2FNew(EAliPayApplication app, EUserInfo AgentUi, EStoreInfo storeInfo, string TotalAmount, out AliPayResult status) { string result = ""; bool NeedControl = false; /* * IAlipayTradeService serviceClient = F2FBiz.CreateClientInstance(AliPayConfig.serverUrl, AliPayConfig.appId, AliPayConfig.merchant_private_key, AliPayConfig.version, * AliPayConfig.sign_type, AliPayConfig.alipay_public_key, AliPayConfig.charset); */ IAopClient aliyapClient = new DefaultAopClient("https://openapi.alipay.com/gateway.do", app.AppId, app.Merchant_Private_Key, "json", "1.0", "RSA2", app.Merchant_Public_key, "GBK", false); _handler = new F2FPayHandler(); //if (AgentUi.UserRole == UserRole.Administrator) // NeedControl = false; AlipayTradePrecreateResponse builder = _handler.BuildNew(app, storeInfo, AgentUi, TotalAmount, true, NeedControl); if (builder.Code == "10000") { result = _handler.CreateF2FQR(builder.QrCode); result = _handler.DeQR(result); status = AliPayResult.SUCCESS; } else { if (builder.Code == "20001") { status = AliPayResult.AUTHERROR; result = "授权错误!"; } else { result = "[Error Message]" + builder.Msg + "[Sub Msg]" + builder.SubMsg; status = AliPayResult.FAILED; } } return(result); }