0

I'm trying to create callback script for Coinbase bitcoin payments. Here is the below function from my payment controller. But somehow the key isn't working as it should. I am trying to access it like that: http://www.example.com/payments/callback?key=true but it's not getting affected basically not working. Take a note that the script is working itself but after adding the key function and validating it ... it's not anymore. The issue is caused by that but I don't know what exactly, so what may cause that in the script below? Thanks for taking the time to check and possibly answer my question.

function is_valid_key($key) {
    // logic to check key
    $valid = true;
    if($valid) {
        return true;
    }
    else {
       return false;
    }
}    

function callback()
    {
        //Check if key is valid.

        $key = $this->input->get('key');
        if( ! $this->is_valid_key($key)) {

        //If key above is valid order is "completed", please proceed.

        $data = json_decode(file_get_contents('php://input'), TRUE);

        $status = $data['order']['status'];
        $userid = '507';

        if (($status === 'completed')) {
            $this->db->query( 'update users set user_money=user_money+15, user_credits=user_credits+5 WHERE users_id=' . $userid );
        }
    }
    }
MobEn
  • 65
  • 9

1 Answers1

0

it has to do with your configuration settings. check out this question Enabling $_GET in codeigniter

Also you can use

parse_str($_SERVER['QUERY_STRING'], $_GET);

which would push GET right back on

Community
  • 1
  • 1
codemonk
  • 56
  • 1
  • 6
  • Is there any way to do that as I simply need specific parameter to secure my script for being access by unathorized source. So, by adding any secret/key I can achieve this. Any other option for that to apply that parameter? or can I use `$this->uri->segment( 3 );` for example ? – MobEn Sep 15 '14 at 19:56
  • @MobEn you can also use parse_str($_SERVER['QUERY_STRING'], $_GET); which would push GET right back on – codemonk Sep 15 '14 at 21:21