EasyIPN - Usage Examples

Using EasyIPN is extremely easy. The following examples will show you how to integrate EasyIPN into your existing website.

The following snipets of code can be added into any of your sale pages, if you have difficulties in doing so, please contact us and we'll help you.

1. Integrate a Single PayPal Buy Now Button

This example will show you how to print a listing to display the paypal button of an existing button from the EasyIPN database (You'll first have to create it from the administration backend).

include_once(dirname(__FILE__) . "/easyipn/core/class.easyipn.php");

$ei = new EasyIPN();
// get the product by its name
$myProduct = $ei->GetProductByName("My Product Name");

if ($myProduct) {
    $myProduct->PrintPPButtonText();
}


include_once(dirname(__FILE__) . "/easyipn/core/class.easyipn.php");

$ei = new EasyIPN();
// this time, get the product by its id (item number)
$myProduct = $ei->GetProductById(2);

if ($myProduct) {
    print $myProduct->GetProductName();
    print "<br />";
    $myProduct->PrintPPButtonText();
}

2. Integrate Multiple PayPal Buy Now Buttons

This example enumerates & prints all the products that exists in the database.

include_once(dirname(__FILE__) . "/easyipn/core/class.easyipn.php");

$ei = new EasyIPN();
$myProducts = $ei->GetAllProducts();

// print all products
foreach ($myProducts as $id => $product) {
    print "<b>Item Number</b>: " . $id . "<br />";
    print "<b>Name</b>: " . $product->GetProductName() . "<br />";
    print "<b>Description</b>: " . $product->GetProductDescription() . "<br />";
    print "<b>Price</b>: " . $product->GetProductPrice() . "<br />";
    $product->PrintPPButtonText();
    print "<br />";
}

3. EasyIPN() Class Functions List

  • GetAllProducts() -
    Returns an array of EIProduct() instances, or FALSE on failure.
  • GetProductByID($id) -
    Returns an instance of EIProduct(), or FALSE on failure.
  • GetProductByName($name) -
    Returns an instance of EIProduct(), or FALSE on failure.

4. EIProduct() Class Functions List

You get an instance of this class as a result of calling one of the EasyIPN() class methods.

  • GetProductID() -
    Returns the product's id (PayPal Item Number).
  • GetProductName() -
    Returns the product's name.
  • GetProductDescription() -
    Returns the product's description.
  • GetProductPrice() -
    Returns the product's price.
  • GetProductPriceCurrency() -
    Returns the product's price currency (YEN, EUR, USD, etc...)
  • PrintPPButtonText() -
    Prints a PayPal buy now text which is ready to be integrated into any website.