Asp.net mvc 如何为其他支付网关定制NOP商务插件
我想为其他支付网关(Easy Pay)定制nopCommerceAsp.net mvc 如何为其他支付网关定制NOP商务插件,asp.net-mvc,plugins,nopcommerce,Asp.net Mvc,Plugins,Nopcommerce,我想为其他支付网关(Easy Pay)定制nopCommerce插件。我更改了付款URL和参数 public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest) { var strPost = "storeId=" + _eWayHostedPaymentSettings.CustomerId; strPost += Format("amount", postProcessPa
插件。我更改了付款URL和参数
public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
{
var strPost = "storeId=" + _eWayHostedPaymentSettings.CustomerId;
strPost += Format("amount", postProcessPaymentRequest.Order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture));
strPost += Format("orderRefNum", postProcessPaymentRequest.Order.Id.ToString());
strPost += Format("postBackURL", "http://www.smmotors.org/onepagecheckout");
var url = _eWayHostedPaymentSettings.PaymentPage + "?" + strPost;
var objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = WebRequestMethods.Http.Get;
var objRequest1 = (HttpWebRequest)WebRequest.Create(url);
objRequest1.Method = WebRequestMethods.Http.Post;
var objResponse = (HttpWebResponse)objRequest.GetResponse();
此时
Easypay
服务器将名为auth_token
的参数发送回作为GET参数发送的postbackURL
但是Var objResponse
无法获取auth_令牌
&postBackURL
。原因和解决办法是什么
//get the response from the transaction generate page
string resultXml;
using (var sr = new StreamReader(objResponse.GetResponseStream()))
{
resultXml = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
//parse the result message
var resultObj = ParseRequestResults(resultXml);
if (resultObj.Result)
{
//redirect the user to the payment page
HttpContext.Current.Response.Redirect(resultObj.Uri);
}
else
{
throw new NopException(resultObj.Error);
}
}
下面是插件集成步骤:
商户将遵循以下流程在其店铺中嵌入Easypay
插件:
•商户通过Easypay
代理获得账户。成功注册后,将向商户发送包含唯一店铺ID和URL的欢迎电子邮件
•商户登录Easy Pay门户并访问“集成指南”菜单,在该菜单中,商户将逐步获得将Easypay
插件集成到其购物车/在线零售商店的说明
以下是商户登录Easypay
门户后应该找到的流量示例
具有唯一店铺ID的商户在其在线商店/网站的结账页面上嵌入了Easypay
插件。这将集成“通过Easypay
支付”作为其网站中的支付解决方案。集成Easypay
插件是一个简单的两步过程:
Easypay
: using (var client = new HttpClient())
{
var values = new List<KeyValuePair<string, string>>();
values.Add(new KeyValuePair<string, string>("storeId", "43"));
values.Add(new KeyValuePair<string, string>("amount", "10"));
values.Add(new KeyValuePair<string, string>("postBackURL", "http://www.my.onlinestore.com/transaction/MessageHandler"));
values.Add(new KeyValuePair<string, string>("orderRefNum", "1101"));
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://easypay.easypaisa.com.pk/easypay/Index.jsf", content); var responseString = await response.Content.ReadAsStringAsync();
}
using (var client = new HttpClient())
{
var values = new List<KeyValuePair<string, string>>();
values.Add(new KeyValuePair<string, string>("auth_token", Request.Querystring["auth_token"])); values.Add(new KeyValuePair<string, string>("postBackURL", "http://www.my.online-
store.com/transaction/MessageHandler1"));
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://easypay.easypaisa.com.pk/easypay/Confirm.jsf", content); var responseString = await response.Content.ReadAsStringAsync();
}
使用(var-client=new-HttpClient())
{
var值=新列表();
添加(新的KeyValuePair(“storeId”,“43”));
添加(新的KeyValuePair(“金额”,“10”));
添加(新的KeyValuePair(“postBackURL”),“http://www.my.onlinestore.com/transaction/MessageHandler"));
添加(新的KeyValuePair(“orderRefNum”、“1101”);
var内容=新的FormUrlEncodedContent(值);
var response=wait client.PostAsync(“https://easypay.easypaisa.com.pk/easypay/Index.jsf,content);var responseString=await response.content.ReadAsStringAsync();
}
对于第二个重定向:
using (var client = new HttpClient())
{
var values = new List<KeyValuePair<string, string>>();
values.Add(new KeyValuePair<string, string>("storeId", "43"));
values.Add(new KeyValuePair<string, string>("amount", "10"));
values.Add(new KeyValuePair<string, string>("postBackURL", "http://www.my.onlinestore.com/transaction/MessageHandler"));
values.Add(new KeyValuePair<string, string>("orderRefNum", "1101"));
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://easypay.easypaisa.com.pk/easypay/Index.jsf", content); var responseString = await response.Content.ReadAsStringAsync();
}
using (var client = new HttpClient())
{
var values = new List<KeyValuePair<string, string>>();
values.Add(new KeyValuePair<string, string>("auth_token", Request.Querystring["auth_token"])); values.Add(new KeyValuePair<string, string>("postBackURL", "http://www.my.online-
store.com/transaction/MessageHandler1"));
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://easypay.easypaisa.com.pk/easypay/Confirm.jsf", content); var responseString = await response.Content.ReadAsStringAsync();
}
使用(var-client=new-HttpClient())
{
var值=新列表();
values.Add(新的KeyValuePair(“auth_token”,Request.Querystring[“auth_token”]);values.Add(新的KeyValuePair(“postBackURL”),”http://www.my.online-
store.com/transaction/MessageHandler1”);
var内容=新的FormUrlEncodedContent(值);
var response=wait client.PostAsync(“https://easypay.easypaisa.com.pk/easypay/Confirm.jsf,content);var responseString=await response.content.ReadAsStringAsync();
}