提问者:小点点

paypal无效的交易id


我正在ASP.NET项目中实现Paypal Express结账功能,该功能需要授权,然后取消或捕获授权金额。我使用的是他们版本=104.0的API。

就我对整个过程的理解而言,我做的每件事都是正确的:

>

  • 我在付款详细信息中调用ActionType设置为“authorize”的SetExpressCheckout方法

    SetExpressCheckoutRequestDetailsType reqDetails = new SetExpressCheckoutRequestDetailsType();
    reqDetails.ReturnURL = "http://some.url";
    reqDetails.CancelURL = "http://some.url";
    reqDetails.NoShipping = "1";
    reqDetails.OrderDescription = "You're about to buy items for " + payment.Amount.ToString("F");
    reqDetails.cpplogoimage = "http://some.ulr/image.jpb";
    reqDetails.PaymentDetails = new PaymentDetailsType[1];
    reqDetails.PaymentDetails[0] = new PaymentDetailsType();
    reqDetails.PaymentDetails[0].PaymentDetailsItem = new PaymentDetailsItemType[cart.LineItems.Count];
    int i = 0;
    foreach (LineItemModel li in cart.LineItems)
    {
        PaymentDetailsItemType item = new PaymentDetailsItemType();
        item.Amount = new BasicAmountType();
        item.Amount.Value = li.TotalIncludingShipping.ToString("F");
        item.Amount.currencyID = CurrencyCodeType.AUD;
        item.Name = li.ProductItem.DisplayName;
        item.Number = li.ProductItem.SKU;
        item.Quantity = li.Quantity.ToString();
        item.Description = "";
        reqDetails.PaymentDetails[0].PaymentDetailsItem.SetValue(item, i);
        i++;
    }
    reqDetails.OrderTotal = new BasicAmountType()
    {
        currencyID = CurrencyCodeType.AUD,
        Value = payment.Amount.ToString("F")
    };
    reqDetails.PaymentDetails[0].PaymentAction = PaymentActionCodeType.Authorization;
    reqDetails.PaymentDetails[0].PaymentActionSpecified = true;
    SetExpressCheckoutReq req = new SetExpressCheckoutReq()
    {
        SetExpressCheckoutRequest = new SetExpressCheckoutRequestType()
        {
            Version = "104.0",
            SetExpressCheckoutRequestDetails = reqDetails
        }
    };
    

    然后我打电话给DoExprescheckout。这是请求的代码

    DoExpressCheckoutPaymentReq payReq = new DoExpressCheckoutPaymentReq()
    {
        DoExpressCheckoutPaymentRequest = new DoExpressCheckoutPaymentRequestType()
        {
            Version = ConfigurationManager.AppSettings["PaypalAPIVersion"],
            DoExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType()
            {
                 Token = token,
                 PayerID = payerID,
                 PaymentDetails = new PaymentDetailsType[1]
            }
        }
    };           
    payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentAction = PaymentActionCodeType.Authorization;
    payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentActionSpecified = true;
    payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0] = new PaymentDetailsType();
    payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0].PaymentAction = PaymentActionCodeType.Authorization;
    payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0].PaymentActionSpecified = true;
    payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0].OrderTotal = new BasicAmountType();
    payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0].OrderTotal.currencyID = CurrencyCodeType.AUD;
    payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0].OrderTotal.Value = total.ToString("F");
    

    此请求也返回“成功”。我保存响应的DoExprescheckOutPaymentResponseDetails.PaymentInfo[0].TransactionId以备将来使用

    但是当我使用前面响应中的事务ID运行DoAuthorize时,我得到的是“failure”。下面是请求代码:

    DoAuthorizationReq authReq = new DoAuthorizationReq()
    {
        DoAuthorizationRequest = new DoAuthorizationRequestType() 
        {
            Version = "104.0",
            TransactionID = doCheckoutTransactionId
        }
    };
    authReq.DoAuthorizationRequest.Amount = new BasicAmountType();
    authReq.DoAuthorizationRequest.Amount.currencyID = CurrencyCodeType.AUD;
    authReq.DoAuthorizationRequest.Amount.Value = total.ToString("F");
    

    响应显示“Failure”,错误数组包含1个ErrorCode=10609的项,消息为“无效事务ID”

    你有什么想法为什么会这样吗?

    多谢!


  • 共1个答案

    匿名用户

    要在授权后捕获资金,您需要运行DoCapture,而不是doauthorization。