我正在编写一个商店应用程序使用ASP.NET(网页形式)和WingtipToys教程从微软开发网。
我有一个问题,当我使用贝宝按钮。我有错误:
10401
Transaction refused because of an invalid argument. See additional error messages for details.
Order total is invalid.这是代码的一部分,我认为哪里出了问题:
public bool ShortcutExpressCheckout(string amt, ref string token, ref string retMsg)
{
if (bSandbox)
{
pEndPointURL = pEndPointURL_SB;
host = host_SB;
}
string returnURL = "https://localhost:44317/Checkout/CheckoutReview.aspx";
string cancelURL = "https://localhost:44317/Checkout/CheckoutCancel.aspx";
NVPCodec encoder = new NVPCodec();
encoder["METHOD"] = "SetExpressCheckout";
encoder["RETURNURL"] = returnURL;
encoder["CANCELURL"] = cancelURL;
encoder["BRANDNAME"] = "Shop";
encoder["PAYMENTREQUEST_0_AMT"] = amt;
encoder["PAYMENTREQUEST_0_ITEMAMT"] = amt;
encoder["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
encoder["PAYMENTREQUEST_0_CURRENCYCODE"] = "PLN";
// Get the Shopping Cart Products
using (Shop.Logic.ShoppingCartActions myCartOrders = new Shop.Logic.ShoppingCartActions())
{
List<ElementKoszyka> myOrderList = myCartOrders.GetCartItems();
for (int i = 0; i < myOrderList.Count; i++)
{
encoder["L_PAYMENTREQUEST_0_NAME" + i] = myOrderList[i].Produkt.nazwa_produkt.ToString();
// string tmp = Math.Round(myOrderList[i].Produkt.cena, 2).ToString();
// encoder["L_PAYMENTREQUEST_0_AMT" + i] = Math.Round(myOrderList[i].Produkt.cena, 2).ToString();
encoder["L_PAYMENTREQUEST_0_AMT" + i] = "22.50";
encoder["L_PAYMENTREQUEST_0_QTY" + i] = myOrderList[i].ilosc.ToString();
}
}
string pStrrequestforNvp = encoder.Encode();
string pStresponsenvp = HttpCall(pStrrequestforNvp);
NVPCodec decoder = new NVPCodec();
decoder.Decode(pStresponsenvp);
string strAck = decoder["ACK"].ToLower();
if (strAck != null && (strAck == "success" || strAck == "successwithwarning"))
{
token = decoder["TOKEN"];
string ECURL = "https://" + host + "/cgi-bin/webscr?cmd=_express-checkout" + "&token=" + token;
retMsg = ECURL;
return true;
}
else
{
retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" +
"Desc=" + decoder["L_SHORTMESSAGE0"] + "&" +
"Desc2=" + decoder["L_LONGMESSAGE0"];
return false;
}
}总订单已永久分配(22.50),但仍有问题。
有什么建议吗?
发布于 2017-05-30 10:46:44
价格被指定为
encoder["L_PAYMENTREQUEST_0_AMT" + i] = "22.50";也许它应该是这样的
encoder["L_PAYMENTREQUEST_0_AMT" + i] = myOrderList[i].Produkt.nazwa_price.ToString();发布于 2017-05-31 03:40:38
好了,问题解决了。我必须在不同的类中将amt更改为decimal。
因此,paypal订单的正确格式是:"xx.xx“
发布于 2017-07-04 20:44:57
如果您的计算机使用十进制komma,则应将您的分配更改为:
encoder["L_PAYMENTREQUEST_0_AMT" + i] = (myOrderList[i].Produkt.nazwa_price.ToString()).Replace(",",".");https://stackoverflow.com/questions/44242747
复制相似问题