Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post

    How to use print_r to see what variables are being passed

    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:
    PHP Code:
    {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 Code:
    <?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']) >  ) {
              
    $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_TABLEMEMBERSHIP_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?
    Last edited by sfraise; 03-18-2009 at 06:58 AM.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Add
    PHP Code:
    echo '<pre>';
    print_r($_POST);
    echo 
    '</pre>'
    in your code somewhere. It should display any post variables.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    Add
    PHP Code:
    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:

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

  • #4
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    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.

  • #5
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    Are you including print_r() in your post back page? Is it the same page if transaction is successful or unsuccessful?

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by sfraise View Post
    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

  • #7
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    Quote Originally Posted by oesxyl View Post
    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?

  • #8
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    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 :

    PHP Code:
    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.
    Last edited by steelaz; 03-19-2009 at 02:07 AM.

  • #9
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    Quote Originally Posted by steelaz View Post
    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 :

    PHP Code:
    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.

  • #10
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by sfraise View Post
    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 Code:
    <?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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •