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

    Ok, pulling my hair out on ccbill postback

    I'm trying to integrate ccbill with osdate, everything works, form gets prefilled with correct variables, and payments can be successfully made. I just can't get the membership level to get upgraded using the post back system. But here's the weird thing, it worked once, but then never again. I didn't change a thing in the post back form so I'm going crazy trying to figure this thing out.

    Here is the ccbill_notify.php code that the variables from ccbill get posted back to:
    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;
    Is there anything in here that anyone can see that would prevent the process from working at all? It's writing new lines to the transaction database but it never completes outside of the one single time that it actually worked. Please help.

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    Maybe the problem lies in the functions process_payment_info?
    Here's the code for that:
    PHP Code:
    function process_payment_info($params) {

        global 
    $osDB;

        
    // get the user information for this transaction

        
    $trnrec=$osDB->getRow('select * from ! where id = ? ', array(TRANSACTIONS_TABLE$params['pay_txn_id'] ));

        
    $user_id $trnrec['user_id'];

        
    $user_level        $trnrec['to_membership'];

        
    $levelvars $osDB->getRow'select activedays, name from ! where roleid = ?', array( MEMBERSHIP_TABLE$user_level ) );

        
    $activedays        $levelvars['activedays'];
        
    $level_name        $levelvars['name'];

        if ( 
    $params['valid'] && $trnrec['payment_status'] != 'Completed') {

            
    $osDB->query'update ! set payment_email = ?, amount_paid = ?, txn_id = ?, txn_date = ?, payment_vars = ?, payment_status=? where id = ?', array( TRANSACTIONS_TABLE$params['email'], $params['amount'], $params['txn_id'], date('Y-m-d'), $params['vars'], $params['payment_status'], $params['pay_txn_id'] ) );

            
    // determine when this user's membership was to expire, then extend it by $activedays days

            
    if (trim($params['payment_status']) == 'Completed') {
                
    $curlevel $osDB->getRow'select levelend, level from ! where id = ?', array( USER_TABLE$user_id ) );

                
    $levelend $curlevel['levelend'];

                if ( 
    $levelend time() ) {
                    
    $levelend time();
                }

                
    // new expiration date for this member

                
    if ($curlevel['level'] != $user_level) {

                    
    $levelend strtotime"+$activedays day"time() );

                } else {

                    
    $levelend strtotime"+$activedays day"$levelend );

                }

                
    $osDB->query'UPDATE ! SET level = ?, levelend = ? WHERE id = ?', array( USER_TABLE$user_level$levelend$user_id ) );
            }
        }

        return 
    $level_name;

    Please if anyone sees why the ccbill_notify.php that gets posted back to after payment is made wouldn't work with the following function please let me know. I'm going crazy on this one.

  • #3
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    After this line:

    PHP Code:
    $trnrec=$osDB->getRow('select * from ! where id = ? ', array(TRANSACTIONS_TABLE$params['pay_txn_id'] )); 
    Try inserting:

    PHP Code:
    echo "<pre>"var_dump($trnrec); echo "</pre>"
    Then run test transaction and paste your results here.

  • #4
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    I get
    array(0) {
    }

    The problem in doing a var dump or print_r is that even though ccbill posts back to my ccbill_notify.php page, ccbill doesn't redirect you to the approved page on my site. Instead it takes you to their own approved page where there is a link that the customer is supposed to click on to return back to my site after complete.

  • #5
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts

  • #6
    Regular Coder
    Join Date
    Mar 2009
    Posts
    175
    Thanks
    3
    Thanked 1 Time in 1 Post
    Yeah everything is set right in ccbill webamaster admin section.


  •  

    Posting Permissions

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