1. Go to this page and download the library: Download shakurov/coinbase library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Jobs\CoinbaseWebhooks;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Shakurov\Coinbase\Models\CoinbaseWebhookCall;
class HandleCreatedCharge implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
public function __construct(
CoinbaseWebhookCall $webhookCall,
) {}
public function handle(): void
{
// do your work here
// you can access the payload of the webhook call with `$this->webhookCall->payload`
}
}
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'coinbase::charge:created' => [
App\Listeners\ChargeCreatedListener::class,
],
];
namespace App\Listeners;
use Illuminate\Contracts\Queue\ShouldQueue;
use Shakurov\Coinbase\Models\CoinbaseWebhookCall;
class ChargeCreatedListener implements ShouldQueue
{
public function handle(CoinbaseWebhookCall $webhookCall): void
{
// do your work here
// you can access the payload of the webhook call with `$webhookCall->payload`
}
}
use Shakurov\Coinbase\Models\CoinbaseWebhookCall;
CoinbaseWebhookCall::find($id)->process();
use Shakurov\Coinbase\Models\CoinbaseWebhookCall;
class MyCustomWebhookCall extends CoinbaseWebhookCall
{
public function process(): void
{
// do some custom stuff beforehand
parent::process();
// do some custom stuff afterwards
}
}