这是我之前提出的问题的更新。鉴于该问题的整个问题已经改变,我认为这需要一个更准确和详细的问题。这是我的代码:
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);
}
我的问题是 - 如何检索在SetupPayment()
&amp;中创建的付款的交易编号/ ID。在ExecutePayment()
执行?我在自适应支付API中看到的唯一提到的是,交易号码在IPN消息中......但是真正只能通过IPN获得交易号吗?
答案 0 :(得分:0)
执行付款后致电PaymentDetails。响应应具有交易ID(paymentInfoList.paymentInfo(0).transactionId
表示接收方的交易ID,或paymentInfoList.paymentInfo(n).senderTransactionId
表示发件人的交易ID。