I charge monthly and use a timestamp with some math to determine whether or not an account payment has expired.
My biggest concern is my use of this ...
Code:<input type="hidden" name="on0" value="' . $username . '">
Will this info be present in every recurring charge? I'm hoping it will.
I'd also like advice/opinions about my IPN code ...
Code:<?php
if ( count( $_POST ) > 0 ) {
$account = $_POST[ 'option_name1' ];
if ( $account && $_POST['payment_status'] == 'Completed' && $_POST[ 'payment_gross' ] == '2.99' && $_POST[ 'mc_currency' ] == 'USD' ) {
$connection = mysql_connect( "MYHOST", "MYUSERNAME", "MYPASSWORD" );
mysql_select_db( "MY-SPECIFIC-DATABASE" );
mysql_query( "update users set payment_id = '" . $_POST[ 'subscr_id' ] . "' where username = '" . $account . "'" );
mysql_query( "update users set payment_status = '" . time() . "' where username = '" . $account . "'" );
mysql_close( $connection );
}
$time = time();
while ( file_exists( 'PRIVATE-LOCATION/' . $account . '_' . $time . '.txt' ) )
$time++;
$file = fopen( 'PRIVATE-LOCATION/' . $account . '_' . $time . '.txt', 'w' );
fwrite( $file, print_r( $_POST, true ) );
fclose( $file );
}
?>