2012-06-28 63 views
0

我正在執行DoCapture並使用DoDirectPayment的交易ID。但每次當我捕獲付款時,都會顯示「無效的交易ID」。當我嘗試從直接信用卡付款中獲取peyment時,會發生這種情況,並且此信用卡付款也是通過DoDirectPayment方法付款的。 但是,如果通過轉到我的PayPal賬戶進行expressCheckout並完成我的交易,這也會給我交易ID。如果我使用此交易ID獲取付款,則付款流程將成功完成!我不知道發生了什麼事!請任何人幫助我解決問題! 我使用貝寶API版本59.0 我的示例代碼Docapture方法中的交易ID無效paypal api

   Session["stage"] = ASPDotNetSamples.Constants.ENVIRONMENT; //SandBox Environment 
       //here my api credentials 
       SetProfile.SessionProfile = SetProfile.CreateAPIProfile(ASPDotNetSamples.Constants.API_USERNAME, 
        ASPDotNetSamples.Constants.API_PASSWORD, ASPDotNetSamples.Constants.API_SIGNATURE, "", "", 
        ASPDotNetSamples.Constants.ENVIRONMENT); 


       //NVPCallerServices caller = PayPalAPI.PayPalAPIInitialize(); 
       //NVPCodec encoder = new NVPCodec(); 
       com.paypal.sdk.services.NVPCallerServices caller = PayPalAPI.PayPalAPIInitialize(); 
       NVPCodec encoder = new NVPCodec(); 

       encoder["METHOD"] = "DoCapture"; 
       encoder["TRXTYPE"] = "D"; 
       encoder["AUTHORIZATIONID"] = authorization_id.; //the authrization id i got from the dodirectpayment 
       encoder["COMPLETETYPE"] = CompleteCodeType; //completecodetype is completed 
       double dAmount = Convert.ToDouble(actualAmount); 
       encoder["AMT"] = String.Format("{0:0.00}", dAmount);      

       string pStrrequestforNvp = encoder.Encode(); 
       string pStresponsenvp = caller.Call(pStrrequestforNvp); 

       NVPCodec decoder = new NVPCodec(); 
       decoder.Decode(pStresponsenvp); 
       string parentTransactionID = decoder["PARENTTRANSACTIONID"]; 
       string strAck = decoder["ACK"]; 

       if (strAck != null && (strAck == "Success" || strAck == "SuccessWithWarning")) 
       { 
        string pStrResQue = "AUTHORIZATIONID=" + decoder["AUTHORIZATIONID"] + "&" + 
         //"PAYMENTSTATUS=" + decoder["PAYMENTSTATUS"] + "&" + 
             "PAYMENTSTATUS=" + CompleteCodeType + "&" + 
             "AMT=" + decoder["AMT"] + "&" + 
             "TRANSACTIONID=" + decoder["TRANSACTIONID"];       
         // if Payment is done successfully 

       } 
       else 
       { 
        // if Payment is pending 

        string pStrError = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" + 
             "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" + 
             "Desc2=" + decoder["L_LONGMESSAGE0"];       
        Response.Redirect("APIError.aspx?" + pStrError); 
       } 

提前感謝!

回答

0

看到這個

com.paypal.sdk.services.NVPCallerServices caller = PayPalAPI.PayPalAPIInitialize(); 
    NVPCodec encoder = new NVPCodec(); 
    encoder["METHOD"] = "DoDirectPayment"; 
    encoder["PAYMENTACTION"] = "Authorization"; 
    //encoder["AMT"] = hfHoldAmount.Value.ToString(); 
    encoder["AMT"] = hfHoldAmount.Value.ToString(); 
    encoder["CREDITCARDTYPE"] = ddlCardType.SelectedValue; 
    encoder["ACCT"] = txtCardNnumber.Text.Trim(); 
    encoder["EXPDATE"] = (ddlExpMonth.SelectedValue.Length == 1 ? "0" + ddlExpMonth.SelectedValue : ddlExpMonth.SelectedValue) + ddlExpYear.SelectedValue; 
    encoder["CVV2"] = txtCVCode.Text.Trim(); 
    encoder["FIRSTNAME"] = txtFirstName.Text.Trim(); 
    encoder["LASTNAME"] = txtLastName.Text.Trim(); 
    encoder["STREET"] = txtAddress.Text.Trim(); 
    encoder["CITY"] = txtCity.Text.Trim(); 
    encoder["STATE"] = ddlStateProvince.Items.FindByValue(ddlStateProvince.SelectedValue).Text; 
    encoder["ZIP"] = txtZipCode.Text.Trim(); 
    encoder["COUNTRYCODE"] = "US"; 
    encoder["CURRENCYCODE"] = "USD"; 
+1

PAYMENTACTION必須是授權DoCapture – 2012-07-02 08:47:25

+1

喔真棒!完善!它現在正在工作! – Mushfiq