PayPal Send-Money Form
We recently added a "support this website" form below Willmaster blog and library articles. I'll show you how to make something similar.
PayPal no longer offers "Donate" payment functionality. So we made our own form where people can contribute funds to help the site.
You'll see a live Support This Website form below this article. The form can be tested without completing the last step to finalize the payment. Finalize the payment only if you wish to contribute to the operations of Willmaster.com.
This article shows you how to make a PayPal payment form for your own websites.
When you see the code, you'll see the form is simple to implement. It can be used for pretty much any simple PayPal payments.
To implement the payment form, you'll need two things.
-
The PayPal payment form.
-
A thank-you page (for the payer to land on after they've made the payment and are returned from PayPal).
You'll need a thank-you page URL before you can make the PayPal payment form. So let's get that made, first.
A Thank-You Page
Here's a bare-bones thank-you page you can adapt. Both the amount paid and the transaction ID (that PayPal embeds into the return URL) are inserted into the thank-you page.
<!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Thank You</title> </head> <body> <h1>Thank You</h1> <p> Your transaction has been completed and PayPal will email a receipt to you. </p> <p> You may log into your account at <a href="https://www.paypal.com"><nobr>https://www.paypal.com</nobr></a> to view details of this transaction. </p> <p> Transaction amount: <?php echo(@$_GET['amt']); ?> <br>Transaction ID: <?php echo(@$_GET['tx']); ?> </p> </body> </html>
Upload the page to your server and name it thankyou.php
or any other file name with a .php
extension.
You'll need the thank-you page's URL when you make the form.
The PayPal Payment Form
To make the form, you'll need two additional items.
-
A PayPal image button for the form.
You may copy the PayPal image from our live Support This Website form found below this article, or create your own. (Alternatively, a regular submit button could be used instead of an image button.)
-
Your PayPal Business ID.
You could use your PayPal email address as the Business ID — either will work. However, because of the proliferation of spam bots, it isn't recommended to make your PayPal email address available in a public web page form.
PayPal recently re-designed their merchant interface. You'll probably find your Merchant ID at Profile and Settings → Merchant account ID.
When you have the PayPal image URL, your Merchant ID, and the URL of the thank-you page, you can go ahead and install the payment form. Here is the source code (comments follow).
<form method="post" action="https://www.paypal.com/cgi-bin/webscr"> <input type="hidden" name="cmd" value="_xclick"><!-- PayPal required field and value --> <input type="hidden" name="business" value="SFJJF7CEMT8HG"> <!-- Business ID --> <input type="hidden" name="item_name" value="Contribution"> <!-- Item name --> <input type="hidden" name="return" value="http://example.com/page.php"><!-- After-payment URL --> Amount: <br><input type="text" name="amount" style="width:109px; border:1px solid #ccc; height:35px; border-radius:.25em;"> <br><input type="image" src="https://example.com/image.png" style="border:1px solid #ccc; padding:.25em; border-radius:.25em; margin-top:9px;"> </form>
There are four items to customize in the PayPal payment form source code.
-
Replace
SFJJF7CEMT8HG
with your Merchant ID. -
Replace
Contribution
with a description of what the payment will be for. -
Replace
http://example.com/page.php
with the URL of the thank-you page for the payer to land on after they've made the payment and are returned from PayPal. -
Replace
https://example.com/image.png
with the URL of the image to use for the PayPal image button.
Paste the form into a test web page and verify it works as it should.
Change the design as needed.
You'll notice that typing in a payment amount isn't required. If the form user doesn't type in an amount, PayPal will ask them for it.
As you see, it's a simple form, easy to implement.
(This article first appeared with an issue of the Possibilities newsletter.)
Will Bontrager