title: Paypal with express checkout to get BillingAgreementID
body: <p>I am working with the paypal using express checkout to get a billing agreement id.</p>
  
  <p>I was following this guide:</p>
  
  <p><a href="https://www.x.com/developers/paypal/documentation-tools/how-authorize-and-run-reference-transaction-express-checkout" rel="nofollow">https://www.x.com/developers/paypal/documentation-tools/how-authorize-and-run-reference-transaction-express-checkout</a></p>
  
  <p>In the first step when i do "SetExpressCheckout":
  The following is the code</p>
  
  <pre><code>public string SetExpressCheckout(string Amount)
      {
          string returnURL = "http://localhost:50325/ReviewOrder.aspx" + "?amount=" + Amount + "&amp;PAYMENTREQUEST_0_CURRENCYCODE=USD";
          string cancelURL = returnURL.Replace("ReviewOrder", "ExpCheckOut");
          string strCredentials = "USER=" + strUsername + "&amp;PWD=" + strPassword + "&amp;SIGNATURE=" + strSignature;
          string strNVP = strCredentials;
          strNVP += "&amp;PAYMENTREQUEST_0_PAYMENTACTION=AUTHORIZATION&amp;&amp;PAYMENTREQUEST_0_AMT=25" + "&amp;L_BILLINGTYPE0=MerchantInitiatedBilling" + "&amp;RETURNURL=" + returnURL;
          strNVP += "&amp;CANCELURL=" + cancelURL;
          strNVP += "&amp;METHOD=SetExpressCheckout&amp;VERSION=" + strAPIVersion + "&amp;DESC=test EC payment" +"&amp;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;
      }
  </code></pre>
  
  <p>The response is:</p>
  
  <pre><code>    TOKEN=EC-09082530FY878870B&amp;
      TIMESTAMP=2013-03-25T00:45:56Z&amp;
      CORRELATIONID=3d33037174d55&amp;
      ACK=SuccessWithWarning&amp;
      VERSION=86&amp;
      BUILD=5479129&amp;
      L_ERRORCODE0=11452&amp;
      L_SHORTMESSAGE0=Merchant not enabled for reference transactions&amp;
      L_LONGMESSAGE0=Merchant not enabled for reference transactions&amp;
      L_SEVERITYCODE0=Warning
  </code></pre>
  
  <p>How to to get a BillingAgreeentd in Step 3:</p>
  
  <p>Code for step 3 is:</p>
  
  <pre><code>public string GetBillingAgreementID()
      {
          string returnURL = "http://localhost:50325/ReviewOrder.aspx" + "?amount=" + Amount + "¤cy=USD";
          string cancelURL = returnURL.Replace("ReviewOrder", "ExpCheckOut");
          string strCredentials = "USER=" + strUsername + "&amp;PWD=" + strPassword + "&amp;SIGNATURE=" + strSignature;
          string strNVP = strCredentials;
          strNVP += "&amp;RETURNURL=" + returnURL;
          strNVP += "&amp;CANCELURL=" + cancelURL;
          strNVP += "&amp;METHOD=CreateBillingAgreement&amp;VERSION=" + strAPIVersion + "&amp;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;
      }
  </code></pre>
  
  <p>Response is:</p>
  
  <pre><code> TIMESTAMP=2013-03-25T00:51:34Z&amp;
   CORRELATIONID=854e6beed1e82&amp;
   ACK=Failure&amp;
   VERSION=86&amp;
   BUILD=5479129&amp;
   L_ERRORCODE0=11455&amp;
   L_SHORTMESSAGE0=Buyer did not accept billing agreement&amp;
   L_LONGMESSAGE0=Buyer did not accept billing agreement&amp;
   L_SEVERITYCODE0=Error
  </code></pre>
  
  <p>How to get a BillingAgreemntId?
  Is that because of "L_SHORTMESSAGE0=Merchant not enabled for reference transactions" this message from "SetExpressCheckout" am i not able to get BillingAgreementID?</p>
  
  <p>Please help me on this. Thanks.</p>