使用信用购物车付款方式的PayPal REST API



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

 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?我想念什么吗?

您不需要在信用卡付款时进行payment.Execute(...)

创建付款后...

Payment createdPayment = payment.Create(apiContext);

...,只需致电createdPayment.id获取付款ID。

如果想通过贝宝方法付款将需要payment.Create(...),然后需要payment.Execute(...)(买方通过重定向付款到PayPal批准付款)。

关于付款人ID

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

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

请参阅PayPal Pro API。我认为这对您有好处,并为您提供更好的知识。

相关内容

  • 没有找到相关文章

最新更新