承接 shakurov/coinbase 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shakurov/coinbase

最新稳定版本:v0.8.0

Composer 安装命令:

composer require shakurov/coinbase

包简介

Laravel wrapper for the Coinbase Commerce API

README 文档

README

This package is abandoned and no longer maintained. The author suggests using the antimech/coinbase package instead.

Installation

You can install the package via composer:

composer require shakurov/coinbase

The service provider will automatically register itself.

You must publish the config file with:

php artisan vendor:publish --provider="Shakurov\Coinbase\CoinbaseServiceProvider" --tag="config"

This is the contents of the config file that will be published at config/coinbase.php:

return [ 'apiKey' => env('COINBASE_API_KEY'), 'apiVersion' => env('COINBASE_API_VERSION'), 'webhookSecret' => env('COINBASE_WEBHOOK_SECRET'), 'webhookJobs' => [ // 'charge:created' => \App\Jobs\CoinbaseWebhooks\HandleCreatedCharge::class, // 'charge:confirmed' => \App\Jobs\CoinbaseWebhooks\HandleConfirmedCharge::class, // 'charge:failed' => \App\Jobs\CoinbaseWebhooks\HandleFailedCharge::class, // 'charge:delayed' => \App\Jobs\CoinbaseWebhooks\HandleDelayedCharge::class, // 'charge:pending' => \App\Jobs\CoinbaseWebhooks\HandlePendingCharge::class, // 'charge:resolved' => \App\Jobs\CoinbaseWebhooks\HandleResolvedCharge::class, ], 'webhookModel' => Shakurov\Coinbase\Models\CoinbaseWebhookCall::class, ];

In the webhookSecret key of the config file you should add a valid webhook secret. You can find the secret used at the webhook configuration settings on the Coinbase Commerce dashboard.

Next, you must publish the migration with:

php artisan vendor:publish --provider="Shakurov\Coinbase\CoinbaseServiceProvider" --tag="migrations"

After the migration has been published you can create the coinbase_webhook_calls table by running the migrations:

php artisan migrate

Finally, take care of the routing: At the Coinbase Commerce dashboard you must add a webhook endpoint, for example: https://example.com/api/coinbase/webhook

Usage

Charges

List charges:

$charges = Coinbase::getCharges();

Create a charge:

$charge = Coinbase::createCharge([ 'name' => 'Name', 'description' => 'Description', 'local_price' => [ 'amount' => 100, 'currency' => 'USD', ], 'pricing_type' => 'fixed_price', ]);

Show a charge:

$charge = Coinbase::getCharge($chargeId);

Cancel a charge:

$charge = Coinbase::cancelCharge($chargeId);

Resolve a charge:

$charge = Coinbase::resolveCharge($chargeId);

Checkouts

List checkouts:

$checkouts = Coinbase::getCheckouts();

Create a checkout:

$checkout = Coinbase::createCheckout([ 'name' => 'Name', 'description' => 'Description', 'requested_info' => [], 'local_price' => [ 'amount' => 100, 'currency' => 'USD', ], 'pricing_type' => 'fixed_price', ]);

Show a checkout:

$checkout = Coinbase::getCheckout($checkoutId);

Update a checkout:

$checkout = Coinbase::updateCheckout($checkoutId, [ 'name' => 'New Name', 'description' => 'New Description', 'local_price' => [ 'amount' => 200, 'currency' => 'USD', ], 'requested_info' => [ 'name', ], ]);

Delete a checkout:

$checkout = Coinbase::deleteCheckout($checkoutId);

Invoices

List invoices:

$invoices = Coinbase::getInvoices();

Create an invoice:

$invoice = Coinbase::createInvoice([ 'business_name' => 'Business Name', 'customer_email' => 'customer@example.com', 'customer_name' => 'Customer Name', 'local_price' => [ 'amount' => 100, 'currency' => 'USD', ], 'memo' => 'A memo/description for the invoice', ]);

Show an invoice:

$invoice = Coinbase::getInvoice($invoiceId);

Void an invoice:

$invoice = Coinbase::voidInvoice($invoiceId);

Resolve an invoice:

$invoice = Coinbase::resolveInvoice($invoiceId);

Events

List events:

$events = Coinbase::getEvents();

Show an event:

$event = Coinbase::getEvent($eventId);

Webhooks

Coinbase Commerce will send out webhooks for several event types. You can find the full list of events types in the Coinbase Commerce documentation.

Coinbase Commerce will sign all requests hitting the webhook url of your app. This package will automatically verify if the signature is valid. If it is not, the request was probably not sent by Coinbase Commerce.

Unless something goes terribly wrong, this package will always respond with a 200 to webhook requests. Sending a 200 will prevent Coinbase Commerce from resending the same event over and over again. All webhook requests with a valid signature will be logged in the coinbase_webhook_calls table. The table has a payload column where the entire payload of the incoming webhook is saved.

If the signature is not valid, the request will not be logged in the coinbase_webhook_calls table but a Shakurov\Coinbase\Exceptions\WebhookFailed exception will be thrown. If something goes wrong during the webhook request the thrown exception will be saved in the exception column. In that case the controller will send a 500 instead of 200.

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.

Handling webhook requests using jobs

If you want to do something when a specific event type comes in you can define a job that does the work. Here's an example of such a job:

<?php 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` } }

We highly recommend that you make this job queueable, because this will minimize the response time of the webhook requests. This allows you to handle more Coinbase Commerce webhook requests and avoid timeouts.

After having created your job you must register it at the jobs array in the coinbase.php config file. The key should be the name of the coinbase commerce event type where but with the . replaced by _. The value should be the fully qualified classname.

// config/coinbase.php 'jobs' => [ 'charge:created' => \App\Jobs\CoinbaseWebhooks\HandleCreatedCharge::class, ],

Handling webhook requests using events

Instead of queueing jobs to perform some work when a webhook request comes in, you can opt to listen to the events this package will fire. Whenever a valid request hits your app, the package will fire a coinbase::<name-of-the-event> event.

The payload of the events will be the instance of CoinbaseWebhookCall that was created for the incoming request.

Let's take a look at how you can listen for such an event. In the EventServiceProvider you can register listeners.

/**  * The event listener mappings for the application.  *  * @var array  */ protected $listen = [ 'coinbase::charge:created' => [ App\Listeners\ChargeCreatedListener::class, ], ];

Here's an example of such a listener:

<?php 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` } }

