Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Herve FOUCHER  >  paypal_ipn  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Usefull for testing i_paypal.php
Class: paypal_ipn
Paypal payment notification processing
Author: By
Last change: Added set_proxy_options()
Date: 2002-11-22 15:54
Size: 3,990 bytes
 

Contents

Class file image Download
<?php

function my_pre_processing ($ipn)
{
    
// Process IPN as soon as it is received from Paypal server
}

function 
my_post_processing ($ipn$status)
{
    
// Process IPN after the connection to the Paypal secured server
    // Depending of the status (INVALID or VERIFIED or false)
    
print_r($ipn);
}

if(
count($_POST)>0)
{
    include 
"i_paypal.php";

    
$pp = new paypal_ipn ();

    
// If you need proxy support
    //$pp->set_proxy_options ("proxy:8080", "user:pwd");

    // Give function references
    
$pp->set_process_functions ("my_pre_processing""my_post_processing");

    
// Pass the POST table to the Paypal processor
    
$pp->process_notification ($_POSTtrue);
}
else
{
    
// Use the form below to simulate a POST from Paypal server
    // Note : MD5 used below are real Paypal IDs
    
?>
<pre>        
<form method="post" action="<?php echo $_SERVER["PHP_SELF"?>">
<input type="submit"><br>
receiver_email     <input name="receiver_email" value="email@domain.com">
item_name          <input name="item_name" value="Item Name">
item_number        <input name="item_number" value="10010">
quantity           <input name="quantity" value="1">
invoice            <input name="invoice" value="<?php echo md5(microtime()) ?>">
custom             <input name="custom" value="">
option_name1       <input name="option_name1" value="">
option_selection1  <input name="option_selection1" value="">
option_name2       <input name="option_name2" value="">
option_selection2  <input name="option_selection2" value="">
num_cart_items     <input name="num_cart_items" value="">
payment_status     <select name="payment_status"><option value="Completed">Completed</option><option value="Pending">Pending</option><option value="Failed">Failed</option><option value="Denied">Denied</option></select>
pending_reason     <select name="pending_reason"><option value="echeck">echeck</option><option value="intl">intl</option><option value="verify">verify</option><option value="address">address</option><option value="upgrade">upgrade</option><option value="unilateral">unilateral</option><option value="other">other</option></select>
payment_date       <input name="payment_date" value="<?php echo date("h:i:s M j, Y"?>">
payment_gross      <input name="payment_gross" value="100">
payment_fee        <input name="payment_fee" value="5">
txn_id             <input name="txn_id" value="<?php echo md5(microtime().rand(0,1000)) ?>">
txn_type           <select name="txn_type"><option value="web_accept">web_accept</option><option value="cart">cart</option><option value="send_money">send_money</option></select>
first_name         <input name="first_name" value="John">
last_name          <input name="last_name" value="Smith">
address_street     <input name="address_street" value="2, Hollywood Bld">
address_city       <input name="address_city" value="Hollywood">
address_state      <input name="address_state" value="California">
address_country    <input name="address_country" value="USA">
address_status     <select name="address_status"><option value="confirmed">confirmed</option><option value="unconfirmed">unconfirmed</option></select>
payer_email        <input name="payer_email" value="payer_email@payer_domain.com">
payer_id           <input name="payer_id" value="ID_123456">
payer_status       <select name="payer_status"><option value="verified">verified</option><option value="unverified">unverified</option><option value="intl_verified">intl_verified</option></select>
payment_type       <select name="payment_type"><option value="echeck">echeck</option><option value="instant">instant</option></select>
notify_version     <input name="notify_version" value="1.3">
verify_sign        <input name="verify_sign" value="<?php echo md5(rand(1,10000)) ?>">
mc_gross           <input name="mc_gross" value="">
mc_fee             <input name="mc_fee" value="">
mc_currency        <input name="mc_currency" value="">
</form>
<pre>
    <?php
}

?>