Published Tuesday 5th August 2014
Paypal is one of the nicest platforms to take online payments through. A developer can build Paypal integration in to just about any website relatively easily and most web users already know of and trust the service. You also don't usually need to worry about securing a website with an SSL certificate as Paypal payments are taken off-site.
Most Paypal integrations make use of Instant Payment Notifications, or IPN. Essentially, when your Paypal account receives a payment, it notifies a script on your website so that the website can acknowledge the payment, perhaps to reduce stocks or to flag an order as paid and ready for shipping.
Actual integration is dependent on specific project requirements, but, regardless of how your website works, if you want to use IPN you need to enable it in your Paypal account. Here's how:
<?php
$req = 'cmd=_notify-validate';
foreach($_REQUEST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= '&'.$key.'='.$value;
}
$header = 'POST /cgi-bin/webscr HTTP/1.1'."\r\n"
.'Content-Type: application/x-www-form-urlencoded'."\r\n"
.'Host: www.paypal.com:443'."\r\n"
.'Content-Length: '.strlen($req)."\r\n"
.'Connection: close'."\r\n\r\n";
$fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30);
if($fp) {
fputs($fp, $header.$req);
while(!feof($fp)) {
$res = fgets($fp, 1024);
}
fclose ($fp);
}
?>
You're now ready to use your account with an IPN enabled shopping cart, which should override this dummy script with it's own. Your developer just needs to know your merchant ID which is shown at the bottom of Profile & Settings.
Blog posts are written by individuals and do not necessarily depict the opinions or beliefs of QWeb Ltd or its current employees. Any information provided here might be biased or subjective, and might become out of date.
Nobody has commented yet.
Your email address is used to notify you of new comments to this thread, and also to pull your Gravatar image. Your name, email address, and message are stored as encrypted text. You won't be added to any mailing list, and your details won't be shared with any third party.