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 );
}
}
}
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