title: Paypal integration issue in titanium
body: <p>I have to implement Paypal into my application. Here I have added some products into the cart. If I click the cart, I have to pay the amount using Paypal.</p>
  
  <p>When clicking the Paypal button, I am getting the following error:</p>
  
  <p><strong>The amounts specified for item price,tax,and shipping do not add up to the total amount.</strong></p>
  
  <p>Why am getting this error?</p>
  
  <p>I am using the following code:</p>
  
  <pre><code>$.paypalWindow.addEventListener('open', function(){ 
  var Paypal = require('ti.paypal'); 
  var u = Ti.Android != undefined ? 'dp' : 0; 
  var status = Ti.UI.createLabel({ top: 20 + u, height: 50 + u, color: '#333', text: 'Loading, please wait...' }); 
  $.paypalWindow.add(status); var price = totalamount; 
   var   invoiceitemslist = JSON.stringify(data);
  
  var button; function addButtonToWindow() {
  if (button) { $.paypalWindow.remove(button); button = null; } 
  button = Paypal.createPaypalButton({ width: 194 + u, height: 37 + u,    buttonStyle: Paypal.BUTTON_194x37, top: 20 + u,
  
      language: 'en_US',
      appID: 'APP-80W284485P519543T',
      paypalEnvironment: Paypal.PAYPAL_ENV_SANDBOX, 
      feePaidByReceiver: false,
      enableShipping: false,
      payment: { 
          paymentType: Paypal.PAYMENT_TYPE_BUSINESS,
          subtotal: price, 
          tax: 0.00,
          shipping: 0.00,
          currency: 'USD',
          recipient: 'thaibusiness@gmail.com',
          customID: 'anythingYouWant',
          invoiceItems:
      [{"name":"Bajaj 200 mm Ultima PT01 Personal Fan","totalPrice":2997,"itemPrice":999,"itemCount":3},
            ],
          ipnUrl: 'http://www.appcelerator.com/',
          merchantName: 'EYMOBINS Insurance',
          memo: 'For the insurance with EYMOBINS!'
            }
          });
  
  button.addEventListener('paymentCancelled', function (e) {
      alert('Payment cancelled. Please try again!');
      addButtonToWindow();
  });
  button.addEventListener('paymentSuccess', function (e) {
      alert('Payment successfull. Please get your Policy No.!'+"  "+e.transactionID);
      $.paypalWindow.remove(button);
      //addButtonToWindow();
  });
  button.addEventListener('paymentError', function (e) {
      alert('Payment Error. Please try again!');
      addButtonToWindow();
  });
  
  button.addEventListener('buttonDisplayed', function () {
      $.paypalWindow.remove(status);
      //alert('Please pay '+Ti.App.totalcost+'$ with Paypal!')
  });
  
  button.addEventListener('buttonError', function () {
  
  });
  
   $.paypalWindow.add(button);
   } 
   addButtonToWindow();            
    });
  
  
   $.paypalWindow.open();
  </code></pre>
  
  <p>Please check the code and give me an idea to resolve the above issue.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here I am facing one issue:</p>
  
  <pre><code>[{"name":"Bajaj 200 mm Ultima PT01 Personal Fan","totalPrice":999,"itemPrice":999,"itemCount":1},{"name":"Average2Excellent CBSE KG EVS MATHS ENG Educational CD ROMS","totalPrice":547,"itemPrice":547,"itemCount":1}]
  </code></pre>
  
  <p>Here the totalamount is 1546. Here I have printed the invoiceitems in the console, and I am getting the data like above.</p>
  
  <p>So that I have given like:</p>
  
  <pre><code>invoiceItems:invoiceitems,
  </code></pre>
  
  <p>Like means am getting the issue (the amounts specified for item price, tax, and shipping do not add up to the total amount).</p>
  
  <p>Same thing I have written the code like:</p>
  
  <pre><code>invoiceItems:[{"name":"Bajaj 200 mm Ultima PT01 Personal Fan","totalPrice":999,"itemPrice":999,"itemCount":1},{"name":"Average2Excellent CBSE KG EVS MATHS ENG Educational CD ROMS","totalPrice":547,"itemPrice":547,"itemCount":1}]
  </code></pre>
  
  <p>it's working perfectly.</p>
  
  <p>It is not working dynamically when assigned the value. Can you please check the code and help?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p><strong>If i have tried to run this code on android device, as am clicking the paypal button nothing happends. Why the login form is not open in the android device.</strong></p>