shakurov / laravel-coinbase

Laravel wrapper for the Coinbase Commerce API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Illuminate\Database\Eloquent\ModelNotFoundException

imadrn0202 opened this issue · comments

commented

Required Information

  • Operating system:
  • PHP version: 7.2
  • Laravel version: 6.0
  • Laravel Coinbase Commerce wrapper version: v0.7.6

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"

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.