We highly recommend that you make the event listener queueable, as this will minimize the response time of the webhook requests. This allows you to handle more Coinbase Commerce webhook requests and avoid timeouts.

The above example is only one way to handle events in Laravel. To learn the other options, read the Laravel documentation on handling events.

Advanced usage

Retry handling a webhook

All incoming webhook requests are written to the database. This is incredibly valuable when something goes wrong while handling a webhook call. You can easily retry processing the webhook call, after you've investigated and fixed the cause of failure, like this:

use Shakurov\Coinbase\Models\CoinbaseWebhookCall; CoinbaseWebhookCall::find($id)->process();

Performing custom logic

You can add some custom logic that should be executed before and/or after the scheduling of the queued job by using your own model. You can do this by specifying your own model in the model key of the coinbase config file. The class should extend Shakurov\Coinbase\Models\CoinbaseWebhookCall.

Here's an example:

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 } }

License

The MIT License (MIT). Please see License File for more information.

Backers

shakurov/coinbase 适用场景与选型建议

shakurov/coinbase 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 58.29k 次下载、GitHub Stars 达 38, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「coinbase」 「coinbase commerce」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 shakurov/coinbase 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 shakurov/coinbase 我们能提供哪些服务?
定制开发 / 二次开发

基于 shakurov/coinbase 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 58.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 39
  • 点击次数: 36
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 38
  • Watchers: 4
  • Forks: 25
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04