2013-03-25 106 views
2

我正在與貝寶使用快速結帳得到一個結算協議ID。當我這樣做 「SetExpressCheckout」貝寶與快速結帳得到帳單協議ID

https://www.x.com/developers/paypal/documentation-tools/how-authorize-and-run-reference-transaction-express-checkout

在第一步驟:

我按照本指南 以下是代碼

public string SetExpressCheckout(string Amount) 
    { 
     string returnURL = "http://localhost:50325/ReviewOrder.aspx" + "?amount=" + Amount + "&PAYMENTREQUEST_0_CURRENCYCODE=USD"; 
     string cancelURL = returnURL.Replace("ReviewOrder", "ExpCheckOut"); 
     string strCredentials = "USER=" + strUsername + "&PWD=" + strPassword + "&SIGNATURE=" + strSignature; 
     string strNVP = strCredentials; 
     strNVP += "&PAYMENTREQUEST_0_PAYMENTACTION=AUTHORIZATION&&PAYMENTREQUEST_0_AMT=25" + "&L_BILLINGTYPE0=MerchantInitiatedBilling" + "&RETURNURL=" + returnURL; 
     strNVP += "&CANCELURL=" + cancelURL; 
     strNVP += "&METHOD=SetExpressCheckout&VERSION=" + strAPIVersion + "&DESC=test EC payment" +"&NOSHIPPING=0" ; 
     //Create web request and web response objects, make sure you using the correct server (sandbox/live) 
     HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(strNVPSandboxServer); 
     //Set WebRequest Properties 
     wrWebRequest.Method = "POST"; 
     // write the form values into the request message 
     StreamWriter requestWriter = new StreamWriter(wrWebRequest.GetRequestStream()); 
     requestWriter.Write(strNVP); 
     requestWriter.Close(); 
     // Get the response. 
     HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse(); 
     StreamReader responseReader = new StreamReader(wrWebRequest.GetResponse().GetResponseStream()); 
     // and read the response 
     string responseData = responseReader.ReadToEnd(); 
     responseReader.Close(); 
     return responseData; 
    } 

的響應:

TOKEN=EC-09082530FY878870B& 
    TIMESTAMP=2013-03-25T00:45:56Z& 
    CORRELATIONID=3d33037174d55& 
    ACK=SuccessWithWarning& 
    VERSION=86& 
    BUILD=5479129& 
    L_ERRORCODE0=11452& 
    L_SHORTMESSAGE0=Merchant not enabled for reference transactions& 
    L_LONGMESSAGE0=Merchant not enabled for reference transactions& 
    L_SEVERITYCODE0=Warning 

如何獲得一個Bi llingAgreeentd在第3步:

守則第3步是:

public string GetBillingAgreementID() 
    { 
     string returnURL = "http://localhost:50325/ReviewOrder.aspx" + "?amount=" + Amount + "¤cy=USD"; 
     string cancelURL = returnURL.Replace("ReviewOrder", "ExpCheckOut"); 
     string strCredentials = "USER=" + strUsername + "&PWD=" + strPassword + "&SIGNATURE=" + strSignature; 
     string strNVP = strCredentials; 
     strNVP += "&RETURNURL=" + returnURL; 
     strNVP += "&CANCELURL=" + cancelURL; 
     strNVP += "&METHOD=CreateBillingAgreement&VERSION=" + strAPIVersion + "&TOKEN=" + Session["Token"]; 
     //Create web request and web response objects, make sure you using the correct server (sandbox/live) 
     HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(strNVPSandboxServer); 
     //Set WebRequest Properties 
     wrWebRequest.Method = "POST"; 
     // write the form values into the request message 
     StreamWriter requestWriter = new StreamWriter(wrWebRequest.GetRequestStream()); 
     requestWriter.Write(strNVP); 
     requestWriter.Close(); 
     // Get the response. 
     HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse(); 
     StreamReader responseReader = new StreamReader(wrWebRequest.GetResponse().GetResponseStream()); 
     // and read the response 
     string responseData = responseReader.ReadToEnd(); 
     responseReader.Close(); 
     return responseData; 
    } 

的迴應是:

TIMESTAMP=2013-03-25T00:51:34Z& 
CORRELATIONID=854e6beed1e82& 
ACK=Failure& 
VERSION=86& 
BUILD=5479129& 
L_ERRORCODE0=11455& 
L_SHORTMESSAGE0=Buyer did not accept billing agreement& 
L_LONGMESSAGE0=Buyer did not accept billing agreement& 
L_SEVERITYCODE0=Error 

如何獲得BillingAgreemntId? 這是因爲「L_SHORTMESSAGE0 =商家未啓用參考交易」此消息從「SetExpressCheckout」我無法獲得BillingAgreementID嗎?

請幫我解決這個問題。謝謝。

回答

1

您需要聯繫PayPal並要求在帳戶中啓用此功能(如果這是針對真實帳戶的)。如果您需要在沙盒上啓用它,則需要聯繫PayPal MTS,並在沙箱帳戶上啓用此功能。