php - Logic for all possible scenarios paypal IPN -


okay i'm writing ipn page, got work inserting db when payment_status completed. here query far:

if($payment_status=="completed"){         $txn_id_check = $mysqli->query("select `transaction_id` `payment` `transaction_id`='$txn_id'");         if($txn_id_check->num_rows != 1) {                       $query = "insert `payment` (`transaction_id`, `payment_status`, `users_id`) values(?, ?, ?)";                     $statement = $mysqli->prepare($query);                     $statement->bind_param('ssi',$txn_id, $payment_status, $id);                     if($statement->execute()){                     print 'success! id of last inserted record : ' .$statement->insert_id .'<br />';                      }else{                     die('error : ('. $mysqli->errno .') '. $mysqli->error);                     }                     $statement->close();         }     } 

because i'm making subscription service i'm unsure all scenarios happen. thoughts:

user buys membership

  • user makes purchase premium membership ( subscribes )
  • add data database
  • update account premium

checks: must check payment correct recepient, transaction_id doesnt exist, payment amount correct.

user cancels membership

  • user cancels membership through paypal ( unsubscribes )
  • update database against transaction id
  • downgrade account non-premium

is there else need consider?

thank in advance.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -