我使用 Paypal 的付款方式不起作用。在用户带着他购买的商品的描述到达 Paypal 页面后,它被定向到我的网站,上面说付款成功
http://example.com/Store/ReturnPaypal/?token=EC-8F726826L7777777&PayerID=PEWR9EA
但是当我转到我的 PayPal 帐户时,我没有看到任何额外的钱
public ActionResult OrderPaypal()
{
string api_paypal = "https://api-3t.paypal.com/nvp?";
string user = "info_api1.example.com";
string pass = "testpass";
string signature = "test.test-test";
string version = "124.0";
string requete = api_paypal + "VERSION=" + version + "&USER=" + user + "&PWD=" + pass + "&SIGNATURE=" + signature;
requete = requete + "&METHOD=SetExpressCheckout" +
"&CANCELURL=" + HttpUtility.UrlEncode("http://example.com/Store/CancelPaypal/") +
"&RETURNURL=" + HttpUtility.UrlEncode("http://example.com/Store/ReturnPaypal/") +
"&AMT=" + SessionData.CurrentOrder.Total.ToString().Replace(',','.') +
"&CURRENCYCODE=EUR" +
"&DESC=" + HttpUtility.UrlEncode("Paiement total:" + SessionData.CurrentOrder.Total+" €") +
"&LOCALECODE=FR" +
"&HDRIMG=" + HttpUtility.UrlEncode("http://example.com/assets/images/home/image_10000.png");
var httpWebRequest = (HttpWebRequest)WebRequest.Create(requete);
WebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
string rep = streamReader.ReadToEnd();
if (!string.IsNullOrEmpty(rep))
{
string[] list = rep.Split('&');
Dictionary<string,string> dicParam = new Dictionary<string,string>();
foreach(string str in list)
{
string key = str.Split('=')[0];
string value = str.Split('=')[1];
dicParam.Add(key, value);
}
if (dicParam["ACK"] == "Success")
return Redirect("https://www.paypal.com/webscr&cmd=_express-checkout&token=" + dicParam["TOKEN"]);
else
{
ViewBag.State = "-1";
return View("ReturnSolution",dicParam["L_SHORTMESSAGE0"]);
}
}
else
{
ViewBag.State = "-1";
return View("ReturnSolution", "Error communication PayPal ");
}
}
}