ClickBank & thanks.php

Discussion in 'Payments processing' started by dan_kelly, Aug 18, 2010.

  1. dan_kelly

    dan_kelly New Member

    Joined:
    Aug 29, 2006
    Messages:
    91
    How do I get the payment, member, product, and products variables on my thank you page?

    For a ClickBank sale, it does not appear that any of these variables are set.

    This is because thanks.php looks for GET variables in the URL (like $_GET['member_id'], $_GET['product_id'], & $_GET['payment_id']), but those variables do not exist in the ClickBank thanks.php URL.

    Here is an example of all of the variables are ARE available after a CB transaction:


    item=12
    cbreceipt=FXXXXEDX
    time=1282159233
    cbpop=BF6FFFFF
    cbaffi=0
    cname=dan+kelly
    cemail=dan%40mydomain.com
    czip=90210
    ccountry=US


    That's it!


    So, when those variables are given to thanks.php, NONE of the payment, member, product, or products data is available.


    How do I get the payment, member, product, and products variables on my thank you page?
  2. dan_kelly

    dan_kelly New Member

    Joined:
    Aug 29, 2006
    Messages:
    91
    hmmm...

    The first time I tested it, I didn't get any of the variables... and I even printed out the SESSION, COOKIE, and all Smarty variables.

    The second time I testing it, the SESSION variables were there, but the Smarty variables for payment, member, product, and products were still not there.

    The third time I tested it, the SESSION variables were cleared, and the Smarty variables were still not there.
  3. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Dan,
    payment_id variable is assigned from clickbank.inc.php from function process_thanks
    So all variables should be available in smarty.
    How did you test this exactly?
  4. dan_kelly

    dan_kelly New Member

    Joined:
    Aug 29, 2006
    Messages:
    91
    In my thanks.html I put code to include the Smarty debug.html template (which prints ALL Smarty variables) and print_r the SESSION and COOKIE variables.

    Then I ran through several ClickBank transactions.

    -

    The problem, as I mentioned, is that thanks.php looks for GET variables in the URL (like $_GET['member_id'], $_GET['product_id'], & $_GET['payment_id']), but those variables do not exist in the ClickBank thanks.php URL.

    from thanks.php:

    Code:
    if (!$vars['payment_id']) $vars['payment_id'] = $_GET['payment_id'];
    -- $_GET['payment_id'] doesn't exist in this case.

    Code:
    if (!$vars['payment_id'])
        $vars['payment_id'] = $_SESSION['_amember_payment_id'];
    -- $_SESSION['_amember_payment_id'] doesn't exist in this case either.
  5. dan_kelly

    dan_kelly New Member

    Joined:
    Aug 29, 2006
    Messages:
    91
    Here's my solution:

    #1. You need to get the member_id, product_id, & payment_id in the SESSION variable:

    In, clickbank.inc.php I put the following code:

    Code:
            //I added these 3 for thanks.php to work
            $_SESSION['_my_payment_id'] = $payment_id;
            $_SESSION['_my_member_id']  = $p['member_id'];
            $_SESSION['_my_product_id'] = $p['product_id'];
    ...right AFTER...

    Code:
        function do_auto_login($payment_id){
            global $db, $config;
            
            $p = $db->get_payment($payment_id);
            $u = $db->get_user($p['member_id']);
    #2. You need to set the VARS variables in thanks.php using your new variables... if they haven't been set already.

    In, thanks.php I put the following code:

    Code:
    //I added these for ClickBank & thanks.html to work
    if (!$vars['member_id'])  $vars['member_id']  = $_SESSION['_my_member_id'];
    if (!$vars['product_id']) $vars['product_id'] = $_SESSION['_my_product_id'];
    if (!$vars['payment_id']) $vars['payment_id'] = $_SESSION['_my_payment_id'];
    if (!$_SESSION[_amember_in_payment]) $_SESSION[_amember_in_payment] = $_SESSION['_my_payment_id'];
    ...right AFTER...

    Code:
    if (!$vars['member_id'])  $vars['member_id']  = $_GET['member_id'];
    if (!$vars['product_id']) $vars['product_id'] = $_GET['product_id'];
    if (!$vars['payment_id']) $vars['payment_id'] = $_GET['payment_id'];

Share This Page