Results 1 to 7 of 7

Thread: Paypal php integration

  1. #1
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Paypal php integration

    Hi
    I am trying to integrate paypal in my php website:
    I created an id at paypal and made code like this:

    <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="pp_form" target="_blank">
    <input type="hidden" name="cmd" value="_cart" >
    <input type="hidden" name="business" value="abc@yahoo.com">
    <input type="hidden" name="upload" value="1" >
    <input type="hidden" name="item_name_1" value="Testitem1">
    <?php
    echo "<input type=\"hidden\" name=\"amount_1\" id=\"amountText\">"

    ?>
    <input type="hidden" name="return" value = "../views/notify.php?status=T"><br>
    <input type="hidden" name="cancel_return" value = "../views/notify.php?status=F"><br>
    <input type="image" src="../img/x-click.gif" border="0" name="submit" alt="PayPal - the safer, easier way to pay" width="5" height="50" class="button"/>
    </form>
    It is going to paypal page and I am sending the amount but how will i send 'n' different articles to paypal where it will show 'n' different articles with the cost individually .... and then final cost ....

    Another thing that I wanted to ask that I am really not sure of making database entries:
    suppose from my page a user selects the classes he wants to attend , i am using javascript function that displays the cost of classes on page ... then the user hits add to cart button that goes to paypal page... but at the same time when user will complete his transaction at paypal I want to make these entries in database with userid ...Like there is a table which will have entries of userid and classid ... how can I do that ..

    Thanks
    Varun

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Paypal does all the dirty work for you, or at least it's said to. One of the problems is that there's noway to put an automatic code in each of your items, you've gotta do that individually. Some of the things it does is: finds total cost, sets cookies that the user has x and y in there shopping cart and there using i's cart, and lets you chose quantities unless you've disabled that option.

    What you'd have to try is for each item in the database you need to give it an ID that's from Paypal. What you would do is make a new field called "payID" and go through every single item, and give it the ID that Paypal gives.

    I hope this helps,
    Nile
    Jeremy | jfein.net

  3. #3
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am sorry but if you can give some example of code , will really help... if you can just modify my code...
    also, at what point should i make database entries...
    on my page, user selects classes and click button "add to cart" and goes to paypal sandbox website where it shows the total of the money but after that user can just pay it ... i need to enter the classes user selected with userid in the table ....

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Have a look at the following:

    http://paypal.sourceforge.net/

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok I think I was not able to write my problem..


    I am implementing paypal for the first time..

    I have suppose 6 checkbox on the page ... I am findin which checkbox is clicked... and depending upon that using a javascript function like this to find out the total amount:

    $(document).ready(function()
    {
    var value;
    $("input[@name='checkbox']":smileywink:.click(function()
    {
    var n = $("input:checked":smileywink:.length;
    if((n>=6))
    {
    $("#txtAmount":smileywink:.val((n-1)*45);
    value=$("#txtAmount":smileywink:.val();

    }
    else
    {
    $("#txtAmount":smileywink:.val(n*45);
    value=$("#txtAmount":smileywink:.val();

    }
    $('#amountText').val(value);
    $('#hiddenText').val(n);
    });


    });



    after this I am using this in php which takes me to paypal:

    <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="pp_form" target="_blank">
    <input type="hidden" name="cmd" value="_cart" >
    <input type="hidden" name="business" value="khatri_vk@yahoo.com">
    <input type="hidden" name="upload" value="1" >
    <input type="hidden" name="item_name_1" value="Classes">
    <?php
    echo "<input type=\"hidden\" name=\"amount_1\" id=\"amountText\">";
    ?>
    <input type="hidden" name="return" value = "http://localhost/php_framework/views/notify.php?status=T"><br>
    <input type="hidden" name="cancel_return" value = "http://localhost/php_framework/views/notify.php?status=F"><br>
    <input type="image" src="../img/x-click.gif" border="0" name="submit" alt="PayPal - the safer, easier way to pay" width="5" height="50" class="button"/>
    </form>



    and after this it comes back to notify page...

    the url that comes back to notify page is http://localhost/php_framework/views...rn+to+Merchant

    that too if user clicks return to merchant:

    but the problem is that I want to send each checkbox (order) individually and final amount also, which will send id of these checkbox to notify page .... where i can use these id to make database entry if transaction return "True"... I really dont understand ... how to that ...

    any help will be appreciated ..

    Thanks

  6. #6
    Join Date
    Dec 2008
    Posts
    48
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    hi, go here: http://www.paypaldeveloper.com/pdn/

    ask your questions there, they got some very experienced paypal developers that can really help you out.

  7. #7
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks but I have already posted my question at this site... did not get any replies...

Bookmarks

Posting Permissions

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