定制 ramiroauditore/coinbase-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ramiroauditore/coinbase-laravel

Composer 安装命令:

composer require ramiroauditore/coinbase-laravel

包简介

Un wrapper para la API de Coinbase Commerce en Laravel

README 文档

README

A wrapper for Coinbase Commerce's API for Laravel projects that require token purchases. It should work without issues if you follow the README to the tee, but I'm still new to cryptocurrency and Coinbase doesn't have the best docs, so please do submit an issue if you find a bug or something that could be improved and I'll take a look at it.

Notes

Right now the package just handles creating charges and has a webhook for the updates of charges. I might add the rest of endpoints in the future.

Installation

Install with Composer:

composer require ramiroauditore/coinbase-laravel

Then you need to include the ServiceProvider in the config/app.php file like this:

/*
 * Package Service Providers...
 */
coinbaselaravel\CoinbaseLaravelServiceProvider::class

Add the following to your .env file:

COINBASE_API_KEY=<YOUR_API_KEY> //An API Key you generated from your Coinbase's dashboard
TOKENS_BY_DOLLAR=<YOUR_TOKENS_PER_DOLLAR_EQUIVALENCE> //The ammount of tokens that should be given to the user per dollar spent

Run php artisan: migrate and a migration will run, adding the coinbase_transactions table to your database.

Usage

Create a charge

To create a charge you will need a POST to the following route:

https://yoursite.com/create_charge

You will need to send the following data:

user_id: An id from the users table so you know who the tokens belong to
amount: The amount in USD that the user wishes to spend
token_amount: The amount of tokens that the user will receive should they pay the value from the amount field

Should the request be successful a new row will be added to your coinbase_transactions with the charge data and you will receive the following JSON response:

{
"pricing":{
    "local":
        {"amount":"0.50","currency":"USD"},
    "bitcoincash":
        {"amount":"0.00145658","currency":"BCH"},
    "litecoin":
        {"amount":"0.00792959","currency":"LTC"},
    "bitcoin":
        {"amount":"0.00005480","currency":"BTC"},
    "ethereum":
        {"amount":"0.002146000","currency":"ETH"},
    "usdc":
        {"amount":"0.500000","currency":"USDC"},
    "dai":
        {"amount":"0.498643440520065163","currency":"DAI"}
    },
"qr_strings":{
  "bitcoincash":"qrztp9f44tkdplvk822prfqqtep820hfs5hqhrktzc",
  "litecoin":"M97sEjpXCih4RHZiNtR6h3H8pZt134ECTt",
  "bitcoin":"37YVDwLSJbfUggqt3K6reBJS1awoXiEU2s",
  "ethereum":"0x0275b18043776cc73b57ebe980b58c521bf5ce67",
  "usdc":"0x0275b18043776cc73b57ebe980b58c521bf5ce67",
  "dai":"0x0275b18043776cc73b57ebe980b58c521bf5ce67"
  }
}

In which each object in the pricing object represents the equivalent of the local (USD) price the user submitted and each property in the qr_strings object represents a string you can use to generate a QR code to pay with the respective currency.

Webhooks

The webhook function resides in the following route:

https://yoursite.com/charge_update

So you should exclude it from the CSRF protection by modfying your Http/Middleware/VerifyCsrfToken.php file like this:

protected $except = [
  'charge_update/'
];

After doing that you should register the webhook by providing the URL of the route in the settings of you Coinbase Commerce and it should automatically start functioning whenever there's an event (I recommend disabling the charge:created hook). It will update the corresponding table entry with the new data. Including doing recalculations of the amount and token_amount fields to adjust in case the user underpaid or overpaid.

NOTE: Keep in mind, though, that if the user does over or underpay and you want the charge to still be valid, you will need to "resolve it" manually through the dashboard, otherwise it will be marked as failed and the money will be returned to the user. There's a way to do this through an endpoint, I might add it later.

ramiroauditore/coinbase-laravel 适用场景与选型建议

ramiroauditore/coinbase-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 03 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-05