gpt4 book ai didi

c# - 带有信用卡支付方式的 Paypal Rest API

转载 作者:太空宇宙 更新时间:2023-11-03 23:37:43 24 4
gpt4 key购买 nike

这就是我创建 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?我错过了什么吗?

最佳答案

当您使用信用卡支付时,您​​不需要执行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);

关于c# - 带有信用卡支付方式的 Paypal Rest API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30095448/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com