i have two type of payments in my system built in phpfox
one is recurring method and other is parallel payment
i dint get return values in parallel payment but i get return parameters in recurring option
the following is the sample output i got in parallel payment option
Array ( [do] => /subscribe/complete/ [PHPSESSID] => 74b50226b0076bd66e1ddbc8baecd23d [corecf2bvisit] => 1400432842 [corecf2binvited_by_email_form] => akhil@wdstech.com [corecf2bcur_mailid] => akhil@wdstech.com [corecf2binvited_by_user] => 0 [corecf2binvited_by_email] => 0 )
but i got returnvalues including amount in recurring option
how can i solve it
a detailed view of my code is given below
public function getForm()
{
$bCurrencySupported = true;
echo "<script>console.log('within-paypal')</script>";
if (!in_array($this->_aParam['currency_code'], $this->_aCurrency))
{
if (!empty($this->_aParam['alternative_cost']))
{
$aCosts = unserialize($this->_aParam['alternative_cost']);
foreach ($aCosts as $aCost)
{
$sCode = key($aCost);
$iPrice = $aCost[key($aCost)];
if (in_array($sCode, $this->_aCurrency))
{
$this->_aParam['amount'] = $iPrice;
$this->_aParam['currency_code'] = $sCode;
$bCurrencySupported = false;
break;
}
}
if ($bCurrencySupported === true)
{
return false;
}
}
else
{
return false;
}
} #//by son
$package_id = $this->_aParam['package_id']; //purchased package id - 2:Good Friend
echo "<script>console.log('packageId-in-paypalclass-$package_id')</script>";
if($package_id == 2){
#//chk if its an upgrade
$isUpgrad = $this->_aParam['is_upgrade'];
if(isset($isUpgrad) && $isUpgrad==1){
return Phpfox_Error::display('Need invitation to upgrade to this subscription level!!');
}
#//get the details of the inviter users end */
$pay_ids = $this->_aParam['pay_ids'];
echo "<script>console.log('payid-count-". count($pay_ids)."')</script>";
#//echo '<pre>'; print_r($pay_ids); echo '</pre>';
if($pay_ids[0] == 'admin'){
$rec_dtl[0]['rec_email'] = $this->_aParam['setting']['paypal_email'];
$rec_dtl[0]['rec_amount'] = $this->_aParam['amount'];
$rec_dtl[0]['primary_recvr'] = "false";}else{
if(count($pay_ids) >0){
$j = 0;
foreach($pay_ids as $pay){
if($pay[$j] != 'NULL'){
$rec_dtl[$j]['rec_email'] = $pay;
$rec_dtl[$j]['primary_recvr'] = 'false'; }
$j++;
}
}
switch (count($pay_ids)) {
case 1:
$rec_dtl[0]['rec_amount'] = $this->_aParam['amount'];
break;
case 2:
if($pay_ids[1] == 'NULL'){
$rec_dtl[0]['rec_amount'] = $this->_aParam['amount'];
}else{
$rec_dtl[0]['rec_amount'] = $this->_aParam['amount']-1;
$rec_dtl[1]['rec_amount'] = '1.00';
}
break;
case 3:
if($pay_ids[1]=='NULL' && $pay_ids[2]=='NULL'){
$rec_dtl[0]['rec_amount'] = $this->_aParam['amount'];
}
if($pay_ids[2] == 'NULL'){
$rec_dtl[0]['rec_amount'] = $this->_aParam['amount']-1;
$rec_dtl[1]['rec_amount'] = '1.00';
}
if($pay_ids[1] == 'NULL'){
$rec_dtl[0]['rec_amount'] = $this->_aParam['amount'];
}else{
$rec_dtl[0]['rec_amount'] = $this->_aParam['amount']-2;
$rec_dtl[1]['rec_amount'] = '1.00';
$rec_dtl[2]['rec_amount'] = '1.00';
}
break;
default:
break;
}
}
$receiver = array();
$recvr_dtls = $rec_dtl;
$currencyCode = $this->_aParam['currency_code'];
$returnUrl = $cancelUrl = $this->_aParam['return'];
for($i=0; $i<count($recvr_dtls); $i++) {
$receiver[$i] = new Receiver();
$receiver[$i]->email = $recvr_dtls[$i]['rec_email'];
$receiver[$i]->amount = $recvr_dtls[$i]['rec_amount'];
$receiver[$i]->primary = $recvr_dtls[$i]['primary_recvr'];
}
$receiverList = new ReceiverList($receiver);
$payRequest = new PayRequest(new RequestEnvelope("en_US"), "PAY", $cancelUrl, $currencyCode, $receiverList, $returnUrl);$payRequest->returnUrl = $returnUrl;
$payRequest->currencyCode = $currencyCode;
$payRequest->receiverList = $receiverList;
$service = new AdaptivePaymentsService(Configuration::getAcctAndConfig());
$response = $service->Pay($payRequest);
$ack = strtoupper($response->responseEnvelope->ack);
if($ack == "SUCCESS"){$payKey = $response->payKey;
$aForm = array(
'url' => ($this->_aParam['is_test'] ? 'https://www.sandbox.paypal.com/cgi-bin/webscr&cmd=_ap-payment&paykey='.$payKey : 'https://www.paypal.com/cgi-bin/webscr&cmd=_ap-payment&paykey=' . $payKey),
'item_name' => $this->_aParam['item_name'],
'item_number' => $this->_aParam['item_number'],
'currency_code' => $this->_aParam['currency_code'],
'amount' => $this->_aParam['amount'],
'notify_url' => Phpfox::getLib('gateway')->url('paypal'),
'return' => $this->_aParam['return'],'rm'=> '2',
'no_shipping' => '1',
'no_note' => '1'
);
}else{$aForm = array('url' => '#');
return Phpfox_Error::display('Failed Registration!!');
}}else{$aForm = array(
'url' => ($this->_aParam['is_test'] ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr'),
'param' => array(
'business' => $this->_aParam['setting']['paypal_email'],
'item_name' => $this->_aParam['item_name'],
'item_number' => $this->_aParam['item_number'],
'currency_code' => $this->_aParam['currency_code'],
'notify_url' => Phpfox::getLib('gateway')->url('paypal'),
'return' => $this->_aParam['return'],
'no_shipping' => '1',
'no_note' => '1'
)
);if ($this->_aParam['recurring'] > 0)
{
switch ($this->_aParam['recurring'])
{
case '1':
$t3 = 'M';
$p3 = 1;
break;
case '2':
$t3 = 'M';
$p3 = 3;
break;
case '3':
$t3 = 'M';
$p3 = 6;
break;
case '4':
$t3 = 'Y';
$p3 = 1;
break;
}
if (!empty($this->_aParam['alternative_recurring_cost']))
{
$aCosts = unserialize($this->_aParam['alternative_recurring_cost']);
$bPassed = false;
foreach ($aCosts as $sKey => $iCost)
{
if (in_array($sKey, $this->_aCurrency))
{
$this->_aParam['recurring_cost'] = $iCost;
if (is_array($this->_aParam['recurring_cost']))
{
$aRec = array_values($this->_aParam['recurring_cost']);
$this->_aParam['recurring_cost'] = array_shift($aRec);
}
$bPassed = true;
break;
}
}
if ($bPassed === false)
{
return false;
}
}
/*
a1 is optional an price for the trial period @see https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables#id08A6HI00JQU
a3 is the price of the transaction required
*/
$aForm['param']['cmd'] = '_xclick-subscriptions';
$aForm['param']['a1'] = $this->_aParam['amount'];
$aForm['param']['a3'] = $this->_aParam['recurring_cost']; // $aCosts[$this->_aParam['currency_code']]; change made for 3.7.1
$aForm['param']['t1'] = $t3;
$aForm['param']['p1'] = $p3;
$aForm['param']['t3'] = $t3;
$aForm['param']['p3'] = $p3;
$aForm['param']['src'] = '1';
$aForm['param']['sra'] = '1';
}
else
{
$aForm['param']['cmd'] = '_xclick';
$aForm['param']['amount'] = $this->_aParam['amount'];
}
}
return $aForm;
}