1

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"},
    }
}
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.