【发布时间】:2024-01-06 00:29:02
【问题描述】:
这是对我之前的问题的更新。鉴于该问题的整个问题已经改变,我觉得有必要提出一个更准确和详细的问题。这是我的代码:
SetupPayment()
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() 中创建并在 ExecutePayment() 中执行的付款的交易编号/ID?我在 Adaptive Payments API 中看到的唯一提及是说交易号在 IPN 消息中......但是真的只能通过 IPN 获得交易号吗?
【问题讨论】:
标签: paypal paypal-adaptive-payments