【问题标题】:PayPal Sandbox Transaction Numbers but No Transactions贝宝沙盒交易号但没有交易
【发布时间】:2015-04-27 23:41:05
【问题描述】:

我正在使用 PayPal 的 Adaptive Payments API 从我的网站向人们付款。在 PayPal 沙箱(当然是为了测试)中,我从 API 调用中获得了 PayPal 交易编号和日期,但是当我检查测试账户时,钱没有变化,也没有记录的交易。

如果有交易号,不应该有对应的交易吗?为什么我会得到一个没有实际交易发生的交易号?

更新:以下是我调用 PayPal API 的支付函数:

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 = "PAY";
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 = "SENDER_EMAIL_HERE"
};


_payPalConfig = new Dictionary<string, string>
{
    {"mode", "sandbox"},
    {"account1.apiUsername", "USERNAME_HERE"},
    {"account1.apiPassword", "PASSWORD_HERE"},
    {"account1.apiSignature", "SIGNATURE_HERE"},
    {"account1.applicationId", "SANDBOX_APP_ID_HERE"}
};

AdaptivePaymentsService adaptivePaymentService = new AdaptivePaymentsService(_payPalConfig);
PayResponse payResponse = adaptivePaymentService.Pay(payRequest);

if (!payResponse.error.Any())
{
    PaymentDetailsRequest paymentDetailsRequest = new PaymentDetailsRequest(new RequestEnvelope("en_US"))
    {
        payKey = payResponse.payKey
    };

    adaptivePaymentService = new AdaptivePaymentsService(_payPalConfig);
    PaymentDetailsResponse paymentDetailsResponse =
        adaptivePaymentService.PaymentDetails(paymentDetailsRequest);

    return paymentDetailsResponse.responseEnvelope;
}
return payResponse.responseEnvelope;

这里是我处理响应信封的地方:

ResponseEnvelope payResponse = ppa.SendPayment(payPalUserEmail, commissionAmount);

if (payResponse.ack.ToString() == "SUCCESS")
{
    payment.PayPalTrxNumber = //??
    payment.PayPalTrxDate = DateTime.Parse(payResponse.timestamp);
}

我意识到我使用 Correlation ID 作为我的交易号...不知道为什么,但这会解释交易号的奇怪之处。但是付款成功后的交易号在哪里?

EDIT2:考虑一下,我是在if (payResponse.ack.ToString() == "SUCCESS") 支票内付款,所以这是否意味着付款成功?

【问题讨论】:

  • ACK 仅表示 API 调用成功。这并不意味着任何资金实际上已经转移。这取决于呼叫的设置方式、是否使用电子支票等。

标签: paypal


【解决方案1】:

我需要查看您的 API 请求和响应示例以了解更多信息,但是如果您发送的支付请求的 ActionType 设置为 CREATE,就会发生这种情况。这将生成一个支付密钥(在这种情况下,我认为您必须将其称为交易 ID),但在您调用 ExecutePayment API 之前不会转移任何资金。

不过,这只是一个例子。另一个原因可能是您查看了错误的沙盒帐户,坦率地说,我已经看到很多次了。

同样,如果没有看到您的要求,很难说。

【讨论】:

  • 我正在使用“PAY”ActionType,但我意识到我在需要交易 ID 的地方使用了相关 ID,这没有任何意义。不知道我为什么这样做,但我在哪里可以得到我的交易 ID?我已经用我的代码更新了问题。
  • 您应该只使用 PayKey。
  • PayKey 在哪里?我在我拥有的对象中找不到它。
  • PayKey 将在 Pay API 响应中返回。看起来您已经将其保存到变量中:payKey = payResponse.payKey
  • 哦!好的,所以我应该使用那个 PayKey 来获取交易?还是那是交易?
猜你喜欢
  • 1970-01-01
  • 2012-11-23
  • 2015-09-18
  • 2012-01-22
  • 2018-08-20
  • 1970-01-01
  • 2017-07-31
  • 2017-08-29
  • 2012-08-31
相关资源
最近更新 更多