dev-master
9999999-devCoinPayment PHP client for Laravel
MIT
The Requires
- php >=7.1
- guzzlehttp/guzzle ^6.3
- nesbot/carbon ^1.25
by Saifullah Syahidin
by Harrison Favour
payment gateway cryptocurrency payment method coinpayment
CoinPayment PHP client for Laravel
CoinPayment is a laravel module for handle transaction from CoinPayment like a create transaction, history transaction, etc.
, (*1)
You can install the package via composer:, (*2)
$ composer require harrison/coinpayment
Publishing vendor, (*3)
$ php artisan vendor:publish --tag=coinpayment-publish
First you should add trait class on User
model and use this trait Harrison\CoinPayment\Entities\CoinPaymentuserRelation
check the example below:, (*4)
<?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; use Harrison\CoinPayment\Entities\CoinPaymentuserRelation; class User extends Authenticatable { use Notifiable, CoinPaymentuserRelation; ...
Install CoinPayment configuration, (*5)
$ php artisan coinpayment:install
Setting schedule for checking transaction succesed in your file app > console > kernel
. example:, (*6)
... protected function schedule(Schedule $schedule) { // If IPN is enable set the schedule for ->daily() // And if IPN is disable set schedule for ->everyMinute() $schedule->command('coinpayment:transaction-check') ->daily(); } ...
visit the Documentation Schedule, (*7)
Install the table transaction, (*8)
$ php artisan migrate
Installation finish., (*9)
Create Button transaction. Example placed on your controller, (*10)
use CoinPayment; // use outside the class ... /* * @required true */ $trx['amountTotal'] = 50; // USD $trx['note'] = 'Note for your transaction'; /* * @required true * @example first item */ $trx['items'][0] = [ 'descriptionItem' => 'Product one', 'priceItem' => 10, // USD 'qtyItem' => 2, 'subtotalItem' => 20 // USD ]; /* * @example secound item */ $trx['items'][1] = [ 'descriptionItem' => 'Product two', 'priceItem' => 10, // USD 'qtyItem' => 3, 'subtotalItem' => 30 // USD ]; /* * if you want to remember your data at a later date, you can add the parameter below */ $trx['payload'] = [ // your cusotm array here 'foo' => [ 'foo' => 'bar' ] ]; $link_transaction = CoinPayment::url_payload($trx); ... /* * On your balde * <a href="{{ $link_transaction }}" target="_blank">Pay Now</a> */ ...
Please except the route from csrf proccess, get the file app > Http > Middleware > VerifyCsrfToken.php
, (*11)
... protected $except = [ ... '/coinpayment/ipn' ... ]; ...
Open file app > Jobs > coinPaymentCallbackProccedJob.php
for handle transaction proccess, (*12)
And Open app > Jobs > IPNHandlerCoinPaymentJob.php
for handle IPN proccess, (*13)
Route Name | Route URL | Method | Description |
---|---|---|---|
coinpayment.transaction.histories |
/transactions/histories |
GET | Route for access transaction histories |
CoinPayment PHP client for Laravel
MIT
payment gateway cryptocurrency payment method coinpayment