Hello Friends,
Finally i have done Recurring Payment System for os_paypal_pro plugin.
Please follow following steps if you want this feature in your os_paypal_pro plugin :-
1) First go to your database ( phpmyadmin ) area and browse the prefix_osmembership_plugins table and click on edit button near to os_paypal_pro plugin and set the support_recurring_subscription value is 1 .
2) Add following function in os_paypal_pro.php file . ( components/com_osmembership/plugins/os_paypal_pro.php )
function processRecurringPayment($row, $data){
$mainframe = & JFactory::getApplication();
$Itemid = JRequest::getInt('Itemid');
$this->setParam('PAYMENTACTION', 'Sale');
$this->setParam('AMT', round($data, 2));
$this->setParam('CREDITCARDTYPE', $data);
$this->setParam('ACCT', $data);
$this->setParam('EXPDATE', $data.$data);
$this->setParam('CVV2', $data);
$this->setParam('FIRSTNAME', $data);
$this->setParam('LASTNAME', $data);
$this->setParam('STREET', $data);
$this->setParam('CITY', $data);
$this->setParam('STATE', $data);
$this->setParam('ZIP', $data) ;
$this->setParam('COUNTRYCODE', OSMembershipHelper::getCountryCode($data));
$this->setParam('CURRENCYCODE', 'USD');
$this->setParam('METHOD','CreateRecurringPaymentsProfile') ;
// Recurring Paremeter
$this->setParam('BILLINGPERIOD', urlencode('Month'));
$this->setParam('BILLINGFREQUENCY', 12);
$this->setParam('INITAMT', round($data, 2));
$this->setParam('FAILEDINITAMTACTION', urlencode("ContinueOnFailure"));
$this->setParam('DESC', urlencode("Recurring $".$data));
$this->setParam('AUTOBILLAMT', urlencode("AddToNextBilling"));
$this->setParam('PROFILEREFERENCE', urlencode("Anonymous"));
// End Recurring Paremeter
$this->setParam('VERSION', $this->VERSION);
$this->setParam('PWD', $this->API_PASSWORD);
$this->setParam('USER', $this->API_USERNAME);
$this->setParam('SIGNATURE', $this->API_SIGNATURE);
$fields = '' ;
foreach ($this->params as $key=>$value) {
$fields.= "$key=" . urlencode($value) . "&";
}
$fields.= "PROFILESTARTDATE=".urlencode(date('Y-m-d H:i:s'));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$this->API_ENDPOINT);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($fields, "& "));
$response = curl_exec($ch);
$nvpResArray = $this->deformatNVP($response);
if ($nvpResArray == 'Success') {
$config = OSMembershipHelper::getConfig() ;
$row->transaction_id = $nvpResArray ;
$row->payment_date = date('Y-m-d H:i:s');
$row->published = 1 ;
$row->store();
if($row->act == 'upgrade') {
OSMembershipHelper::processUpgradeMembership($row);
}
OSMembershipHelper::sendEmails($row, $config);
JPluginHelper::importPlugin( 'osmembership' );
$dispatcher =& JDispatcher::getInstance();
$dispatcher->trigger( 'onMembershipActive', array($row));
$mainframe->redirect(JRoute::_('index.php?option=com_osmembership&view=complete&act='.$row->act.'&subscription_code='.$row->subscription_code.'&Itemid='.$Itemid, false, false));
return true;
} else {
$_SESSION = $this->getResponseText() ;
$mainframe->redirect(JRoute::_('index.php?option=com_osmembership&view=failure&id='.$row->id.'&Itemid='.$Itemid, false, false));
return false;
}
}
3) $this->setParam('BILLINGPERIOD', urlencode('Month'));
$this->setParam('BILLINGFREQUENCY', 12);
This value is currently hard-code you need to manage this value from admin area using your logic.
4) If you get error like (DPRP is disabled for this merchant) so you need to contact paypal services enable this options
check following URL :-
www.paidmembershipspro.com/2012/03/paypa...led-for-this-client/
www.paypal-community.com/t5/About-Paymen...disabled/td-p/654451
This is only issue (4 no) i get, The code is running properly with sandbox mode.
Enjoy