Difference between revisions of "PayPal"

From Organic Design wiki
(Good IPN tech info)
m
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
== MediaWiki Extension ==
+
== Getting verified ==
[[MW:Extension:PayPal]] is an extension for creating PayPal donation forms using a <paypal> tag. [http://www.rentacoder.com/RentACoder/SoftwareBuyers/ShowBuyerInfo.asp?lngAuthorId=1573573 PokerCoder] requested adding IPN support to the extension through [http://www.rentacoder.com/RentACoder/misc/BidRequests/ShowBidRequest.asp?lngBidRequestId=816040&txtForceRefresh=1129200723554297227 this RentACoder job] and has accepted [[User:Nad]]'s bid to complete the work.
+
If you're not a "verified user" then there are restriction imposed
 +
*US$500/month sending
 +
*Can't accept credit cards on your site
 +
The only way to get verified is to add a credit card to your account.
  
== IPN ==
+
=== Loaded Card ===
'''I'''nstant '''P'''ayment '''N'''otification, included with Website Payment products, Express Checkout, and Standard Checkout, is available to PayPal Premier and Business members. Instant Payment Notification allows you to integrate your PayPal payments with your website's back-end operations, so that you get immediate notification and authentication of any PayPal payments and disputes you may receive.
+
NZPost do [http://www.nzpost.co.nz/Cultures/en-NZ/ProductsAndServices/P/PrezzyCard/AboutPrezzyCard.htm Prezzy Cards] and [https://www.loadedcard.co.nz/ Loaded Cards] which work like a normal VISA credit card, but are pre-paid. The Prezzy cards are anonymous, but the Loaded Cards are registered to a particular person and require ID to aquire (but there are no credit restrictions), so they should be able to be used for account verification for PayPal users who with bad credit ratings.
 +
*According to [http://smilecity.co.nz/benefits.asp?go=forum&tp=165801&ca=8 this comment] Loaded cards are accepted by PayPal
  
When a customer makes a payment to you, PayPal will post a notification to your server at a URL you specify. Included in this notification will be all of your customer's payment information (e.g. customer name, amount) as well as a piece of encrypted code. When your server receives a notification, it will then post the information, including the encrypted code, back to a secure PayPal URL. PayPal will authenticate the transaction by checking the encrypted string. This post-back of the IPN data to PayPal prevents "spoofing," so you can be sure that the IPN came from PayPal. Upon verification, PayPal will send confirmation of its validity back to your server.
+
[[Category:PayPal]][[Category:Money]]
*[https://www.paypal.com/IntegrationCenter/ic_ipn.html IPN at PayPal Integration Center]
 
*[http://www.paypal.com/us/cgi-bin/webscr?cmd=p/pdn/article_pdn_intro-outside IPN Introduction for Developers]
 
*[http://designertuts.com/paypal-ipn-receiving-instant-payments-in-your-web-application/ DesignerTuts Tutorial]
 
*[https://www.paypal.com/us/cgi-bin/webscr?cmd=p/xcl/rec/ipn-manual-outside IPN Manual]
 
*[https://www.paypal.com/us/cgi-bin/webscr?cmd=p/xcl/rec/ipn-techview-outside IPN Technical Overview]
 
*[https://www.paypal.com/us/cgi-bin/webscr?cmd=p/xcl/rec/ipn-code-outside Instant Code Samples]
 
*[https://www.paypal.com/us/cgi-bin/webscr?cmd=p/xcl/rec/ipn-techniques-outside IPN Techniques]
 
*[http://www.superfreaker.com/paypal/inventory.asp Basic Inventory Management Using IPN]
 
*[http://www.eliteweaver.co.uk/testing/ipntest.php IPN Test Environment]
 
*[http://www.paypal-tech.com/SG2/scriptparse.php IPN PHP Script Generator]
 
*[http://www.eliteweaver.co.uk/testing/ipntest.php?mode=_fetch-help Good IPN tech info]
 
 
 
== PDT ==
 
*[https://www.paypal.com/helpcenter/main.jsp;jsessionid=HJYGzrhnBSnHTFvBB1JLFSrVq5FGw7LT49RVPCr34y3J3LPDlphh!-1839041657?t=solutionTab&ft=homeTab&ps=&target=_parent&solutionId=10768&locale=en_US&_dyncharset=UTF-8&countrycode=US&cmd=_help&serverInstance=9003 What's the difference between IPN and PDT?]
 
 
 
=== IPN code sample ===
 
{{code|<php>
 
<?php
 
 
 
// read the post from PayPal system and add 'cmd'
 
$req = 'cmd=_notify-validate';
 
 
 
foreach ($_POST as $key => $value) {
 
$value = urlencode(stripslashes($value));
 
$req .= "&$key=$value";
 
}
 
 
 
// post back to PayPal system to validate
 
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
 
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
 
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
 
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
 
 
 
if (!$fp) {
 
// HTTP ERROR
 
}
 
else {
 
fputs ($fp, $header . $req);
 
while (!feof($fp)) {
 
$res = fgets ($fp, 1024);
 
if (strcmp ($res, "VERIFIED") == 0) {
 
// check the payment_status is Completed
 
// check that txn_id has not been previously processed
 
// check that receiver_email is your Primary PayPal email
 
// check that payment_amount/payment_currency are correct
 
// process payment
 
 
 
// echo the response
 
echo "The response from IPN was: <b>" .$res ."</b><br><br>";
 
 
 
//loop through the $_POST array and print all vars to the screen.
 
 
 
foreach($_POST as $key => $value) echo $key." = ". $value."<br>";
 
 
 
}
 
else if (strcmp ($res, "INVALID") == 0) {
 
// log for manual investigation
 
 
 
// echo the response
 
echo "The response from IPN was: <b>" .$res ."</b>";
 
}
 
}
 
fclose ($fp);
 
}
 
?>
 
</php>}}
 
 
 
== PDT code sample ==
 
{{code|<php>
 
<?php
 
// read the post from PayPal system and add 'cmd'
 
$req = 'cmd=_notify-synch';
 
 
 
$tx_token = $_GET['tx'];
 
$auth_token = "GX_sTf5bW3wxRfFEbgofs88nQxvMQ7nsI8m21rzNESnl_79ccFTWj2aPgQ0";
 
$req .= "&tx=$tx_token&at=$auth_token";
 
 
 
// post back to PayPal system to validate
 
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
 
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
 
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
 
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
 
// If possible, securely post back to paypal using HTTPS
 
// Your PHP server will need to be SSL enabled
 
// $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
 
 
 
if (!$fp) {
 
// HTTP ERROR
 
} else {
 
fputs ($fp, $header . $req);
 
// read the body data
 
$res = '';
 
$headerdone = false;
 
while (!feof($fp)) {
 
$line = fgets ($fp, 1024);
 
if (strcmp($line, "\r\n") == 0) {
 
// read the header
 
$headerdone = true;
 
}
 
else if ($headerdone)
 
{
 
// header has been read. now read the contents
 
$res .= $line;
 
}
 
}
 
 
 
// parse the data
 
$lines = explode("\n", $res);
 
$keyarray = array();
 
if (strcmp ($lines[0], "SUCCESS") == 0) {
 
for ($i=1; $i<count($lines);$i++){
 
list($key,$val) = explode("=", $lines[$i]);
 
$keyarray[urldecode($key)] = urldecode($val);
 
}
 
// check the payment_status is Completed
 
// check that txn_id has not been previously processed
 
// check that receiver_email is your Primary PayPal email
 
// check that payment_amount/payment_currency are correct
 
// process payment
 
$firstname = $keyarray['first_name'];
 
$lastname = $keyarray['last_name'];
 
$itemname = $keyarray['item_name'];
 
$amount = $keyarray['payment_gross'];
 
 
 
echo ("<p><h3>Thank you for your purchase!</h3></p>");
 
 
 
echo ("<b>Payment Details</b><br>\n");
 
echo ("<li>Name: $firstname $lastname</li>\n");
 
echo ("<li>Item: $itemname</li>\n");
 
echo ("<li>Amount: $amount</li>\n");
 
echo ("");
 
}
 
else if (strcmp ($lines[0], "FAIL") == 0) {
 
// log for manual investigation
 
}
 
 
 
}
 
 
 
fclose ($fp);
 
 
 
?>
 
</php>}}
 

Latest revision as of 01:09, 4 January 2012

Getting verified

If you're not a "verified user" then there are restriction imposed

  • US$500/month sending
  • Can't accept credit cards on your site

The only way to get verified is to add a credit card to your account.

Loaded Card

NZPost do Prezzy Cards and Loaded Cards which work like a normal VISA credit card, but are pre-paid. The Prezzy cards are anonymous, but the Loaded Cards are registered to a particular person and require ID to aquire (but there are no credit restrictions), so they should be able to be used for account verification for PayPal users who with bad credit ratings.

  • According to this comment Loaded cards are accepted by PayPal