I am configuring a page that adds a timestamp to a database after payment. This code should prevent clever clients from extending their subscription. It also needs to pass the Client_id to Paypal and back
In the header I have defined the start and expiry times and these are passed as sessions
session_start();
global $wpdb;
$client_id=$_SESSION['client_id'];
$time=date("Y-m-d");
$_SESSION[expire];
$_SESSION[start];
if ($time > $_SESSION[expire])
{ echo 'Your susbcription is out of date.';
}
else {
$timestamp = date('Y-m-d');
if(!empty($client_id)){
$wpdb->update( 'database_field', array ('subscription'=> $timestamp), array('id' => $client_id));
}
}
If you are using paypal as a payment gateway to collect amount, then i suggest to use IPN
.
Instant Payment Notification (IPN) is a message service that notifies you of events related to PayPal transactions.
IPN will call only once when your customer try to do payment and he/she get success or failure.
Based on IPN data you can check that payment is successfull or not.
Please refer to this for further details
https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/# https://developer.paypal.com/docs/classic/ipn/ht_ipn/#do-it
Thanks for answer. Will see if that works for me