1 Reply Latest reply on Jul 29, 2007 1:06 PM by africanshox

    Flex 2 and paypal cart upload

    africanshox
      can i ask in relation to paypal....i want to be able to post multiple items to a basket instead of single items as your example shows. how could this be done?

      according to the paypal developer center if i want to upload an entire cart to paypal this is how the code would look like in html

      <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
      <input type="hidden" name="cmd" value="_cart">
      <input type="hidden" name="upload" value="1">
      <input type="hidden" name="business"
      value="seller@designerfotos.com">
      <input type="hidden" name="item_name_1"
      value="Item Name 1">
      <input type="hidden" name="amount_1" value="1.00">
      <input type="hidden" name="item_name_2"
      value="Item Name 2">
      <input type="hidden" name="amount_2" value="2.00">
      <input type="submit" value="PayPal">
      </form>


      so ive tried to convert this form so tha i can use it within flex

      and my code looks like this

      public function checkOut():void
      {
      var url:URLRequest = new URLRequest("https://www.paypal.com/cgi-bin/webscr");
      var uv:URLVariables = new URLVariables();
      url.method = "POST";
      uv.cmd = "_cart";
      uv.upload="1";
      uv.business = "munene_uk@yahoo.co.uk";

      for(var i:int=0;i<courseChoice.length;i++){


      if(i==0)
      {
      uv.item_name_[i+1] = courseChoice .CourseName;
      uv.amount_[i+1]= courseChoice
      .fee;

      }
      else{

      uv.item_name_ = courseChoice.CourseName;
      uv.amount_ = courseChoice.fee;
      }


      }
      url.data = uv;

      navigateToURL(url,"_blank");

      }


      no i already know that my syntax is wrong in the lines where i have written uv.item_name_[i+1]

      so my question is how can i append a variable name during a loop so that its uv.item_name_1,uv.item_name_2 e.t.c.

      many thanks
        • 1. Re: Flex 2 and paypal cart upload
          africanshox Level 1
          ive found the answer through flexcoders...

          simply change the uv variable to this....

          public function checkOut():void
          {
          var url:URLRequest = new URLRequest("https://www.paypal.com/cgi-bin/webscr");
          var uv:URLVariables = new URLVariables();
          url.method = "POST";
          uv.cmd = "_cart";
          uv.upload="1";
          uv.business = "email@yahoo.co.uk";

          var x:int=1;
          for(var i:int=0;i<courseChoice.length;i++)
          {

          uv["item_name_"+x] = courseChoice .CourseName;
          uv["amount_"+x]= courseChoice
          .fee;
          x=x+1;


          }
          url.data = uv;

          navigateToURL(url,"_blank");

          }