Download the PHP package moki74/laravel-btc without Composer

On this page you can find all versions of the php package moki74/laravel-btc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-btc

laravel-btc

Package for receive payments via BTC

Prerequisites

Laravel version >= 5.5

There is lot of docs about installing Laravel, not covered here ...

Running Bitcoind server

You can find docs here : https://bitcoin.org/en/full-node#what-is-a-full-node

Installation

First, make laravel application :

then cd in first-bitcoin-app:

Install package via composer:

After installation publish package with artisan command :

and choose by tag bitcoin.

In config folder you'll find new config file - bitcoind.php You can change values in file directly, but most common way is to put values in Laravel .env file, like this :

Next, run migrations :

Usage

There are two main objects in package :

1. moki74\LaravelBtc\Bitcoind - this is a wrapper for RPC commands to bitcoin server. You can make this object via Laravel app helper function like this:

and then call RPC method on object :

You can use just this object for simpler projects ...

2. moki74\LaravelBtc\Models\Payment - this object is model for payment with Bitcoin , creates for you new Bitcoin address, amount, track if customer made payment, store it to database ...

Again, use app helper function like this:

This object contains following properties:

user_id - id of user who made order

order_id - order id (not mandatory)

address - bitcoin address (this is automatically generated for you when you call $payment = app("bitcoinPayment"))

paid - this is indicator if user is made payment and number of confirmations on block chain is ok (there is configuration parameter for minimum number of confirmations BITCOIND_MIN_CONFIRMATIONS in .env file or directly in bitcoind.conf file in config folder)

amount - price that user need to pay

amount_received - amount of bitcoin that is actually received (some user can make mistake and send bitcoins with fee deducted from amount send from their wallet, than you wont get expected amount)

txid - transaction id in block chain for this payment (this is populated in database when user actually make payment)

confirmations - number of confirmations for payment.

Typical workflow

When order is made by user, you make new Payment object and populate its properties :

Checking payments and confirmations:

Package contains class moki74\LaravelBtc\Commands\CheckPayment. This is Laravel Command and you can call it via php artisan :

Each time you call it, it scan for payments and confirmations on block chain. You can call it manually for testing purposes like mentioned above , but there is no much sense to do so, because it's job is to check for payments and it needs to run always.

You need to make crontab entry on linux servers or task scheduler on Win servers to call this command every minute.

This script also fires events that we can listen ...

Listening for payments

You'll find new classes in app\Listeners folder of your app when you published pakage ( see installation section). Those are :

ConfirmedPaymentListener.php

UnconfirmedPaymentListener.php

UnknownTransactionListener.php

Each of these Listeners correspond to Events which are placed in vendor folder of project : vendor\moki74\laravel-btc\src\Events

ConfirmedPaymentEvent.php

UnconfirmedPaymentEvent.php

UnknownTransactionEvent.php

To activate these Listeners copy this code in app\Providers\EventServiceProvider.php class (this class exists by default installation of Laravel), in $listen attribute of this class.

Like this:

In each of these class there is handle method, where you can put logic for actions that need to be done when event is fired (DB insert-update, sending mails ...).

Below is example of ConfimedPaymentListener, event is generated when number of confirmations is equal to BITCOIND_MIN_CONFIRMATIONS in .env file and we can be sure that payment is ok.

Events

  1. moki74\LaravelBtc\Events\UnconfirmedPaymentEvent - Payment is made by user. Transaction id is generated on block chain, number of conifrmation on block chain is 0 - so you have to wait for additional confirmations.

  2. moki74\LaravelBtc\Events\ConfirmedPaymentEvent - Payment is made and number of confirmations is equal or greater than value of BITCOIND_MIN_CONFIRMATIONS in .env file.

  3. moki74\LaravelBtc\Events\UnknownTransactionEvent - Usually this happens when user make payment and transaction fee is deducted from amount that he sends from his wallet and you don't receive whole amount. This payments are stored in separate table and you can make logic how to resolve situation like this.

Models

moki74\LaravelBtc\Models\Payment - Represents Confirmed and Unconfirmed Payments (see Usage section)

moki74\LaravelBtc\Models\UnknownTransaction - Represent transaction on block chain with amount that does not correspond to amount in Payment model.

License

MIT License

To help this project grow, please make donation in bitcoin:

BTC address : 1D3PDXSQDjvyLXeMb34XR6UeCwZX7tcjXP


All versions of laravel-btc with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package moki74/laravel-btc contains the following files

Loading the files please wait ....