<p>You're not accessing the post data correctly.</p>

<pre><code>$data = json_decode(file_get_contents("php://input"))['order'];
$total = User::Get($data['custom'], FIELD_USERS_CENT) + $data['total_native']['cents'];
User::Set($data['custom'], FIELD_USERS_CENT, $total);
</code></pre>

<p><a href="https://coinbase.com/docs/merchant_tools/callbacks" rel="nofollow">See also.</a></p>

CC BY-SA 3.0
2014-09-10T17:38:08.647Z
2014-09-10T17:38:08.647Z
Nick ODell
<p>I've a problem with the callback.
The post data is not right, because the users cents is not update.</p>

<p>My Code:</p>

<pre><code>    public function bitcoin($secret) {
        if($secret == App::Config(ROW_CONFIG_COINBASE_SC)) {
            if($_POST) {
                $total = User::Get($_POST["custom"], FIELD_USERS_CENT) + $_POST["total_native"];
                User::Set($_POST["custom"], FIELD_USERS_CENT, $total);
            }
        } else {
            die("error");
        }
    }
</code></pre>

<p>the post data:</p>

<pre><code>{
    "order {
        "total_btc":{"cents":269800,"currency_iso":"BTC"},
        "total_native":{"cents":100,"currency_iso":"EUR"},
        "total_payout":{"cents":0,"currency_iso":"USD"},
    }
}
</code></pre>

<coinbase.com><php>
PHP Coinbase Callback POST
user3803645
# PHP Coinbase Callback POST

(Asked by: username_0 on 2014-09-10)

I've a problem with the callback.
The post data is not right, because the users cents is not update.

My Code:

```
    public function bitcoin($secret) {
        if($secret == App::Config(ROW_CONFIG_COINBASE_SC)) {
            if($_POST) {
                $total = User::Get($_POST["custom"], FIELD_USERS_CENT) + $_POST["total_native"];
                User::Set($_POST["custom"], FIELD_USERS_CENT, $total);
            }
        } else {
            die("error");
        }
    }

```

the post data:

```
{
    "order {
        "total_btc":{"cents":269800,"currency_iso":"BTC"},
        "total_native":{"cents":100,"currency_iso":"EUR"},
        "total_payout":{"cents":0,"currency_iso":"USD"},
    }
}

```

**Tags:** coinbase.com, php


---

## 1 answers

### Answer by username_1 on 2014-09-10. Score: 1

You're not accessing the post data correctly.

```
$data = json_decode(file_get_contents("php://input"))['order'];
$total = User::Get($data['custom'], FIELD_USERS_CENT) + $data['total_native']['cents'];
User::Set($data['custom'], FIELD_USERS_CENT, $total);

```

[See also.](https://coinbase.com/docs/merchant_tools/callbacks)


---

