Announcement

Collapse
No announcement yet.

Please help with linking a paypal page to my webpage using php or javascript..!

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Please help with linking a paypal page to my webpage using php or javascript..!

    I am building my first site. I am currently trying to link a paypal payment service. I have a list of milk products with different prices.. that I am trying to link to the paypal site. However, my desire is for a milk product selected to include its respective price on form submission of the paypal form without a client having to type the price into the form. The paypal form I am trying to modify is the following:-

    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">

    <!-- Identify your business so that you can collect the payments. -->
    <input type="hidden" name="business" value="groceries_sales@mybusiness.com">

    <!-- Specify a Buy Now button. -->
    <input type="hidden" name="cmd" value="_xclick">

    <!-- Specify details about the item that buyers will purchase. -->
    <input type="hidden" name="milk_brand " value=" 1">
    <input type="hidden" name="price" value=" ">
    <input type="hidden" name="currency_code" value="USD">

    <!-- Provide a dropdown menu option field. -->

    <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="hidden" name="on0" value="Type"><br />

    <select name="os0">

    <option value="Select a Product">Select a Product for ePayment</option>

    <option value="Frozen Milk">Frozen Milk</option>
    <option value="Powdered Milk ">Powdered Milk</option>
    <option value="Homogenized Milk">Homogenized Milk</option>
    <option value="Fully Skimmed Milk">Skimmed Milk</option>
    <option value="Milk Shake">Milk Shake</option>
    <option value="Butter Milk">Butter Milk</option>
    <option value="Partly Skimmed Milk">Partly Skimmed Milk</option>
    <option value="Unpasteurised Milk">Unpasteurised Milk</option>

    </select> <br />

    <!-- Display the payment button. -->
    <input type="image" name="submit" border="0"
    src="https://www.thcservers.com/images/paypal_cards.jpg" width="230" height="60"
    alt="">


    <img alt="" border="0" width="1" height="1"
    src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
    </p>
    </form>


    My purpose is to be able to develop a php or javascript that would enable the various prices of milk products to automatically show when a client selects a product by clicking them.. I was wondering if I need to develop a database (milk products vs prices) for the it to work or php could add prices to items on click without a database..?

    I have been looking at php (switch/break) option.. but i have no clue.. especially on how to augment (incorporate) the php element to the code above and onto the whole web page itself..

    Your help and orientation and all other possible solutions are highly appreciated.. please!

    Thank you.

  • #2
    Hi there aldaism66,

    I have coded the"Paypal" form for you.

    It now opens the cart properly.

    Of course, I did not know the item values so
    you will have to edit the HTML yourself.

    If you feel that you are unable to do it then
    don't hesitate to let me know and I will do it
    for you.
    Attached Files
    Last edited by coothead; 06-08-2016, 09:49 PM. Reason: tpynig eorrr


    ~ the original bald headed old fart ~

    Comment


    • #3
      Originally posted by coothead View Post
      If you feel that you are unable to do it then
      don't hesitate to let me know and I will do it
      for you.
      Hmm, That's mighty fine of ye!
      Who needs a Signature?

      Comment


      • #4
        WuponT sarcasm rules OK.


        p.s.

        How are you getting on with your "Turdpress" and "Bootcrap" frameworks?


        ~ the original bald headed old fart ~

        Comment


        • #5
          Originally posted by coothead View Post
          WuponT sarcasm rules OK.


          p.s.

          How are you getting on with your "Turdpress" and "Bootcrap" frameworks?



          Fortunately, I have the pleasure of saying that I continue to dislike wordpress and thankfully don't have to use it at work and definitely don't use it personally!
          Bootstrap on the other hand... Despite my dislike, i have to keep in with the company "Standards" when developing front end "UI'ey" stuff.
          This does not stop me from hanging my head in shame, however!


          And as you continue to beat me to the punch on pretty much every post, i suppose i'll just continue to hide in the shadows...
          Who needs a Signature?

          Comment


          • #6
            Once again it is simply brilliant..! Thanks a lot coothead..

            Comment


            • #7
              Hi there aldaism66,

              stone me, it's over two weeks since I posted your code.

              I thought that you had found a solution elsewhere.



              ~ the original bald headed old fart ~

              Comment


              • #8
                Hi Coothead, It is me again. Your previous code worked perfectly. But I wanted to separate products sold according tot their sizes and prices before getting a total price.

                After looking up a lot of examples I have come up with this code for my site, posted below.
                I am trying to set up larger 1 litre cans prices and smaller 500gram cans prices of milk products that must respond to quantities of either size to bring about total amount of money a client will be required to pay .. according to the amounts of cans purchased. I am seeking help in making the below code be able to sum up hence obtain total of prices for larger and smaller cans in two text boxes (id="select2-basic" and id="select4-basic"), before the total price is submitted to the paypal account indicated below. I am planning to use the completed form on paypal payments. I have done some research and developed my code to where it is now. But being a new bee, I do not have an idea on how to develop code to obtain a Total Price. The price for smaller cans {costs} is supposed to be half that of the adult price{Price}, as I have indicated. Below is an example of where I have reached but cant crack it to completion. I need your help!



                <label><input type="radio" name="os0" value="Milk Products" checked="checked">: - Select a Product</label>
                <label><input type="radio" name="os0" value="Powdered Milk">: $20 - Powdered milk</label>
                <label><input type="radio" name="os0" value="Homogenous milk">: $30 - Homogenous milk</label>
                <label><input type="radio" name="os0" value="Skimmed milk">: $40 - Skimmed milk</label>


                <select name="Milk Products" id="select2-basic" class="#">
                <option value="Powdered Milk">Powdered Milk</option>
                <option value="Homogenous milk">Homogenous milk</option>
                <option value="Skimmed milk">Skimmed milk</option>

                </br></br>
                <p>Large 1litres Cans:<select name="Largercans" id="select3-basic" value="#">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>

                </br></br>
                <p>Smaller 500gram Cans:<select name="Smallercans" id="select5-basic" value="#">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>




                <input class="span1" readonly type="text" name="Price" id="select2-basic" value="">

                <input class="span1" readonly type="text" name="costs" id="select4-basic" value=""></br></br>


                <script src="https://code.jquery.com/jquery-3.1.1.js"></script>


                <script>

                $(function(){

                var prices = {
                'Powdered milk':20,'Homogenous':30,'Skimmed milk':40
                };



                $('#select2-basic, #select3-basic').on('change', function(){
                if(this.name == 'Largercans'){
                $('input[name="Quantity"]').val(+this.value);
                $('input[name="Price"]')
                .val(prices[$('#select2-basic').val()] ? (prices[$('#select2-basic').val()] * this.value) : (1 * this.value));
                };
                });
                });

                </script>



                <script>

                $(function(){

                var costs = { 'Powdered milk':10,'Homogenous milk':15,'skimmed milk':20

                };

                $('#select2-basic, #select5-basic').on('change', function(){
                if (this.name == 'Smallercans'){
                $('input[name="Smallercans"]').val(+this.value);
                $('input[name="costs"]')
                .val(costs[$('#select2-basic').val()] ? (costs[$('#select2-basic').val()] * this.value) : (.5 * this.value));
                };
                });
                });

                </script>



                <script> // HELP NEEDED HERE!


                function add(x,y) {

                return x+y;

                }

                add(x,y);

                var x = document.getElementById("select2-basic").value;

                var y = document.getElementById("select4-basic").value;

                // HELP HUMBLY NEEDED..HERE i HAVE NO IDEA ON HOW TO BE ABLE TO ADD THE PRICE FOR LARGER CANS AND SMALLER CANS.. PLEASE FEEL FREE TO MAKE ANY NECESSARY EDITS AND CHANGES TO MAKE CODE WORK.. THX!

                </script>



                <input type="hidden" name="item_name" value="Products">
                <input type="hidden" name="tax_rate" value="1.17">
                <input type="hidden" name="shipping" value="4.35">
                <input type="hidden" name="business" value="groceries_sales@mybusiness.com">

                **************************************************************************************************** **

                <input type="hidden" name="cmd" value="_cart">
                <input type="hidden" name="lc" value="US">
                <input type="hidden" name="button_subtype" value="Products">
                <input type="hidden" name="no_note" value="0">
                <input type="hidden" name="add" value="1">
                <input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHostedGuest">
                <input type="hidden" name="currency_code" value="USD">
                <input type="hidden" name="option_index" value="0">
                <input type="hidden" name="on0" value="Type">
                <input type="image" name="submit" src="https://www.paypalobjects.com/webstatic/en_US/i/btn/png/btn_buynow_107x26.png" alt="ePayment">
                <img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" alt="">

                </fieldset>

                </form>

                </html>



                You help is highly needed.

                Thank you.

                Comment

                Working...
                X