Download the PHP package ramiroauditore/coinbase-laravel without Composer
On this page you can find all versions of the php package ramiroauditore/coinbase-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ramiroauditore/coinbase-laravel
More information about ramiroauditore/coinbase-laravel
Files in ramiroauditore/coinbase-laravel
Package coinbase-laravel
Short Description Un wrapper para la API de Coinbase Commerce en Laravel
License MIT
Informations about the package coinbase-laravel
coinbase-laravel
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:
Then you need to include the ServiceProvider in the config/app.php file like this:
Add the following to your .env file:
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:
You will need to send the following data:
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:
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:
So you should exclude it from the CSRF protection by modfying your Http/Middleware/VerifyCsrfToken.php
file like this:
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.