我正在开发ASP.NET上的Web应用程序 . 在应用程序中,用户可以购买物品 . 对于PayPal的工作,我使用PayPal Merchant SDK for .NET包 . 应用程序适用于沙箱,但有实时显示错误: "This transaction is invalid"
. 请返回收件人的网站,使用他们的常规结帐流程完成您的交易 . “当用户点击购买按钮时,我执行代码:
// only for live
var paypalConfig = new Dictionary<string, string> {
{"account1.applicationId", "<APP-LIVEID>"},
{"account1.apiUsername", "<username>"},
{"account1.apiPassword", "<pass>"},
{"account1.apiSignature", "<signature>"},
{"mode", "live"}};
try
{
var currency = CurrencyCodeType.USD;
var paymentItem = new PaymentDetailsItemType
{
Name = "item",
Amount = new BasicAmountType(currency, amount.ToString()),
ItemCategory = ItemCategoryType.DIGITAL,
};
var paymentItems = new List<PaymentDetailsItemType>();
paymentItems.Add(paymentItem);
var paymentDetail = new PaymentDetailsType();
paymentDetail.PaymentDetailsItem = paymentItems;
paymentDetail.PaymentAction = PaymentActionCodeType.SALE;
paymentDetail.OrderTotal = new BasicAmountType(currency, amount.ToString());
paymentDetail.SellerDetails = new SellerDetailsType {
PayPalAccountID= sellerEmail
};
var paymentDetails = new List<PaymentDetailsType>();
paymentDetails.Add(paymentDetail);
var ecDetails = new SetExpressCheckoutRequestDetailsType {
ReturnURL = returnUrl,
CancelURL = cancelUrl,
PaymentDetails = paymentDetails,
};
var request = new SetExpressCheckoutRequestType
{
Version = "104.0",
SetExpressCheckoutRequestDetails = ecDetails,
};
var wrapper = new SetExpressCheckoutReq
{
SetExpressCheckoutRequest = request
};
var service = new PayPalAPIInterfaceServiceService(paypalConfig);
var setECResponse = service.SetExpressCheckout(wrapper);
if (sandbox)
return "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token={0}".FormatWith(setECResponse.Token);
return "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&TOKEN={0}".FormatWith(setECResponse.Token);
}
// # Exception log
catch (System.Exception ex)
{
// Log the exception message
Console.WriteLine("Error Message : " + ex.Message);
}
毕竟我用收到的TOKEN将用户重定向到url .
对于我的应用程序,在PayPal上注册,我只在选项中设置 "Adaptive Payments > Basic Payments > Checkout, Send Money or Parallel Payments"
为什么直播PayPal付款不起作用?是什么原因?
2 回答
删除
和所有的工作
根据以前的经验,这个问题通常来自拥有“空”令牌,因为“setExpressCheckout”请求中的某些错误(在快速结账流程中,您向paypal请求交易令牌) .
基本上,你问paypal一个令牌,所以你可以 Build 重定向URL,但你犯了一些错误,paypal给你一个错误,但没有令牌,所以你 Build 没有令牌(或错误的URL)的URL .
如果您尝试将用户重定向到带有空令牌的结帐URL(https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token= &useraction = ),您将收到此错误 .
其实我想知道还有其他原因......