Docapture 方法 paypal api 中的交易 ID 无效
Posted
技术标签:
【中文标题】Docapture 方法 paypal api 中的交易 ID 无效【英文标题】:Invalid transaction ID in Docapture method paypal api 【发布时间】:2012-06-29 17:40:21 【问题描述】:我正在执行 DoCapture 并使用 DoDirectPayment 的交易 ID。但每次我捕获付款时,它都会显示“无效的交易 ID”。当我尝试从信用卡直接付款中获取一笔付款时,就会发生这种情况,而且这种信用卡付款是通过 DoDirectPayment 方法进行的。 但是,如果通过转到我的 PayPal 帐户并完成我的交易来进行 expressCheckout,这也会给我交易 ID。如果我使用此交易 ID 捕获付款,则付款过程成功完成!我不知道发生了什么事!请任何人帮助我摆脱问题! 我正在使用 PayPal API 版本 59.0 我的示例代码
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);
提前致谢!
【问题讨论】:
【参考方案1】:See DoCapture Documentation here
See DoDirectPayment Documentation here
【讨论】:
【参考方案2】:看到这个
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";
【讨论】:
PAYMENTACTION 必须是对 DoCapture 的授权以上是关于Docapture 方法 paypal api 中的交易 ID 无效的主要内容,如果未能解决你的问题,请参考以下文章
Paypal“SetExpressCheckout”API 方法已停止使用沙盒卖家账户
关于经典nvp API paypal的HTTP get和post方法
调用未定义的方法 PayPal\Api\Payer::setPayment_method()