简体   繁体   中英

How can I get the TransactionID after payment in PayPal

I'm developing a website with MVC and I'm going to manage the payment with PayPal.

After the payment I need the transaction ID but I don't know how can I get it. Anyone can help me?

payRequest.ReturnURL = url + Url.Action("PaymentPayPalOk");
            payRequest.CancelURL = url + Url.Action("PaymentKo");
            payRequest.Amount = Math.Round(model.total, 2);
            payRequest.Commento = string.Format("Ordine: {0}", OrderId);
            payRequest.ReceiverEmail = PayPal.RecipientEmail;
            var payResponse = _payPalService.ProcessPayment(payRequest, Server.MapPath("~/"));
            model.TransactionId = payResponse.PayPalKey;
            if (payResponse.IsSuccessful)
            {
                return Redirect(payResponse.RedirectURL);
            }
            else
                return RedirectToAction("Index", "Error");

I attached the image of the information that i need

在此输入图像描述

I'm not sure which kind of SDK you're using but normally you find the TransactionID in your REST Response at the related_resources property of each transaction element in the id value.

示例JSON响应


I recommend you to look up the PayPal-NET-SDK on github . It has a nice and strong community and also a fast response on your issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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