threesquared/laravel-paymill

Laravel wrapper for the Paymill API

1.3.2 2016-09-30 16:20 UTC

README

Build Status Latest Stable Version Packagist Packagist

Laravel Paymill is a Laravel 5 specific wrapper for the Paymill PHP library.

Please use the 1.0.0 release for Laravel 4

Install

Simply add the following line to your composer.json and run install/update:

"threesquared/laravel-paymill": "~1.3"

Configuration

Publish the package config files to configure your api keys:

php artisan vendor:publish

You will also need to add the service provider and the facade alias to your config/app.php:

'providers' => array(
  Threesquared\LaravelPaymill\LaravelPaymillServiceProvider::class
)

'aliases' => array(
  'Paymill'   => Threesquared\LaravelPaymill\Facades\Paymill::class
),

By default the package will use your test keys. In order to use the live Paymill keys you need to set the PAYMILL_ENV enviroment variable.

PAYMILL_ENV=live

Usage

Please see the Paymill API for full documentation on all available entities, actions and methods.

First start with instantiating the Paymill entity you want to work with.

$transaction = Paymill::Transaction();

Available entities are:

Then add in any additional information the request requires with setter methods.

$transaction->setAmount(4200)
    ->setCurrency('EUR')
    ->setPayment('pay_2f82a672574647cd911d')
    ->setDescription('Test Transaction');

Finally chose which action you want to perform.

$transaction->create();

Available actions are:

  • create()
  • details()
  • update()
  • all()
  • delete()

So an example to create a transaction would be:

try {

    Paymill::Transaction()
        ->setAmount(4200)
        ->setCurrency('EUR')
        ->setPayment('pay_2f82a672574647cd911d')
        ->setDescription('Test Transaction')
        ->create();

} catch(PaymillException $e) {

    $e->getResponseCode();
    $e->getStatusCode();
    $e->getErrorMessage();

}

You can set the ID of an entity by passing it as an argument.

Paymill::Client('client_8127a65bf3c84676c918')->details();

Payment create can also take the token as an argument.

Paymill::Payment()->create('098f6bcd4621d373cade4e832627b4f6');

You can also use the $paymill_public_key variable across all blade views.

<script type="text/javascript">
  var PAYMILL_PUBLIC_KEY = '{{ $paymill_public_key }}';
</script>