简体   繁体   English

如何使用PayPal C#sdk(直接付款方法的transactionid)获取

[英]How to get with paypal C# sdk, the transactionid of a directpayment method

Im using the c# sdk to do a direct payment to paypal. 我正在使用C#SDK向Paypal直接付款。

Everything works great, however im not getting the transactionId because the sdk's "Payment" object does not have a transactionId nor does the http response. 一切都很好,但是由于sdk的“ Payment”对象既没有transactionId也没有http响应,所以我没有获取transactionId。

the code is very simple. 代码很简单。

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


Payment createdPayment = pymnt.Create(apiContext);

Pymnt Create method, creates and Executes the payment and retrieves back the properties by converting them from json. Pymnt Create方法,创建并执行付款,并通过从json转换属性来取回属性。

I am getting back payid.I checked documentation but couldnt find any on how to get transactionId via payid. 我回来了payid。我检查了文档但是找不到任何关于如何通过payid获取transactionId的信息。

Another part of my application that is created with paypal standard gets the paypal transaction id via the "txn_id" query parameter in the IPN method and saved it in the database. 我使用贝宝标准创建的应用程序的另一部分,通过IPN方法中的“ txn_id”查询参数获取贝宝交易ID,并将其保存在数据库中。

Thus we need save the transactionid in the database to be consistent. 因此,我们需要将transactionid保存在数据库中以保持一致。

Please help. 请帮忙。

(A similar question was asked on GitHub .) (在GitHub上提出了类似的问题。)

The transaction ID for a payment can be found via the related_resources property of each transaction associated with a payment. 可以通过与付款相关的每笔transactionrelated_resources属性找到付款的交易ID。

For example, if you make a sale payment, the transaction ID can be retrieved via the following: 例如,如果您进行销售付款,则可以通过以下方式检索交易ID:

var payment = Payment.Get(apiContext, "PAY-89W644977H834061FKTDRCCY");
var transactionId = payment.transactions[0].related_resources[0].sale.id;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM