...

View Full Version : How to use print_r to see what variables are being passed



sfraise
03-18-2009, 07: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?

_Aerospace_Eng_
03-18-2009, 09:51 AM
Add

echo '<pre>';
print_r($_POST);
echo '</pre>';
in your code somewhere. It should display any post variables.

oesxyl
03-18-2009, 10:08 AM
Add

echo '<pre>';
print_r($_POST);
echo '</pre>';
in your code somewhere. It should display any post variables.

I was tempted to give same answer but I guess the script is remote not on op domain:



<form action='https://bill.ccbill.com/jpost/signup.cgi' method=POST>


best regards

sfraise
03-18-2009, 09:27 PM
Would there be a reason why print_r wouldn't work?
I tried several variations of it including
echo '<pre>';
print_r($_POST);
echo '</pre>';
but it never returns anything besides the code it's self.
I've put the <?php ?> around it, I've tried the examples given on the php site and it doesn't return what the example says it should.

steelaz
03-18-2009, 10:28 PM
Are you including print_r() in your post back page? Is it the same page if transaction is successful or unsuccessful?

oesxyl
03-18-2009, 11:01 PM
Would there be a reason why print_r wouldn't work?
I tried several variations of it including
echo '<pre>';
print_r($_POST);
echo '</pre>';
but it never returns anything besides the code it's self.
I've put the <?php ?> around it, I've tried the examples given on the php site and it doesn't return what the example says it should.
as I said in my replay, to work this( print_r) must be in the file jpost/signup.cgi on bill.ccbill.com.
that is the script who process your form data when on submit.

best regards

sfraise
03-19-2009, 02:39 AM
as I said in my replay, to work this( print_r) must be in the file jpost/signup.cgi on bill.ccbill.com.
that is the script who process your form data when on submit.

best regards

That's what I was afraid of.
ccbill is very unhelpful when it comes to this kind of stuff so I guess I'll just do what I can do.

Is there anything in the postback page that any of you can see that would prevent accepting the variables passed from ccbill or that would prevent it from changing the variables in the database?

steelaz
03-19-2009, 03:04 AM
You don't have to place anything in signup.cgi on bill.ccbill.com. I assume you have your Approval and Denial URLs set up. For example, lets say you have youwebsite.com/ccbill/approved.php and youwebsite.com/ccbill/denied.php . In both files add this line right after first <?php :


echo '<pre>'; var_dump($_POST); echo '</pre>';

Then try submitting your form. You will be redirected to one of these pages and will be able to see what kind of information came in from ccbill.

sfraise
03-20-2009, 08:41 AM
You don't have to place anything in signup.cgi on bill.ccbill.com. I assume you have your Approval and Denial URLs set up. For example, lets say you have youwebsite.com/ccbill/approved.php and youwebsite.com/ccbill/denied.php . In both files add this line right after first <?php :


echo '<pre>'; var_dump($_POST); echo '</pre>';

Then try submitting your form. You will be redirected to one of these pages and will be able to see what kind of information came in from ccbill.

It doesn't return anything.
Ccbill doesn't actually redirect you automatically to the approved page on your own site, instead takes you to their own approved page with a link to whatever url you specify that the customer is supposed to click on to return to your site.

oesxyl
03-20-2009, 09:18 AM
It doesn't return anything.
Ccbill doesn't actually redirect you automatically to the approved page on your own site, instead takes you to their own approved page with a link to whatever url you specify that the customer is supposed to click on to return to your site.
I don't know if will help you but try to replace the action attribute in form with a cgitest.php, where 'cgitest.php' is:



<?php
print_r($_POST);
?>


this way you can see what you submit and compare with what you expect to send to ccbil script.

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum