by nunos
9 replies
Hi.

I have been trying to find a paypal script but still haven't found what I am looking for.

I suppose this the basics of paypal payment processing.

What I want is to be able to do is to have the amount to be paid by paypal in a parameter.

So it would be like this:

  • user fills a form
  • the amount is calculated based on the filled form
  • the user pays the amount calculated in paypal

That's it.

I know HTML and PHP. I just haven't done this before and can't seem to find a way to do it right...

I would really appreciate any help on this. I have already looked up a few php paypal libraries but I can't get to make them work properly.

Thanks for your help and time,
nunos
#paypal
  • Profile picture of the author Lisa Copen
    If you have the form on the page, and can do your calculations in JavaScript, the following script will update the PayPal form:

    Code:
    		function addToCart(sItem, sPrice, sQty)  {
    			with (document.frmPayPal)  {
    
    				// call function to calculate amount
    
    				item_name.value = sItem;
    				amount.value = sPrice;
    				quantity.value = sQty;
    				submit();
    			}
    		}
    This code allows a single form on the page, regardless of how many products you have. I use this in conjunction with the PayPal shopping cart form code. The script is called from a link on the web page.


    Hope this helps.

    Lisa
    {{ DiscussionBoard.errors[656390].message }}
  • Profile picture of the author ehicks727
    Originally Posted by nunos View Post

    • user fills a form
    • the amount is calculated based on the filled form
    • the user pays the amount calculated in paypal
    What determines the price? In other words, what, in the form, would affect the price and how? Is it just Quantity??
    {{ DiscussionBoard.errors[656555].message }}
    • Profile picture of the author viane
      Are you using session variable to store quantity and price ? Please give us more information to look at the problem
      {{ DiscussionBoard.errors[657209].message }}
  • Profile picture of the author codeswarrior
    I have script for Paypal you can check this Paypal Demo . Hope this help you.
    Furthermore if you want his script i will provide you.
    {{ DiscussionBoard.errors[660373].message }}
  • Profile picture of the author Bugala
    Sorry from spamming this, but seems i need 2 more sent messages to be able to PM you.

    Im interested in your code.
    {{ DiscussionBoard.errors[813640].message }}
  • Profile picture of the author Dan Grossman
    form-processor.php:
    PHP Code:
    <?php

    //put your code here to compute $price based on the submitted form
    $price = 5;

    //now fill these in
    $email = "your paypal e-mail address";
    $name = "the product name you want to display";
    $thanks = "http://the url of your thank-you page";

    //Now redirect to PayPal to pay
    header("Location: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" . urlencode($email) . "&quantity=1&item_name=" . urlencode($name) . "&amount=$price&no_shipping=1&return=" . urlencode($thanks) . "&currency_code=USD&lc=US&bn=PP%2dBuyNowBF&charset=UTF%2d8");
    ^ That's it
    Signature
    Improvely: Built to track, test and optimize your marketing.

    {{ DiscussionBoard.errors[813710].message }}
    • Profile picture of the author egturnkey
      Originally Posted by Dan Grossman View Post

      ^ That's it
      didn't worked for me ...
      {{ DiscussionBoard.errors[817688].message }}
      • Profile picture of the author Dan Grossman
        Originally Posted by egturnkey View Post

        didn't worked for me ...
        If you want help using it, then you'll have to write more than "didn't worked". I've been using similar code in custom written shopping carts for more than 5 years.
        Signature
        Improvely: Built to track, test and optimize your marketing.

        {{ DiscussionBoard.errors[818750].message }}
  • Profile picture of the author Aaron Sustar
    Yup, we are a little short on details here ...

    However, changing the settings of your PayPal button with JavaScript might seem like an elegant way, but you will *always* need to double-check those values with your server-side language as well.
    {{ DiscussionBoard.errors[820837].message }}

Trending Topics