sfraise
03-18-2009, 06:14 AM
I'm trying to get the post back system to auto upgrade a membership after successful payment through ccbill, but I can't get it to work.
If I can see what variables are being posted back I could better troubleshoot the problem, but not really sure how to do it. I'm assuming I need to use print_r but I'm not sure how to set it up.
The page that passes the info on is:
{strip}
<form action='https://bill.ccbill.com/jpost/signup.cgi' method=POST>
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td class="module_detail" width="100%">
{assign var="page_hdr01_text" value="{lang mkey='confirmation'}"}
{assign var="page_title" value="{lang mkey='confirmation'}"}
{include file="page_hdr01.tpl"}
<table border="0" cellpadding="{$config.cellpadding}" cellspacing="{$config.cellspacing}" width="100%">
<tr><td>{lang mkey='info_confirm'}</td></tr>
<tr><td>{lang mkey='name'}{$smarty.session.FullName|stripslashes}
</td></tr>
<tr><td>{lang mkey='change_mship_to'}<b>{$item_name}</b>.</td></tr>
<tr><td>{lang mkey='amount'}{mylang mkey='support_currency' skey=$currency}{$amount}</td></tr>
<tr><td>
<div align="center"><b><font color="#BBAAGG" size="4" face="Verdana, Arial, Helvetica, sans-serif">PAY BY CREDIT CARD</font></b><br>
<input type=hidden name=clientAccnum value='{$accNum}'>
<input type=hidden name=clientSubacc value='{$subaccNum}'>
<input type=hidden name=formName value='{$formName}'>
<input type=hidden name=language value='English' >
<input type=hidden name=currencyCode value='840' >
<input type=hidden name=allowedTypes value='{$allowedTypes}:840'>
<input type=hidden name=subscriptionTypeId value='{$subType}:840'>
<input type=hidden name=invoiceid value='{$invoice_no}' >
<input type=hidden name=username value='{$smarty.session.UserName}' >
<input type=hidden name=password value='{$smarty.session.password}' >
<input type=hidden name=confirm_password value='{$smarty.session.password}' >
<input type=hidden name=customer_fname value='{$smarty.session.FirstName}' >
<input type=hidden name=customer_lname value='{$smarty.session.FirstName|replace:$smarty.session.FirstName:""}' >
<input type=hidden name=paid_thru value='ccbill' >
<input type="submit" name="submit" value="Pay Now">
</div></form>
<form action='https://bill.ccbill.com/jpost/signup.cgi' method=POST>
<br><div align="center"><b><font color="#BBAAGG" size="4" face="Verdana, Arial, Helvetica, sans-serif">PAY BY ELECTRONIC CHECK</font></b><br>
<input type=hidden name=clientAccnum value='{$accNum}'>
<input type=hidden name=clientSubacc value='{$subaccNum}'>
<input type=hidden name=formName value='{$formName2}'>
<input type=hidden name=language value='English' >
<input type=hidden name=currencyCode value='840' >
<input type=hidden name=allowedTypes value='{$allowedTypes}:840'>
<input type=hidden name=subscriptionTypeId value='{$subType}:840'>
<input type=hidden name=invoiceid value='{$invoice_no}' >
<input type=hidden name=username value='{$smarty.session.UserName}' >
<input type=hidden name=password value='pass{$smarty.session.UserName}' >
<input type=hidden name=confirm_password value='pass{$smarty.session.UserName}' >
<input type=hidden name=customer_fname value='{$smarty.session.FirstName}' >
<input type=hidden name=customer_lname value='{$smarty.session.FirstName|replace:$smarty.session.FirstName:""}' >
<input type=hidden name=paid_thru value='ccbill' >
<input type="submit" name="submit" value="Pay Now">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
{/strip}
The post back page after successful payment is:
<?php
if ( !defined( 'SMARTY_DIR' ) ) {
include_once( 'init.php' );
}
//already processed subscription_id, exit
$trnrec=$osDB->getRow('select * from ! where txn_id = ? ', array(TRANSACTIONS_TABLE, $_POST['subscription_id'] ));
if( $trnrec['id'] )
exit;
// amount paid is less than amount expected
$trnrec=$osDB->getRow('select * from ! where invoice_no = ? ', array(TRANSACTIONS_TABLE, $_POST['invoiceid'] ));
if( $_POST['initialPrice'] < $trnrec['amount_paid'] )
{
$params['payment_status'] = 'Error';
}
else {
// deals with both Approval and Denial URLs
if ( isset($_POST['subscription_id']) && strlen($_POST['subscription_id']) > 3 ) {
$params['payment_status'] = 'Completed';
} elseif ( isset($_POST['reasonForDecline']) ) {
$params['payment_status'] = 'Declined';
} else {$params['payment_status'] = 'Error'; }
}
$params['txn_id'] = $_POST['subscription_id'];
$params['valid'] = true;
$params['pay_txn_id'] = $pay_txn_id = $_POST['invoiceid'];
$params['paid_thru'] = 'ccbill';
$params['amount'] = $_POST['initialPrice'];
$params['email'] = $_POST['email'];
$params['vars'] = serialize($_POST);
$level_name = process_payment_info($params);
$levels =$osDB->getRow('select mem.name, trn.payment_status from ! as trn, ! as mem where trn.invoice_no = ? and mem.roleid = trn.to_membership', array(TRANSACTIONS_TABLE, MEMBERSHIP_TABLE, $pay_txn_id) );
$t->assign ( 'level', $levels['name'] .' - Status: '.$levels['payment_status']);
$_SESSION['security'] = '';
hasRight('');
$t->assign('rendered_page', $t->fetch('checkout_process.tpl') );
$t->display( 'index.tpl' );
exit;
?>
I will note that when I check the transaction database it only says started when I complete a transaction instead of saying complete, and also doesn't add the payment details. It does show the membership level being upgraded from, and to, id, invoice number, user id, amount paid, and transaction date. I just can't figure out why this worked one time and then never again.
Anyone have any ideas on this?
If I can see what variables are being posted back I could better troubleshoot the problem, but not really sure how to do it. I'm assuming I need to use print_r but I'm not sure how to set it up.
The page that passes the info on is:
{strip}
<form action='https://bill.ccbill.com/jpost/signup.cgi' method=POST>
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td class="module_detail" width="100%">
{assign var="page_hdr01_text" value="{lang mkey='confirmation'}"}
{assign var="page_title" value="{lang mkey='confirmation'}"}
{include file="page_hdr01.tpl"}
<table border="0" cellpadding="{$config.cellpadding}" cellspacing="{$config.cellspacing}" width="100%">
<tr><td>{lang mkey='info_confirm'}</td></tr>
<tr><td>{lang mkey='name'}{$smarty.session.FullName|stripslashes}
</td></tr>
<tr><td>{lang mkey='change_mship_to'}<b>{$item_name}</b>.</td></tr>
<tr><td>{lang mkey='amount'}{mylang mkey='support_currency' skey=$currency}{$amount}</td></tr>
<tr><td>
<div align="center"><b><font color="#BBAAGG" size="4" face="Verdana, Arial, Helvetica, sans-serif">PAY BY CREDIT CARD</font></b><br>
<input type=hidden name=clientAccnum value='{$accNum}'>
<input type=hidden name=clientSubacc value='{$subaccNum}'>
<input type=hidden name=formName value='{$formName}'>
<input type=hidden name=language value='English' >
<input type=hidden name=currencyCode value='840' >
<input type=hidden name=allowedTypes value='{$allowedTypes}:840'>
<input type=hidden name=subscriptionTypeId value='{$subType}:840'>
<input type=hidden name=invoiceid value='{$invoice_no}' >
<input type=hidden name=username value='{$smarty.session.UserName}' >
<input type=hidden name=password value='{$smarty.session.password}' >
<input type=hidden name=confirm_password value='{$smarty.session.password}' >
<input type=hidden name=customer_fname value='{$smarty.session.FirstName}' >
<input type=hidden name=customer_lname value='{$smarty.session.FirstName|replace:$smarty.session.FirstName:""}' >
<input type=hidden name=paid_thru value='ccbill' >
<input type="submit" name="submit" value="Pay Now">
</div></form>
<form action='https://bill.ccbill.com/jpost/signup.cgi' method=POST>
<br><div align="center"><b><font color="#BBAAGG" size="4" face="Verdana, Arial, Helvetica, sans-serif">PAY BY ELECTRONIC CHECK</font></b><br>
<input type=hidden name=clientAccnum value='{$accNum}'>
<input type=hidden name=clientSubacc value='{$subaccNum}'>
<input type=hidden name=formName value='{$formName2}'>
<input type=hidden name=language value='English' >
<input type=hidden name=currencyCode value='840' >
<input type=hidden name=allowedTypes value='{$allowedTypes}:840'>
<input type=hidden name=subscriptionTypeId value='{$subType}:840'>
<input type=hidden name=invoiceid value='{$invoice_no}' >
<input type=hidden name=username value='{$smarty.session.UserName}' >
<input type=hidden name=password value='pass{$smarty.session.UserName}' >
<input type=hidden name=confirm_password value='pass{$smarty.session.UserName}' >
<input type=hidden name=customer_fname value='{$smarty.session.FirstName}' >
<input type=hidden name=customer_lname value='{$smarty.session.FirstName|replace:$smarty.session.FirstName:""}' >
<input type=hidden name=paid_thru value='ccbill' >
<input type="submit" name="submit" value="Pay Now">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
{/strip}
The post back page after successful payment is:
<?php
if ( !defined( 'SMARTY_DIR' ) ) {
include_once( 'init.php' );
}
//already processed subscription_id, exit
$trnrec=$osDB->getRow('select * from ! where txn_id = ? ', array(TRANSACTIONS_TABLE, $_POST['subscription_id'] ));
if( $trnrec['id'] )
exit;
// amount paid is less than amount expected
$trnrec=$osDB->getRow('select * from ! where invoice_no = ? ', array(TRANSACTIONS_TABLE, $_POST['invoiceid'] ));
if( $_POST['initialPrice'] < $trnrec['amount_paid'] )
{
$params['payment_status'] = 'Error';
}
else {
// deals with both Approval and Denial URLs
if ( isset($_POST['subscription_id']) && strlen($_POST['subscription_id']) > 3 ) {
$params['payment_status'] = 'Completed';
} elseif ( isset($_POST['reasonForDecline']) ) {
$params['payment_status'] = 'Declined';
} else {$params['payment_status'] = 'Error'; }
}
$params['txn_id'] = $_POST['subscription_id'];
$params['valid'] = true;
$params['pay_txn_id'] = $pay_txn_id = $_POST['invoiceid'];
$params['paid_thru'] = 'ccbill';
$params['amount'] = $_POST['initialPrice'];
$params['email'] = $_POST['email'];
$params['vars'] = serialize($_POST);
$level_name = process_payment_info($params);
$levels =$osDB->getRow('select mem.name, trn.payment_status from ! as trn, ! as mem where trn.invoice_no = ? and mem.roleid = trn.to_membership', array(TRANSACTIONS_TABLE, MEMBERSHIP_TABLE, $pay_txn_id) );
$t->assign ( 'level', $levels['name'] .' - Status: '.$levels['payment_status']);
$_SESSION['security'] = '';
hasRight('');
$t->assign('rendered_page', $t->fetch('checkout_process.tpl') );
$t->display( 'index.tpl' );
exit;
?>
I will note that when I check the transaction database it only says started when I complete a transaction instead of saying complete, and also doesn't add the payment details. It does show the membership level being upgraded from, and to, id, invoice number, user id, amount paid, and transaction date. I just can't figure out why this worked one time and then never again.
Anyone have any ideas on this?