我想为其他支付网关(Easy Pay)自定义nopCommerce eWayHosted
插件。我更改了付款网址和参数。
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
的参数发送回postbackURL
,该参数作为GET参数发送。
但是Var objResponse
无法获得auth_token
& 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
:生产(实时)环境: https://easypay.easypaisa.com.pk/easypay/Index.jsf 沙箱环境: https://easypaystg.easypaisa.com.pk/easypay/Index.jsf
• amount
• storeId
• postBackURL
• orderRefNum
成功重定向后,客户将登陆Easypay Checkout屏幕,其中有关于交易信息的表格。
生产(实时)环境: https://easypay.easypaisa.com.pk/easypay/Confirm.jsf 沙箱环境: https://easypaystg.easypaisa.com.pk/easypay/Confirm.jsf •auth_token •postBackURL
在此重定向之后,Easypay验证商家发送的auth_token与上一步中的auth_token,并且在成功验证后,它将使客户登陆成功的结账屏幕,将两个变量发送回第二个postBackURL: • 状态 •desc •orderRefNumber
.NET的示例代码段
首次重定向:
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();
}