php shoping cart: integrating PayPal

Discussion in 'PHP' started by dracula51, May 27, 2010.

  1. #1
    Hello there
    i've made a PHP shopping cart (ecommerce)
    i used SESSION to record cart item.
    ppl can add items more than once.
    so for example the cart might looks like this:

    item1 - quentity: 5 - $20
    item2 - quentity: 2 - $10
    item3 - quentity: 1 - $25
    --------------------------------
    total: $55


    now i want when ppl click on "check out" button...it take them to paypal site, where they can proceed their payment (paypal or credit card...both must be available). And if the payment successful, it send my site "YES" so my site send me an email to me about the orders (product/payment details/order trace number etc)


    how can i do it

    anyone plz help...i need it urgent
     
    dracula51, May 27, 2010 IP
  2. Lost&found

    Lost&found Guest

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    paypal has docs on this I am sure.
     
    Lost&found, May 27, 2010 IP
  3. dracula51

    dracula51 Peon

    Messages:
    146
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    searched & cant understand which one for me...im new in this integration thing :(

    help me plz
     
    dracula51, May 28, 2010 IP
  4. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #4
    Read the documentation on buy now buttons, you can create them dynamically, and also read up on IPN.

    The buy now button will take the shopper to PayPal to bill them for the cart total, assuming payment completes then PayPal will issue an IPN to your site so that you know that the cart was paid for or not.
     
    tolra, May 29, 2010 IP
  5. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
  6. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #6
    Heres the PayPal IPN
    
    
    <?php
    
    echo <<< END
    
    	<form action="$sys_paypal_URL" method="post" id="paymentform">
    		<input type="hidden" name="cmd" value="_xclick">
    		<input type="hidden" name="no_shipping" value="1">
    		<input type="hidden" name="no_note" value="1">
    		<input type="hidden" name="shipping" value="0.00">
    		<input type="hidden" name="lc" value="$sys_locale">
    		<input type="hidden" name="bn" value="PP-BuyNowBF">
    		<input type="hidden" name="rm" value="2">
    		<input type="hidden" name="business" value="$email">
    		<input type="hidden" name="item_name" value="$item_name">
    		<input type="hidden" name="item_number" value="$item_number">
    		<input type="hidden" name="amount" value="$item_price">
    		<input type="hidden" name="currency_code" value="$sys_currency">
    		<input type="hidden" name="notify_url" value="$item_ipn_url">
    		<input type="hidden" name="return" value="$item_download_url">
    		<input type="hidden" name="cbt" value="Click Here to Download">
    		<input type="hidden" name="cancel_return" value="$item_cancel_url">
    		<input type="hidden" name="custom" 
    				value="|$ip|$discount|$country|$state|$zipcode|$sys_domain|$_COOKIE[ref]">
    	</form>
    END;
    
    ?>
    
    
    PHP:
    I hope you can assume the Variables from their name
     
    roopajyothi, May 29, 2010 IP
  7. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #7
    That looks rather like a buy now button form than the IPN handler but still :)
     
    tolra, May 29, 2010 IP
  8. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #8
    That's not really the right form for a proper checkout from a webstore. That will only provide a total cost for one item (and a quantity). The OP will need to have multiple values for each different item, and a total cost will be generated automatically by paypal
     
    JAY6390, May 29, 2010 IP
  9. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #9
    I'd say that depends, if he's already got a cart storing the shopping list which it sounds like he has then there's nothing that stops the total for the whole care being fed to PayPal, you have a PayPal transaction number and the cart information therefore you can tie it all back up in the shop.
     
    tolra, May 29, 2010 IP
  10. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I guess, but I always find it nicer to have a full breakdown available for the consumer on the paypal screen as the user is asked to login, they can review all the costs
     
    JAY6390, May 29, 2010 IP
  11. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #11
    True, guess it depends how you want to implement it and what fits with the cart best.
     
    tolra, May 29, 2010 IP
  12. dracula51

    dracula51 Peon

    Messages:
    146
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    thank you everyone :)

    i think i got it

    but still i need to be cleared abt one more thing

    i want to send a variable to paypal & want paypal will send me back with IPN
    like: a variable orderid=77
    i want to send it to paypal...so when paypal send it back to my site...it will update mysql database table of that orderID with success, failed or other status :)
     
    dracula51, Jun 9, 2010 IP
  13. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #13
    Googling as PayPal IPN solves your problem :)
     
    roopajyothi, Jun 9, 2010 IP