【问题标题】:Getting Transaction Number from AdaptivePayments从 AdaptivePayments 获取交易号
【发布时间】: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


    【解决方案1】:

    执行付款后调用 PaymentDetails。响应应包含事务 ID(paymentInfoList.paymentInfo(0).transactionId 表示接收方的事务 ID,paymentInfoList.paymentInfo(n).senderTransactionId 表示发送方的事务 ID)。

    【讨论】:

    • 这似乎是我正在寻找的。但由于某种原因,paymentDetailsResponse.paymentInfoList 为空。我是否需要通过某种方式请求专门填充数据?
    • 如果 paymentInfoList 为空,可能表示买家从未在 PayPal 上完成付款。