I Make
Games & Pasta.
Super Chibi Knight on Steam PestoForce on Newgrounds PestoForce on Facebook Super Chibi Knight on YouTube

Back when I programmed Abobo's Big Adventure in 2012 (actually more like 2008 through 2012...*sigh*) I learned about a cool feature of PayPal called "IPN" that we used to handle incoming donations and automatically send out a free mini-game download called "Aboboy's Small Adventure."

What is IPN?
IPN stands for: Instant Payment Notification and it does what it sounds like it should do, it sends out a communication instantly when a payment is made!

Here's some more detail:
1. In your PayPal account you define the location of a "script" file on your website's server. ex: http://www.pestoforce.com/somescript.php

2. You write your script (in a language supported by PayPal, I used PHP) to handle the payment data that PayPal will send you and DO STUFF with that information.

STUFF might be "send an official email to the purchaser" or "store the buyer and transaction info in a database" or, like we did for Abobo, "send all the game creators an email with a running total of how much moniez we'd made so far, subject line: 'RICHES ++'." Oh, and "send a download link to the person who donated."

3. You test your script using some of PayPal's tools that let you send fake notifications.

4. When a real payment is authorized by PayPal, they send the info to your site script and MAGIC happens.

For more IPN information click HERE.

What about PayPal Shopping Carts?!
I was disappointed to find out, while recently coding a shopping cart for a freelance website, that the variables I was using for SINGLE transaction PayPal payments would not work for SHOPPING CART transactions.

Shopping cart transactions are different from single transactions because, while the processing is still only done once, there are multiple items being tracked within that single payment.

PayPal has some documentation on the shopping cart variable names vs. the single transaction variable names, but I was surprised to find that the variable list is INCOMPLETE in their documentation. I wanted to track a few extra variables that their documentation was missing.

Here is a more-comprehensive list of SHOPPING CART specific variables to use with your IPN transactions. Where there is a "_#" or a variable that ends in a number, that is a trailing number that could potentially continue on to infinity based on the number of items in your cart. If there is no trailing number, then that is the ENTIRE transaction aggregate sum. The example below shows 2 items in the cart:




















The "option" variables above can also continue on indefinitely based on the number of options you send to PayPal FOR EACH item in your cart. For example, you can have a pen with options for "material", "hardware", and "case" which would be option 1, 2, and 3, (option1_1, option2_1, and option3_1) and also have a t-shirt with just options for "color" and "size" which would show as option1_2, and option2_2. The final trailing number is always the item id, the previous number is the option id.

IMPORTANT: Both item ids and option ids begin at 1 NOT 0.

PHP Example:
Here's an example of my code in PHP (inside the larger IPN script on the website's server) to create a string to send through email to the site owners when a shopping cart transaction is made.

I've tested this and IT WORKS!!! :-D

// Assign payment notification values to local variables
$numitems = $_POST['num_cart_items'];
$names = array();
$nums = array();
$amounts = array();
$shippings = array();
$taxes = array();
$opts = array();
$sum = "";
for ($i = 1; $i < $numitems+1; $i++ )
 $names[$i] 		= $_POST['item_name'.$i];
 $nums[$i] 		= $_POST['quantity'.$i];
 $amounts[$i]		= $_POST['mc_gross_'.$i];
 $shippings[$i]		= $_POST['mc_shipping'.$i];
 $taxes[$i]		= $_POST['tax'.$i];
 $opts[$i] = "";
 for ($j = 1; $j < 6;$j++ )
  $opts[$i] = $opts[$i]."".$_POST['option_name'.$j."_".$i].": ".$_POST['option_selection'.$j."_".$i]."\n";
 $sum = $sum."Item Name: ".$names[$i]."\nQuantity: ".$nums[$i]."\nAmount: ".$amounts[$i]."\n\nOptions:\n".$opts[$i]."\n=============\n\n";

I hope that helps somebody out there save time tracking down variables for PayPal shopping cart IPN transactions!

There is a whole lot of potential here for game developers to create their own payment ecosystems with the worldwide leader in online payments.
PayPal does take a transaction fee off of every authorization, but it's fairly comparable to other payment systems and with IPN, all the POWER is in your hands to customize and brand the experience exactly as you please.

If you have any questions or comments feel free to contact me here.