Paypal 从AdaptivePayments获取交易编号
这是对我之前问题的更新。鉴于这个问题的整个问题已经改变,我觉得有必要提出一个更准确、更详细的问题。这是我的密码: 支付 调用这些函数Paypal 从AdaptivePayments获取交易编号,paypal,paypal-adaptive-payments,Paypal,Paypal Adaptive Payments,这是对我之前问题的更新。鉴于这个问题的整个问题已经改变,我觉得有必要提出一个更准确、更详细的问题。这是我的密码: 支付 调用这些函数 我的问题是-如何检索在SetupPayment()&中创建的、在ExecutePayment()中执行的付款的交易编号/ID?我在Adaptive Payments API中看到的唯一一点是,交易编号在IPN消息中……但是否只有通过IPN才能真正获取交易编号?执行支付后,请致电PaymentDetails。响应应该有事务ID(paymentInfoList.pay
我的问题是-如何检索在
SetupPayment()
&中创建的、在ExecutePayment()中执行的付款的交易编号/ID?我在Adaptive Payments API中看到的唯一一点是,交易编号在IPN消息中……但是否只有通过IPN才能真正获取交易编号?执行支付后,请致电PaymentDetails。响应应该有事务ID(paymentInfoList.paymentInfo(0).transactionId
,用于接收方的事务ID,或者paymentInfoList.paymentInfo(n).senderTransactionId
,用于发送方的事务ID)。这似乎就是我要找的。但由于某些原因,paymentDetailsResponse.paymentInfoList为空。是否有某种方式我需要特别要求填充数据?如果paymentInfoList为空,则可能表明买家从未在PayPal上完成付款。
public PayResponse SetupPayment(string receiverEmail, decimal amountToPay)
{
ReceiverList receiverList = new ReceiverList { receiver = new List<Receiver>() };
Receiver receiver = new Receiver(amountToPay) { email = receiverEmail };
receiverList.receiver.Add(receiver);
RequestEnvelope requestEnvelope = new RequestEnvelope("en_US");
const string actionType = "CREATE";
const string returnUrl = "https://devtools-paypal.com/guide/ap_implicit_payment/dotnet?success=true";
const string cancelUrl = "https://devtools-paypal.com/guide/ap_implicit_payment/dotnet?cancel=true";
const string currencyCode = "USD";
PayRequest payRequest = new PayRequest(
requestEnvelope,
actionType,
cancelUrl,
currencyCode,
receiverList,
returnUrl)
{
senderEmail = ConfigurationManager.AppSettings["PayPalSenderEmail"]
};
AdaptivePaymentsService adaptivePaymentService = new AdaptivePaymentsService(_payPalConfig);
PayResponse payResponse = adaptivePaymentService.Pay(payRequest);
return payResponse;
}
public ExecutePaymentResponse ExecutePayment(string payKey)
{
RequestEnvelope requestEnvelope = new RequestEnvelope("en_US");
ExecutePaymentRequest executePaymentRequest = new ExecutePaymentRequest(requestEnvelope, payKey);
AdaptivePaymentsService adaptivePaymentsService = new AdaptivePaymentsService(_payPalConfig);
ExecutePaymentResponse executePaymentResponse = adaptivePaymentsService.ExecutePayment(executePaymentRequest);
return executePaymentResponse;
}
PayResponse payResponse = payPalAdapter.SetupPayment(payPalUserEmail, commissionAmount);
if (payResponse.responseEnvelope.ack.ToString() == "SUCCESS")
{
ExecutePaymentResponse executePaymentResponse = payPalAdapter.ExecutePayment(payResponse.payKey);
}