Skip to content

Commit

Permalink
Allow support for live and test keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Speakman committed Aug 19, 2015
1 parent 21fb3b2 commit fc7282f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ You will also need to add the service provider and the facade alias to your `app
),
```

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 PHP API](https://developers.paymill.com/en/reference/api-reference/index.html) for full documentation on all available entities, actions and methods.*
Expand Down
20 changes: 12 additions & 8 deletions src/Speakman/LaravelPaymill/LaravelPaymillServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ class LaravelPaymillServiceProvider extends ServiceProvider {
public function boot()
{
$this->publishes([
__DIR__.'/../../config/config.php' => config_path('paymill.php'),
]);
__DIR__.'/../../config/config.php' => config_path('paymill.php'),
]);

$public_key = config('paymill.public_key');
$env = env('PAYMILL_ENV', 'test');

$this->app['view']->share('paymill_public_key', $public_key);
$public_key = config('paymill.' . $env . '.public_key');

$this->app['view']->share('paymill_public_key', $public_key);
}

/**
Expand All @@ -37,11 +39,13 @@ public function register()

$this->app['paymill'] = $this->app->share(function ($app) {

$private_key = config('paymill.private_key');
$env = env('PAYMILL_ENV', 'test');

$private_key = config('paymill.' . $env . '.private_key');

return new Paymill($private_key);
});
return new Paymill($private_key);
});

}

Expand Down
11 changes: 9 additions & 2 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

return array(

'public_key' => '<PUBLIC API KEY>',
'private_key' => '<PRIVATE API KEY>'
'live' => [
'public_key' => '<PUBLIC API KEY>',
'private_key' => '<PRIVATE API KEY>'
],

'test' => [
'public_key' => '<PUBLIC API KEY>',
'private_key' => '<PRIVATE API KEY>'
]

);

0 comments on commit fc7282f

Please sign in to comment.