【问题标题】:Paypal Rest API With Credit Cart Payment Method带有信用卡支付方式的 Paypal Rest API
【发布时间】:2015-07-17 16:39:53
【问题描述】:

这就是我创建 PayPal 付款的方式。

 var apiContext = GetApiContext(clientId, clientSecret);

 CreditCard creditCard = new CreditCard();
 creditCard.number = "4877274905927862";
 creditCard.type = "visa";
 creditCard.expire_month = 11;
 creditCard.expire_year = 2018;
 creditCard.cvv2 = "874";
 creditCard.first_name = firstName;
 creditCard.last_name = lastName;

 Amount amount = new Amount();
 amount.total = "7.47";
 amount.currency = "USD";

 Transaction transaction = new Transaction();
 transaction.amount = amount;
 transaction.description = "This is the payment transaction description.";

 List<Transaction> transactions = new List<Transaction>();
 transactions.Add(transaction);

 FundingInstrument fundingInstrument = new FundingInstrument();
 fundingInstrument.credit_card = creditCard;

 List<FundingInstrument> fundingInstruments = new List<FundingInstrument>();
 fundingInstruments.Add(fundingInstrument);

 Payer payer = new Payer();
 payer.funding_instruments = fundingInstruments;
 payer.payment_method = "credit_card";

 Payment payment = new Payment();
 payment.intent = "sale";
 payment.payer = payer;
 payment.transactions = transactions;

 Payment createdPayment = payment.Create(apiContext);

对于 payment.execute,我需要付款 ID 和付款人 ID。但付款人 ID 为空 你能告诉我,我怎样才能得到付款人ID?我错过了什么吗?

【问题讨论】:

  • 假设我理解了你的问题,以上是credit cardsale 请求,你应该已经从Create 得到了结果。 IINM Execute 用于 paypal 付款。

标签: c# asp.net paypal paypal-sandbox


【解决方案1】:

请参考 Paypal pro API。我认为这对您有好处,并为您提供更好的知识。

【讨论】:

  • 这不是答案。
【解决方案2】:

信用卡支付时无需payment.Execute(...)

创建付款后...

Payment createdPayment = payment.Create(apiContext);

...,只需拨打createdPayment.id 获取付款ID。

如果你想通过paypal方式付款 需要payment.Create(...),然后是payment.Execute(...)(在买家通过重定向到 PayPal 批准付款之后)。

关于付款人 ID

当您通过 paypal 方式付款时,您执行payment.Create(...),然后将买家重定向到 PayPal。买家批准付款后,PayPal 会重定向到您的网址,并在查询字符串中为您提供PayerID。然后,您将像这样执行付款:

var execution = new PaymentExecution { payer_id = Request.Params["PayerID"] };
payment.Execute(apiContext, execution);

【讨论】:

  • Payment createdPayment = payment.Create(apiContext); 行中出现错误错误消息是 {"name":"INTERNAL_SERVICE_ERROR","message":"发生内部服务错误。","information_link":"developer.paypal.com/docs/api/payments/…"}
  • 这通常是由于 PayPal 服务器关闭或您配置错误而导致的。它不应该与代码有任何关系。 PayPal 曾经有一个您可以访问的网站,以检查服务器的状态。你可能想调查一下。这是一个令人沮丧的消息,我知道。如果您还没有这样做,当您收到此类错误消息时,您可能希望借此机会实施您的错误处理。您可以显示一条消息,例如“我们的服务器现在已关闭,请稍后再试。”
  • 首先我想说谢谢你照顾这个。实际上这是我的问题,我提供了一些互联网上可用的“测试卡”(这些卡与其他一些支付网关如 PayU Money 一起使用)。这不是 Paypal 的问题,在 Paypal 控制台中进行了一些研究后,我喜欢开发者控制台中的 Generate Card 选项。我使用了生成的汽车,它至少对我来说很好。
  • 但我还有另一个疑问,我们将如何在交易时收到 Enter OTP 页面。在 Paypal 中使用信用卡付款时,我看不到任何重定向。我错过了什么吗?
  • @Biju,我将我的付款创建调用包装在一个 try/catch 块中。如果有异常,我的 catch 块会将其重定向到异常处理函数。如果没有异常,我会保存付款人ID,并重定向到下一页。
猜你喜欢
  • 2018-06-18
  • 2014-03-08
  • 2017-12-02
  • 2011-10-10
  • 2013-06-07
  • 2017-04-20
  • 2013-12-25
  • 2011-02-22
  • 2013-11-30
相关资源
最近更新 更多