shakurov / laravel-coinbase

Laravel wrapper for the Coinbase Commerce API
MIT License
44 stars 24 forks source link

Illuminate\Database\Eloquent\ModelNotFoundException #9

Closed imadrn0202 closed 1 year ago

imadrn0202 commented 5 years ago

Required Information

Expected behaviour

job handler will work

Actual behaviour

sometimes exception appears, sometimes it works

dispatch(new HandleCreatedCharge(CoinbaseWebhookCall::findOrFail($test)));

Steps to reproduce

post method to charge:create

Extra details

public function test()
{
    $charge = Coinbase::createCharge([
        'name' => 'jajaja',
        'description' => 'jeje',
        'local_price' => [
            'amount' => 100,
            'currency' => 'USD',
        ],
        'pricing_type' => 'fixed_price',
    ]);

    $test = $charge['data']['id'];

    // error here ->>
    dispatch(new HandleCreatedCharge(CoinbaseWebhookCall::findOrFail($test)));
}
$e: Illuminate\Database\Eloquent\ModelNotFoundException
$e->model "Shakurov\Coinbase\Models\CoinbaseWebhookCall"
$e->message "No query results for model [Shakurov\Coinbase\Models\CoinbaseWebhookCall] 289c9315-0ff8-4fef-be8f-7e13aae6090f"
antimech commented 1 year ago

It seems like you use it incorrectly. You don't have to dispatch events, the package does that for you. Please refer to the documentation, there are two ways this package enables you to handle webhook requests: you can opt to queue a job or listen to the events the package will fire. This package takes care of most things for your convenience.