A Flash Developer Resource Site

Page 5 of 6 FirstFirst 123456 LastLast
Results 81 to 100 of 118

Thread: Flash and Paypal?

  1. #81
    Member
    Join Date
    Apr 2007
    Posts
    73
    All right- silentweed helped me with this and here is the answer to my above question:

    aItem[i].instance.onPress = function() {
    this.swapDepths(_root.getNextHighestDepth());
    this.origX = this._x;
    this.origY = this._y;
    this.startDrag();
    };


    And replace the following

    aItem[i].instance.onRelease = function() {
    this.stopDrag();
    if (checkDropLocation(this)) {
    //it has been added to basket so increase quantity in basket
    aItem[this.id].quantity++;

    //update datagrid
    updateDatagrid();

    //also send it back to its original position and fade it in
    this._alpha = 0;
    reposition(this);
    fadeIn(this);

    //let user know it has been added to basket

    } else {
    //not in basket so send it back to its original position
    reposition(this);
    }
    };

    aItem[i].instance.onReleaseOutside = aItem[i].instance.onRelease;


    with



    aItem[i].instance.onRelease = function() {

    //it has been added to basket so increase quantity in basket
    aItem[this.id].quantity++;

    //update datagrid
    updateDatagrid();

    };

  2. #82
    Senior Member
    Join Date
    Mar 2001
    Posts
    536
    This cart does not work that great.
    When you send you to PayPal it does not give you and itemized break down of the purchase.

  3. #83
    Member
    Join Date
    Apr 2007
    Posts
    73
    It's not letting me edit my post right now. It should say "Delete this" before that first bit of code.

  4. #84

  5. #85
    Member
    Join Date
    Apr 2007
    Posts
    73
    Hello- I have a store setup with Paypal that someone else helped me figure out- it worked fine when all the "add to cart" buttons were in the same frame. Now I've gone and set up a movie clip with several frames, each one having a seperate image with "add to cart" buttons underneath. Since I've seperated these "add to cart" buttons onto different frames within a movie clip instead of having them all appear together, one of two things happens.

    1) If I repeat the code in each of these frames, the cart resets (empties) every time the user goes to a new page (or frame).

    2) If I don't repeat the code in each frame it only works in the first frame with the code.

    Here's the code:

    Code:
    var lvSend:LoadVars = new LoadVars();//do not change
    lvSend.business = "art@michaelphipps.net"; //your paypal email address here 
    lvSend.currency_code = "USD"; //the currency you would like to use
    
    
    
    //define items, their prices, quantity in basket and there associated movieclips
    var aItem:Array = new Array();
    	aItem["PGA Poster"] = {instance:mcPgaposter, price:12, quantity:0};
    	aItem["PGA Print"] = {instance:mcPgaprint, price:35, quantity:0};
    	aItem["PGA Shirt Med"] = {instance:mcPgamed, price:20, quantity:0};
    	aItem["PGA Shirt Lg"] = {instance:mcPgalarge, price:20, quantity:0};
    	aItem["PGA Shirt XL"] = {instance:mcPgaxlarge, price:20, quantity:0};
    	aItem["PGA Shirt XXL"] = {instance:mcPgaxxlarge, price:20, quantity:0};
    	//-----------------------DO NOT CHANGE UNLESS FAMILIAR WITH ACTIONSCRIPT--------------------//	
    	
    	
    var totalPrice:Number;
    
    for (var i in aItem) {
    	var currentProduct:String = i;
    	aItem[i].instance.id = currentProduct;
    	
    	aItem[i].instance.onRelease = function() {
                            
                                        //it has been added to basket so increase quantity in basket
                                        aItem[this.id].quantity++;
                                        
                                        //update datagrid
                                        updateDatagrid();
                                        
    };
    }
    
    
    mcPaypal.onRelease = function():Void{
    	//send variables to paypal
    
    	//CONSTANTS
    	lvSend.cmd = "_cart";
    	lvSend.upload = "1";
    	
    	var j:Number = 1;
    	for (var i in aItem) {
    		if(aItem[i].quantity > 0){
    			lvSend["item_name_"+j] = aItem[i].instance.id;
    			lvSend["amount_"+j] = aItem[i].price;
    			lvSend["quantity_"+j] = aItem[i].quantity;
    			j++;
    			}
    			
    	}
    	lvSend.send("https://www.paypal.com/cgi-bin/webscr", "_self", "POST");
    }
    
    
    //--------------------------------------- functions ----------------------------------------------//
    
    
    function updateDatagrid():Void{
    	totalPrice = 0;
    	var aBasket:Array = new Array();
    	for (var i in aItem) {
    	if(aItem[i].quantity > 0 ){
    	   aBasket.push({Product: aItem[i].instance.id, Quantity: aItem[i].quantity, Price: aItem[i].price * aItem[i].quantity });
    	   totalPrice += aItem[i].quantity * aItem[i].price;
    	}
    }
    
    	basketInfo.dataProvider = aBasket;
    	basketInfo.vScrollPolicy = "auto";
    	tTotal.text = totalPrice;
    }

  6. #86
    Senior Member
    Join Date
    Nov 2006
    Posts
    162
    I have been working on this shopping cart for way too long now... anyone would know why it takes me to the login paypal page and not on an actual checkout page???
    I have been trying different codes for tests, and all give me the same...
    i did also tried KilgoreTrout code above..same result..

    Any help will e most welcome!

  7. #87
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    I believe all the PayPal code here is for the Express Checkout.. which is intended to bring you to your PayPal log-in page..and check out with your saved credit card & shipping details from there..(or paypal funds)..

    in order to do the credit card charging behind the scenes.. an keep the users on the site the whole time would be to use the DIRECT PAYMENT PRO option PayPal has.....

    I havent messed with that API yet.. but from what I have read there is a NVP (Named Value Pair) API you can use..

    I wrote an engine (no good grahics or layout to it..just code really...proof of concept)


    here is the STORE:
    http://www.dmstudios.net/demos/PMS/

    heres an all Flash & XML (w/ minor php script usage for scraping directories for image names) store & cart....

    you can view the cart with the text button to the left..same with the check out which brings you to paypal log-in...(itemized summary of all items in basket)

    http://www.dmstudios.net/demos/PMS/admin.html

    is a CMS (I call it a PMS or PMI Product Management System/Interface) i wrote using Flash, XML and minor PHP scripts (for uploads, write/saving to a text file, and image scraping)....

    ------------

    Id like to work with messing with the Direct payment Pro method though.. it would be much cleaner...

    I have some documentation, but could never get any real answers..their dev/help forums completely stink..

    open for discussion...

  8. #88
    Senior Member
    Join Date
    Nov 2006
    Posts
    162
    but I did download silentweed cart example, and it takes the user to a payment page, after it ask you to log-in....but when i drop this in my file...no chance..??
    I did start a new thread with this subject..hope I am not confusing...

  9. #89
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    ok....

    you WANT to be taken to the PayPal website..or not?

    this payment page your talking about.. is the payment screen ON the PayPal.com site?

    yes silentweeds and my demo are very similar... and that it was PayPal.com is calling the EXPRESS checkout... (not to be confused with the Direct Payments Pro version)

  10. #90
    Senior Member
    Join Date
    Nov 2006
    Posts
    162
    Yes, i want to be taken to the payment page ON the Paypal site.
    but what I am saying is..it is taking me to the Paypal site, but NOT on any payment page, just in my account page...and then there is no reference about the shopping cart. Just like if I just randomly signed up not using the shopping cart at all...

  11. #91

  12. #92
    Senior Member
    Join Date
    Nov 2006
    Posts
    162
    It shouldnt matter if i am logged in or not, as users wont necessary be looged in when they shop. In Silentweed sample, if you are not looged in, it takes you to the login page and then to the payment page. Mine does nothing after the login page...even if I take his code and modify it..I am probably doing something wrong when I modify...or am I missing something? ...

  13. #93

  14. #94
    Senior Member
    Join Date
    Nov 2006
    Posts
    162
    My code is probably wrong, would you see what I am missing here?

    Code:
    confirmation_mc.order_btn.onRelease = function()  {
    payPal = new LoadVars();
    payPal.cmd = "_cart";
    payPal.business = "humanvision.sd@gmail.com";
    payPal.currency_code = "CDN";
    payPal.upload = "1";
    payPal.amount = "20.00";
    
    payPal.send("https://www.paypal.com/cgi-bin/webscr", "_blank", "POST");
    
    }
    Eventually, this code will send a variable amount instead of the $20.00, but thats just a test...and it is failing...

    I dont think I need to do anything on the Paypal side, so the problem should be here...
    Last edited by sandraa; 10-21-2007 at 02:58 PM. Reason: hit the wrong button to fast...

  15. #95
    Senior Member
    Join Date
    Nov 2006
    Posts
    162
    ok, I found my problem. The .swf has to be online for this to work,..i was trying to get to paypal from my .swf and I guess that is why it wasnt working... (such a waiste of time..)

    Thanks whisper for your help,

    here is how I got it to work, and it works like a charm!:

    payPal = new LoadVars();
    payPal.cmd = "_cart";
    payPal.business = "humanvision.sd@gmail.com";
    payPal.item_name = "Inverted Suit";
    payPal.currency_code = "CDN";
    payPal.upload = "1";
    payPal["add"] = "1";
    payPal.amount = totalCost_txt.text;

    payPal.send("https://www.paypal.com/cgi-bin/webscr", "_blank", "POST");

  16. #96
    Member
    Join Date
    Sep 2003
    Location
    Seattle
    Posts
    54
    whispers... I'm using the datagrid that silentweed supplies as a shopping cart. I can add items to the cart just fine but I can't figure out how to remove an item. I see in your example, post #41, that if you click on the red circle button the item is taken out of the cart. Do you know how I can achieve this within the datagrid? Or if not within the datagrid, some other way? It looks like your example doesn't use the datagrid? Your help is greatly appreciated!!

  17. #97
    Member
    Join Date
    Sep 2003
    Location
    Seattle
    Posts
    54
    to follow up on my problem above, you can add a button to a datagrid by using cellRenderer. I went through a couple tutorials and they worked fine but when it came down to implementing it into my own site I couldn't get it to work because the way I was collecting info was different then the tutorials. So... I went another route, the way an item is added to the datagrid cart is by using 'iteminstance.quantity ++' so naturally to remove an item from the datagrid it makes sense to use 'iteminstance.quantity --' to remove the item from the datagrid. The question then is what to attach the 'iteminstance.quantity --' code to? I used a movieclip since I couldn't figure out the cellrenderer. Each time a new item is added to the datagrid another instance of the 'deleteme' movieclip appears and each deleteme movieclip is associated to the correct row of the datagrid by using datagrid.getItemAt(row).columnID
    Once you retrieve that columnID you then apply the quantity -- to it.

  18. #98
    hey whispers, anychance that you willing to share the source?




  19. #99
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Id have to dig it out of one of m y archive folders.....


    but.... all code "IS" posted here at Flashkit... (I learn everything here)

    just search my nic and payal as key word or something..

    log into your paypal accoutn first.. then click this link:

    https://www.paypal.com/us/cgi-bin/we...howto_checkout


    quote from the page:

    This means that the minimum required code for your post to PayPal will look like this:

    Code:
    <form action="https://www.paypal.com/us/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="you@youremail.com">
    <input type="hidden" name="item_name" value="Item Name">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="amount" value="0.00">
    <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
    </form>

    so the flash equivalent would be something like: [example]

    PHP Code:
    paypalVars = new LoadVars();

    paypalVars.cmd "_cart"//required PayPal var 
    paypalVars.business "emailforpaypal@whatever.com"//required PayPal var (use your email associated with PayPal)
    paypalVars.item_name "XBOX_360";//required PayPal var
    paypalVars.currency_code "USD"//required PayPal var
    paypalVars.amount "350.00"//required paypal var total amount to send to PayPal

    payPal.send("https://www.paypal.com/cgi-bin/webscr""_blank""POST"); 
    that link will have the break down of what you CAN send and what you HAVE to send..

    in mine I just looped through an array I believe...


    PHP Code:
    //Loop through the array for product details;
    for (var 0i<cartArray.lengthi++) {
        var 
    num i+1;
        
    payPal["item_name_"+num] = cartArray[i].name;
        
    payPal["quantity_"+num] = cartArray[i].quantity;
        
    payPal["amount_"+num] = cartArray[i].amount;
        
    payPal["on0_"+num] = "Color: "+cartArray[i].color;
        
    payPal["on1_"+num] = "Size: "+cartArray[i].size;        


    and so on....

    hope that helps..

  20. #100
    thanks pal..

    btw, i really like the kitten in ur avantar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center