我正试图通过PayPal处理creit卡,并不断收到这个奇怪的错误:
{"name":"VALIDATION_ERROR"、"详细信息":[{"field":"交易[0].金额"、"问题":"交易金额详细信息(小计、税收、运输)必须合计到指定的金额总额"}]、"消息":"无效请求-查看详细信息"、"information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR"、"debug_id":"6e2cef39d556a"}
以下是我使用的方法:
public ActionResult PaymentWithCreditCard(PayWithCCViewModel model)
{
var cart = ShoppingCart.GetCart(this.HttpContext);
var cartItems = cart.GetCartItems();
List<Item> orderItems = new List<Item>();
foreach (var cartItem in cartItems)
{
var item = new Item();
item.name = cartItem.Product.ProductName;
item.currency = "USD";
item.price = cartItem.ProductPrice.ToString();
item.quantity = cartItem.ProductQuantity.ToString();
orderItems.Add(item);
}
ItemList itemList = new ItemList();
itemList.items = orderItems;
//Address for the payment
Address billingAddress = new Address();
billingAddress.city = model.BillingCity;
billingAddress.country_code = "US";
billingAddress.line1 = model.BillingAddressLine1;
billingAddress.line2 = model.BillingAddressLine2;
billingAddress.postal_code = model.BillingPostalCode;
billingAddress.state = model.BillingState;
//Now Create an object of credit card and add above details to it
CreditCard card = new CreditCard();
card.billing_address = billingAddress;
card.cvv2 = model.CVV2;
card.expire_month = model.ExpirationMonth;
card.expire_year = model.ExpirationYear;
card.first_name = model.FirstName;
card.last_name = model.LastName;
card.number = model.Number;
card.type = model.CardType.ToString();
var subTotal = cart.GetTotal();
var tax = Convert.ToDouble(subTotal) * Convert.ToDouble(.076);
var total = Convert.ToDouble(subTotal) + tax;
// Specify details of your payment amount.
Details details = new Details();
details.shipping = "3";
details.subtotal = subTotal.ToString();
details.tax = tax.ToString();
// Specify your total payment amount and assign the details object
Amount amount = new Amount();
amount.currency = "USD";
// Total = shipping tax + subtotal.
amount.total = total.ToString();
amount.details = details;
// Now make a trasaction object and assign the Amount object
Transaction transaction = new Transaction();
transaction.amount = amount;
transaction.description = "Payment to AccessorizeForLess.net";
transaction.item_list = itemList;
transaction.invoice_number = cart.GetCartId(this.HttpContext);
// Now, we have to make a list of trasaction and add the trasactions object
// to this list. You can create one or more object as per your requirements
List<Transaction> transactions = new List<Transaction>();
transactions.Add(transaction);
// Now we need to specify the FundingInstrument of the Payer
// for credit card payments, set the CreditCard which we made above
FundingInstrument fundInstrument = new FundingInstrument();
fundInstrument.credit_card = card;
// The Payment creation API requires a list of FundingIntrument
List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
fundingInstrumentList.Add(fundInstrument);
// Now create Payer object and assign the fundinginstrument list to the object
Payer payr = new Payer();
payr.funding_instruments = fundingInstrumentList;
payr.payment_method = "credit_card";
// finally create the payment object and assign the payer object & transaction list to it
Payment pymnt = new Payment();
pymnt.intent = "sale";
pymnt.payer = payr;
pymnt.transactions = transactions;
try
{
//getting context from the paypal, basically we are sending the clientID and clientSecret key in this function
//to the get the context from the paypal API to make the payment for which we have created the object above.
// Basically, apiContext has a accesstoken which is sent by the paypal to authenticate the payment to facilitator account. An access token could be an alphanumeric string
APIContext context = PayPalModel.GetAPIContext();
// Create is a Payment class function which actually sends the payment details to the paypal API for the payment. The function is passed with the ApiContext which we received above.
Payment payment = pymnt.Create(context);
//if the createdPayment.State is "approved" it means the payment was successfull else not
if (payment.state.ToLower() != "approved")
{
return View("FailureView");
}
}
catch (PayPalException ex)
{
Logger.Log("Error: " + ex.Message);
return View("FailureView");
}
return View("SuccessView");
}
我已经通过代码和总数,税收和运输似乎是正确的,有人有问题时处理PayPal之前,这可能会导致我的解决方案?
我忘了在总数中加运费,现在我得到了批准
早上好,我正在使用paypal express签出我的网站。当客户付款时,它会被重定向到paypal以登录或插入信用卡详细信息,有时paypal会给出“卡无效”错误,我如何检查具体的信用卡错误?(信用卡过期,资金不足,信用卡无效)? 客户收到的错误代码是10486
我正在使用沙箱网址接受测试付款通过贝宝。 当用户点击一个按钮,他被重定向到贝宝沙箱站点。在贝宝沙箱网站上,用户可以选择使用信用卡支付。然而,当我尝试测试信用卡4111-1111-1111-1111时,它给我以下错误:“您输入的卡不能用于此付款。请输入一个不同的借记卡或信用卡号码。” 我不确定我错过了什么?
我已经集成了从贝宝到贝宝帐户的钱转移在我的应用程序,但现在我想转移金额从我的贝宝帐户到任何信用卡。有没有人可以帮助我在这方面发送代码或链接,在那里实现?先谢谢你。
我在移动网站上使用PayPal express结账。当用户使用信用卡支付并输入信用卡信息时,将打开计费信息页面。在这个页面上有一个表单:“创建个人账户(必填)”。为什么贝宝注册需要信用卡支付?
这个块似乎没有捕获发生的错误,这很奇怪,考虑到我对网站的注册部分有一个类似的块。这将处理登录。该错误发生在第三行 并引发此错误: 当电子邮件格式错误时会发生这种情况,例如。因此,当它是时,我希望在块中设置错误消息。 有人知道为什么这个< code>try catch不起作用吗?
通过对错误类型实现 Display 和 From,我们能够利用上绝大部分标准库错误处理工具。然而,我们遗漏了一个功能:轻松 Box 我们错误类型的能力。 标准库会自动通过 Form 将任意实现了 Error trait 的类型转换成 trait 对象 Box<Error> 的类型(原文:The std library automatically converts any type that imp