threesquared / laravel-paymill by Ben-Speakman

Laravel wrapper for the Paymill API
1,245
12
3
Package Data
Maintainer Username: Ben-Speakman
Maintainer Contact: ben@3sq.re (Ben Speakman)
Package Create Date: 2015-01-07
Package Last Update: 2016-10-04
Language: PHP
License: MIT
Last Refreshed: 2024-05-03 03:14:52
Package Statistics
Total Downloads: 1,245
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 12
Total Watchers: 3
Total Forks: 4
Total Open Issues: 1

Laravel Paymill

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>