My code was taken from different samples, so i can't validate your data
points, but you say it works in sandbox, so lets assume
$response->transaction_id is the correct property. Your $sql statement
has the $transaction_id variable in single quotes, ...