Skip to content

Laravel package which provides CashBill payment processor support.

License

Notifications You must be signed in to change notification settings

xpusz3k/laravel-cashbill

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CashBill payment processor for Laravel

Laravel package which provides CashBill payment processor support.

Installation

  1. Install composer package using command:
composer require lukasz-adamski/laravel-cashbill
  1. Add Service Provider in config/app.php:
Adams\CashBill\CashBillServiceProvider::class,
  1. Add Facade in config/app.php:
'CashBill' => Adams\CashBill\Facades\Facade::class,
  1. Publish configuration file to your project:
php artisan vendor:publish --provider="Adams\CashBill\CashBillServiceProvider"
  1. If you have package_routes setting enabled you need to except /webhook/cashbill route from CSRF verification in app/Http/Middleware/VerifyCsrfToken.php:
/**
 * The URIs that should be excluded from CSRF verification.
 *
 * @var array
 */
protected $except = [
    '/webhook/cashbill'
];

Environment

You can setup these environment variables to configure CashBill API access:

  • CASHBILL_MODE - Current API mode, by default this value is set to sandbox to test implementation. On production you need to set this value to live,
  • CASHBILL_SHOP_ID - Your shop identifier received from payment provider,
  • CASHBILL_TOKEN - Random string received from payment provider to sign API requests,
  • CASHBILL_CURRENCY_CODE (optional) - Default currency code for payments (default currency code: PLN).

Testing

To run predefined test set use:

php vendor/bin/phpunit

Usage

Example payment controller implementation:

<?php

namespace App\Http\Controllers;

use CashBill;
use Adams\CashBill\Payment;
use App\Http\Controllers\Controller;

class ExampleController extends Controller
{
    /**
     * Redirect user to payment provider.
     *
     * @return Response
     */
    public function pay()
    {
        $payment = new Payment();
        $payment->setTitle('Title');
        $payment->setDescription('My item description');
        $payment->setData('... additional transaction data ...');
        
        // Currency code is set from 'payment_defaults.currency_code' in config file.
        $payment->setAmount(10); 

        return CashBill::redirect($payload);
    }
}

About

Laravel package which provides CashBill payment processor support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%